1 Thomas EDERC LPRF in Practice
2 Section 4 - Overview 4. LPRF in Practice 4.1Off-the-Shelf Hardware 4.2Operating Systems 4.3Development Environment 4.4Tips & Tricks Thomas EDERC 2010
3 4.1 Off-the-Shelf Hardware
4 Hardware - Overview micro-controllerradiosensors battery mote Thomas EDERC 2010
5 Hardware - Criteria Micro-controller – Reasonably fast – Low-power – Multiple I/O options – Reasonable amount of memory – Timing capabilities – Community / support Radio-chip – Low-power – Standards compliant? – Community / Support Thomas EDERC 2010
6 Hardware - Microcontrollers familynamearchspeed Power active/asleep RAMROMTimersI/Oused in ARM ARM7TDMI32-bit MHz2mW/MHz8kB a - 6 Timers, RTC 3 USART, SPI, 8 10-bit ADC, JTAG Game Boy Advance, Nintendo DS, iPod ARM920T32-bit MHz22.4mA/250uA16kB a 128kB a extensive UART, USB, Ethernet, 4 USART, I2S, SPI,JTAG SunSpot MSP MSP430f bit16MHz390uA b /100nA b 1kB32kB 2 timers with 3 CCR UART/LIN/IrD A/SPI and I2C/SPI TI eZ430 MSP430f bit8MHz500uA b /200nA b 10kB48kB 16-bit (3CCR), 16- bit (7CCR) 1 USART (SPI or UART or I2C), 1 USART (SPI or UART) TelosB, t-mote AVRATmega128A8-bit16MHz9.8mA c /1mA c 4kB128kB 2 8-bit, 2 16-bit 2 USART, SPImica2 a used as cache, primary memory is off-chip b at 1MHz c at 8MHz Thomas EDERC 2010
7 Hardware - Radios Brandname Bandsensitivity Power Tx/Rx/sleep used in TI CC2520Yes2.4GHz-98dBm25.8mA a /18.8mA/30nA CC2420Yes2.4GHz-95dBm17.4mA a /18.8mA/20nA TelosB, MICAz, SunSpot EPIC CC1101No 868/ 915MHz -94dBm16.8mA a /17.1mA/200nAWSN430 CC2500No2.4GHz-89dBm21.2mA a /16.6mA/400nAeZ430-RF2500 Atmel AT86RF230Yes2.4GHz-101dBm16.5mA b /15.5mA/20nAIRIS AT86RF231Yes2.4GHz-101dBm14mA b /12.3mA/20nA a at 0dBm transmission power b at 3dBm transmission power Thomas EDERC 2010
8 Hardware - Motes namemicro-controllerradiobatteryprice eZ430-RF2500MSP430f2274CC25002 AAA$20 e.a. eZ430-RF2480MSP430f2274CC2480A12 AAA$30 e.a. MICAzAtMega128LCC24202 AA$99 e.a. IRISAtMega128LAT86RF2302 AA$119 e.a. TelosBMSP430f1611CC24202 AA$99 e.a. RZ USBstickAT90USB1287AT86RF230USB$39 e.a. deUSB2400AT91SAM7S256AT86RF231USB€35 e.a TI CC2531EMKCC2531 USB$49 e.a. Thomas EDERC 2010
9 Hardware - TelosB User-defined push reset visible light sensor IR light sensor humidity sensor expansion port internal antenna external antenna CC2420 MSP430f1611 (back) 3 LEDs (RGB) USB for programming and UART 2 AA (back) Thomas EDERC 2010
10 eZ430-RF LEDs pushbutton CC2500 chip antenna 26MHz crystal for radio extension ports MSP430 USB programmer: Power Debug (JTAG) Interface (serial) Thomas EDERC 2010
11 Thomas EDERC Operating Systems
12 Software - Requirements Reduced Memory Footprint – binary code occupies a small amount of ROM Hardware Independency – through abstraction of lower layers Re-useability – code is divided in chunks communicating through APIs Real-time – Easy to measure time (access to timer registers) – Reasonably fast – Guaranteed execution time Thomas EDERC 2010
13 Software - Options NameFootprintlicensereal-timecommunity TinyOS (UC Berkeley) overhead open- source best-effort scheduler large (academia) Contiki (SICS, Sweden) overhead open- source best-effort scheduler large (academia) Think (Orange Labs) overhead open- source experimental scheduler modest uC-OS IIoverhead free academic use hard real-time scheduler large (industry) From scratch optimal open- source -- Thomas EDERC 2010
14 Software - TinyOS component-based architecture – code is cut in components – components communicate through APIs component library – TinyOS has been ported to a dozen platforms – Drivers exist for different micro-controllers and radios event-driven execution model – a schedule executes tasks on a FCFS basis – tasks can be halted by interrupts Thomas EDERC 2010
15 Thomas EDERC Development Environment
16 Development Tools Firmware development is complex – not complicated! – develop top-down, always keep an eye on where you’re going – the vast majority of the cases, you’re wrong (not the compiler, not the protocols) – bugs are always due to simple errors – build from atomic building blocks Multi-dimensional Debugging – choose a meaning for each LED, and stick with it – print out error codes, not text – Use the extension pins with an oscilloscope, the easiest way to measure time – Use a spectrum analyzer to see on what channels you are occupying – Use a sniffer to see the packets flying through the air – A GUI is faster than lines text – Use a JTAG debugger whenever possible Thomas EDERC 2010
17 Development Tools Choosing a scope – analog channels for energy (put resistor in series with power source) – the more digital channels, the better – you don’t need a fast scope – some oscilloscopes will interpret SPI, I2C, UART (e.g. Tektronic MSO2024) – cheap USB scopes available Spectrum analyzers – are expensive – can be replaced by a sniffer – can be replaced by the poor man’s spectrum analyzer Sniffer – CC2531 EMK ($49) Graphical User Interface – Python+PySerial is a good candidate Thomas EDERC 2010
18 Thomas EDERC Tips & Tricks
19 A MAC Protocol is a State Machine IDLE RXUF RXCW BACKOFFACK RXDATA TXFIN TXACK SENTACK TXUF TXCW RXACK TXDATA RXFIN Thomas EDERC 2010
20 Clock Drift Thomas EDERC 2010
21 Gotcha’s - Synchronization 1.A sends packet with slot offset α 2.B records the epoch of the time of arrival β 3.B calculates the epoch of the start of the last slot (β- α) 4.B sets its counter register accordingly A B α β Thomas EDERC 2010
22 Gotcha’s - Packet Timestamps 1.MSP430 writes packet to CC2420 with error code in timestamp 2.MSP430 triggers the start of the transmission 3.MSP430 records the time of SFD (interrupts) 4.MSP writes to correct timestamp in the Tx buffer 5.Transmission completes MSP430CC2420 Thomas EDERC 2010
23 Synchronization Thomas EDERC 2010
24 Integration into the Internet NSLU2 by Linksys as a gateway ($100) for tunneling into the IPv6 cloud (free) by Sun to store your data (free) to visualize your data online Thomas EDERC 2010