Presentation is loading. Please wait.

Presentation is loading. Please wait.

David Culler, Jason Hill, Robert Szewczyk, Alec Woo U.C. Berkeley 2/9/2001 TinyOS Programming Boot Camp Part IV – Tiny OS 4.3 Component Overview.

Similar presentations

Presentation on theme: "David Culler, Jason Hill, Robert Szewczyk, Alec Woo U.C. Berkeley 2/9/2001 TinyOS Programming Boot Camp Part IV – Tiny OS 4.3 Component Overview."— Presentation transcript:

1 David Culler, Jason Hill, Robert Szewczyk, Alec Woo U.C. Berkeley 2/9/2001 TinyOS Programming Boot Camp Part IV – Tiny OS 4.3 Component Overview

2 Communication Groupings: ActuatingSensing Communication Application Main Hardware Abstractions

3 Hardware Abstraction Components LEDs Clock UART ADC RFM

4 LEDs – LEDS.comp Provides a generic interface to the LED outputs Abstracts away pin numbering and hardware wiring INIT turns off all LEDs Provide on, off, and toggle interface for each LED TOS_MODULE LEDS; ACCEPTS{ char LEDS_INIT(void); char RED_LED_ON(void); char RED_LED_OFF(void); char RED_LED_TOGGLE(void); char GREEN_LED_ON(void); char GREEN_LED_OFF(void); char GREEN_LED_TOGGLE(void); char YELLOW_LED_ON(void); char YELLOW_LED_OFF(void); char YELLOW_LED_TOGGLE(void); };

5 Timing – CLOCK.comp Generates periodic events to trigger applications Abstracts away counter registers, interrupt masks, and interrupt vectors Initialize with number of ticks between events and scale of the ticks Can use predefined definitions of the form ticksNps All components that connect to the clock event will receive the same event rate Initialization rests counter to zero TOS_MODULE CLOCK; ACCEPTS{ char CLOCK_INIT(char interval, char scale); }; SIGNALS{ void CLOCK_FIRE_EVENT(void); };

6 Timing (cont.) Example initializations: –CLOCK_INIT(64, 2) or CLOCK_INIT(tick64ps) –Fire every 64 ticks where each tick is 1/4096 seconds, or fire 64 times per second Predefined Intervals tick1000ps, tick100ps tick10ps, tick4096ps tick2048ps, tick1024ps tick512ps, tick256ps tick128ps, tick64ps tick32ps, tick16ps tick8ps, tick4ps tick2ps, tick1ps Scale 0 - OFF ticks/second ticks/second ticks/second ticks/second ticks/second ticks/second ticks/second system/include/hardware.h

7 UART – UART.comp Abstracts away baud rate control, data transfer registers, interrupt control and data buffering Fires event on RX and TX completion Operates at the byte level TX_READY signals that the component can handle another byte TOS_MODULE UART; ACCEPTS{ char UART_INIT(void); char UART_TX_BYTES(char data); char UART_PWR(char data); }; SIGNALS{ char UART_RX_BYTE_READY(char data, char error); char UART_TX_BYTE_READY(char success); };

8 ADC – ADC.comp Abstracts away ADC control registers, ADC interrupt handling and sample timing Accepts request for data that contains the port number of the data being requested Fires separate events for each data port – common way of avoiding dynamic dispatching Asynchronous data request, data ready interface TOS_MODULE ADC; ACCEPTS{ char ADC_INIT(void); char ADC_GET_DATA(char port); }; SIGNALS{ char ADC_DATA_READY_PORT_0(int data); char ADC_DATA_READY_PORT_1(int data); char ADC_DATA_READY_PORT_2(int data); char ADC_DATA_READY_PORT_3(int data); char ADC_DATA_READY_PORT_4(int data); char ADC_DATA_READY_PORT_5(int data); char ADC_DATA_READY_PORT_6(int data); char ADC_DATA_READY_PORT_7(int data); };

9 The sensor stack Photo, and Temperature sensing components Sits on top of ADC component Typical request data, wait for data event paradigm TOS_MODULE PHOTO; JOINTLY IMPLEMENTED_BY PHOTO; ACCEPTS{ char PHOTO_INIT(void); char PHOTO_GET_DATA(void); char PHOTO_PWR(char mode); }; SIGNALS{ char PHOTO_DATA_READY(int data); }; USES{ char SUB_ADC_INIT(void); char SUB_ADC_GET_DATA(char port); }; HANDLES{ char PHOTO_ADC_DONE(int data); }; PHOTO.comp interface PHOTO.c ADC Typical Application

