Download presentation
Presentation is loading. Please wait.
Published byFelicity Walton Modified over 9 years ago
1
Lab 5 System Design Thomas Watteyne EE290Q – Spring 2010 http://wsn.eecs.berkeley.edu/290Q
2
2 Result
3
3 sniffer Topology originX Y node gateway displays raw bytes in hex format sends packet every 1+U(2) seconds displays GUI
4
4 Packet Structure 0length 10x00 2 3 4source 50x00 6 7 8destination 9x_coord 10y_coord 11type 12temperature 13battery choose 0x01 measure by hand (unit: feet) 0x01 ADC
5
5 Medium Access Pure Aloha Wait for 1+U(2) seconds Send a packet Listening not required
6
6 SubProjects 1.Send an empty packet with the right format 2.Measure the battery’s voltage 3.Measure the temperature 4.Obtaining a random number 5.Program a sniffer (with text based output) 6.Program a gateway (binary output) 7.Program the GUI
7
7 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
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
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
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
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: “ : \r\n” Check the content of the packets using PuTTY
12
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
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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.