Sorry....
fire-off means call ADCy.getData();
This will start the second (Y) conversion.
Then in ADCy.dataReady() call ADCz.getData();
to start the Z conversion. In ADCz.dataReady()
you could chain back to ADCx.getData() or leave
it to your timer to start the next set.
MS
Chen Bleed wrote:
It seems OK except "// get data from X channel and fire off Y channel
conversion".
I found no method to fire off.
I use tmote sky
OS: tinyos 1.1.15
> Date: Thu, 13 Sep 2007 11:14:00 -0600
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> CC: [email protected]
> Subject: Re: [Tinyos-help] how to get 3 ADC Port value from Tmote sky
>
> I think what you need to do is have separate names for each ADC 'channel'
> and call their getData()'s in sequence, something like this:
>
> in the Config file:
>
> ProjectOtherM.ADCx -> ADCC.ADC[TOS_ADC_SENSORX_PORT];
> ProjectOtherM.ADCy -> ADCC.ADC[TOS_ADC_SENSORY_PORT];
> ProjectOtherM.ADCz -> ADCC.ADC[TOS_ADC_SENSORZ_PORT];
>
> (I'm not sure about your ASSOCIATE_ADC_CHANNEL() stuff, on micaX's
> under T1 I simply use the channel number. Is this perhaps T2, or
> else I'm still unfamiliar with Tmote specifics...?)
>
> in the code:
>
> after startup or in your timer.fired():
>
> call ADCx.getData();
>
> Then chain the gets in the individual Ready() methods:
>
> // get data from X channel and fire off Y channel conversion
> async event result_t ADCx.dataReady( uint16_t data )
> {
> ...
> call ADCy.getData();
> return SUCCESS;
> }
>
>
> MS
>
> Chen Bleed wrote:
> > I want to get three value from tmote sky.I use 3-axis accelerator
> > sensor, and I need the X, Y, Z Output.
> > I'm unable to get three values at one time, so i try to get one value
> > at one time, then get three times to be a cycle.
> > (If anyone get some solutione like get three values at one time,
please
> > tell my how to do.)
> > This program seems to get only one value.Please help me to solve this
> > problem.
> >
> > ***************** IntMsg.h *****************
> > typedef struct IntMsg {
> > uint16_t val;
> > //uint16_t src;
> > uint16_t testval;
> > //uint16_t testval2;
> > //uint16_t testval3;
> > } IntMsg;
> >
> > enum {
> > AM_INTMSG = 153
> > };
> >
> >
> > ***************** SensorX.h *****************
> > enum
> > {
> > TOS_ADC_SENSORX_PORT = unique("ADCPort"),
> >
> > TOSH_ACTUAL_ADC_SENSORX_PORT = ASSOCIATE_ADC_CHANNEL(
> > /* INPUT_CHANNEL_A3,*/
> > INPUT_CHANNEL_A2,
> > REFERENCE_VREFplus_AVss,
> > REFVOLT_LEVEL_1_5
> > ),
> > };
> >
> >
> > ***************** SensorY.h *****************
> > enum
> > {
> > TOS_ADC_SENSORY_PORT = unique("ADCPort"),
> >
> > TOSH_ACTUAL_ADC_SENSORY_PORT = ASSOCIATE_ADC_CHANNEL(
> > /* INPUT_CHANNEL_A1, */
> > INPUT_CHANNEL_A0,
> > REFERENCE_VREFplus_AVss,
> > REFVOLT_LEVEL_1_5
> > ),
> > };
> >
> >
> > ***************** SensorZ.h *****************
> > enum
> > {
> > TOS_ADC_SENSORZ_PORT = unique("ADCPort"),
> >
> > TOSH_ACTUAL_ADC_SENSORZ_PORT = ASSOCIATE_ADC_CHANNEL(
> > /* INPUT_CHANNEL_A2,*/
> > INPUT_CHANNEL_A1,
> > REFERENCE_VREFplus_AVss,
> > REFVOLT_LEVEL_1_5
> > ),
> > };
> >
> > ***************** ProjectOther.nc *****************
> > includes IntMsg;
> > includes SensorX;
> > includes SensorY;
> > includes SensorZ;
> >
> > configuration ProjectOther {
> >
> > }
> >
> > implementation
> > {
> > components Main, ProjectOtherM, TimerC, LedsC, ADCC, GenericComm as
Comm;
> >
> > Main.StdControl -> ProjectOtherM.StdControl;
> > ProjectOtherM.Timer -> TimerC.Timer[unique("Timer")];
> > Main.StdControl -> TimerC.StdControl;
> > ProjectOtherM.Leds -> LedsC.Leds;
> > ProjectOtherM.SendMsg -> Comm.SendMsg[AM_INTMSG];
> > ProjectOtherM.SubControl -> Comm.Control;
> > ProjectOtherM.ADC -> ADCC.ADC[TOS_ADC_SENSORX_PORT];
> > ProjectOtherM.ADC -> ADCC.ADC[TOS_ADC_SENSORY_PORT];
> > ProjectOtherM.ADC -> ADCC.ADC[TOS_ADC_SENSORZ_PORT];
> > ProjectOtherM.ADCControl -> ADCC;
> >
> > }
> >
> > ***************** ProjectOtherM.nc *****************
> > includes IntMsg;
> > includes SensorX;
> > includes SensorY;
> > includes SensorZ;
> >
> > module ProjectOtherM {
> > provides {
> > interface StdControl;
> > interface IntOutput;
> > }
> > uses {
> > interface StdControl as SubControl;
> > interface SendMsg;
> > interface Timer;
> > interface Leds;
> > interface ADC;
> > interface ADCControl;
> > }
> > }
> >
> > implementation {
> > int state;
> > bool pending, flag_y, flag_g, flag_r;
> > TOS_Msg msg_data;
> > uint16_t ADCval;
> >
> > void readIRSensor();
> > task void chooseADCChannel();
> >
> > /* interface StdControl */
> > command result_t StdControl.init() {
> > atomic ADCval = 0;
> > atomic state = 1;
> > pending = FALSE;
> > call Leds.init();
> > call Leds.redOff();
> > call Leds.yellowOff();
> > call Leds.greenOff();
> > call ADCControl.init();
> >
> > return call SubControl.init();
> > }
> >
> > command result_t StdControl.start() {
> > call Timer.start(TIMER_REPEAT, 1000);
> > return call SubControl.start();
> > }
> >
> > command result_t StdControl.stop() {
> > return call SubControl.stop();
> > }
> >
> > /* interface IntOutput */
> > command result_t IntOutput.output(uint16_t value) {
> > IntMsg *message = (IntMsg *)msg_data.data;
> >
> > if(!pending)
> > {
> > pending = TRUE;
> > readIRSensor();
> > atomic {
> > message->val = ADCval;
> > /*message->src = TOS_LOCAL_ADDRESS;*/
> > if(!(state%3)) message->testval = 0x0099;
> > else if((state%3)==1) message->testval = 0x0088;
> > else message->testval = 0x0077;
> > }
> >
> > if (call SendMsg.send(0x0111, sizeof(IntMsg), &msg_data))
> > return SUCCESS;
> >
> > pending = FALSE;
> > }
> > return FAIL;
> > }
> > /* interface ADC */
> > void readIRSensor(){
> > call Leds.greenToggle();
> > call ADC.getData();
> > }
> > async event result_t ADC.dataReady( uint16_t data ) {
> > ADCval = data;
> > post chooseADCChannel();
> > return SUCCESS;
> > }
> >
> > task void chooseADCChannel()
> > {
> > if(!(state%3)) call ADCControl.bindPort( TOS_ADC_SENSORX_PORT,
> > TOSH_ACTUAL_ADC_SENSORX_PORT );
> > else if((state%3)==1)call ADCControl.bindPort(
> > TOS_ADC_SENSORY_PORT, TOSH_ACTUAL_ADC_SENSORY_PORT );
> > else call ADCControl.bindPort( TOS_ADC_SENSORZ_PORT,
> > TOSH_ACTUAL_ADC_SENSORZ_PORT );
> >
> > }
> >
> > /* interface SendMsg */
> > event result_t SendMsg.sendDone(TOS_MsgPtr msg, result_t success) {
> > if (pending && msg == &msg_data)
> > {
> > pending = FALSE;
> > if(success == 0) atomic state--;
> > }
> > return SUCCESS;
> > }
> >
> > /* interface Timer */
> > event result_t Timer.fired() {
> > if (call IntOutput.output(state))
> > atomic state++;
> > dbg(DBG_USR1,"state=%i\n",state);
> > dbg(DBG_USR1,"ADCval=%i\n",ADCval);
> > return SUCCESS;
> > }
> > }
> >
------------------------------------------------------------------------
> > 2 GB 超大容量 、創新便捷、安全防護垃圾郵件和病毒 — 立即升級 Windows
Live
> > Hotmail? <http://mail.live.com >
> >
> >
> >
------------------------------------------------------------------------
> >
> > _______________________________________________
> > Tinyos-help mailing list
> > [email protected]
> >
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
> --
> Platform: WinXP/Cygwin
> TinyOS version: 1.x, Boomerang
> Programmer: MIB510
> Device(s): Mica2, MicaZ, Tmote
> Sensor board: homebrew
>
------------------------------------------------------------------------
聰明搜尋和瀏覽網路的免費工具列 — Windows Live 搜尋工具列
<http://toolbar.live.com/>
--
Platform: WinXP/Cygwin
TinyOS version: 1.x, Boomerang
Programmer: MIB510
Device(s): Mica2, MicaZ, Tmote
Sensor board: homebrew
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help