Counting pulses, while the MM sleeps....
| Author | Message | ||||
Grogster![]() Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 10039 |
I have a project, where I need to count the pulses from a charger module, when the MM2 chip wakes up, which it does every five seconds. When the MM2 wakes up, it currently looks to see if a tilt-sensor is active. If it is, the normal code runs. If it is not, the MM2 goes back to sleep for another five seconds. This repeats forever. What I want to be able to do, is count the pulses from the charger module, when the MM2 wakes up, BUT - it must count in the correct place in the sequence, and must be able to work out the correct pulses vs just whatever the charger module is doing at the time the MM2 happens to wake up. The charger modules are these ones HERE, and the "Battery Status" LED is ground referenced, and the G+ output has the pulses on it that I want to monitor. The charger module outputs pulses based on the condition of the battery. 4 pulses - Battery good. 3 pulses - Battery OK. 2 pulses - Battery weak 1 pulse - Battery flat, recharge immediatley. Each of these sequences of pulses, is seperatted by a 1000mS delay. So, I need a way to first detect the 1000mS delay period, and THEN count the pulses on the pin. However, as the MM2 chip can wake at any point in this sequence, I need a way to sync the pulses from the charger module, to the MM2 count input pin. My very first thought was that upon waking, the MM2 should IGNORE what is going on on the count input pin, and WAIT till it gets NO PULSES for AT LEAST 500mS, then start counting, but the issue with that, is that as the MM2 can wake at any point in the pulse sequence from the charger module, waiting 500mS may still not work. Perhaps I need to count at least TWO sets of pulse sequences? Kinda scratching my head with this one, and how to approach WHEN I try to start counting the pulses, cos with the MM2 chip asleep, when it WAKES UP, the pulse sequence from the charger module can be literally ANYWHERE inside that pulse sequence, and it is doing my head in trying to think of how I sync the MM2 to the pulses when it wakes up and looks to count the pulses from the charger module. Anyone got any ideas? Smoke makes things work. When the smoke gets out, it stops! |
||||