Slide 1ResultTopologyPacket StructureMedium AccessSubProjects1. Send Empty Packet with the right format2. Measure the battery’s voltage3. Measure the temperature4. Obtain a random number5. Program a sniffer6. Program a gateway7. GUILab 5System DesignThomas WatteyneEE290Q – Spring 2010http://wsn.eecs.berkeley.edu/290Q2 Result3 snifferTopologyorigin XYnodegatewaydisplays raw bytes in hex formatsends packet every 1+U(2) secondsdisplays GUI4 Packet Structure0 length1 0x002 0x003 0x004 source5 0x006 0x007 0x008 destination9 x_coord10 y_coord11 type12 temperature13 batterychoose0x01measure by hand(unit: feet)0x01ADC5 Medium AccessPure Aloha•Wait for 1+U(2) seconds•Send a packet•Listening not required6 SubProjects1. Send an empty packet with the right format2. Measure the battery’s voltage3. Measure the temperature4. Obtaining a random number5. Program a sniffer (with text based output)6. Program a gateway (binary output)7. Program the GUI7 1. Send Empty Packet with the right format•Create project lab5_node with C file called system_node•Define global variables MYADDR, MYX, MYY at the beginning of the file•In main():–Initialize the board–Initialize the radio–Initialize a timer which fires regularly (e.g. every 2s)•When timer fires–Fill all the fields except temperature and battery–Transmit the packet•LEDs:–red: I send–(green: I receive)8 2. Measure the battery’s voltage•Create a simple project which reads the voltage when you press a button. You can use the debug mode of IAR to freeze the MSP and read the value•The following functions returns the battery voltage, make sure you understand every line!uint8_t get_battery() { int battery=0; ADC10CTL1 = INCH_11; // AVcc/2 ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE + REF2_5V; for( battery = 240; battery > 0; battery-- ); // delay to allow reference to settle ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start __bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled battery = ADC10MEM; ADC10CTL0 &= ~ENC; ADC10CTL0 &= ~(REFON + ADC10ON); // turn off A/D to save power battery = (battery*25)/512; uint8_t batterybyte = battery&0xFF; return batterybyte;}9 3. Measure the temperature•Create a simple project which reads the temperature when you press a button. You can use the debug mode of IAR to freeze the MSP and read the value•The following functions returns the temperature, make sure you understand every line!uint8_t get_temperature() { int degC; volatile long temp; ADC10CTL1 = INCH_10 + ADC10DIV_4; // Temp Sensor ADC10CLK/5 ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON + ADC10IE + ADC10SR; for( degC = 240; degC > 0; degC-- ); // delay to allow reference to settle ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start __bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled degC = ADC10MEM; ADC10CTL0 &= ~ENC; // oC = ((A10/1024)*1500mV)-986mV)*1/3.55mV = A10*423/1024 - 278 // the temperature is transmitted as an integer where 32.1 = 321 // hence 4230 instead of 423 temp = degC; degC = (((temp - 673) * 4230) / 1024); if( tempOffset != 0xFFFF ) { degC += tempOffset; } return (uint8_t)(degC&0xFF);}10 4. Obtain a random number•Create a simple project which blinks the LED with a period of 1+U(2) seconds.•The key function is MRFI_RandomByte(), explore in the drivers how it is implemented•Use the scope to measure the timing; evaluate how uniform the distribution isreads the temperature when you press a button. You can use the debug mode of IAR to freeze the MSP and read the value11 5. Program a sniffer•Create project lab5_sniffer with C file called system_sniffer.c•In main()–Initialize the board–Initialize the radio–Enable serial communication•When you receive a packet, output every byte to the serial port using the following format: “<byte>:<value>\r\n”•Check the content of the packets using PuTTY12 6. Program a gateway•Create project lab5_gateway with C file called system_gateway.c•In main()–Initialize the board–Initialize the radio–Enable serial communication•When you receive a packet,–In text mode, output every byte to the serial port using the following format:"from XXX @(XXX,XXX) to XXX: T=XX.XC B=X.XV\r\n“–In binary mode, output a string of uint8_t values using the following format: output[0] = src;output[1] = dest;output[2] = x_coord;output[3] = y_coord;output[4] = type;output[5] = temperature;output[6] = battery;•Pushing the button should switch the output mode13 7. GUI•Create a Python GUI called system.py which opens the serial port and receives lines from the mote in the format:output[0] = src;output[1] = dest;output[2] = x_coord;output[3] = y_coord;output[4] = type;output[5] = temperature;output[6] = battery;•Followed by \r\n•Display the motes in space, using x and y, and display the temperature and battery
View Full Document