[Tinyos-help] TinyOS:Amtega128 ADC values help
Varun Jain
varun at spiderbox.com.au
Mon Jun 2 18:44:08 PDT 2008
Hi,
Thanks a lot as my problem is fixed (I guess!!!!). By removing the code
from ResourceConfigure, it works fine only if I use ATM128_ADC_VREF_AVCC
or ATM128_ADC_VREF_2_56 but still gives me 0x3ff with
ATM128_ADC_VREF_OFF as probably the voltage its reading is above some
reference so it gives the max value of 0x3ff. But I need to clarify a
point here. If I am using the internal 2.56V as the reference voltage, I
get the readings as 0x190 0x191..... which is decimal 400 401 (Vo) so to
convert this into V(t) to know the temperature, I do something like in
the OscilloscopeMsg.java file:
-----------------------------------------------------------------------
V(t) = (Vo / 1024) * 2.56
Now the LM61 temperature sensor datasheet says that there is a DC offset
of 600mV and its temperature slope is 10mV/degree Celsius
For a Vo of say decimal 400, the result would be something like:
V(t) = (400 / 1024) * 2.56 = 1V or 1000mV (1024 in this equation is
the resolution of 10 bit ADC)
V(new) = V(t) - 600mV = 400mv
Since temperature slope is 10mV/degree Celsius for LM61, the temperature
reading from temp sensor that I am reading is:
Temperature = 400 / 10 = 40 degree Celsius
-----------------------------------------------
AM I on the right path??????? Or am I calculating it wrong???
Thanks a lot for your help....
Cheers,
Varun Jain
R&D Embedded Design Engineer
Spiderbox Pty. Ltd.
-----Original Message-----
From: Razvan Musaloiu-E. [mailto:razvanm at cs.jhu.edu]
Sent: Monday, June 02, 2008 11:55 AM
To: Varun Jain
Cc: tinyos-help at millennium.berkeley.edu
Subject: RE: TinyOS:Amtega128 ADC values help
Hi!
On Sun, 1 Jun 2008, Varun Jain wrote:
> Hi,
> Thanks for your reply. I have taken the basic sensor code from the
> tos/sensorboards/basicb. Further, I have modified it according to my
> Chipcon CC2420DBK boards which has an onboard LM61 temperature sensor.
> The code is as follows:
>
> generic configuration TempC() {
> provides interface Read<uint16_t>;
> }
> implementation {
> components new AdcReadClientC(), TempP;
> components HplAtm128GeneralIOC as AtmGeneralIO;
>
> Read = AdcReadClientC;
> AdcReadClientC.Atm128AdcConfig -> TempP;
> AdcReadClientC.ResourceConfigure -> TempP;
> TempP.TempPin -> AtmGeneralIO.PortF3; //WIRING PORT-F3 and then
setting it up in TempP
> }
>
> ---------------------------------------------
> module TempP
> {
> provides {
> interface ResourceConfigure;
> interface Atm128AdcConfig;
> }
> uses {
> interface GeneralIO as TempPin;
> }
> }
> implementation
> {
> async command uint8_t Atm128AdcConfig.getChannel() {
> return ATM128_ADC_SNGL_ADC3;
> }
>
> async command uint8_t Atm128AdcConfig.getRefVoltage() {
> return ATM128_ADC_VREF_OFF;
> }
>
> async command uint8_t Atm128AdcConfig.getPrescaler() {
> return ATM128_ADC_PRESCALE;
> }
>
>
> async command void ResourceConfigure.configure() {
> call TempPin.makeOutput();
> call TempPin.set();
> }
>
> async command void ResourceConfigure.unconfigure() {
> call TempPin.clr();
> }
> }
>
> ----------------------------------------------
I found your problem: PortF3 is exactly the ADC3 and you are making it
output when you are trying to read something from it. I removed the code
from ResourceConfigure.configure and ResourceConfigure.unconfigure and
then Oscilloscope application star working properly. :-)
All the best!
Razvan ME
> I am using the Oscilloscope application where DemoSensorC is called
> which further calls the TempC() module. I am getting constant reading
of
> 03 FF 03 FF 03 FF 03 FF 03 FF in the payload part using the listen
tool.
>
> If i use the MsgReader tool from Oscilloscope application and connect
> the serial port on the "BaseStation" application, i constantly get
'0xff
> 0xff.... 0xff' as the readings for "local.readings" in the
> "OscilloscopeMsg"
>
> If i use a voltmeter across the temp.sensor, it gives about 1000mV
which
> is approximately 40 degrees according to LM61 (National Semiconductor
> temp sensor) datasheet, but my readings still come out to be 03 FF 03
> FF..., it does not vary at all. Even after putting the temp. sensor in
> front of a hot air source which makes it really hot and voltage
changes
> to 1100mV which is 50 degrees C [10mV/degree C + 600mV(offset) ].
>
> Even if i use "ATM128_ADC_VREF_2_56" or "ATM128_ADC_VREF_AVCC" to get
> the reference voltage, the result is the same, if the reading across
the
> temp.sensor is only 1V then these references should be alright. What
is
> the effect of using "ATM128_ADC_VREF_OFF" but anyways in all cases it
> gives me 03 FF 03 FF...
>
> Thanks.
>
> Cheers,
> Varun
>
>
> ________________________________
>
> From: Razvan Musaloiu-E. [mailto:razvanm at cs.jhu.edu]
> Sent: Sun 6/1/2008 10:21 AM
> To: Varun Jain
> Cc: tinyos-help at millennium.berkeley.edu
> Subject: Re: TinyOS:Amtega128 ADC values help
>
>
>
> Hi!
>
> Sorry for answering so late. :-(
>
> On Fri, 30 May 2008, Varun Jain wrote:
>
>> Hi,
>>
>> I am currently trying to set up a WSN using tinyos-2.x. I have
Chipcon's
>> CC2420DBK with me, it has an onboard temperature sensor LM61 attached
to
>> it with atmega128 processor. I am trying to read the temperature
values
>> from this sensor, I am constantly getting 0x3ff as my data in the raw
>> packet using the Listen tool. I am trying to get Oscilloscope
>> application running. I am reading the value on ADC3 channel on
PortF3.
>>
>
> The Atmega128 has 10 bits of precision so the 0x3ff is the maximum
value.
> This is the value you'll get if the voltage you are reading is above
the
> reference used by the ADC. How did you configured the ADC? Can you
measure
> the output voltage from temperature sensor with a voltmeter?
>
> --
> Razvan ME
>
>>
>> I read somewhere you discussing about this value. Can you guide me as
to
>> what does this value depict, I think I am reading wrong values as I
>> keep the board in front of hot air source which really heats up the
>> sensor but still it gives the same value.
>>
>>
>>
>> Any help or direction will really help...
>>
>>
>>
>> Varun Jain
>> R&D Engineer
>> Spiderbox Pty. Ltd.
>> P: +617 3318 9509
>> F: +617 3318 9595
>> M: +61401 091 248
>> E: varun at spiderbox.com.au <mailto:bdarcy at spiderbox.com.au>
>> W: http://www.spiderbox.com.au <http://www.spiderbox.com.au/>
<http://www.spiderbox.com.au/>
>>
>>
>
>
>
More information about the Tinyos-help
mailing list