Post a new topicPost a reply Page 1 of 2   [ 16 posts ]
Go to page 1, 2  Next
Author Message
 Post subject: Problems Waking from Hibernate
PostPosted: Fri Jun 08, 2012 7:55 pm 

Joined: Fri Jun 01, 2012 8:18 pm
Posts: 14
Hello,

I have been having some trouble getting the waspmote to wake from hibernate. I have run the basic codes, and they work as expected. I have copied in my code for you to look at. It seems to get to the point where the LEDs blink, the first time, but then gets stuck somewhere in the method call when it comes out of hibernate. It never gets to the point where the LEDs flash for a long period of time at the end of the method (in order to see that the SD write is sucessful each time a line is written).

Thanks!


Quote:
void setup(){

  USB.begin();
  USB.println("USB Started.");
  
  SD.begin();
  SD.setMode(SD_ON);
  SD.init();
  
  RTC.ON();
  USB.println("Initialize RTC");
  PWR.ifHibernate();
  

  if (SD.create("TemperatureData.txt")){
      USB.println("Successfully created TemperatureData.txt.");
     }
    else{
      USB.println("Temperature.txt not successfully created, check for existing files.");
     }
}

void loop(){
  
  Utils.blinkLEDs(1000);
//   RTC.setTime("12:06:07:05:11:24:00");

  
  if( intFlag & HIB_INT ) {
    Utils.blinkLEDs(1000);
    hibInterrupt();
  }
  
   PWR.hibernate("00:00:00:10",RTC_OFFSET,RTC_ALM1_MODE2);
   
}
 
void hibInterrupt()
 {
   SD.begin();
  SD.setMode(SD_ON);
  SD.init();
  

   
     char temperature_data[10]="";
  Utils.float2String(RTC.getTemperature(),temperature_data,5);
    
//      USB.print("Time: ");
//    USB.println(RTC.getTime());
   Utils.blinkLEDs(1000);
//    USB.print(",Temperature(Celcius): ");
//    USB.print(RTC.getTemperature(),DEC);
//    USB.println("]");
    
//    
    SD.writeSD("TemperatureData.txt",temperature_data,20);
    SD.writeSD("TemperatureData.txt",RTC.getTime(),20);
    if(!SD.appendln("TemperatureData.txt",temperature_data)){
      USB.println("Temperature Data Write Unsuccessful");
    }
    if(!SD.appendln("TemperatureData.txt",RTC.getTime())){
      USB.println("Temperature Data Time Write Unsuccessful");
  }

     Utils.blinkLEDs(1000);
     Utils.blinkLEDs(1000);
     Utils.blinkLEDs(1000);
     Utils.blinkLEDs(1000);
     Utils.blinkLEDs(1000);

     intFlag &= ~(HIB_INT);
  }
  



Top
 Profile  
 
 Post subject: Re: Problems Waking from Hibernate
PostPosted: Mon Jun 11, 2012 8:34 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7516
koz,

try applying this changes:

  • Move PWR.ifHibernate(); at the beginning of setup loop.
  • Use SD.ON() instead of Sd.begin(), setMode and init.

Besides that, are you removing the hibernate jumper?

Let us know.

Regards.


Top
 Profile  
 
 Post subject: Re: Problems Waking from Hibernate
PostPosted: Tue Jun 12, 2012 5:02 pm 

Joined: Fri Jun 01, 2012 8:18 pm
Posts: 14
It is still not working as expected. How about this code?


Quote:

 
 
void setup()
{
  PWR.ifHibernate();
  
 RTC.ON();
  
  RTC.setTime("09:10:20:03:17:35:00");
  
  USB.begin();
  
  SD.ON();
 
    if (SD.create("TemperatureData.txt")){
      USB.println("Successfully created TemperatureData.txt.");
      }
    else{
      USB.println("Temperature.txt not successfully created, check for existing files.");
    }
  

  // Checks if we come from a normal reset or an hibernate reset

}

void loop()
{
  

  

  Utils.blinkLEDs(1000);
  
  RTC.setAlarm1("20:17:35:10",RTC_ABSOLUTE,RTC_ALM1_MODE3); //1 minute later
  
  // If Hibernate has been captured, execute hte associated function
  if( intFlag & RTC_INT )
  {
    hibInterrupt();
  }
  
  // Set Waspmote to Hibernate, waking up after 10 seconds
  PWR.hibernate(RTC.getAlarm1(),RTC_ABSOLUTE,RTC_ALM1_MODE3);
  RTC.clearAlarmFlag();

}

