Posts Tagged ‘nrf24’

h1

Getting started with nrf24: Hardware connection

2010/09/27

The nrf24 chips are all SPI-based, which means they use a bit clock (SCK), chip select (CS#), and two data lines (MISO, MOSI) to communicate with the host.  In addition, there is a chip enable (CE) that is used as an external control over the radio itself.  Finally, if your application calls for it, you can elect to connect the interrupt line (IRQ), which tells you when various events complete within the nrf24 itself, to save you from status polling.

I won’t cover the various non-digital connections at this point, but rather leave that to other sources such as the schematic for SparkFun’s nrf24l01+ module.  I’ll probably write a section on that eventually though, stay tuned.

Now, to connect it to your average microcontroller, you simply want to find the SCK/MISO/MOSI pins and connect them straight across.  The CS# pin may or may not go to one labeled on the microcontroller as such (or SS# for “slave select”), and in general it doesn’t matter because most microcontrollers do not maintain automatic control over the slave/chip select lines in master mode, since there could be an arbitrary number of them.  CE is even more loose as far as were you connect it, since it’s not actually part of the SPI interface itself anyway.  IRQ would ideally connect to a microcontroller pin that’s capable of actually triggering an interrupt, should you wish to use that functionality.

Here’s the nrf24l01+ connected up to an ATmegaXX8:

An Xmega is “better” since you can use any of the “serial” ports you want, and since every single pin is capable of triggering an interrupt you can wire IRQ anywhere you want as well:

However, if you are prepared to “bitbang” your interface, you can connect it any which way you want.  If communication speed and efficiency is not your main concern, this can make your board routing significantly easier:

A special case are the various nrf24 chips which also contain microcontrollers.  Examples are the nrf24LE1 and nrf24LU1(+).  The actually SPI interface is present inside the chip, but instead of having to wire it up, they’ve simply connected them inside the chip.  In that sense it’s almost the same as connecting up a nrf24l01+ to a regular 8051 microcontroller and using the existing SPI registers, except you’re just using a different SPI port.  Kindof.

Now another option to seriously consider in your PCB design is that of actually driving the chip’s power entirely from the microcontroller.  This gives you the ability to completely turn off the chip if you so desire (for power savings), or to hard reset the chip in case it goes wonky (which I seem to have happen on a regular basis):

Be sure that the maximum current of the nrf24l01+ does not exceed that which your microcontroller can supply.  In the above case, the Xmega is capable of driving 20mA on each pin, which is plenty of headroom over the 13.5mA max draw of the nrf24l01+.  If your chip doesn’t drive that hard, you can simply connect multiple pins together.  Just make sure those pins all turn on at exactly the same time, or you’ll short out your power supply and probably fry your microcontroller…

The next post will cover the software side of the physical connection: getting and setting registers, transferring actual packet data, and making the radio actually radiate.

Advertisements
h1

Getting started with nrf24: Introduction

2010/09/27

So anybody who’s been following my blog for the last few weeks will have noticed I’ve been fighting with the nrf24 series of chips, trying to get a wireless protocol in place I can use for program & debug capabilities.  Unfortunately, finding any kind of coherent and properly documented example code, or tutorials that make sense, has been rather hard.  I’ve found a few that at least got me partially started, in particular diyembedded‘s tutorials even though they’re based on the PIC and ARM.  However, the many and varied code examples all seem to say slightly different things, generally in less than straightforward ways.  Thus, I’m going to attempt to write my own tutorial series, as I bootstrap my way up through the available functionality.  It’s going to be very code-based, yet hopefully in a form that’s not too confusing.  This will also provide me with the opportunity to solidify my own understanding of the chip(s).

To start things off, the nrf24 series of chips from Nordic Semiconductor have gained a lot of popularity both in product and DIY circles because of their (relative) simplicity and low cost.  The radios themselves operate in the 2.4GHz band, and have a maximum air bitrate of 2Mbps in a 2MHz channel.  They use a GFSK encoding with a -82dBm sensitivity at 2Mbps, giving them a range in the 10’s of meters on average.  There are relatively few external components required, though I’ve had some problems there myself…

The tutorial sections themselves are [will be]:

  1. Hardware connection
  2. Physical layer communication
  3. Trivial transmission
  4. …[TBD]

The sections will be linked here as they are written, and this will eventually be the root document for the tutorial.