Hi, Just one thing, you should post your query to tinyos-help as well because may be I cannot answer a particular question but some one else can.
All the setting of the registers is done in Hardware Presentation Layer, see HplAtm128AdcC.nc……………… You need to do a Resource Configuration if you see the files at /tos/chips/atm128/adc/ , you will understand. The values are converted according to the following formula….. ADC = VIN ⋅ 1024 / VREF So, it is quite possible that the values you are getting are not constant (as I think it would depend on the intensity of light) and hence the behavior you see. I think if you add a Java application (See Oscilloscope and one of the tutorials explains how to send the value to BaseStation) and read the value on a console would be much better way to go about testing your sensor. Lastly, my name is Varun and not Verun J Cheers, Varun Jain From: Farooq Sultan [mailto:[email protected]] Sent: Tuesday, 4 August 2009 3:40 PM To: Varun Jain Subject: RE: [Tinyos-help] ADC Problems Hello Verun, Thanks for your help with the ADC. But I notice that You are not setting the ADCSRA register for the ADC, Can the ADC function that way? Also I modified my sensorC and sensorP like you did but without using the resourceconfigure interface, Here is my demosensorC: generic configuration DemoSensorC() { provides interface Read<uint16_t>; } implementation { components new sensorC() as DemoChannel; Read = DemoChannel; } This is the application (Sense) that i am using:- configuration SenseAppC { } implementation { components SenseC, MainC, LedsC, new TimerMilliC(), new DemoSensorC() as Sensor; SenseC.Boot -> MainC; SenseC.Leds -> LedsC; SenseC.Timer -> TimerMilliC; SenseC.Read -> Sensor; } #include "Timer.h" module SenseC { uses { interface Boot; interface Leds; interface Timer<TMilli>; interface Read<uint16_t>; } } implementation { // sampling frequency in binary milliseconds #define SAMPLING_FREQUENCY 100 event void Boot.booted() { call Timer.startPeriodic(SAMPLING_FREQUENCY); } event void Timer.fired() { call Read.read(); } event void Read.readDone(error_t result, uint16_t data) { if (result == SUCCESS){ if (data & 0x0004) call Leds.led2On(); else call Leds.led2Off(); if (data & 0x0002) call Leds.led1On(); else call Leds.led1Off(); if (data & 0x0001) call Leds.led0On(); else call Leds.led0Off(); } } } I attached the light-to-voltage sensor(TSL13S) with ADC1 and ran the application on the device. The sense application is expectd to display the 3 lowest order bits of the digitized output on the 3 platform LEDs. In my case the Leds blink without any order and dont remain constant. Since the light hitting the sensor is not changing i would expect the digitized output to be the same, hence the LEDs should become constant for a given lighting situation. If you have any ideas or any suggestions kindly assist me with this! Regards, Farooq > Subject: RE: [Tinyos-help] ADC Problems > Date: Tue, 4 Aug 2009 10:58:47 +1000 > From: [email protected] > To: [email protected]; [email protected] > > Hi Farooq, > I have successfully used a PIR Sensor with atmega128 board on Port F0 > i.e. ADC Channel 0. Here is the code: > > ------------------------------------------------ > module SensorP > { > provides { > interface ResourceConfigure; > interface Atm128AdcConfig; > } > uses { > interface GeneralIO as SensorPin; > } > } > implementation > { > async command uint8_t Atm128AdcConfig.getChannel() { > return ATM128_ADC_SNGL_ADC0; // FOR POTENTIOMETER > } > > async command uint8_t Atm128AdcConfig.getRefVoltage() { > return ATM128_ADC_VREF_AVCC; > } > > async command uint8_t Atm128AdcConfig.getPrescaler() { > return ATM128_ADC_PRESCALE; > } > > async command void ResourceConfigure.configure() { > call SensorPin.makeInput(); > call SensorPin.get(); > } > > async command void ResourceConfigure.unconfigure() { > call SensorPin.clr(); > } > } > ---------------------------------------- > > generic configuration SensorC() { > provides interface Read<uint16_t>; > } > implementation { > components new AdcReadClientC(),SensorP; > components HplAtm128GeneralIOC as AtmGeneralIO; > > Read = AdcReadClientC; > AdcReadClientC.Atm128AdcConfig -> SensorP; > AdcReadClientC.ResourceConfigure -> SensorP; > > PIRSensorP.SensorPin -> AtmGeneralIO.PortF0; //Port F0 - Pin 11 on > Pinhead 4 of chipconz > } > > --------------------------------------------- > > In your platform you need to declare a component which provides the > "Read" Interface LIKE this: > > generic configuration DemoSensorC() { > provides interface Read<uint16_t>; > } > implementation { > components new SensorC() as Sensor; > > Read = Sensor; > } > --------------------------------------------- > > In your application you need to wire up the "Read" interface with your > platform component. > > > I hope this helps. Also see the Oscilloscope Application. > > > Cheers, > Varun Jain > > > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of > farooq_s > Sent: Monday, 3 August 2009 10:28 PM > To: [email protected] > Subject: [Tinyos-help] ADC Problems > > > Hi, > > Guys I am trying to attach a light-to-voltage sensor to my atmega128 > based > custom node. In order to use this i need to activate the ADC and I have > been > unable to do so up till now. When I checked the Sense application for > telosb, it uses the VoltageC which inturn uses the Sensor Specific code > of > the MCU. > > I wrote the following for my sensor: atmADCP > #include "Atm128Adc.h" > > module atmADCP { > provides interface Atm128AdcConfig; > } > implementation { > > const Atm128Adcsra_t config = { > adps: ATM128_ADC_PRESCALE; > adie: ATM128_ADC_INT_ENABLE_OFF; > adif: ATM128_ADC_INT_FLAG_OFF; > adfr: ATM128_ADC_FREE_RUNNING_OFF; > adsc: ATM128_ADC_START_CONVERSION_ON; > aden: ATM128_ADC_ENABLE_OFF; > }; > > async command uint8_t Atm128AdcConfig.getChannel() > { > return ATM128_ADC_SNGL_ADC1; > } > > async command uint8_t Atm128AdcConfig.getRefVoltage() > { > return ATM128_ADC_VREF_AVCC; > } > > async command uint8_t Atm128AdcConfig.getPrescalar() > { > return ATM128_ADC_PRESCALE; > } > } > > atmADCC: > generic configuration atmADCC() { > provides interface Read<uint16_t>; > } > implementation { > components new AdcReadClientC(); > Read = AdcReadClientC; > > components atmADCP; > AdcReadClientC.Atm128AdcConfig -> atmADCP; > } > > > > I have connected the sensor at pin 60(ADC1) but when i install the code > onto > the node, the LEDs start to flash without any order, kindly help me with > this. > > Regards, > Farooq Sultan > -- > View this message in context: > http://www.nabble.com/ADC-Problems-tp24789889p24789889.html > Sent from the TinyOS - Help mailing list archive at Nabble.com. > > _______________________________________________ > Tinyos-help mailing list > [email protected] > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help ________________________________ Windows Live™: Keep your life in sync. Check it out. <http://windowslive.com/explore?ocid=PID23384::T:WLMTAGL:ON:WL:en-US:NF_BR_sync:082009>
_______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
