Ok, I made the following changes and it is not responding to any data now. It does continue to send data, just won't receive.
Also the code from the PC sets the corosponding relay back to 0 at the end of the command.
Example TX 2,1 then TX 2,0 meaning relay 2 HIGH then relay 2 LOW. Relays 3 thru 6 are latching and are unlatched when a differint relay is selected. Only relays 1 and 2 are momentary.
Intersting thing is I had this working great when connecting to a PC directly using COM Port with OUT interupts. I was using RTS/CTS but now that I am going thru a LAN to serial adapter it does not behave the same. I just recently added a RS-232 level converter that has a MAX232 of some flavor on board, so maybe I'll give the RTS/CTS deal a try again. I would love to get a handle on this interupt thing though so I can grow my PIC projects!
I also took out the wait statement, because I understand the UART can only grab 2 bytes at a time. Changed loop to MAIN.
Thanks for the info on ENABLE/DISABLE. It is for the compiler! I'll keep grinding away here.
on interrupt goto RECEIVE
MAIN:
TRANSMIT:
ADCIN 0, POTADC 'convert ADC value to a byte value:
HSEROUT [DEC POTADC,32] 'TX DATA on PORTC.6
PAUSE 300
GOTO MAIN
DISABLE
RECEIVE:
IF (RCSTA.2=1) THEN
HSERIN [RXBYTE]
else
HSERIN 500,TRANSMIT,[relay,stat] 'Serial data in on PortC.7
endif
IF relay = 1 THEN GOSUB outr1 ' Process relay#1 routine
IF relay = 2 THEN GOSUB outr2 ' Process relay#2 routine
IF relay = 3 THEN GOSUB outr3 ' Process relay#3 routine
IF relay = 4 THEN GOSUB outr4 ' Process relay#4 routine
IF relay = 5 THEN GOSUB outr5 ' Process relay#5 routine
IF relay = 6 THEN GOSUB outr6 ' Process relay#6 routine
RESUME
ENABLE
GOTO MAIN
'***************** DRIVE RELAYS ******************************************
outr1:
IF stat = 1 THEN high1
LOW CW: RETURN
high1:
HIGH CW: RETURN ' Turn on CW Relay
outr2:
IF stat = 1 THEN high2
LOW CCW: RETURN
high2:
HIGH CCW: RETURN ' Turn on CCW Relay
outr3:
IF stat = 1 THEN
HIGH ANT1: LOW ANT2: LOW ANT3: LOW ANT4
RETURN ' Turn On Relay for Antenna 1
endif
outr4:
IF stat = 1 THEN
HIGH ANT2: LOW ANT1: LOW ANT3: LOW ANT4
RETURN ' Turn On Relay for Antenna 2
endif
outr5:
IF stat = 1 THEN
HIGH ANT3: LOW ANT1: LOW ANT2: LOW ANT4
RETURN ' Turn On Relay for Antenna 3
endif
outr6:
IF stat = 1 THEN
HIGH ANT4: LOW ANT1: LOW ANT2: LOW ANT3
RETURN ' Turn On Relay for Antenna 4
endif
END




Bookmarks