You may be getting power line noise. Try shorting the ADC input
to ground to see if the fluctuation goes away. If not there may
be a problem with your power supply itself -- although the
accelerometer reading would indicate otherwise. If the noise
goes away when shorted you can try shielding the sensor wires
and fiddling with the wiring and routing. It could also be a
ground loop if you aren't connecting your ground wires to a
common point.

I'm not clear how you are connecting your bend sensor. If it
is a "straight-ahead" variable resistance, you need to have
a fixed resistor in series.... Oh, maybe that's the issue....
Are you just running it between the ADC input and ground?
If so a better way would be to have a resistor from the
Vref or power supply to the sensor, who's other end is
grounded. Then attach the ADC input to the resistor-sensor
connection point. That makes the whole thing a voltage divider.
Start with a 10K resistor, since that's how much your bender
changes. You can use ohms law to figure out a more optimal
value based on the min/max resistance of the sensor. Bear in
mind that the ADC input has an impedance which will be in
parallel with your sensor, IIRC, something around 250Kohms.

MS

krisa wrote:
> I am having a problem with reading value from ADC ports of telosb mote
> using TinyOS 2.1.1
> I have a simple variable resistor sensors (bend sensors) attached to
> ports 6.3 - 6.7 (ADC3-ADC7), and while their resistace is not changed
> I would assume their readings to be somewhat constant (of course with
> some noise), but they are fluctuating in almost a sine like pattern -
> while sampling with 100ms rate some 3-4 readings have a value which
> seems lke the correct value, then some 4-5 readings have value lower
> by some 200-300 or even more.
> On  the other hand I have an accelerometer attached to ADC0-ADC2 and
> its readings while in peaceful condition only fluctuates a little
> (maybe 10-20 units max) and not in such a recognizable pattern - which
> seems as it should be.
> 
> I am using this configuration for reading the values
>   const msp430adc12_channel_config_t config = {
>       inch: INPUT_CHANNEL_A0, //Of course changing to the correct port
>       sref: REFERENCE_VREFplus_AVss,
>       ref2_5v: REFVOLT_LEVEL_2_5,
>       adc12ssel: SHT_SOURCE_ACLK,
>       adc12div: SHT_CLOCK_DIV_1,
>       sht: SAMPLE_HOLD_4_CYCLES,
>       sampcon_ssel: SAMPCON_SOURCE_SMCLK,
>       sampcon_id: SAMPCON_CLOCK_DIV_1
>   };
> but I have experimented with many others - by some manipulations to
> clock selection or sample hold time, I have managed to get constant
> readings, but then the readings dont change even if the resistor value
> is changed - basically not working.
> I have tried both reading thorough the Read<uint16_t> interface and
> Msp430Adc12MultiChannel through Msp430Adc12ClientAutoRVGC with the
> same results  - maybe there is another method?
> 
> Also - even if I disconnect the sensor from the port i still get
> uneaven readings - sometimes maximum of 4095 and sometimes as low as
> 0.
> I am quite sure that the problem is me not knowing how to read the
> sensor data in TinyOS and not broken mote, because It was previously
> tested with another programming language which gave more consistent
> sensor readings.
> The only possiblity what comes to my mind is that there is some kind
> of inconsistency with clocks (some interferance pattern?) because the
> readings are distorted in a regular pattern and if I change the
> sampling rate the distortions also still are sine form only longer or
> shorter. (1000 ms sampling yields some 9 high and 9 low readings, 25
> ms sampling yields approx 2 high and 2 low readings).
> 
> I think the problem is the configuration, and seeing as I am quite new
> to mote programming I am a little in dark here - which reference and
> clock should I use (it seems they could be different from those used
> for the accelerometer)
> 
> Also a followup question - the resistor when changed has approx 10kohm
> variance which translates in approx 100-200 points of reading change -
> is there a way to enhace this so the range would be closer to the
> whole scale of 0-4095?
> 
> I have spent many days on this problem and would really appreciate any
> help or insight in this matter.
> 
> Thank you in advance!
> 
> 
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to