Yes, the magnetic switch will be the ony thing to wake it and tell it to sleep in this application. It should not turn on/off (wake/sleep) until a user turns it or on with the switch..
Yes, the magnetic switch will be the ony thing to wake it and tell it to sleep in this application. It should not turn on/off (wake/sleep) until a user turns it or on with the switch..
Here's one scenario;
The PIC wakes up at regular intervals using the WDT. If switch = 0, then go
back to sleep. It's only awake for a few uS testing the switch.
If switch = 1, then do whatever you need to do, then test the switch input
before going back to sleep.
A switch press can also wake the PIC up before a WDT timeout. Handle
whatever you need to do, test the switch, and go back to sleep or stay
awake (resetting WDT) as required, based on the switch input.
It's still going to save a boat-load of power since it will be sleeping until your
switch is active, or the WDT times out.
If the switch isn't active, it's still alseep for the majority of time, and you'll
be operating at low current until the switch input forces the wake up, or the
WDT timeout.
Wouldn't that work?
This could work.... I will try this as soon as I get the chance (prob after the weekend). Thanks for your suggestions, I've been working on multiple projects and they all run together which makes it hard to really focus on the issue at hand enough to get outside the box. Sometimes its just nice to get a fresh perspective on a project.
Thanks again Bruce! I'll post my results when I get back to it next week.
Kessral
If I understand you correctly, you want to do a pulsout (1) every time the PIC is woken by the magnetic switch. Waking on a magnetic switch can be done by a pin change interrupt, if available in the 10F(Havent used, so I cant comment on this). So, your ideal work loop will be something like
while (1)
PULSOUT pin, period
@ SLEEP
@ nop
@ nop
' on waking from interrupt, go back to pulsout
wend
Of course, I haven't shown the part needed to configure the PIC for interrupt on change, etc
Jerson
No Jerson, I'm trying to get it to pulsout as the main function every few seconds or so. I want it to sleep as if it were turned off. And then continue its normal function pulsing when awakened.
I have tried your suggestion tho Bruce and come up with this code:
__________________________________________________ ____________
TRISIO=%11111111
STATUS=%10010000
OPTION_REG=%00001000
check var bit
Low GPIO.0
loop:
nap 4
pulsout 0, 4000
nap 5
IF GPIO.1 = 1 then
suspend:
pause 2000
check = GPIO
sleep 65535
IF GPIO.1 = 1 then
goto loop
else
goto suspend
endif
endif
goto loop
__________________________________________________ _____________
This seems to work. It wakes and sleeps on pin change just fine... however my problem now is that its drawing some 60uA instead of the 5-10uA listed in the datasheet. I'll keep looking through to see if there is something else I can do to lower the current drain, but for now this seems to be as close as I am going to get.
I DID notice however that GPIO 3 is constantly high... this could have something to do with current drain being slightly higher so that is what I am currently looking into.
Again thanks for the Input guys.
P.S. This is on a PIC10F202 and I am using MPLAB IDE v7.11
Last edited by kessral; - 15th January 2007 at 21:11.
This is a good point. And I did think of this. Currently I have 1 15k pulldown to ground from the pin connected to magnetic switch to help determine high/low state.
However 60uA is not consistent with this.. I'll just have to keep it in the back of my mind, as I have many other things to get to as well, maybe I'll think of something.
Last edited by kessral; - 15th January 2007 at 23:02.
Bookmarks