[Tinyos-help] TinyOS:Amtega128 ADC values help

Michael Schippling schip at santafe.edu
Sun Jun 1 09:46:09 PDT 2008


I think you are using T2 and I'm not familiar with all the hoohaw
that goes into getting anything to work there, but it appears that
you want to use Port F3 as ADC3 to read your temp sensor, right?

If so, you seem to be making it to an output and setting it high in
ResourceConfigure.configure(). Have a look at whatever "they" have
made the ADC input modules into to see if there's a better way.

In T1 I just use the ADCC module like this:

  RobotM.BVoltage -> ADCC.ADC[ROBOADC_BVOLTAGE];

  call BVoltage.getData();

  async event result_t BVoltage.dataReady( uint16_t data )
  {
	// use data
  }

MS

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 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/>
>  >
>  >
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help at millennium.berkeley.edu
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


More information about the Tinyos-help mailing list