pinworm21
- 23rd October 2012, 18:51
Ok everyone....I have spent many hours trying to figure this out. I am trying to talk to an Entertron PLC through a 18F4550 PIC. I have the serial routine working through a terminal emulator with no problems @ all. But when I connect it to the PLC its not working right. The PLC is receiving commands (the PLC goes into stop mode) but when it sends the "K" back as an acknowledge...the 18F4550 does not receive it (although monitoring the comm between the PLC and PIC.....the PLC is sending back the "K") So the term emulator works throught the routine with out a problem but the PLC will not. Has me stumped........David
Define OSC 20 ' 20 MHz oscillator
RCSTA = %00000000
BAUDCON = %01000000
ADCON1 = 15 ' All I/O pins digital
Pause 100
pause 3000
:STPCMD
HIGH PORTD.0
PAUSE 10
LOW PORTD.0
Serout2 PORTC.6, 84, [$1B,"S",$d] 'SEND STOP COMMAND <ESC>S
SERIN2 PORTC.7, 84, 1000, STPCMD,[WAIT ("K")]
HIGH PORTD.1
:DWNLDCMD
HIGH PORTD.0
PAUSE 10
LOW PORTD.0
Serout2 PORTC.6, 84, [$1B,"D",$d] 'SEND STOP COMMAND <ESC>S
SERIN2 PORTC.7, 84, 1000, DWNLDCMD,[WAIT ("K")]
HIGH PORTD.2
'SEND OUT CONFIG REGISTERS FOR TROUBLESHOOTING
Serout2 PORTC.6, 84, [$d]
Serout2 PORTC.6, 84, [".......BIT7^..BIT0^",$d]
Serout2 PORTC.6, 84, ["TXSTA......",BIN TXSTA,$d]
Serout2 PORTC.6, 84, ["RXSTA......",BIN RCSTA,$d]
Serout2 PORTC.6, 84, ["BAUDCON....",BIN BAUDCON,$d]
Serout2 PORTC.6, 84, ["OSCTUNE....",BIN OSCTUNE,$d]
Serout2 PORTC.6, 84, ["OSCCON.....",BIN OSCCON,$d]
Serout2 PORTC.6, 84, ["PORTC......",BIN PORTC,$d]
Serout2 PORTC.6, 84, ["LATC.......",BIN LATC,$d]
Serout2 PORTC.6, 84, ["TRISC......",BIN TRISC,$d]
Serout2 PORTC.6, 84, ["UCON.......",BIN UCON,$d]
Serout2 PORTC.6, 84, ["HAVE A NICE DAY !",$d]
STOP
Define OSC 20 ' 20 MHz oscillator
RCSTA = %00000000
BAUDCON = %01000000
ADCON1 = 15 ' All I/O pins digital
Pause 100
pause 3000
:STPCMD
HIGH PORTD.0
PAUSE 10
LOW PORTD.0
Serout2 PORTC.6, 84, [$1B,"S",$d] 'SEND STOP COMMAND <ESC>S
SERIN2 PORTC.7, 84, 1000, STPCMD,[WAIT ("K")]
HIGH PORTD.1
:DWNLDCMD
HIGH PORTD.0
PAUSE 10
LOW PORTD.0
Serout2 PORTC.6, 84, [$1B,"D",$d] 'SEND STOP COMMAND <ESC>S
SERIN2 PORTC.7, 84, 1000, DWNLDCMD,[WAIT ("K")]
HIGH PORTD.2
'SEND OUT CONFIG REGISTERS FOR TROUBLESHOOTING
Serout2 PORTC.6, 84, [$d]
Serout2 PORTC.6, 84, [".......BIT7^..BIT0^",$d]
Serout2 PORTC.6, 84, ["TXSTA......",BIN TXSTA,$d]
Serout2 PORTC.6, 84, ["RXSTA......",BIN RCSTA,$d]
Serout2 PORTC.6, 84, ["BAUDCON....",BIN BAUDCON,$d]
Serout2 PORTC.6, 84, ["OSCTUNE....",BIN OSCTUNE,$d]
Serout2 PORTC.6, 84, ["OSCCON.....",BIN OSCCON,$d]
Serout2 PORTC.6, 84, ["PORTC......",BIN PORTC,$d]
Serout2 PORTC.6, 84, ["LATC.......",BIN LATC,$d]
Serout2 PORTC.6, 84, ["TRISC......",BIN TRISC,$d]
Serout2 PORTC.6, 84, ["UCON.......",BIN UCON,$d]
Serout2 PORTC.6, 84, ["HAVE A NICE DAY !",$d]
STOP