Hello everybody,

I have the following problem with ADC sampling in TinyOS (using an Iris node, Atm1281 chip):

- My hardware has two sensors (say A and B), which are connected to ADC ports 7 and 5. - The sensors are properly wired in TinyOS and hidden behind a self-made ADC layer that takes N samples (consecutively) using the Read interface and returns (signals) the average value, when the N-th sample has been taken. For that purpose, my ADC layer uses the Read interface to start the first conversion of N. The readDone-event of the actual sensor is used to sum up the values, start a new conversion until N samples have been summed up, and finally signal a readDone event itself (see above).
- This implementation generally works.

However, consider the following scenario (which I have in my setup).
- My program runs two timers TA and TB for two sensors.
- When the timers fire, the read command of my ADC layer (the one averaging N samples) is called. When the average samples are available, they are sent via radio. - Both timers have different (but constant) timings, so that at some point, they will fire "at the same time" (i.e., one directly following the user from the software timer implemenation; NOTE that using tasks here did not bring any relaxation of the following problem). In this instance, the first ADC conversion of A is started. The Arbiter of the ADC implemenation accepts the conversion of B, but postpones it until reading A has finished. The conversion of B is then started, but the corresponding ADC conversion interrupt occurs almost directly after starting this second conversion, and the value in the ADC register is the same as before. Both readings (for A *and* B) are thus the same, although the value at the ADC pins are not the same at all (roughly 650 vs. 90 on the range [0,1023) ).

It generally appears that there is some problem caused by calling the read command (from inside the readDone) while another ADC conversion is about to start/is pending. I have verified that both conversions (the first one of A and B) are properly started and the ADMUX register is initialized correctly (using and tracking free IO/pins). However, the problem may also occur, if only one sensor uses my ADC layer, and the other one is read multiple times using a task (which is posted by the timer for the first time with subsequent posts from the sensor's readDone). In addition, on some nodes the problem occurs randomly (onl once in a while and without a pattern).

The question now is, if I'm doing something (terribly) wrong, or if there is any timing issue related to reading (ADC) sensors (maybe even a problem in the Atm1281 ADC implementation).


I'd appreciate any kind of help, since I'm the terrible situation that I can't trust my sensor readings. ;-)


Best
Christian

--
__Christian_Renner________________________________________________________
  Hamburg University of Technology        [email protected]
  Institute of Telematics (E-17)               Tel.: (+49) 40 42878-3746
  Schwarzenbergstrasse 95                      Fax:  (+49) 40 42878-2581
  21073 Hamburg, Germany       http://www.ti5.tu-harburg.de/staff/renner

<<attachment: adc_error_d9sample.png>>

<<attachment: adc_error_no2.png>>

_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to