[Tinyos-help] ADC reading fluctuations

krisa krisatm at gmail.com
Sun Nov 7 19:18:38 PST 2010

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
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!

Krišjānis Nesenbergs

More information about the Tinyos-help mailing list