Congratulations on sorting it Dick.
I'm having problems with my code which seems so simple but it won't work with serin/out2 qualifiers.
I have commented out the Serin2 ACK in the control code as it doesn't get one due to the field code not working. This way, at least the code works the relay ok if I remove the Serin2 qualifier and just send "BOB".
This points to the qualifiers as the culprit as without them the code works OK.
I've tried every combination and it doesn't respond. All I want in the Field unit is to receive a qualifier to branch to the desired gosub.
Please bear in mind code below is probably incorrect as it's what's left of trying.
Control code
Code:Include "modedefs.bas" DEFINE OSC 10 TRISA=%00000000 TRISB=%11110000 CMCON=7 ; comparators off redled VAR PortB.4 greenled VAR PortB.5 yellowled VAR PortB.6 switch VAR PortB.7 redstop VAR BYTE greengo VAR BYTE flip VAR BYTE ;relay var PortA.1 flip = 0 ; counter flipflop for single command send redstop = 1 greengo = 2 test: ; test led outputs high redled pause 500 low redled high greenled pause 500 low greenled high yellowled pause 500 low yellowled pause 2000 main: IF SWITCH = 1 and flip = 0 THEN GOSUB red pause 500 IF switch = 0 and flip = 1 then gosub green goto main red: pause 1 SEROUT2 PortA.3,T9600,["BOB",redstop] ; send command to field unit ;SERIN2 PortA.2,84,[WAIT("ACK")] ; wait for acknowledge signal low greenled high redled flip = 1 ; flip flop counter to ensure send only once gosub flash ; flash test led return green: pause 1 SEROUT2 PortA.3,T9600,["BOB",greengo] ;SERIN2 PortA.2,84,[WAIT("ACK")] low redled high greenled flip = 0 gosub flash return flash: high yellowled pause 50 low yellowled PAUSE 50 high yellowled pause 50 low yellowled PAUSE 50 high yellowled pause 50 low yellowled return END
Field code
Code:Include "modedefs.bas" DEFINE OSC 10 TRISA=%00000100 CMCON=7 relay VAR PortA.1 signal var BYTE low relay ' Program MAIN: SERin2 PortA.2,84,[wait("BOB"),dec SIGNAL] if signal = 1 then gosub redstop endif if signal = 2 then GOsub greengo endif goto main redstop: high relay pause 25 SEROUT2 PortA.3,T9600,["ACK"] return greengo: low relay pause 25 SEROUT2 PortA.3,T9600,["ACK"] return END
As an oddball I also discovered that FOR NEXT just doesn't seem to work in any of my codes?
Rob




Bookmarks