[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/
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).
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.
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
the two female header rails represents the LaunchPad J1 and J2 headers, please correspond to the photo.
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.
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.
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
to flash firmware, attach your launchpad and do
mspdebug rf2500 "prog ezrfm.elf"
windows build via TI CCS
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)
window users, you have to install a brunch of things for this to work
construction and example FHSS capture session