how do I quickly respond when system is "active", but also go to sleep when sys
wheelguy
Posts: 4
First timer here - this forum is amazing! I·looked at the most recent 400 posts, and searched, but didn't see anything like the following problem...
I plan to use the BS2pe to perform round counting·in an M16 type weapon. First, a nice paint job - then smartify it with some software control
So, I·need for the system to respond to·roughly 1 millisecond events (detecting bolt·movement and trigger status), so am using
POLLWAIT 8 'dont sleep while I wait for a button to be pressed
To wait for any one of·8 inputs to happen, then I take the appropriate action.
That part of the system works well, but I also need to put the system to sleep if it hasn't seen any events for a period of 5-99 minutes (configurable). However POLLWAIT will simply wait forever - what I need it to do is wait until either an event is detected OR a time period has elapsed - then I could loop in order to count the number of "timeouts".
Is there a way of doing this purely in software - perhaps making use of the WatchDog timer or oscillator that is built into the Stamp? I shouldn't use an I/O pin for this feature, because they are all spoken for. Guess I am hoping for a behavior tweek to POLLWAIT, but any software solution would be wonderful.
If it is just not possible otherwise, then any suggestions on a simple external timer·that I can attach to one precious I/O pin··? It doesn't have to be accurate, should activate the pin about every 100ms,·require no ongoing software overhead (such as charging an RC circuit), and no additional circuitry beyond the chip except wiring.
Sorry if this question has been asked before·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Be safe, help others.
Post Edited (wheelguy) : 7/26/2007 8:01:50 PM GMT
I plan to use the BS2pe to perform round counting·in an M16 type weapon. First, a nice paint job - then smartify it with some software control
So, I·need for the system to respond to·roughly 1 millisecond events (detecting bolt·movement and trigger status), so am using
POLLWAIT 8 'dont sleep while I wait for a button to be pressed
To wait for any one of·8 inputs to happen, then I take the appropriate action.
That part of the system works well, but I also need to put the system to sleep if it hasn't seen any events for a period of 5-99 minutes (configurable). However POLLWAIT will simply wait forever - what I need it to do is wait until either an event is detected OR a time period has elapsed - then I could loop in order to count the number of "timeouts".
Is there a way of doing this purely in software - perhaps making use of the WatchDog timer or oscillator that is built into the Stamp? I shouldn't use an I/O pin for this feature, because they are all spoken for. Guess I am hoping for a behavior tweek to POLLWAIT, but any software solution would be wonderful.
If it is just not possible otherwise, then any suggestions on a simple external timer·that I can attach to one precious I/O pin··? It doesn't have to be accurate, should activate the pin about every 100ms,·require no ongoing software overhead (such as charging an RC circuit), and no additional circuitry beyond the chip except wiring.
Sorry if this question has been asked before·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Be safe, help others.
Post Edited (wheelguy) : 7/26/2007 8:01:50 PM GMT
Comments
Counting or timing multiple events on the order of 1ms with a Stamp is always difficult since you can't execute many statements in that interval. Maybe you could use some external hardware to help out like some set/reset flipflops
The WatchDog timer is used already internally for the SLEEP and NAP statements and there isn't any other access to a timer other than as part of various statements.
An RC timer on a free pin would not take much overhead at all. When an event on that pin is detected, simply increment your seconds counter, recharge the capacitor, and go back to POLLWAIT 8.
You could possibly avoid using another pin by multiplexing the wakeup into one of your existing POLLIN pins by use of a diode or transistor. One thing that comes to mind is a 555 timer set to generate very narrow pulses (just a few microseconds). The pulse would be so narrow that it disappears by the time the interpreter gets around to looking at the input state. If it sees no change in state, that means ~0.1 second has passed. A lot depends on how long the natural button events are and how you set up the POLLing. Are you using POLLMODE 10?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
You guys totally rock!!!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Be safe, help others.
Post Edited (wheelguy) : 7/27/2007 5:16:50 PM GMT
TestRcTimeout:
DO
·OUTPUT rcSleepTimerPin
·rcSleepTimer = 1
·'PAUSE 600 'wait to charge capacitor
·w = 0
·INPUT rcSleepTimerPin
·DO
· w=w+1
· IF rcSleepTimerPin = 0 THEN EXIT
·LOOP
·DEBUG "Loops=",DEC5 w,CR
·PAUSE 1000
LOOP
END
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Be safe, help others.
Post Edited (wheelguy) : 7/27/2007 5:16:29 PM GMT