Gixxer
- 25th January 2008, 00:49
Hello,
I have a simple serial relay controller setup using two pics, one for the transmitter and one for the receiver. Using the "serout2" command I can send control data to the RX. The RX code was written using the "serin" command. I have tried but to no avail, here is the original code, how do I convert this code to allow "serin2" to be used along with modes..ie 396 for t2400.
PAUSE 100
INCLUDE "bs2defs.bas"
relay VAR b3 'relay number storage variable
stat VAR b4 'relay status ON/OFF variable
trisa = %00010000
trisb = %00000000
loop:
SERIN porta.4,t2400,[254],relay,stat 'serial data in on PortA.4
IF relay = 1 THEN outr1 ' if request is for relay#1 then goto relay#1 routine
IF relay = 2 THEN outr2 ' if request is for relay#2 then goto relay#2 routine
IF relay = 3 THEN outr3 ' if request is for relay#3 then goto relay#3 routine
IF relay = 4 THEN outr4 ' if request is for relay#4 then goto relay#4 routine
IF relay = 5 THEN outr5
IF relay = 6 THEN outr6
IF relay = 7 THEN outr7
IF relay = 8 THEN outr8
IF relay = 9 THEN outr9
IF relay = 10 THEN outr10
IF relay = 11 THEN outr11
IF relay = 12 THEN outr12
GOTO loop
outr1:
IF stat = 1 THEN high1 ' If status request is I/O pin#0 logic 1 [high]
LOW 0: GOTO loop ' then make I/O pin#0 high, else make it [low]
high1:
HIGH 0: GOTO loop ' Make I/O pin#0 logic 1 [high]
outr2:
IF stat = 1 THEN high2
LOW 1: GOTO loop
high2:
HIGH 1: GOTO loop
outr3:
IF stat = 1 THEN high3
LOW 2: GOTO loop
high3:
HIGH 2: GOTO loop
outr4:
IF stat = 1 THEN high4
LOW 3: GOTO loop
high4:
HIGH 3: GOTO loop
outr5:
IF stat = 1 THEN high5
LOW 4: GOTO loop
high5:
HIGH 4: GOTO loop
outr6:
IF stat = 1 THEN high6
LOW 5: GOTO loop
high6:
HIGH 5: GOTO loop
outr7:
IF stat = 1 THEN high7
LOW 6: GOTO loop
high7:
HIGH 6: GOTO loop
outr8:
IF stat = 1 THEN high8
LOW 7: GOTO loop
high8:
HIGH 7: GOTO loop
outr9:
IF stat = 1 THEN high9
porta.0 = 0: GOTO loop
high9:
porta.0 = 1: GOTO loop
outr10:
IF stat = 1 THEN high10
porta.1 = 0: GOTO loop
high10:
porta.1 = 1: GOTO loop
outr11:
IF stat = 1 THEN high11
porta.2 = 0: GOTO loop
high11:
porta.2 = 1: GOTO loop
outr12:
IF stat = 1 THEN high12
porta.3 = 0: GOTO loop
high12:
porta.3 = 1: GOTO loop
thanks alot
John
I have a simple serial relay controller setup using two pics, one for the transmitter and one for the receiver. Using the "serout2" command I can send control data to the RX. The RX code was written using the "serin" command. I have tried but to no avail, here is the original code, how do I convert this code to allow "serin2" to be used along with modes..ie 396 for t2400.
PAUSE 100
INCLUDE "bs2defs.bas"
relay VAR b3 'relay number storage variable
stat VAR b4 'relay status ON/OFF variable
trisa = %00010000
trisb = %00000000
loop:
SERIN porta.4,t2400,[254],relay,stat 'serial data in on PortA.4
IF relay = 1 THEN outr1 ' if request is for relay#1 then goto relay#1 routine
IF relay = 2 THEN outr2 ' if request is for relay#2 then goto relay#2 routine
IF relay = 3 THEN outr3 ' if request is for relay#3 then goto relay#3 routine
IF relay = 4 THEN outr4 ' if request is for relay#4 then goto relay#4 routine
IF relay = 5 THEN outr5
IF relay = 6 THEN outr6
IF relay = 7 THEN outr7
IF relay = 8 THEN outr8
IF relay = 9 THEN outr9
IF relay = 10 THEN outr10
IF relay = 11 THEN outr11
IF relay = 12 THEN outr12
GOTO loop
outr1:
IF stat = 1 THEN high1 ' If status request is I/O pin#0 logic 1 [high]
LOW 0: GOTO loop ' then make I/O pin#0 high, else make it [low]
high1:
HIGH 0: GOTO loop ' Make I/O pin#0 logic 1 [high]
outr2:
IF stat = 1 THEN high2
LOW 1: GOTO loop
high2:
HIGH 1: GOTO loop
outr3:
IF stat = 1 THEN high3
LOW 2: GOTO loop
high3:
HIGH 2: GOTO loop
outr4:
IF stat = 1 THEN high4
LOW 3: GOTO loop
high4:
HIGH 3: GOTO loop
outr5:
IF stat = 1 THEN high5
LOW 4: GOTO loop
high5:
HIGH 4: GOTO loop
outr6:
IF stat = 1 THEN high6
LOW 5: GOTO loop
high6:
HIGH 5: GOTO loop
outr7:
IF stat = 1 THEN high7
LOW 6: GOTO loop
high7:
HIGH 6: GOTO loop
outr8:
IF stat = 1 THEN high8
LOW 7: GOTO loop
high8:
HIGH 7: GOTO loop
outr9:
IF stat = 1 THEN high9
porta.0 = 0: GOTO loop
high9:
porta.0 = 1: GOTO loop
outr10:
IF stat = 1 THEN high10
porta.1 = 0: GOTO loop
high10:
porta.1 = 1: GOTO loop
outr11:
IF stat = 1 THEN high11
porta.2 = 0: GOTO loop
high11:
porta.2 = 1: GOTO loop
outr12:
IF stat = 1 THEN high12
porta.3 = 0: GOTO loop
high12:
porta.3 = 1: GOTO loop
thanks alot
John