X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fplatforms%2Ftmirws%2Fsensors%2FWindVaneAdcP.nc;h=67f019df5f7404c979dd95cb62064a0ecc1644ce;hb=f6c92b59f03adcffc10b150474f9a7062be5ca30;hp=a80362bad34021a7db41aea82dacd40b86718b44;hpb=4f0def622af5baa14e297eac8f3fb695b0a25bb7;p=tinyos-2.x.git diff --git a/tos/platforms/tmirws/sensors/WindVaneAdcP.nc b/tos/platforms/tmirws/sensors/WindVaneAdcP.nc index a80362ba..67f019df 100644 --- a/tos/platforms/tmirws/sensors/WindVaneAdcP.nc +++ b/tos/platforms/tmirws/sensors/WindVaneAdcP.nc @@ -28,42 +28,43 @@ */ /** - * Battery ADC reading. + * Reads the ADC pin connected to the Davis Instruments anemometer. The + * connection is made via a resistor divider. The voltage seen by the ADC + * is related to VREF, the maximum voltage presented to the ADC. + * 0V or VREF means North + * VREF*1/4 means East + * VREF*2/4 means South + * VREF*3/4 means West + * + * We assume a 12-bit ADC, so VREF reads as 4095 and 0V reads as 0. * * @author R. Steve McKown */ #include "Msp430Adc12.h" -module BatteryAdcP { +module WindVaneAdcP { provides interface AdcConfigure; } implementation { - /* TODO: The internal references are unsable, varying by more than 0.1V and - * jumping around. The external reference of 2.50V seems stable. + /* We use the external reference because it is probably more accurate (see + * the circuit), and there is no arbitration for the voltage reference. With + * the external reference, we can ReadStream 4 data points in 420 us. Using + * the internal reference, this time increases significantly to over 18 ms. */ const msp430adc12_channel_config_t config = { - inch: INPUT_CHANNEL_A0, -#if 0 /* internal references unstable */ - sref: REFERENCE_VREFplus_AVss, - ref2_5v: REFVOLT_LEVEL_1_5, /* REFVOLT_LEVEL_2_5, */ -#else /* external reference is stable */ + inch: INPUT_CHANNEL_A2, sref: REFERENCE_VeREFplus_AVss, - ref2_5v: REFVOLT_LEVEL_1_5, -#endif -#if 0 /* clock source doesn't seem to affect stability */ + ref2_5v: REFVOLT_LEVEL_1_5, /* doesn't matter since external ref used */ adc12ssel: SHT_SOURCE_ADC12OSC, adc12div: SHT_CLOCK_DIV_8, -#else - adc12ssel: SHT_SOURCE_ACLK, - adc12div: SHT_CLOCK_DIV_1, -#endif sht: SAMPLE_HOLD_8_CYCLES, sampcon_ssel: SAMPCON_SOURCE_ACLK, sampcon_id: SAMPCON_CLOCK_DIV_1 }; - async command const msp430adc12_channel_config_t* AdcConfigure.getConfiguration() + async command const msp430adc12_channel_config_t* + AdcConfigure.getConfiguration() { return &config; }