1 / 13

Lab 5 System Design

Lab 5 System Design. Thomas Watteyne EE290Q – Spring 2010 http://wsn.eecs.berkeley.edu/290Q. Result. Topology. origin. X. sends packet every 1+U(2) seconds. Y. displays raw bytes in hex format. displays GUI. gateway. sniffer. node. Packet Structure. choose. 0x01.

astro
Download Presentation

Lab 5 System Design

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lab 5System Design Thomas Watteyne EE290Q – Spring 2010 http://wsn.eecs.berkeley.edu/290Q

  2. Result

  3. Topology origin X sends packet every 1+U(2) seconds Y displays raw bytes in hex format displays GUI gateway sniffer node

  4. Packet Structure choose 0x01 measure by hand(unit: feet) 0x01 ADC

  5. Medium Access Pure Aloha • Wait for 1+U(2) seconds • Send a packet • Listening not required

  6. SubProjects • Send an empty packet with the right format • Measure the battery’s voltage • Measure the temperature • Obtaining a random number • Program a sniffer (with text based output) • Program a gateway (binary output) • Program the GUI

  7. 1. Send Empty Packet with the right format • Create project lab5_nodewith 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() { intdegC; 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 value

  11. 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 PuTTY

  12. 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 mode

  13. 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 voltage

More Related