I'm positive there's no missed resistors or diodes in relation to the push buttons - as much as it's a very abbreviated schematic, the circuit really doesn't have much more - I can upload some scans of the board if you like, but I've actually decided to approach this a different way.
Originally I was going to sacrafice the remote control function to gain a serial interface, but what I've since decided to do is take the two outputs from the original pic and feed it into another pic - this will give me my serial interface and keep the remote control - without having to deal
Now I have a problem with frightfully slow interrupts - I've tested this in PIC Simulator and it works reasonably quickly there. In real life tho, this code interrupts 'eventually' usually 5-20 seconds later. I can't see why, I'm only tying it up for 10 ms then I've inserted an extra pauseus so it's got something to interrupt before/after before returning to serin.
Anyway I can speed up the interrupt to... between 11 and 100 ms?
Code:
' Configure the pic
@ device pic12F675, INTRC_OSC_NOCLKOUT, WDT_ON, PWRT_ON, MCLR_OFF, BOD_ON, CPD_OFF, PROTECT_OFF
N9600 CON 6
CMCON = 7
ANSEL = 0
Relay1 VAR GPIO.5
Relay2 VAR GPIO.4
SlavePower VAR GPIO.2
SlaveRelay1 VAR GPIO.0
SlaveRelay2 VAR GPIO.1
Serial VAR GPIO.3
B0 var BYTE
INPUT SlaveRelay1
INPUT SlaveRelay2
INPUT Serial
OUTPUT Relay1
OUTPUT Relay2
OUTPUT SlavePower
ON INTERRUPT GOTO slaveSpeaks
IOC = %00000011
INTCON = %10001000
' Turn on the original PIC
HIGH SlavePower
main:
B0 = 0
PAUSEUS 1
SERIN Serial, N9600, 10, main, [1], B0
' The original PIC latches it's output, we want to reboot the original pic if we get something from the serial port to force it's outputs low
IF B0 > 1 THEN LOW SlavePower
if B0 = 2 THEN GOSUB subUp
IF B0 = 3 THEN GOSUB subDown
IF B0 = 4 THEN GOSUB subStop
IF B0 > 1 THEN
PAUSEUS 1000
HIGH SlavePower
ENDIF
GOTO main
DISABLE
subUp:
LOW Relay2
HIGH Relay1
RETURN
subDown:
LOW RELAY1
HIGH Relay2
RETURN
subStop:
LOW Relay1
LOW Relay2
RETURN
slaveSpeaks:
if SlaveRelay1 THEN
GOSUB subUp
ELSE
IF SlaveRelay2 THEN
GOSUB subDown
ELSE
GOSUB subStop
ENDIF
ENDIF
INTCON = %10001000
RESUME
ENABLE
Bookmarks