10 RFM – RFM.comp Bit level interface to the RFM radio Abstracts away bit level timing, RFM specific control logic (TX vs. RX modes) Signals RX and TX bit events RFM_SET_BIT_RATE accepts 3 sampling rates… 0 = 50us (2 x bit rate) 1 = 75us (1.5 x bit rate) 2 = 100us (1x bit rate) 2x Bit rate used for detecting start symbol, bit rate 1.5 x used to transition to middle of bit transmission, 1x bit rate used to read and write data TOS_MODULE RFM; ACCEPTS{ char RFM_INIT(void); char RFM_TX_MODE(void); char RFM_TX_BIT(char data); char RFM_RX_MODE(void); char RFM_PWR(char mode); char RFM_SET_BIT_RATE(char level); }; SIGNALS{ char RFM_TX_BIT_EVENT(void); char RFM_RX_BIT_EVENT(char data); };

11 The Communications Stack Building up from the RFM bit level Bit level abstracts away radio specifics Byte level radio component collects individual bits into bytes Packet Level constructs packets from bytes Messaging layer interprets packets as messages Data pump paradigm used to connect layers RFM Bit Level Byte Level Packet Level Messaging

12 Data Pump Paradigm High level components initiate transfer (COMMANDS) Lower level components signal when more data can be handled (EVENTS) Collection of bit events aggregated into single byte event Collection of byte events collected into single packet event RFM Bit Level Byte Level Packet Level …

13 RFM and RFM_LOW_POWER Two options for bit level components: –RFM and RFM_LOW_POWER RFM low_power –Performs turn off radio when channel is idle –Radio on 1/10 th of the time –When idle, 270us off and 30us on –If transmission detected, it returns to normal mode of operation TOS_MODULE RFM; ACCEPTS{ char RFM_INIT(void); char RFM_TX_MODE(void); char RFM_TX_BIT(char data); char RFM_RX_MODE(void); char RFM_PWR(char mode); char RFM_SET_BIT_RATE(char level); }; SIGNALS{ char RFM_TX_BIT_EVENT(void); char RFM_RX_BIT_EVENT(char data); };

14 Radio Byte Level RADIO_BYTE.comp, FOUR_B_RADIO_BYTE.comp, SEC_DED_RADIO_BYTE.comp, SEC_DED_RADIO_BYTE_SIGNAL.comp All have similar interfaces Transfer individual bits to the radio Fires off TX_READY event when it can accept another byte TOS_MODULE RADIO_BYTE; ACCEPTS{ char RADIO_BYTE_INIT(void); char RADIO_BYTE_TX_BYTES(char data); char RADIO_BYTE_PWR(char mode); }; SIGNALS{ char RADIO_BYTE_RX_BYTE_READY(char data, char error); char RADIO_BYTE_TX_BYTE_READY(char success); char RADIO_BYTE_TX_DONE(void); };

15 General Radio Byte Operation Pipelines transmission – transmits single byte while encoding next byte Trades 1 byte of buffering for additional latency Separates high level latencies from low level latency requirements Encoding Task must complete before byte transmission completes Decode must complete before next byte arrives Encode Task Bit transmission Byte 1 Byte 2 RFM Bits Byte 2 Byte 1Byte 3 Byte 4 start …

16 Radio Byte FSM with Tasks (Sending) 0 2 tx_bytes/POST_TASK 34 tx_bit &~c16 tx_bytes accepted tx_byte_rdy signaled Encode Task Executed 1 tx_bit &c16 / tx_byte_rdy tx_bit &~c16 tx_bit called State Table 0 = idle 1 = waiting to send out first byte 2 = sending out byte, no next byte 3 = sending out byte, waiting to encode next byte 4 = sending out byte, done encoding next byte tx_bytes/POST_TASK tx_bit &~c16 tx_bit &c16 / tx_byte_rdy,tx_done tx_done signaled

