![]() |
Forum Index : Microcontroller and PC projects : CPU SLEEP while keeping (approximate) track of time
Author | Message | ||||
robert.rozee Guru ![]() Joined: 31/12/2012 Location: New ZealandPosts: 2426 |
this is probably a question for Geoff: with the Micromite Mk2 (MX170), is there any way of keeping approximate track of how long a CPU SLEEP has lasted? i have an I2C ADC set up to collect samples at a rate of around 64 samples per second; these are summed, and around every 300ms are averaged and transmitted. whenever the ADC has a new sample ready it signals the MX170 by toggling pin 16 - so this can (and indeed does) wake up mmbasic, the sample is read from the ADC, and the ADC then instructed to collect another sample if we are still within the 300ms collection window. i want to use CPU SLEEP for a couple of reasons: (a) so i can keep the current consumption down at the 1mA level, this is for a battery operated device and i'm hoping to achieve a battery life in the hundreds of hours; (b) having the MX170 sleep while the ADC is operating is desirable to minimize electrical noise issues. signal levels are down into the 100's of microvolts. one hardware option i'm thinking of is simply an LM555 set to produce a 50/50 600ms square wave that is fed into a pin on the MX170, thereby providing a 300ms ON, 300ms OFF tick-tock that i can check. but, if there was a SIMPLE software option... cheers, rob :-) |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7783 |
How about a RC network. A resistor trickle charges a cap. At the trigger point the MX170 wakes up, increments a counter, pulls the pin low to discharge the cap through a diode, makes it an input again then goes back to sleep. It may not be too accurate, depending on the type of capacitor used, and may also drift with temperature. That would at least give you a sort of clock without having to use a 555 as well. I'm not even sure if this is possible. I've not used the MX170 for ages and I can't find my manual either. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
robert.rozee Guru ![]() Joined: 31/12/2012 Location: New ZealandPosts: 2426 |
not a bad idea ![]() cheers, rob :-) |
||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2168 |
Hi Rob quick question: what 3.3V regulator are you using? I had a bit of a rude awakening here while persuing similar reasons to yours. I use hi-side switches (PFETs) to switch off bits of my project (4x555 based sensors pulling 6mA a-piece and some UHF stuff) when not in use - I wake every 6 minutes, and I got my SLEEP current down to 250µA with still some bits and bobs running h Edited 2025-06-15 04:42 by CaptainBoing |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7783 |
linear regs are pretty inefficient. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
circuit Senior Member ![]() Joined: 10/01/2016 Location: United KingdomPosts: 274 |
For low power operation in the MicroMite family, don't forget the Armmite L4. This was promoted by Peter as a low power alternative to the 170 for battery operation. The MX170 draws 40uA when sleeping; the Armmite sleeps at 3uA. The chip also will run as low as 0.8mA when clocked at 2MHz which is perfectly functional for many operations. At 48MHz the 170 draws 31mA and the Armmite just 7.5mA. The Armmite can also run at 80MHz if you need performance and it still only draws 12.7mA. Available in 32, 48 and 64 pin variants, I have the STM32L432 Nucleo-32 which comes on a neat DIL board. The 32 pin variant has 9 x 12bit ADC pins. The 48 and 64 pin variants have a built-in RTC which can be read with millisecond precision. Would this not be a better selection than the 170? |
||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2168 |
I had forgotten ![]() Just completed a project with the 170 and I am happy with the results, but that sort of power might have changed a few design parameters. I will re-look at it. cheers h |
||||
robert.rozee Guru ![]() Joined: 31/12/2012 Location: New ZealandPosts: 2426 |
success, using an external RC as suggested by Mixtel90, using just a single pin: ![]() and the following code: ' automatic calibration SetPin 7, dout Pin(7)=0 Pause 10 SetPin 7, ain t=Timer+300 Do Vcal=Pin(7) Loop Until Timer>t Print "calibration = " Str$(Vcal, 0, 3) " volts" ' timing test loop Do SetPin 7, dout Pin(7)=0 Pause 10 SetPin 7, ain t=Timer Do : Loop Until Pin(7)>Vcal Print Timer-t, Loop this is the output from the above code: > RUN calibration = 2.404 volts 302 302 302 303 302 302 302 302 302 302 303 302 302 302 302 302 302 302 302 302 302 303 302 302 302 302 303 302 302 302 302 302 302 > > i've also been able to verify that CPU SLEEP does not have any effect on the timing. cheers, rob :-) |
||||
robert.rozee Guru ![]() Joined: 31/12/2012 Location: New ZealandPosts: 2426 |
i'm using an E-28 module while prototyping on a solderless breadboard, but when building up a full version will pick a suitable LDO regulator with a low bias current. cheers, rob :-) |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |