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