17 Radio Byte FSM with Tasks (Receiving) 0 rx_bit & start frame 6+ 6 rx_bit rx_bit &~start symbol rx_bit &~c16 byte_rdy_evt byte_rdy_evt signaled rx_bit handled Decode Task 5 byte_rdy_evt rx_bit &~c16 State Table 0 = idle 5 = Start Symbol Received 6 = Reading in byte 6+ = Reading in byte, waiting to decode previous rx_bit & c16/POST_TASK

18 Different Encoding Options RADIO_BYTE.comp –Basic Manchester encoding –Each bit encoded as two bits –0 -> 01, 1 -> 10 –2x overhead, provides no error correction –Does not perform error detection FOUR_B_RADIO_BYTE.comp –Performs 4b/6b, DC balancing encoding –4 bite nibbles transmitted at 6 bits –1.5 x overhead, no error correction possible –Does not perform error detection –Table look-up used to perform encoding

19 Different Encoding Options (cont.) SEC_DED_RADIO_BYTE.comp »Combination of SEC_DED forward error correction and DC balancing –8 bits encoded as 17 bits –Can correct 1 bit errors and detect two bit errors –Based on binary matrix multiplication SEC_DED_RADIO_BYTE_SIGNAL.comp –Same as SEC_DED_RADIO_BYTE except it also provides the value of the BBOUT pin from the RFM –Each time a 1 bit is read in, the ADC samples the value of the BBOUT pin. The readings are averaged and put into the Byte_Ready event

20 SEC_DED_BYTE encoding matrix Based on hamming codes Performs both DC_balance and FEC in one step Generator Matrix:

21 Packet Level Components UART_PACKET.comp, PACKETOBJ.comp, PACKETOBJ_SIGNAL.comp, CRCPACKETOBJ.comp, RED_PACKETOBJ.comp Transfer individual bytes down to byte level components Top of the communications data pumps Deals with fixed length packets Refuses to accept packet if busy TOS_MODULE PACKETOBJ; ACCEPTS{ char PACKET_TX_PACKET( TOS_MsgPtr data); void PACKET_POWER(char mode); char PACKET_INIT(void); }; SIGNALS{ char PACKET_TX_PACKET_DONE( TOS_MsgPtr packet); TOS_MsgPtr PACKET_RX_PACKET_DONE( TOS_MsgPtr packet); };

22 Packet Options PACKETOBJ.comp –Generic fixed length packets CRCPACKETOBJ.comp –Add a 16 bit CRC check to the end of the packet –Drops packet if CRC check fails RED_PACKET.comp –Redundancy based forward error correction –Each packet is transmitted 3 times –For each byte, if two of the three version match, it accepts the value –Otherwise the first version is used PACKETOBJ_SIGNAL.comp –Designed to work with SED_DED_RADIO_BYTE_SIGNAL.comp –Averages the signal strength readings and places it in the strength variable of the packet –Requires that MSG.h be modified to add the strength field to the end of the packet

