Hey everyone,
I have a home-made temperature sensor attached to pin 5 (VSENSE_ADC2) on the
Internal Expansion Connector of a SHIMMER mote. I'm confused as to which
"input channel" this corresponds to in TinyOS.
I'm using the *msp430adc12_channel_config_t* to configure the ADC.
According to the SHIMMER accellerometer driver (The driver made for SPINE
framework), it uses A3-A5 on the internal connector, so it can't be those.
I've tried INPUT_CHANNEL_A2 without luck. Now, there's no guarantee that my
sensor actually works. I'm just trying to rule out the fact that i
configured the ADC wrong. If anyone has had experience with adding sensors
to the shimmers internal expansion connector, i'd appreciate a hint. If need
be, i can supply more driver code as i use it.
I'm pretty much using the drivercode as it's defined by the SPINE gyroscope
defined in contrib/tos/sensorboards/spine/ (Writte by *Raffaele Gravina*).
For those who use SPINE, i've already setup up needed constants, and i build
this driver along with the rest of the shimmer platform, and the sensor is
recognized "serverside" in the node it is attached to. Its only the reading
that's bothering me. Here's the code as i use it (I've removed all comments
and copyright notices for brevity). I appreciate your help!
*IHATConfigC.nc:
*generic configuration IHATConfigC() {
provides interface Read<uint16_t>;
provides interface ReadStream<uint16_t>;
}
implementation {
components new AdcReadClientC();
Read = AdcReadClientC;
components new AdcReadStreamClientC();
ReadStream = AdcReadStreamClientC;
components IHATConfigP;
AdcReadClientC.AdcConfigure -> IHATConfigP;
AdcReadStreamClientC.AdcConfigure -> IHATConfigP;
}*
IHATConfigP.nc:*
module IHATConfigP {
provides interface AdcConfigure<const msp430adc12_channel_config_t*>;
}
implementation {
*const msp430adc12_channel_config_t config = {**
inch: INPUT_CHANNEL_A2,
sref: REFERENCE_AVcc_AVss,
ref2_5v: REFVOLT_LEVEL_1_5,
adc12ssel: SHT_SOURCE_ACLK,
adc12div: SHT_CLOCK_DIV_1,
sht: SAMPLE_HOLD_4_CYCLES,
sampcon_ssel: SAMPCON_SOURCE_SMCLK,
sampcon_id: SAMPCON_CLOCK_DIV_1
};*
async command const msp430adc12_channel_config_t*
AdcConfigure.getConfiguration()
{
return &config;
}
}
*HilIHATempSensorC.nc:*
configuration HilIHATempSensorC {
provides interface Sensor;
}
implementation {
components HilIHATempSensorP;
components new IHATConfigC() as Temperature;
components MainC;
components SensorsRegistryC;
Sensor = HilIHATempSensorP;
HilIHATempSensorP.Temperature-> Temperature;
HilIHATempSensorP.Boot -> MainC;
HilIHATempSensorP.SensorsRegistry -> SensorsRegistryC;
}
*HilIHATempSensorP.nc:*
module HilIHATempSensorP {
uses {
interface Read<uint16_t> as Temperature;
interface Boot;
interface SensorsRegistry;
}
provides interface Sensor;
}
implementation {
uint16_t temperature = 0;
uint8_t acqType;
uint8_t valueTypesList[1];
uint8_t acquireTypesList[1];
bool registered = FALSE;
event void Boot.booted() {
if (!registered) {
valueTypesList[0] = CH_1;
acquireTypesList[0] = CH_1_ONLY;
call SensorsRegistry.registerSensor(IHA_TEMPERATURE_SENSOR);
registered = TRUE;
}
}
command uint8_t Sensor.getSignificantBits() {
return 12;
}
command error_t Sensor.acquireData(enum AcquireTypes acquireType) {
acqType = acquireType;
call Temperature.read();
return SUCCESS;
}
command uint16_t Sensor.getValue(enum ValueTypes valueType) {
switch (valueType) {
case CH_1 : return temperature;
default : return 0xffff;
}
}
command void Sensor.getAllValues(uint16_t* buffer, uint8_t* valuesNr) {
*valuesNr = sizeof valueTypesList;
buffer[0] = temperature;
}
command enum SensorCode Sensor.getSensorCode() {
return IHA_TEMPERATURE_SENSOR;
}
command uint16_t Sensor.getSensorID() {
return 0x45ac; // the ID has been randomly choosen
}
event void Temperature.readDone(error_t result, uint16_t data) {
temperature = data;
signal Sensor.acquisitionDone(result, acqType);
}
command uint8_t* Sensor.getValueTypesList(uint8_t* valuesTypeNr) {
*valuesTypeNr = sizeof valueTypesList;
return valueTypesList;
}
command uint8_t* Sensor.getAcquireTypesList(uint8_t* acquireTypesNr) {
*acquireTypesNr = sizeof acquireTypesList;
return acquireTypesList;
}
}
Thank you!
/Martin
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help