Hi Mona
 
As pointed out by David, setLocalSleepInterval(400) is used by
lowpowerlistening to turn the radio off for 400 ms.  You radio will only be
on for as long as it takes to have the possibility of receiving a signal
(approx 5 ms).  If you check back through the help mail messages you should
come across the e-mails discussing this.
 
I've done a similar thing using AMcontrol's start() and stop() commands
coupled with a few timers to manually duty cycle the radio.  The only
problem I found was that the stopDone command did not seem to run as I
expected it to if at all.  You should probably use two oneshot timers with
the use of 300 ms and 700 ms respectively or a single oneshot timer cleverly
alternated between a period of 300 and 700 ms.. The pseudocode below runs
the timers from when the radio is confirmed started/stopped.  They could
instead be started from within each other's timer.fired() events.
 
When the radio is confirmed started:
Start myjob
Start timer1 (oneshot 300 ms)
 
When timer1 fires:
stop myjob
stop the radio 
 
When the radio is confirmed stopped:
Start timer0 (oneshot 700 ms)
 
When timer0 fires:
start the radio
 
Some of the commands you will need are demonstrated below:
 
 
 
call AMControl.start(); //inside some command or other
 
event void AMControl.startDone(error_t err) {
  if (err == SUCCESS || err == EALREADY) {
  }
  else {
   call AMControl.start();
  }
 }
 
 
call AMControl.stop();//inside some command or other

 event void AMControl.stopDone(error_t err) { //radio stopped okay?
  if (err == SUCCESS || err == EALREADY) { //if radio shut down okay or is
already off

  }
  else {
   call AMControl.stop();
  }
 }

-----Original Message-----
From: mona zima [mailto:[EMAIL PROTECTED]
Sent: 21 August 2007 12:52
To: Murray, Ben
Subject: Re: [Tinyos-help] Duty cycle


Hi Ben,
Thank you for your reply but I want to switch the radio on and off, I am
confusing about how to power it up and down .
Suppose I know that my job will take only 300ms and I want to switch the
radio off for 700ms and repeat this actions. Do i have to use the LPL
interfaces or what do you think?. 

Also it is not clear for how long the radio will be on or off in case I
used setLocalSleepInterval(400). can you answer this question ?

finally can you take a look to this: 

event void Boot.booted() {
  call Timer0.startPeriodic(700); //this will fire every 700ms

} 
 
 event void Timer0.fired(){ //called when Timer0 fires
  callyourjob();
  call SplitControl.stop() ;// does that mean that the radio is off 
}

Thanks for any help
   Mona
  
     



On 8/20/07, Murray, Ben < [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote: 

Hi Mona,

Sounds like you could probably use a 400 ms timer to periodically run your
task/job. In tos2 the MCU should automatically be put to sleep if there are
no tasks to run, although you can call McuSleep.sleep() yourself if you need
to.  Setlocalsleepinterval () is used to duty cycle the radio only.  The
code below will call your job to start every 400 ms.  If you wanted the gap
specifically to be 400 ms from the end of the job to the beginning of the
next job, rather than between the starts of successive jobs then you could
call a one shot timer every time your job finished instead.  As long as your
mote is not tasked with doing anything else during the 400 ms I think it
should automatically go to sleep. 
 
 event void Boot.booted() {
  call Timer0.startPeriodic(400); //this will fire every 400ms
 }
 
 event void Timer0.fired(){ //called when Timer0 fires
  callyourjob();
 }
 
 
tep's 112 and 102 should be of interest I imagine...
 
-Ben
 

-----Original Message-----
From: mona zima [mailto: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> ]

Sent: 20 August 2007 15:11
To: Murray, Ben
Subject: Re: [Tinyos-help] Duty cycle


Hi Daivd, 
Thanks very much for your help and support.
I am wondering if you can help me with the following:
I would like to let the node sleep for 400 ms and then wakeup for some time
do some job and then return to sleep mode for 400ms and so on.... . I think
setLocalSleepInterval() will not help in this case! 
Is it possible to specify the on and off periods in tinyos2.

kind regards
  Mona  


On 8/13/07, Murray, Ben <  <mailto:[EMAIL PROTECTED]>
[EMAIL PROTECTED]> wrote: 

It's all looking a lot clearer now, I guess the only question remaining is -
is there any limit to setLocalSleepInterval()? Could I tell it to sleep for
4 hours [setLocalSleepInterval(14400000)] ...ignoring the (relatively)
potentially devestating power requirements on trying to send a message to
that node if you had no idea when it might be turning on.
 
i guess a system that totally slept for 4 hours and then woke for a few
seconds, somehow in-sync with those around it, and used Lpl during those few
seconds would be the route to take anyway. No doubt I'll be back with
confused queries about Timer0 :-)
 
thanks again, been a real help clearing some of this stuff up!
 
-Ben


*******************************************************************************
Please consider the environment before printing this email.
*******************************************************************************
This email and any files transmitted with it are intended solely for the use of
the individual or entity to whom they are addressed and may not be divulged to
any third party without the express permission of the originator.  Any views
expressed in this message are those of the individual sender, except where the
sender specifically states them to be the views of Thales Research & Technology
(UK) Limited.
*******************************************************************************

_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to