rfm12b spectrum analyzer


[Nov 10th, 2010] this project has been entered in the 43oh.com november (2010) project of the month contest. more info here http://www.43oh.com/2010/11/november-2010-the-msp430-project-of-the-month-contest-win-a-ti-chronos-watch/

description

this is a simple rf spectrum analyzer project based on TI Launchpad. i have been working on other rf transceiver projects and in need of a simple rf spectrum analyzer to help me visualize what's happening.

this is a linux project, i had given attention with my best knowledge to make provisions so that it can be built under windows. however i do not have the time and resources to try out everything under windows.

i did successfully built and run the project under windows 7 w/ TI CCS IDE, for host visualization script, it also works under windows but required you to install some unixish packages (cygwin and more)

i need something simple to show the pattern of frequency hopping. i do not need very accurate display of rf power. the Launchpad came in handy as it is inexpensive and contains fast ADC functions. the included usb to uart is a plus as i can communicate data between the MCU application w/ a PC side application for visualization. there are around a dozen or so commands that you can issue via SPI to control the RFM12B, as well as sending and receiving data.

a RFM12B module is used to capture signal strengths of different frequencies. the RFM12B utilizes a SPI interface to communicate to a MCU. a software SPI is implemented in this project for simplicity.

initially i set out to use the documented DRRSI function. but the result is poor, to do this you have to set a "threshold" signal level (between 0-5) via a SPI command, and read from the RFM12B whether the signal strength is met. apart from the very poor resolution (only 6 steps), you need to do perform this for each threshold steps, meaning 6 times for each frequency. the settlement time is also not acceptable, in that (from the data-sheet) you need to wait for 500us to get proper results.

i discovered that are mentions of a ARRSI signal that you can use to take analog signal strengths, it is only available on the SMD type of modules and it is not on any of the pin-outs, you will need solder an extra pin out from the module. you can see the extra add-on lead running from the surface of the pcb module, this is where the ARRSI lies.


after some trial and error i was able to get rather reliable readings from this ARRSI pin. the range of the ARRSI output is between 0.7V and 2.2V, which match what i discovered via google. the timing is important to a fast and successful ARRSI read, if we are to perform the ADC immediately after issuing a "read" command (0xb000), i can get decent readings.

the Launchpad firmware basically received commands from the PC side perl script to start sampling for signal strengths, the frequency and signal strength are then sent to a host application (written in perl) for visualization. there is a threshold in the firmware that prohibits data sending if the signal strength is below it. this is needed as the LaunchPad can only do 9600bps communicating w/ the PC and if we include all the zeros and noises for sending, the uart is not able to catch-up.

the current firmware also does not read all possible frequency due to the uart bottleneck, instead of reading at 7.5Khz gaps the firmware is only reading 16 x 7.5Khz (120Khz) steps. the valid range for the RFM12B is between 36 and 3903 (3867 steps) and we are doing 241 steps per sweep. the Launchpad would perform a full sweep of 241 frequency steps, reporting those frequencies and signal strengths if they are above a threshold, and at the end of a full sweep, send a signal as indication.

on the PC side, the perl script will send a "start" command during start-up. it then reads data from the Launchpad, continuously updating the display grid to show "near" real-time results. there are some other settings on the perl script that affects the visualization and is described separately.

although the RFM12B module i used is tuned for 915Mhz, i am able to get signal strengths (may not be optimized) from the 433Mhz and 868Mhz bands.


host side application written in perl


show here is the perl script i used for visualization. i am using perl/tk and device::serial packages. the green bars are the current signal strength of various frequencies. the blue peaks are peak hold values. the yellow curve is a previous peak hold curve that i had "marked" for comparison.

the test scenario shown was on a FHSS transceiver pair working together. at an initial partnering stage one transceiver set out to look for a partner (show in the yellow curve), once partnering is accomplished, they switch to another hopping list to perform data exchange (blue curve and green bars).



features

  • higher resolution w/ analog ARSSI reads
  • adequate speed to show FHSS activities
  • "915Mhz" RFM12B module used, can also set at 433Mhz, 868Mhz with less optimal results
  • "amplify" setting (software) to visualize weak signals
  • "sweep" setting to accumulate and average over time, used to analyze intermittent signals (digital, RHSS, etc)
  • "zoom" to zoom in part of the capturing spectrum
  • "peak" and peak hold function in gui for better visual and signal comparison


parts list

  • TI Launchpad kit
  • led (optional, for command received indication)
  • HopeRF RFM12B SMB module (433Mhz, 868Mhz or 915Mhz band)


it is important to get the RFM12B module in SMD format, as the ARRSI is not available in the DIP format.


