[Firebug-cvs] mts400/apps/TestSensirion .cvsignore,NONE,1.1 Makefile,NONE,1.1 Sensirion.nc,NONE,1.1
Brought to you by:
doolin
From: <do...@us...> - 2003-11-05 16:06:44
|
Update of /cvsroot/firebug/mts400/apps/TestSensirion In directory sc8-pr-cvs1:/tmp/cvs-serv3919/mts400/apps/TestSensirion Added Files: .cvsignore Makefile Sensirion.nc SensirionM.nc Log Message: Started adding individual test applications for the sensors on the fireboard. --- NEW FILE: .cvsignore --- build *~ --- NEW FILE: Makefile --- COMPONENT=Sensirion SENSORBOARD=sensirion include ../Makelocal include $(TOSROOT)/apps/Makerules --- NEW FILE: Sensirion.nc --- /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ /** * Sensirion SHT11 driver test application. * * The Sensirion SHT11 sensor is manufactured by: * * Sensirion AG * Eggbuehlstrasse 14 * CH-8052 Zurich * Switzerland * Telephone +41 (0)1 306 40 00 * Fax +41 (0)1 306 40 30 * in...@se... * http://www.sensirion.com * * Spec sheet is located at: * @url http://www.sensirion.com/en/sensors/humidity/sensors_devices/sensorSHT11.htm * * Characteristics of the sensor, from the web page given above: * * - 2 sensors for relative humidity & temperature * - Precise dewpoint calculation possible * - Measurement range: 0-100% RH * - Absolute RH accuracy: +/- 3.5% RH * - Temp. accuracy: +/- 0.5°C @ 25 °C * - Calibrated & digital output (2-wire interface) * - Fast response time < 4 sec. * - Low power consumption (typ. 30 µW) * - Low cost * * From the PDF spec sheet, the combined sensor is 14 bit ADC. * * ===== Relative humidity ===== * Range: 0 to 100 % RH * Accuracy: +- 3.5 % RH (20 to 80% RH) * Response time: =< 4 sec. * Reproducibility: +- 0.1 % RH * Resolution: 0.03 % RH * Operating temperature: -40 to 120 C * * ===== Temperature ===== * Range: -40 to 120 C * Accuracy: +- 0.5 C @ 25 C, +- 0.9 C (0 to -40 C) * Response time: =< 20 sec. * Reproducibility: +- 0.1 C * Resolution: 0.01 C * * ===== Electrical ===== * Power consumption: * 30 uW @5V, 12 bit, 2 sec. sampling * 1 uW @2.4V, 8 bit, 2 min. sampling * * Supply Voltage range: 2.4 to 5.5 V * * Measurement input current: 0.5 mA * Standby input current: 0.3 uA * * ===== Physics ===== * Might have to get patent data for this stuff. * * The temperature sensor works by: * * * The humidity sensor works by: * * * Misc. SHT11 is a surface mountable CMOS component. * They claim it is pre-calibrated. */ configuration Sensirion { } implementation { components Main, SensirionM, SensirionHumidity, MicaWbSwitch, TimerC, NoLeds, LedsC; Main.StdControl -> SensirionM; Main.StdControl -> TimerC; // Wiring for Sensirion humidity/temperature sensor SensirionM.TempHumControl -> SensirionHumidity; SensirionM.Humidity -> SensirionHumidity.Humidity; SensirionM.Temperature -> SensirionHumidity.Temperature; SensirionM.HumidityError -> SensirionHumidity.HumidityError; SensirionM.TemperatureError -> SensirionHumidity.TemperatureError; SensirionM.Leds -> LedsC; SensirionM.Timer -> TimerC.Timer[unique("Timer")]; } --- NEW FILE: SensirionM.nc --- /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ /* History: created 1/25/2001 */ /****************************************************************************** * Measures MTS400/420 weatherboard sensors & gps and converts to engineering units * were possible. *----------------------------------------------------------------------------- * Output results through mica2 uart port. Connect serial cable from programming * board to PC to monitor ouput. Use any terminal monitoring program set for * 57600, N,8,1 * * NOTE: * No real power strategy; just turns sensors on sequentially. * Should add BusArbitration routines, like mica2dotwb for better power control *****************************************************************************/ module SensirionM { provides interface StdControl; uses { //Sensirion interface SplitControl as TempHumControl; interface ADC as Humidity; interface ADC as Temperature; interface ADCError as HumidityError; interface ADCError as TemperatureError; interface Timer; interface Leds; } } implementation { #include "SODebug.h" enum {START, BUSY, HUMIDITY_DONE}; char count; uint16_t calibration[6]; uint16_t C1,C2,C3,C4,C5,C6; //intersema calibration coefficients uint16_t HumData; uint8_t state; command result_t StdControl.init() { init_debug(); call Leds.init(); call TempHumControl.init(); //init Sensirion //call PressureControl.init(); // init Intersema return SUCCESS; } command result_t StdControl.start() { call HumidityError.enable(); //in case Sensirion doesn't respond call TemperatureError.enable(); // " call Leds.redOn(); call Leds.yellowOn(); call Leds.greenOn(); state = START; call Timer.start(TIMER_REPEAT, 1000); //start up weather sensor measurements return SUCCESS; } command result_t StdControl.stop() { return SUCCESS; } /****************************************************************************** * Timer fired, test GPS, humidity/temp * async for test only *****************************************************************************/ event result_t Timer.fired() { call Leds.redOff(); call Leds.yellowOff(); call Leds.greenOff(); call TempHumControl.start(); return SUCCESS; } /****************************************************************************** * Sensirion SHT11 humidity/temperature sensor * - Humidity data is 12 bit: * Linear calc (no temp correction) * fRH = -4.0 + 0.0405 * data -0.0000028 * data^2 'RH linear * With temperature correction: * fRH = (fTemp - 25) * (0.01 + 0.00008 * data) + fRH 'RH true * - Temperature data is 14 bit * Temp(degC) = -38.4 + 0.0098 * data *****************************************************************************/ async event result_t Temperature.dataReady(uint16_t data) { float fTemp, fHumidity; fTemp = -38.4 + 0.0098*(float)data; atomic { fHumidity = -4.0 + 0.0405 * HumData -0.0000028 * HumData * HumData; fHumidity= (fTemp-25.0)* (0.01 + 0.00008 * HumData) + fHumidity; } fTemp = 10*fTemp; SODbg(DBG_USR2, "Humidity: Temp(adc): %i Humidity(adc): %i Temp(degCx10): %i Humidity(%): %i \n", data,HumData,(int)fTemp, (int)fHumidity); atomic { call TempHumControl.stop(); } return SUCCESS; } async event result_t Humidity.dataReady(uint16_t data) { atomic { HumData = data; } return call Temperature.getData(); } event result_t TempHumControl.startDone() { call Humidity.getData(); return SUCCESS; } event result_t TempHumControl.initDone() { return SUCCESS; } event result_t TempHumControl.stopDone() { state = HUMIDITY_DONE; return SUCCESS; } event result_t HumidityError.error(uint8_t token) { call Leds.redOff(); call Leds.yellowOff(); call Temperature.getData(); return SUCCESS; } event result_t TemperatureError.error(uint8_t token) { call TempHumControl.stop(); call Leds.yellowOff(); return SUCCESS; } } |