Thread: [Firebug-cvs] firebug/project/src/multihop CollectDataFB.nc,1.6,1.7 CollectDataMFB.nc,1.10,1.11 Make
Brought to you by:
doolin
From: <che...@us...> - 2003-08-22 06:47:47
|
Update of /cvsroot/firebug/firebug/project/src/multihop In directory sc8-pr-cvs1:/tmp/cvs-serv4454 Modified Files: CollectDataFB.nc CollectDataMFB.nc Makefile Log Message: add real Humidity, Pressure, and Temp data Index: CollectDataFB.nc =================================================================== RCS file: /cvsroot/firebug/firebug/project/src/multihop/CollectDataFB.nc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CollectDataFB.nc 20 Aug 2003 20:52:14 -0000 1.6 --- CollectDataFB.nc 22 Aug 2003 06:47:44 -0000 1.7 *************** *** 14,18 **** implementation { components Main, CollectDataMFB, MHSender, TimerWrapper, LedsC, ! VirtualComm, ParentSelection, CC1000ControlM, TaosPhotoM; Main.StdControl -> CollectDataMFB.StdControl; --- 14,19 ---- implementation { components Main, CollectDataMFB, MHSender, TimerWrapper, LedsC, ! VirtualComm, ParentSelection, CC1000ControlM, SensirionHumidity, ! IntersemaPressure,MicaWbSwitch; Main.StdControl -> CollectDataMFB.StdControl; *************** *** 24,29 **** CollectDataMFB.Leds -> LedsC; Main.StdControl -> MHSender.StdControl; - //CollectDataMFB.Random -> RandomLFSR; CollectDataMFB.CC1000Control -> CC1000ControlM; } --- 25,45 ---- CollectDataMFB.Leds -> LedsC; Main.StdControl -> MHSender.StdControl; CollectDataMFB.CC1000Control -> CC1000ControlM; + + // Wiring for Sensirion humidity/temperature sensor + CollectDataMFB.TempHumControl -> SensirionHumidity; + CollectDataMFB.Humidity -> SensirionHumidity.Humidity; + CollectDataMFB.Temperature -> SensirionHumidity.Temperature; + CollectDataMFB.HumidityError -> SensirionHumidity.HumidityError; + CollectDataMFB.TemperatureError -> SensirionHumidity.TemperatureError; + + // Wiring for Intersema barometric pressure/temperature sensor + CollectDataMFB.IntersemaCal -> IntersemaPressure; + CollectDataMFB.PressureControl -> IntersemaPressure; + CollectDataMFB.IntersemaPressure -> IntersemaPressure.Pressure; + CollectDataMFB.IntersemaTemp -> IntersemaPressure.Temperature; + + + } Index: CollectDataMFB.nc =================================================================== RCS file: /cvsroot/firebug/firebug/project/src/multihop/CollectDataMFB.nc,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** CollectDataMFB.nc 19 Aug 2003 22:33:42 -0000 1.10 --- CollectDataMFB.nc 22 Aug 2003 06:47:44 -0000 1.11 *************** *** 16,32 **** */ - //includes RoutingStackShared; - //includes Routing; includes RoutingStack; - /** max int is 2^16 for the lfsr random - * number generation scheme used in tinyos. - */ - #define FB_RAND_MAX 256*256 - module CollectDataMFB { provides { - interface StdControl; } --- 16,24 ---- *************** *** 37,49 **** interface Timer as Timer; interface Leds; - //interface HandleBcast; - //interface Random; interface CC1000Control; } } ! #define DATA_FREQ 3000 implementation { TOS_Msg msgToSend; --- 29,55 ---- interface Timer as Timer; interface Leds; interface CC1000Control; + + //Intersema + interface SplitControl as PressureControl; + interface ADC as IntersemaTemp; + interface ADC as IntersemaPressure; + interface Calibration as IntersemaCal; + + //Sensirion + interface SplitControl as TempHumControl; + interface ADC as Humidity; + interface ADC as Temperature; + interface ADCError as HumidityError; + interface ADCError as TemperatureError; } } ! #define DATA_FREQ 1000 implementation { + #include "gps.h" + + enum {START, BUSY, HUMIDITY_DONE, PRESSURE_DONE}; TOS_Msg msgToSend; *************** *** 60,66 **** uint16_t counter; uint8_t sending; command result_t StdControl.init() { ! return SUCCESS; } --- 66,102 ---- uint16_t counter; uint8_t sending; + uint8_t state; + float TempData; + float HumData; + float PressureData; + char count; + uint16_t calibration[6]; + uint16_t C1,C2,C3,C4,C5,C6; //intersema calibration coefficients + + task void SendToRadio(){ + + uint8_t *dataPortion; + uint16_t availableLength = 0; + + struct DataFormat_t *df; + + if (sending != 1) { + dataPortion = call MultiHopSend.getBuffer(&msgToSend, &availableLength); + df = (struct DataFormat_t *) dataPortion; + df->addr = TOS_LOCAL_ADDRESS; + df->cnt = counter++; + df->temp = TempData; + df->rel_hum = HumData; + df->baro_pres = PressureData; + + sending = call MultiHopSend.send(&msgToSend, sizeof(struct DataFormat_t)); + call Leds.greenToggle(); + } + } + command result_t StdControl.init() { ! call TempHumControl.init(); //init Sensirion ! call PressureControl.init(); // init Intersema return SUCCESS; } *************** *** 74,77 **** --- 110,117 ---- call Timer.start(TIMER_REPEAT, DATA_FREQ); call CC1000Control.SetRFPower(255); + + call HumidityError.enable(); //in case Sensirion doesn't respond + call TemperatureError.enable(); // " + return SUCCESS; } *************** *** 81,118 **** } - - /* Some temporary code for generating gaussian density. - * This can be moved out of here later. However, it - * does compile. - * @url http://www.taygeta.com/random/gaussian.html - */ - - float get_temp() { - /* - //#if 0 - float x1,x2,w,y1,y2; - - do { - x1 = (2*((call Random.rand())/FB_RAND_MAX)) - 1; - x2 = (2*((call Random.rand())/FB_RAND_MAX)) - 1; - w = x1*x1 + x2*x2; - } while (w >= 1.0); - - w = sqrt( (-2.0*log(w))/w); - y1 = x1*w; - y2 = x2*w; - //#endif - */ - return 72.1; - } - - float get_rel_hum() { - return 98.3; - } - - float get_baro_pres() { - return 29.1; - } - /** * When the clock fired we are ready to send, CollectData ask the stack --- 121,124 ---- *************** *** 125,153 **** */ event result_t Timer.fired() { ! //uint8_t result; ! uint8_t *dataPortion; ! uint16_t availableLength = 0; ! struct DataFormat_t *df; ! if (sending == 1) { ! return SUCCESS; } ! ! dataPortion = call MultiHopSend.getBuffer(&msgToSend, &availableLength); ! df = (struct DataFormat_t *) dataPortion; ! df->addr = TOS_LOCAL_ADDRESS; ! df->cnt = counter++; ! //df->sampledata=TOS_LOCAL_ADDRESS; ! //put more sensor data here ! //.... ! //df->temp=0x04CE; ! df->temp = get_temp(); ! df->rel_hum = get_rel_hum(); ! df->baro_pres = get_baro_pres(); ! sending = call MultiHopSend.send(&msgToSend, sizeof(struct DataFormat_t)); ! call Leds.greenToggle(); return SUCCESS; } --- 131,278 ---- */ event result_t Timer.fired() { + if ( state == PRESSURE_DONE) state = START; ! if (state == START){ ! state = BUSY; ! call TempHumControl.start(); ! } ! ! if (state == HUMIDITY_DONE){ ! state = BUSY; ! call PressureControl.start(); ! } ! return SUCCESS; ! } ! ! /****************************************************************************** ! * Intersema MS5534A barometric pressure/temperature sensor ! * - 6 cal coefficients (C1..C6) are extracted from 4, 16 bit,words from sensor ! * - Temperature measurement: ! * UT1=8*C5+20224 ! * dT=data-UT1 ! * Temp=(degC x10)=200+dT(C6+50)/1024 ! * - Pressure measurement: ! * OFF=C2*4 + ((C4-512)*dT)/1024 ! * SENS=C1+(C3*dT)/1024 + 24576 ! * X=(SENS*(PressureData-7168))/16384 - OFF ! * Press(mbar)= X/32+250 ! *****************************************************************************/ ! event result_t IntersemaTemp.dataReady(uint16_t data) { ! float UT1,dT,Temp; ! float OFF,SENS,X,Press; ! //temperature ! UT1=8*(float)C5+20224; ! dT = (float)data-UT1; ! Temp = 200.0 + dT*((float)C6+50.0)/1024.0; ! //pressure ! OFF = (float)C2*4 + (((float)C4-512.0)*dT)/1024; ! SENS = (float)C1 + ((float)C3*dT)/1024 + 24576; ! X = (SENS*((float)PressureData-7168.0))/16384 - OFF; ! Press = X/32.0 + 250.0; ! ! call PressureControl.stop(); ! return SUCCESS; ! } ! ! event result_t IntersemaPressure.dataReady(uint16_t data) { ! PressureData = data; ! call Leds.yellowToggle(); ! return call IntersemaTemp.getData(); ! } ! ! event result_t IntersemaCal.dataReady(char word, uint16_t value) { ! // make sure we get all the calibration bytes ! count++; ! calibration[word-1] = value; ! ! if (count == 4) { ! C1 = calibration[0] >> 1; ! C2 = ((calibration[2] & 0x3f) << 6) | (calibration[3] & 0x3f); ! C3 = calibration[3] >> 6; ! C4 = calibration[2] >> 6; ! C5 = ((calibration[0] & 1) << 10) | (calibration[1] >> 6); ! C6 = calibration[1] & 0x3f; ! ! call IntersemaPressure.getData(); } ! return SUCCESS; ! } ! event result_t PressureControl.initDone() { ! return SUCCESS; ! } ! ! event result_t PressureControl.stopDone() { ! post SendToRadio(); ! return SUCCESS; ! ! ! } ! ! event result_t PressureControl.startDone() { ! count = 0; ! call IntersemaCal.getData(); ! 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 ! *****************************************************************************/ ! event result_t Temperature.dataReady(uint16_t data) { ! float fTemp, fHumidity; ! ! fTemp = -38.4 + 0.0098*(float)data; ! fHumidity = -4.0 + 0.0405 * HumData -0.0000028 * HumData * HumData; ! fHumidity= (fTemp-25.0)* (0.01 + 0.00008 * HumData) + fHumidity; ! fTemp = 10*fTemp; ! ! call TempHumControl.stop(); ! return SUCCESS; ! } ! ! event result_t Humidity.dataReady(uint16_t data) { ! HumData = data; //pressure data ! call Leds.redToggle(); ! 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; } *************** *** 165,168 **** --- 290,294 ---- event result_t MultiHopSend.sendDone(TOS_MsgPtr msg, uint8_t success) { sending = 0; + state= PRESSURE_DONE; return SUCCESS; } Index: Makefile =================================================================== RCS file: /cvsroot/firebug/firebug/project/src/multihop/Makefile,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Makefile 20 Aug 2003 20:52:14 -0000 1.15 --- Makefile 22 Aug 2003 06:47:44 -0000 1.16 *************** *** 9,15 **** ## This is the Makefile for multihop. ! ifndef XBOWROOT ! echo Please set the XBOWROOT environment variable ! endif --- 9,15 ---- ## This is the Makefile for multihop. ! #ifndef XBOWROOT ! # echo Please set the XBOWROOT environment variable ! #endif *************** *** 17,20 **** --- 17,22 ---- UISP_FLAGS = -dprog=dapa $(UISP_EXTRA_FLAGS) TOSROOT=/cygdrive/c + XBOWROOT = $(TOSROOT)/tinyos-1.x/contrib/xbow + PLATFORMS= mica mica2 pc #DATASTRUCTURE=$(TOSROOT)/broken/experimental/terence/tos/lib/DataStructure *************** *** 23,31 **** #CC1000=-I/cygdrive/d/tinyos-1.x/tos/platform/mica2 ! INCLUDES=-I$(TOSROOT)/Blast-0.1/Sender \ ! -I$(TOSROOT)/Blast-0.1/Interface \ ! -I$(TOSROOT)/Blast-0.1/DataStructure \ ! -I$(TOSROOT)/Blast-0.1/VirtualComm \ ! -I$(TOSROOT)/Blast-0.1/ParentSelection \ -I$(TOSROOT)/tinyos-1.x/tos \ -I$(XBOWROOT)/tos/sensorboards/mts400 \ --- 25,33 ---- #CC1000=-I/cygdrive/d/tinyos-1.x/tos/platform/mica2 ! INCLUDES=-I$(TOSROOT)/Blast-0.11/Sender \ ! -I$(TOSROOT)/Blast-0.11/Interface \ ! -I$(TOSROOT)/Blast-0.11/DataStructure \ ! -I$(TOSROOT)/Blast-0.11/VirtualComm \ ! -I$(TOSROOT)/Blast-0.11/ParentSelection \ -I$(TOSROOT)/tinyos-1.x/tos \ -I$(XBOWROOT)/tos/sensorboards/mts400 \ |