Custom Bluetooth Low Energy board with 2.4GHz antenna hack and Nordic nRF51822…

I wanted to dabble with BLE and learn a bit:

  • Can you hack together in your garage an antenna and RF section that will work at 2.4GHz?
  • If it works, who good/bad will it be?
  • What is hand soldering QFN packages like? Many BLE devices are only available in CSP or QFN48.

If you want to make IoT and Wearable devices that can be controlled from your phone/tablet/whatever, ZigBee is a neat mesh networking technology; but it’s not in any phones. Bluetooth (and more recently) Bluetooth Low Energy is in all of them. It’s easy to write a BLE control app write yourself using the Cocoa frameworks or download one like the excellent LightBlue for iPhone:

IMG_3617

Make a Board

So, I broke out Eagle and designed a PCB around the Nordic nRF51822 chip, basing the design on a reference from the Nordic data sheet,

I picked the Nordic device because:

  • There aren’t many catalogue BLE devices around yet
  • It’s Cortex M0. No need to learn ARC (CSR).
  • The CPU is integrated into the SoC (unlike the TI device)

The nRF51822 worked great, but it wasn’t all good. More on that later…

My Eagle board design is on GitHub here.

Board

Antenna Design

The most challenging part was the 2.4GHz antenna design. The key decisions were:

  • Pi network or balun
  • Chip antenna or the “real thing”

Since I wanted some RF experience, I picked both of the harder options i.e. pi network and PCB strip antenna.

This whole project was brought to you by app notes…. the best I found

read more

Using JTAG and Eclipse on MacOS

Though many eval boards come with an embedded JTAG-USB interface, I still like to use a separate purpose-built JTAG debug box.

If you pick the right one:

  • It can be used with many boards and SoCs. Once set up, one debug toolchain works for many projects.
  • You can use it to debug MCUs on bread-boarded projects. You will need to make a hacked SWD cable like the one I show in this post.
  • Not that expensive. I picked up a Segger JTAG EDU on a home-use deal for $60. I remember the early days at ARM when we first launched our “EmbeddedICE” box; the price then was over $1K….Today you can get some very cheap $20 knock offs from China on EBay and AliExpress. These may or may not work, but I believe it not worth my time to rely on dodgy tools with questionable software.
  • It works natively with Mac OSX. At least the Segger version does. I don’t need to run Fusion, Parallels or Virtual Box.
  • Does not require special USB drivers etc. The Mac version works by looking like a TCP device and speaking IP.
  • Supported directly under Eclipse. Again no special driver required
  • Supports SWD or full JTAG

(1) Connection to the target

The first thing you will need is a SWD cable. I made one out of some 20 core ribbon cable and a 20 pin IDC box connector. The ARM documentation on SWD pinouts is highly ambiguous since they talk about the pins to a “connector”. What’s a connector? Do they mean the plug (male) or socket (female)? I figured out the Segger pin out by using a Salaea Logic Analyzer:JTAG box end

Pin allocation

Segger setup

Breadboard connection

(2) Get the Segger software tools working

On a Mac, this is as simple as starting the JLinkExe terminal application in the Segger Application folder. Don’t try and use the JLinkGDBServer app from terminal.

If all is well, JLinkExe reports something like this:

STM32F100 segger

Note how JLinkExe switched automatically to SWD. This works most of the time, but not always. It depends on whether your target device is “known” to the box or not. If it is not known, you can fix this by

read more

STM MEMs pressure sensor, gyroscope and accelerometer hook up to ARM MBED

I used a header board for an STM MEMS evaluation kit in order to take a look at some common MEMS sensors:

  • LPS301: Pressure and temperature sensor
  • LG3D20: Gyroscope
  • LSM303DLHC: Accelerometer and magnetometer

The header was an STEVAL-MKI124V1 which is designed to work with an STM motherboard evaluation system. I took a shortcut and used it with an ARM MBED board featuring an NXP LPC1768 MBED.

Hook-up using I2C was trivial:

Screen Shot 2014-08-10 at 9.37.23 PM

The schematic for the evaluation board is here:

http://www.st.com/web/en/catalog/tools/PF253482

The orientation of the sensors on the board is like this:

Screen Shot 2014-08-10 at 9.38.10 PM

MBED-based code I write to drive the I2C is on the MBED website here

The code sets up each of the sensors and then provides a continuous output of temperature, pressure and orientation. Rather than optimize for performance or efficiency, the code here is intended to show clearly how to access the sensors.

An interesting twist was to use the linear accelerometer to find the vector of the earth’s gravitational field (i.e. down) and to use that to make a tilt-adjusted compass. Algorithm

read more

Breadboard breakout board for 48pin QFP STM32F100

Quick and simple project to make an adapter PCB to use a QFP packaged MCU on a traditional through-hole breadboard.

I ended up making a double-sided PCB to support 2 different QFP sizes. One side set up for 48 pins, the other for 32pins. Usage is to populate one side or the other, not both….

Screenshot 2014-08-13 17.56.56

Simple pin-out to two standard 24-pin headers. No on board components such as decoupling capacitors.

Here is the board in action on a breadboard and loaded up with a 48-pin STM32F100C8:

IMG_3872_safe

Eagle files for the board are on GitHub here.

 

Using MBED SPI to drive Analog Devices AD9850 frequency synthesizer

I was looking for a way to test the frequency response of a new oscilloscope.

Analog Devices has a nice IC that can produce a digitally synthesized sine wave of frequency between 0 and about 70 MHz. AD9850 link is here.

The quickest way to throw together a prototype was using an MBED platform. My code is here

What made things even easier was the availability of ready-to-go evaluation boards from China on Ebay for less than $5. This is the one I used.

This design is limited to about 40MHz if you want a clean signal without aliasing.

Frequency and phase are set by a 40-bit command that has:

  • 32-bit frequency setting
  • 5-bit phase setting
  • 1-bit power up/down
  • 2-bits factory debug access

MBED_SPI packet

Output frequency is given by: fOUT = (frq × CLKIN)/(2^32)

where frq is the 32-bit frequency and CLKIN is the frequency of the on-board crystal (125MHz in this case) So, for example 0x147AE148 is 10MHz.

Frequency resolution has a step size of 29KHz with the 125MHz clock.

You can also change phase in increments of 180°, 90°, 45°, 22.5°, 11.25° or any combination thereof using

read more