0
\$\begingroup\$

I have an Xbee configured as receiver and Arduino (standalone w/ atmega328p chip) connected together. The RSSI pin of the Xbee is connected to one of the Arduino Board PWM pin. I used the PulseIn to get the digital equivalent of the RSSI (i named it rssiDur) I used the Hyperterminal to display the rssiDur value. The rssiDur values displayed on the HT is not consistent. Any interference between my Xbees changes the rssiDur dramatically. I wish to stabilize the rssiDur reading so that the interference will not be of great effect.

it has been suggested to use a timer. i don't know how though. it was something like when the rssiDur displays 10 consecutive of the same value, that value will be the rssiDur. ( example: 9 9 9 9 9 9 9 9 9 9 8 8 6 7 10, rssiDur=9) Does anyone know how to do this? Or any suggestions on how to treat the values of rssiDur? it will much help on our project.

**Update: Hi again! I used the Average Library but I am still getting outliers every now and then for example: (copied from HT) :
25
4
25
27
25
20
32
1
24
24
20
20
27
28
20
22
20
19
1
3
19
18
20
20
1
20

how do you throw out the outliers? Will it be advisable if I used a double Mode filter?

\$\endgroup\$
  • \$\begingroup\$ thats a nice suggestion. what are possible functions to be used? or do you have a sample code for this? thank you. \$\endgroup\$ – roseannvalorie Feb 11 '14 at 10:26
  • \$\begingroup\$ You are trying to read an analogue voltage (Received Signal Strength Indicator) by using PulseIn - this doesn't make sense to me. Surely PulseIn is for reading duration of logic levels inputted to the PWM pin? \$\endgroup\$ – Andy aka Feb 11 '14 at 11:28
1
\$\begingroup\$

According to the Arduino Reference pulseIn: "Works on pulses from 10 microseconds to 3 minutes in length." So that should be borne in mind.

To answer your question, my understanding is that you want to "clean up" or filter the rssiDur value. You could filter this digitally using a low pass filter to approximate the mean value:

int rssiDurFilt = (1-0.99)*rssiDur + 0.99*rssiDurFilt;

Change the 0.99 to change the cut off frequency (closer to 1.0 is lower frequency). The actual expression for that value is exp(-2*pi*f/fs) where f is the cutoff frequency you want and fs is the frequency the data is sampled at.

Another type of "digital filter" is an event filter. It works well on data that has outliers; e.g. 9,9,8,10,9,25,9 In this case you fill an array with sampled values and build a frequency table (i.e. count the number of occurrences of each value), then select the value with the most occurrences. Statistically this is the mode.

UPDATE: Statistical averages such as Mean, Mode etc.. can be calculated using the Arduino Average Library.

\$\endgroup\$
  • \$\begingroup\$ A comment on the Moving Average: the code above is the Recursive (or IIR) equivalent of the Moving Average. Has the advantage of lower storage requirement and simpler code. \$\endgroup\$ – akellyirl Feb 11 '14 at 11:18
  • \$\begingroup\$ I think the event filter suits best in our project. Do you have an algorithm for this? Or better yet a code? thanks! \$\endgroup\$ – roseannvalorie Feb 12 '14 at 3:54
  • \$\begingroup\$ also, I'm new to programming in Arduino IDE, do you know how to make an array and fill it with values? \$\endgroup\$ – roseannvalorie Feb 12 '14 at 3:56
  • \$\begingroup\$ @roseannvalorie You can get the Mode quite easily using an Arduino function as follows: playground.arduino.cc/Main/Average \$\endgroup\$ – akellyirl Feb 12 '14 at 9:40
  • \$\begingroup\$ @roseannvalorie Thanks. But the site etiquette is not to write a "thank you" but rather to vote-up the answer or mark it as the best answer if appropriate. :-) \$\endgroup\$ – akellyirl Feb 13 '14 at 10:06
0
\$\begingroup\$

I would just keep a moving average by keeping the last 10 RSSI values in an array and shifting the contents of the array by one each time a new value is read.

I don't see how changing what value you store has an affect on actual interference unless you are using it to delay transmission until the "network" is quiet.

\$\endgroup\$
  • \$\begingroup\$ what are possible functions to be used? or do you have a sample code for this? thank you. \$\endgroup\$ – roseannvalorie Feb 11 '14 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.