Hi,
(I’m very new to PICs. Also I have no programming experience of any kind to speak of.)
The problem I need help with is as follows:
I have 4 single pole double throw switches (Standard UK wall light switches in fact (2-ways)). I need to get a pulse to go to another circuit every time the switch is thrown. I don’t need to know the position of the switch.
At the moment I can only seem to solve the problem for one switch only (I have not learnt all the 35 instructions yet, perhaps there’re other commands that might help)
For one SW I came up with
The common goes to one of the inputs on the PIC. One terminal is connected to 1 the other to 0
TP1: Test Position1 If 1 Jump Line [btfss]
Goto TP1
Call Pulse
Goto TP2
TP2: Test Position2 If 0 Jump Line [btfsc]
Goto TP2
Call Pulse
Goto TP1
Pulse: Pulse subroutine. Return
end
But my code just sits there waiting for the switch to be thrown, Im not sure how to get it to do that for 3 others too. I need it to jump out of the loop and check the others, return back to switch one and start the checking all over again.
--------
Another solution I came up with was just to have an LED and capacitor in series. Throw the switch and you would get the LED to pulse. Throw the switch the other way and it would discharge the capacitor through a second LED, giving you the other pulse. (Trouble is I did not know where to tap off this output to my other circuit. Well I just tried to use an oscilloscope to look for a voltage jump when I threw the switch, I could not really see one. Maybe if I used resistors in place of the LED’s I would have seen a bigger jump?
--------
Thanks
(I’m very new to PICs. Also I have no programming experience of any kind to speak of.)
The problem I need help with is as follows:
I have 4 single pole double throw switches (Standard UK wall light switches in fact (2-ways)). I need to get a pulse to go to another circuit every time the switch is thrown. I don’t need to know the position of the switch.
At the moment I can only seem to solve the problem for one switch only (I have not learnt all the 35 instructions yet, perhaps there’re other commands that might help)
For one SW I came up with
The common goes to one of the inputs on the PIC. One terminal is connected to 1 the other to 0
TP1: Test Position1 If 1 Jump Line [btfss]
Goto TP1
Call Pulse
Goto TP2
TP2: Test Position2 If 0 Jump Line [btfsc]
Goto TP2
Call Pulse
Goto TP1
Pulse: Pulse subroutine. Return
end
But my code just sits there waiting for the switch to be thrown, Im not sure how to get it to do that for 3 others too. I need it to jump out of the loop and check the others, return back to switch one and start the checking all over again.
--------
Another solution I came up with was just to have an LED and capacitor in series. Throw the switch and you would get the LED to pulse. Throw the switch the other way and it would discharge the capacitor through a second LED, giving you the other pulse. (Trouble is I did not know where to tap off this output to my other circuit. Well I just tried to use an oscilloscope to look for a voltage jump when I threw the switch, I could not really see one. Maybe if I used resistors in place of the LED’s I would have seen a bigger jump?
--------
Thanks
Last edited: