Main Site Documentation

G120 4.3.2 vs 4.3.3 power tests


#1

I have just done some real quick power tests on the G120 to compare the changes with the latest firmware.

 Debug.Print("Sleep for 8secs");
Thread.Sleep(8000);
Debug.Print("Doing some hard work");
int n = 500000;
while (n > 0) n--;
Debug.Print("Hibernates/Sleeps");
Thread.Sleep(1000);
PowerState.Sleep(SleepLevel.DeepSleep, HardwareEvent.OEMReserved2);//Hibernate in 4.3.2

Results

4.3.2 (BETA)
Sleep = 157mA
Work = 158mA
Hibernate = 106mA

4.3.3
Sleep = 108mA
Work = 161mA <- 155mA with debugger attached.
DeepSleep = 18mA

This looks really good so far. The lower sleep power means that almost all applications should use less power.


#2

Thanks, great work.

Stupid question, I want to try this myself, is it possible to try this with a Cobra II and using an external button to wake it up?


#3

Yes, easy. Just use OEM1 as the wake source and set up your button as an interrupt port.


#4

Does anyone want to try this in a loop using the Real Time Clock wakeup. I’m sure I had it working, but now it will only do the first deepsleep. Not sure what I changed.


#5

@ hagster - Yes please, ship some code. Lets try all wake-up methods!


#6

I haven’t got the code at present, but the info is in the documents https://www.ghielectronics.com/docs/141/low-power


#7

Ahh, that one has improved since last I was there…will try it!


#8

please note that it won’t wake up if in debug mode.
and RTC Alarm uses OEM2,


#9

It does the first sleep wake cycle fine. Obviously the debugger drops out. I can monitor the state via a DMM.

I need to do some more playing to see what I’ve done and probably add some debug LEDs for good measure.

I’m sure I had it working on my first attempt, but no longer. My mind may be playing tricks on me though.

Or are you saying I need to deploy in release build mode? I have never noticed a difference before, even the debug print statements still work.


#10

no no, I just meant we should run without VS2012 debugger attached.

:think: can you try to reset the RTC. It may something wrong with RTC and the Alarm can not be set. You can check by GetAlarm to make sure Alarm was set correctly.


#11

@ Dat - I can’t run these tests until tomorrow(wed). I will try a fresh board and see what happens.


#12

To simplify things I gave up with the RTC and am just using an interrupt port.

Here is my code for:-


        static OutputPort LED1G120HDR = new OutputPort(GHI.Pins.G120.P1_5, true);
        static OutputPort LED1 = new OutputPort(GHI.Pins.G120.P1_14, false);  //46
        static OutputPort LED2 = new OutputPort(GHI.Pins.G120.P1_17, false);  //49
        static OutputPort LED3 = new OutputPort(GHI.Pins.G120.P1_16, false);   //48
        static OutputPort LED4 = new OutputPort(GHI.Pins.G120.P1_15, false);   //47
        static InterruptPort SW1 = new InterruptPort(GHI.Pins.G120.P2_13, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);

        public static void Main()
        {   
            LED4.Write(true);
            Thread.Sleep(4000);
            LED4.Write(false);
            SW1.EnableInterrupt();
            SW1.OnInterrupt += new NativeEventHandler(IntButton_OnInterrupt);
      
            while (true)
            {

                LED3.Write(true);
                Thread.Sleep(4000);
                LED3.Write(false);

                LED2.Write(true);
                int n = 500000;
                while (n > 0) n--;
                LED2.Write(false);

                LED1G120HDR.Write(true);
                SW1.EnableInterrupt();   
                PowerState.Sleep(SleepLevel.DeepSleep, HardwareEvent.OEMReserved1);
                LED1G120HDR.Write(false);
            }

        }

        static void IntButton_OnInterrupt(uint port, uint state, DateTime time)
        {
            Debug.Print("Button Pressed");
        }

The first loop always works fine. I can see the debug LED on the G120HDR board light up until I push the button. The next loop through the LED just flashes really quickly and the loop continues. The other LED’s show me that the rest of the loop is working fine. E.g LED4 only lights up after a reset.

Can anyone else test this to see what happens?


#13

Strange…

I modified the code a bit.

The first loop works ok but after the first wake up the led’s dont change and if i connect MFDeploy i can see the debug output but device is not going to sleep…


using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHI.IO;
using GHI.Pins;
using System; 
using System.Threading;

  
namespace MFConsoleApplication1
{
    public class Program
    {
         static OutputPort LED1G120HDR = new OutputPort(GHI.Pins.G120.P1_14, true);
         static OutputPort LED1 = new OutputPort(GHI.Pins.G120.P1_17, false);  //46
         static OutputPort LED2 = new OutputPort(GHI.Pins.G120.P1_16, false);  //49
         static OutputPort LED3 = new OutputPort(GHI.Pins.G120.P1_15, false);   //48
         static OutputPort LED4 = new OutputPort(GHI.Pins.G120.P1_9, false);   //47

         static InterruptPort SW1 = new InterruptPort(GHI.Pins.G120.P2_8, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);

         public static void Main()
         {   
             LED4.Write(true);
             Thread.Sleep(4000);
             LED4.Write(false);
             SW1.EnableInterrupt();
             SW1.OnInterrupt += new NativeEventHandler(IntButton_OnInterrupt);

             SW1.EnableInterrupt();   

             while (true)
             {

                 LED3.Write(true);
                 Thread.Sleep(4000);
                 LED3.Write(false);

                 LED1G120HDR.Write(true);
                 Debug.Print("Feeling sleepy...");
                 PowerState.Sleep(SleepLevel.DeepSleep, HardwareEvent.OEMReserved1);
                 LED1G120HDR.Write(false);
             }

         }

         static void IntButton_OnInterrupt(uint port, uint state, DateTime time)
         {
             Debug.Print("Button Pressed");
         }
        }

    }




#14

@ David@ Emrol -

Wakeup does not work if connected to MFDeploy or VS.

@ hagster
we were able to reproduce the issues, and trying to know why it is happened

:’(


#15

It’s was deployed and started without device manager or VS connected.
Then connected MFDeploy and saw got the debug output.

it looks the same in the device manager, first loop device disappears, next loop the device stays in device manager.


#16

@ Dat - Thanks DAT.

Note, I did also try it running from a battery with no USB attached at all.


#17

Hi,

I’m landing here thanks to Hagster.

I have the same problem on my G120:

  • Sleep/Resume does not work if MFDeploy/VS is connected.
  • First resume works on a input interrupt, after that, the devices wakes up by itself, right after falling to deep sleep…

#18

Hi,

I am implementing the wake up on RTC Alarm on my G120, and it seems impossible to resume after a deep sleep.

I do this simple code, from the example:

RealTimeClock.SetAlarm(DateTime.Now.AddSeconds(30));
PowerState.Sleep(SleepLevel.DeepSleep, HardwareEvent.OEMReserved2);

The RTC value is coherent becase I print out a result RealtTimeClock.GetDateTime() to be sure.

I read in a previous post, the project must be deployed in “release”, so I do that too…

I am just testing the first suspend/resume after a reset, because it could stay in sleep mode after that (see my previous post and Hagster’s).

I am running out of ideas … does anyone have a G120 capable of waking up from DeepSleep on a RTC event (HardwareEvent.OEMReserved2)?

Thanks,


#19

@ thomas_exmakhina - have you got the power on the RTC battery backup pin?


#20

Yes, VBAT (Pin 60 on the G120 module) is connected directly to the battery.