hi all !
My project involves a picaxe 14m which spends a sedentary life waking up from a sleep loop roughly every 10 seconds to check if there is any input voltage/high on input2[portc 5 or fifth pin down from + or leg 5 ref manual]. This input comes from a timing capacitor[2mohm/10mf;; normal state discharged] connected to input 2 so that whenever pic wakes up there will be a high recorded if an externally operated switch has charged the timing capacitor while pic was asleep.
main:
sleep 3
if input2 = 1 then goto dothis
goto main
dothis:
etc etc ' just few commands, very little time involved
goto main
All works okay if I initially leave the pic in its default input\output state[ie inputs on the left outputs on the right]. My problem is when I start reconfiguring the inputs/ using the "let dirsc =" or "input" commands. There appears no problem reconfiguring and using the reconfigurable/portc pins as outputs. I need portc 3 and 4 as outputs[these remain as outputs]. However after the initial waking up and checking input2 high I also need capacitor to be rapidly discharged which I do by making this reconfigurable mentioned above [low portc 5] low. I then need this pin changed to an input again, to recognize further operation of the switch\charge of capacitor... which is the ultimate problem!
main:
sleep 3
if input2 = 1 then goto dothis ' capacitor has been charged
goto main
dothis:
low portc 5 ' to discharge the capacitor through it
pause 100
let dirsc = %00011111 ' set pin back to input[ dream on!]
pause 5000 ' just for testing;; time to operate switch and charge capacitor again
goto main
[ code has been simplified eg in reality I know when pause and sleep begins so that the capacitor is not discharging for too long before it wakes up]
With the coding above, and with the capacitor charged, the first time I switch on the pic the input2 command is recognized ie as high and triggers dothis .the low portc 5 command also discharges the capacitor. However the moment the let command is triggered to make this an input again, going back to main[ and with the capacitor now charged again during the pause command], the "if input2 = 1" will not be recognized again. It just loops indefinitely back to sleep. And the moment I released the switch the capacitor is immediately discharged[ I assume because the pin is remaining an output\low??] Exactly the same thing happens if I use "if portc5 = 1;; will be recognized on the first pass even before any dirsc command is mentioned in the coding, but not when it goes back to main after the first pass.
I have also tried just setting it individually without any use of dirsc eg leaving it out completely and after the low portc 5 command inserting "input 2" [ as it says in the basic commands section of the manual] or even trying " input portc 5 " and pretty well any other combination I can think of. the program simply will not accept the input command [ message box saying input is not available in this mode]. The manual says these inputs can be manipulated, the type of chip selected in the options box is correctly set at 14m, I try a similar thing with an 08m and everything is accepted and works fine. I must be doing something wrong?? Because everything goes pear shaped the moment I use dirsc with picaxe 14m, or the moment I use these configurable pins as an output I cannot set them back to an input again
Any comments or suggestions ?? Just tell me it is a known fault and you will hear me scream from there!
My project involves a picaxe 14m which spends a sedentary life waking up from a sleep loop roughly every 10 seconds to check if there is any input voltage/high on input2[portc 5 or fifth pin down from + or leg 5 ref manual]. This input comes from a timing capacitor[2mohm/10mf;; normal state discharged] connected to input 2 so that whenever pic wakes up there will be a high recorded if an externally operated switch has charged the timing capacitor while pic was asleep.
main:
sleep 3
if input2 = 1 then goto dothis
goto main
dothis:
etc etc ' just few commands, very little time involved
goto main
All works okay if I initially leave the pic in its default input\output state[ie inputs on the left outputs on the right]. My problem is when I start reconfiguring the inputs/ using the "let dirsc =" or "input" commands. There appears no problem reconfiguring and using the reconfigurable/portc pins as outputs. I need portc 3 and 4 as outputs[these remain as outputs]. However after the initial waking up and checking input2 high I also need capacitor to be rapidly discharged which I do by making this reconfigurable mentioned above [low portc 5] low. I then need this pin changed to an input again, to recognize further operation of the switch\charge of capacitor... which is the ultimate problem!
main:
sleep 3
if input2 = 1 then goto dothis ' capacitor has been charged
goto main
dothis:
low portc 5 ' to discharge the capacitor through it
pause 100
let dirsc = %00011111 ' set pin back to input[ dream on!]
pause 5000 ' just for testing;; time to operate switch and charge capacitor again
goto main
[ code has been simplified eg in reality I know when pause and sleep begins so that the capacitor is not discharging for too long before it wakes up]
With the coding above, and with the capacitor charged, the first time I switch on the pic the input2 command is recognized ie as high and triggers dothis .the low portc 5 command also discharges the capacitor. However the moment the let command is triggered to make this an input again, going back to main[ and with the capacitor now charged again during the pause command], the "if input2 = 1" will not be recognized again. It just loops indefinitely back to sleep. And the moment I released the switch the capacitor is immediately discharged[ I assume because the pin is remaining an output\low??] Exactly the same thing happens if I use "if portc5 = 1;; will be recognized on the first pass even before any dirsc command is mentioned in the coding, but not when it goes back to main after the first pass.
I have also tried just setting it individually without any use of dirsc eg leaving it out completely and after the low portc 5 command inserting "input 2" [ as it says in the basic commands section of the manual] or even trying " input portc 5 " and pretty well any other combination I can think of. the program simply will not accept the input command [ message box saying input is not available in this mode]. The manual says these inputs can be manipulated, the type of chip selected in the options box is correctly set at 14m, I try a similar thing with an 08m and everything is accepted and works fine. I must be doing something wrong?? Because everything goes pear shaped the moment I use dirsc with picaxe 14m, or the moment I use these configurable pins as an output I cannot set them back to an input again
Any comments or suggestions ?? Just tell me it is a known fault and you will hear me scream from there!