Power Sleeping Functionality – eS2 Pro
Most of the time, we program our microcontrollers (Arduino board, etc.) to do something and then wait until it needs to be done again. Even though the microcontroller isn’t accomplishing anything, it still consumes power while it waits. In order to save power, we’ve designed the enregyShield 2 Pro with the ability to turn everything off while it isn’t needed. To use power sleeping, you need to write a program that executes once, performing your tasks, and then issues the sleepSeconds() command. This command sets an alarm that will re-enable the power and then turns the power off. Once the alarm is triggered, the power is restored to the microcontroller and the other circuitry, and the program executes again. This allows you to run your microcontroller, sensors, and other circuitry intermittently with dramatic power savings.
So, how does power sleeping work? The power sleeping is performed by the real-time clock (RTC) onboard the energyShield 2 Pro. The alarm output of the RTC is able to turn on the power enable net. To perform a power sleep cycle, the microcontroller reads the current time, sets the alarm registers to a time X seconds in the future (X being your chosen sleep time in seconds), and clears the alarm flag to turn off the power. When the RTC time registers match the alarm registers, the alarm pin becomes active, turning the power back on.
The trick to prioritizing the power switch over the RTC’s control involves some specialized logic circuitry. That logic says that the switch will always turn the energyShield ON and the RTC can only turn the power off after the alarm has triggered once. So, after the energyShield is turned on from the switch, the RTC has to trigger its alarm (the state where the RTC turns the power on) before it can turn the power off. This prevents the RTC from overriding the switch and is handled by the sleepSeconds() function.
Links