23 Tasks in low-level packet processing char TOS_COMMAND(PACKET_TX_PACKET)(TOS_MsgPtr data){ if(VAR(state) == 0){/* receiving */ VAR(data) = (char*)data; if(TOS_CALL_COMMAND(PACKET_SUB_TX_BYTES)(VAR(data)[0])){ /* start tx */ TOS_POST_TASK(CRC_calc); VAR(state) = 1;/* transmitting */ VAR(count) = 1; return 1; }else{ return 0; } }else{ return 0; } Post task to calculate CRC in the background while event driven data pumps push bytes system/CRC_PACKET_OBJ.c

24 Messaging Level Components AM.comp, AM_BASE.comp Adds Addressing, Active Message Dispatching, and Group IDs to the communications layer One byte message type used to direct packet to handlers –AM_MSG_HANDLER_0 handles message 0 Buffer Swapping on message receipt 0xff = Broadcast Address AM_BASE sends 0x7E to UART interface TOS_MODULE AM; ACCEPTS{ char AM_SEND_MSG(char addr,char type, TOS_MsgPtr data); char AM_POWER(char mode); char AM_INIT(void); }; SIGNALS{ char AM_MSG_SEND_DONE(TOS_MsgPtr msg); TOS_MsgPtr AM_MSG_HANDLER_0(TOS_MsgPtr data); TOS_MsgPtr AM_MSG_HANDLER_1(TOS_MsgPtr data);. TOS_MsgPtr AM_MSG_HANDLER_255(TOS_MsgPtr data); };

25 Messaging Format Set in system/include/MSG.h Data structure needs to be modified to account for the packet layer used Packet layers use sizeof(MSG_VALS) to set transmission size struct MSG_VALS{ char addr; char type; char group; char data[DATA_LENGTH]; //short crc; //int strength; }; system/include/MSG.h


27 Full PC support of communication Hardware abstraction components modified to work on PCs RFM and UART replaced by sockets Each individual radio bit is sent as a character over a socket RFM connects to :9876 UART connects to :8765 Implemented in: –system/include/Fullpc_radio.h –system/include/Fullpc_uart_connect.h RF_simulator used to simulate connectivity

28 RF_Simulator Connects individual Mote processes together By default, nodes 1->10 are fully connected –Edit RF_simulator/ to change topology Can construct arbitrary topologies of connectivity add_conn(ID1, ID2) creates a bi-directional link between mote with ID1 and ID2 RF_simulator/ add_conn(1, 2); add_conn(2, 3); add_conn(3, 4); add_conn(4, 2);

29 Example use of RF_simulator 1.Compile CNT_TO_RFM.decs for the PC Copy main.exe to counter.exe 2.Compile generic_base.desc for the PC 3.Open three console windows 1.In the first, cd RF_simulator; java ConnectionManager 2.In the second, run main 5 3.In the third, run counter 3 4.You will see packets transmitted by counter, forwarded by the connection manager and received by the generic_base 5.The generic base will then send the packet out the UART

30 Other System Components MAIN I2C_OBJ LOGGER

31 MAIN.comp Issues INIT and Start command to applications Required to be in all applications Actually calls and includes the scheduler Should not need to be modified TOS_MODULE MAIN USES{ char MAIN_SUB_INIT(void); char MAIN_SUB_START(void); };

32 I2C_OBJ.comp Implementation of I2C protocol on I2C bus 2 Single Master Only Transmissions take place inside individual tasks Used to interact with EEPROM or external digital sensors Uses tasks to implement split phase protocol ACCEPTS{ char I2C_init(void); char I2C_read(void); char I2C_write(char val); char I2C_send_start(void); char I2C_send_end(void); }; SIGNALS{ char I2C_read_done(char val, char error); char I2C_write_done(char success); char I2C_send_start_done(void); char I2C_send_end_done(void); };

33 Logger Uses on-board I2C based EEPROM to store log entries Has 30 byte log entries Append Only Log Currently starts over at 0 when initialized ACCEPTS{ char APPEND_LOG(char* data); char READ_LOG(int line, char* dest); char LOGGER_INIT(void); }; SIGNALS{ char APPEND_LOG_DONE(char success); char READ_LOG_DONE(char* packet, char success); };

34 Application Level Components AM_BEACON.comp –Sends out periodic beacons that contain the local address AM_ECHO.comp –Responds to a message by sending out a message to the address specified by data[0] AM_ROUTE.comp –Ad-hoc routing application that sends collected data to a base station BLINK.comp –Blinks the LEDS CHIRP.comp –Repeatedly sends out packets that contain light sensor readings

35 Application Level Components (cont.) CONNECT.comp –Ad-hoc routing application that maintains the connectivity graph of which surrounding nodes can be heard COUNTER.comp –Sends the value of the counter to an output device (leds or RFM) SENS_OUTPUT.comp –Send the value of a sensor to an output device GENERIC_BASE.comp –Listens on the RADIO and forwards any packets received to the UART

36 Application Level Components (cont.) INTERP.comp –Virtual machine for programming the motes LOGGER_TEST.comp –Demonstrations of the Logger functionality. It takes periodic sensor readings and records them to the log. It also sends the values to the UART. It will respond to active messages that request log entries to be read MAGS.comp –Reads data from the ADC and forwards it to the UART. It performs band pass filtering on the data for event detection. Data readings are double buffered WAVE.comp –Changes the values displayed on the LEDs based on the value read from PHOTO.comp

Download ppt "David Culler, Jason Hill, Robert Szewczyk, Alec Woo U.C. Berkeley 2/9/2001 TinyOS Programming Boot Camp Part IV – Tiny OS 4.3 Component Overview."

Similar presentations

Ads by Google