DOC PREVIEW
Berkeley ELENG 290Q - Lab 3: spectrum analyzer, RSSI vs. distance

This preview shows page 1-2 out of 6 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Lab 3: spectrum analyzer, RSSI vs. distanceUC Berkeley - EE 290QThomas WatteyneFebruary 22, 2010Installation required! From this lab on, you will use Python scripts foryour laptop to communicate with your motes. Before the lab, make surethat Pythonaand PySerialbare installed.ahttp://www.python.org/, version 2.5.4 and 2.6.4 are known to workbhttp://pyserial.sourceforge.net/, pyserial-2.5-rc1.win32.exe is known to work1 Poor Man’s Spectrum AnalyzerGoal. The CC2500 can easily change its operating frequency, throughthe use of channels. For each of these channels, the CC2500 can sensethe level of electro-magnetic noise, in dBm. The goal of this section is tobuild a spectrum analyzer by continuously plotting noise vs. frequency. Wetherefore use a Python script running on the host computer.1.1 Running the Code• Copy-paste the code form Listing 1 into IAR1, and program a single board;close IAR.• Connect your board to the host computer, and find the COMx port it isconnected to. Use PuTTY to read from that COMx port; you should seelines of 200 numbers appearing. Close PuTTY.• Double-click on spectrum analyzer.py2, you should see a bar graph sim-ilar to the one in Fig. 1.Some keys for understanding the code running on the mote:• Line 3. print rssi() is a function which prints the RSSI value readfrom the CC2500 onto the serial port which is initialized between lines 18and 23. TXString() is a function provided in bspboard.c1or use the project lab3spectrum analyzer in the downloaded source code2download from the lab’s webpage1Listing 1: Spectrum analyzer sensor code (Section 1).1 #i n c lu d e ” mrf i . h”2 #i n c l u d e ” r a d i o s / f a m ily 1 / m r f is p i . h”3 void p r i n tr s s i ( i n t 8 t r s s i )4 {5 char output [ ] = {” 000 ” } ;6 i f ( r s s i <0) { output [0]= ’ − ’; r s s i=−r s s i ; }7 output [ 1 ] = ’0 ’+(( r s s i /100)%10);8 output [ 2 ] = ’0 ’+(( r s s i /10)%10);9 output [ 3 ] = ’0 ’+ ( r s s i %10);10 TXString ( output , ( s i z e o f output ) −1);11 }12 i n t main ( void )13 {14 i n t 8t r s s i ;15 u i n t 8t chann el ;16 BSP Init ( ) ;17 MRFIInit ( ) ;18 P3SEL |= 0x30 ;19 UCA0CTL1 = UCSSEL2 ;20 UCA0BR0 = 0x41 ;21 UCA0BR1 = 0x3 ;22 UCA0MCTL = UCBRS2 ;23 UCA0CTL1 &= ˜UCSWRST;24 MRFIWakeUp ( ) ;25 b i s S R r e g i s t e r (GIE ) ;26 w hile ( 1 ) {27 f o r ( chan nel =0; channel <200; c hannel++) {28 MRFIRxIdle ( ) ;29 mrfiSpiWriteReg (CHANNR, chann e l ) ;30 MRFIRxOn ( ) ;31 r s s i=MRFI Rssi ( ) ;32 p r i n tr s s i ( r s s i ) ;33 }34 TXString (”\n ” , 1 ) ;35 }36 }37 void MRFIRxCompleteISR ( )38 {39 }2Figure 1: Output of the spectrum analyzer in Section 1; microwave oven is on.• Lines 18-23 initialize the serial p ort, which enable your code to outputlines of text using the TXString() function. Output characters can beread using PuTTY.• Line 25 instructs the MSP430 to stay in active mode all the time, i.e. notto enter any low power mode.• Lines 26-35 is a loop which continuously scans through channels 0-200,recording and outputting the RSSI value. MRFIRssi() is a function de-clared in the drivers.1.2 Refresh Rate of the Spectrum Analyzer• in the code, add after line 16P2DIR |= 0x02;• in the code, add after line 26P2OUT ∧= 0x02;• using the oscilloscope, measure on extension port P4 the refresh rate ofthe frequency analyzer. It should be around 1.1s.• move the last added line after line 27. You now measure the time it takesfor the mote to sample the noise level on one channel, and move to theother. Make sure you measure a value close to 5.5ms.1.3 Testing the Spectrum Analyzer• Reprogram a second board using the code used in Lab 2 for a continuoustransmission, so that it continuously sends data. Start the continuous3sending and visualize this transmission on the spectrum analyzer.• Change the operating channel, and see the implications on the spectrumanalyzer.• You can also see the impact of a running microwave oven.42 RSSI vs. DistanceGoal. You will draw the RSSI received as a function of distance betweensender and receiver, experimentally. Because of the random nature of prop-agation, especially indoors, you will see that this relationship is not straight-forward to predict. It should be clear that repeating these measurementsunder different conditions yields very different results.You will modify the code used in Section 1 in order to read 200 times theRSSI value from the same channel. A python s cript will then average thosevalues. To this end:• In the code used in the previous section, comment out line 29. The motewill now read the RSSI 200 times on channel 0.• Reprogram the receiver board and visualize the values output on theCOMx port using PuTTY. Close PuTTY.• Run rssi vs dist.py3. It outputs the average value of the 200 valuesreceived.• Reprogram a second board so that it continuously sends data, on channel0 and with a transmission power of 0dBm.• Start the continuous sending and see how the RSSI decreases as the trans-mitter is moved away from the receiver.3download from the lab’s webpage53 QuestionsHand in at the beginning of the next lab.1. What is the refresh rate of your spectrum analyzer (Section 1.2)?2. What the single-channel sample period (Section 1.2)?3. Provide a screen shot of your spectrum analyzer when your mote is nextto a micro-wave, when a second mote transmits (Section 1.3).4. What is the frequency of each channel (Section 1.3)?5. What did you do to the previous question? Can you think of another wayof getting the same answer? List as many as you can (Section 1.3).6. Plot RSSI vs. distance in at least 3 different scenarios. One plot shouldbe at least 10 points gathered over a significant enough. What is thisdistance. Describe the scenarios, and why you chose them. Send the rawdata file to watteyne@eecs using the following format:#setting 1distance1 rssi1...#setting 2distance1 rssi1...7. Are we really measuring the RSSI of the packets we receive? Why not?What should we do to do this right (2)? How much would the two mea-surements differ?8. Answer one of the ”for enthusiastic students” questions.For enthusiastic students:1. Change the firmware on the mote so that we measure RSSI vs. distanceright. You s hould be able to use rssivs dist.py as-is. Compare thesemeasurements with the ones from Section 2. How much is the difference?Why?2. Add a max-min feature to spectrumanalyzer.py: each bar should bethe maximum value on that channel seen so far (tip: to


View Full Document

Berkeley ELENG 290Q - Lab 3: spectrum analyzer, RSSI vs. distance

Documents in this Course
Lab 1

Lab 1

16 pages

Lab 1

Lab 1

16 pages

Load more
Download Lab 3: spectrum analyzer, RSSI vs. distance
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lab 3: spectrum analyzer, RSSI vs. distance and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lab 3: spectrum analyzer, RSSI vs. distance 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?