notice in the above picture that a lead is added to the ARRSI spot, you have to be careful and if possible, use a fine solder tip (i didn't have one). pre-tin your lead properly and limit your solder time.



application notes

  • plug-in Launchpad, start perl script on PC side
  • signal streaming should start immediately, if you got not signal, there will be nothing showing on your screen
  • click 'hold' and 'start' to stop and start signal streaming from Launchpad
  • click '915Mhz' to toggle between different frequency bands (i.e. 433Mhz, 868Mhz, 915Mhz)
  • click 'sweeps' to set the number of sweeps to accumulate for averaging, a low number will allow fast showing of data and a high number will tell the perl script to accumulate and average over several sweeps. this allows for visualization of digital (i.e. intermittent) or FHSS signals
  • click 'amplify' to amplify the signal strength. this is purely visual as we just multiply the signal strength for easy viewing
  • clock 'zoom' to zoom into a part of the spectrum, not really meaningful at this stage as the firmware is not capable of bands narrower than 90Khz
[Nov 7th, 2010] added 'sampling' options to change frequency gaps, i.e. default is sample every 120Khz on the 915Mhz band, now can be down to 7.5Khz.


credits and references


HopeRF, RFM12B manufacturor and resources here
TI LaunchPad wiki here
blog.strobitics.com had a tutorial series on the RFM12B here
jeelabs had a host of topics and forum posts on the RFM12B, start here
for software uart, i learn and use code snippets from ti's example, also njc's uart tutorial and hodgepig's LaunchPad Stakulator


project layout


the two female header rails represents the LaunchPad J1 and J2 headers, please correspond to the photo.


schematic



alternate construction

you can, if you wish, free up your launchpad and make this project as a standalone breadboard project. place the MSP430G2231 chip underneath your RFM12B module and run your jumper wires. they all fit rather nicely.


for uart communications you can use a FTDI cable, or, as in my case, hack a nokia ca-42 cable as shown here. i can no longer find those cables that have a Vcc supply wire any more. looks like every supplier is making only 3 wires available (gnd, rx and tx). i had to cut out the assembly and have the pcb exposed, then run a 3.3v (along w/ gnd, rx and tx) through a 4 wire header jumper. this way i do not need extra power for the finished setup.


another benefit on using a usb to serial cable is you can run your uart at far higher speed (57600bps i did), with the launchpad 9600bps is the limit.



project status

the spectrum analyzer had met my initial objective as a tool to diagnosis my other RHSS projects. it is fast enough to show digital signal patterns and fairly accurate to give me some idea of signal strengths. however there are improvement that can be made.

  • speedy uart. this should solve part of the last problem if implemented. the current bottleneck on the device is related to the fact that i am only doing 9600bps uart w/ the PC. in the alternate (launchpad free) construction i am using a nokia ca-42 cable and getting better performances
  • crc and other means to validate incoming data, as we are using internal oscillator and software uart here, there is always chance that false reads being made
  • ADC conversions is fast but can be faster by implementing continous reads
  • accurate signal strength reading. currently i am just showing ADC results from RFM12B ARRSI reads, i had no clue on the real mW or dbm values, i am no RF expert


source code and firmware building


following are instructions for linux only, my environment is ubuntu 10.04, other distros should work as long as you had installed the msp403 toolchain and mspdebug properly.

source file are in dos format as linux is more tolerant and will compile w/o problem. anyway if you need to switch formats you can open them w/ vim and do "set ff=dos" or "set ff=unix"

you can create a directory and place the following files in them


i do not have a makefile for this to compile, i use a bash script to compile most of my projects, it is mentioned on my launchpad shield page, scroll down to the section "workspace directory layout" and get the details.

or you can do the following

  msp430-gcc -Os -mmcu=msp430x2013 -o ezrfm.elf ezrfm.c 
msp430-objdump -DS ezrfm.elf > ezrfm.lst
msp430-objdump -h ezrfm.elf
msp430-size ezrfm.elf

to flash firmware, attach your launchpad and do

  mspdebug rf2500 "prog ezrfm.elf"


windows build via TI CCS


  • create a new project ezrfm and copy rfm12.h and ezrfm.c into your project directory
  • select gcc compatible option in your project properties
  • rebuild project


host side visualization script


this is the perl script that runs on the PC side

apart from core perl, you need to install (via cpan)

  • Tk
  • Device::SerialPort
  • Time::HiRes


window users, you have to install a brunch of things for this to work
  • cygwin, during which need to include
  • perl, tk, make, gcc
  • X11, xorgserver, xinit
  • after cygwin installed, use cpan to install these perl modules
  • Tk, Device::SerialPort, Time::HiRes
  • for Device::SerialPort, the test will fail, need to use -f (force) option
  • you have to start X11 server before running the script. i.e. startxwin
  • com port conventions are different. COM1 is /dev/ttyS0 in cygwin, adjust perl script accordingly


troubleshooting

  • adding the ARRSI can be a challenge, tin the lead you are adding and limit your solder time. apply flux before soldering and use a fine tip if you can. you won't know how easy one can tap the solder tip on the tiny pad and have the whole smd resistor lifted.
  • there are no factory calibrated values for the MSP430G2231 on 8Mhz DCO, you need to try different values or use a calibration firmware and crystal (from ti examples).
  • don't assume software uart is reliable, you may miss or gain some higher bits (especially 0x40-0xa0 range) if your timing is not right. you may not even notice them. i used a seperate script to test the reliably of the comms during development, basically a stress test on different baud rates w/ full range of data.


notes

  • will expand webpage from feedbacks, especially on window builds as i am not too confident on the current instructions.
  • will include more information on the RFM12B module when time permits.


construction and example FHSS capture session




Comments