void hibInterrupt()
{
  
  
  USB.begin();
  Utils.blinkLEDs(1000);
  Utils.blinkLEDs(1000);
  USB.println("I'm awake!");
  USB.print("Temperature: ");
  USB.println(RTC.getTemperature(),DEC);
  USB.print("Time: ");
  USB.println(RTC.getTime());
  
 SD.ON();
  
  char temperature_data[10]="";
  Utils.float2String(RTC.getTemperature(),temperature_data,5);
  
   SD.appendln("TemperatureData.txt",temperature_data);
  SD.appendln("TemperatureData.txt",RTC.getTime());
  if(!SD.appendln("TemperatureData.txt",temperature_data)){
    USB.println("Temperature Data Write Unsuccessful");
  }
  if(!SD.appendln("TemperatureData.txt",RTC.getTime())){
    USB.println("Temperature Data Time Write Unsuccessful");
  }
  intFlag &= ~(HIB_INT);  
  
}



Top
 Profile  
 
 Post subject: Re: Problems Waking from Hibernate
PostPosted: Tue Jun 12, 2012 5:13 pm 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7516
koz,

Could you please be more specific?

Where is your code sticking?

Regards.


Top
 Profile  
 
 Post subject: Re: Problems Waking from Hibernate
PostPosted: Tue Jun 12, 2012 5:19 pm 

Joined: Fri Jun 01, 2012 8:18 pm
Posts: 14
Sure, with this new code (using the alarm instead of just timing how often this should happen), the mote does not come back up from hibernate at all. I am removing the jumper and I have modified the code as you specified earlier. The code I first posted I finally got working, so I switched to setting an alarm instead (because this is what is wanted), but now the mote will not wake up. Is there an error in my posted code?


Top
 Profile  
 
 Post subject: Re: Problems Waking from Hibernate
PostPosted: Tue Jun 12, 2012 6:24 pm 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7516
koz,

Try these things.

  • Not necessary to use RTC.ON(). It is already ON when you use PWR.hibernate.
  • Try increasing hibernate time to 5 minutes, maybe you are spending more than one minute in doing your stuff.

Let us know.

Regards.


Top
 Profile  
 
 Post subject: Re: Problems Waking from Hibernate
PostPosted: Tue Jun 12, 2012 6:34 pm 

Joined: Fri Jun 01, 2012 8:18 pm
Posts: 14
Took out RTC.ON(); It should not take more than a minute, because the code worked previously with 10 second delay rather than using the alarm for 30 seconds later..


Top
 Profile  
 
 Post subject: Re: Problems Waking from Hibernate
PostPosted: Wed Jun 13, 2012 9:03 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7516
koz,

What if you check code behaviour with deep sleep mode, where no jumper needs to be removed, and then, when it is working, just change to hibernate?

Let us know.

Regards.


Top
 Profile  
 
 Post subject: Re: Problems Waking from Hibernate
PostPosted: Wed Jun 13, 2012 8:33 pm 

Joined: Fri Jun 01, 2012 8:18 pm
Posts: 14
I can get it to wake from sleep but not always from hibernate. I am having a lot of troubles with timing sleep functions in my code. I want some sensors to capture data every minute and others every four hours, which use both alarms but then I also need Wifi to send this data every 24 hours, but there are no more alarms to set. I am also have trouble getting wifi to wake from sleeping. I have read all of the guides and resources available and it is not working out.


Top
 Profile  
 
 Post subject: Re: Problems Waking from Hibernate
PostPosted: Thu Jun 14, 2012 9:10 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7516
koz,

Well, you say that sleep modes are ok. That is a starting point.

Now, let's try to make a simple code which hibernates well. We recommend you to put a delay of a few seconds or a led blink before PWR.hibernate() sentence to allow removing hibernate jumper correctly.

Then, you can make a smart code which sleeps corresponding time (1 hour, 4 hours 24 hours) depending of some variable that you can set and save into EPPROM memory before going sleep/hibernate, all done using only one alarm. Do you understand? Check example of managing EEPROM.

Let us know your comments.

Regards.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 2   [ 16 posts ]
Go to page 1, 2  Next


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Libelium theme based on 610nm Style by Daniel St. Jules of http://www.gamexe.net


© Libelium Comunicaciones Distribuidas S.L. | Terms of use