
CAN add-on
ADwin
42
ADwin-Gold
USB / ENET, manual version 3.8, October 2005
RS485
In this example the RS485 interface is a passive participant, which reads data
coming from the input. If a specified value (55) is received, the interface starts
to send. It sends continuously the value 44.
REM Interface 2 reads all data coming from the bus
REM until it receives the value 55. Now the interface
REM becomes active and sends the value 44.
#INCLUDE
adwgcan.inc
DIM
ret_val
,
val
AS
LONG
INIT
:
RS_RESET
()
REM Initialization of the interfaces:
REM 38400 Baud, no parity bit, 8 data bits,
REM 1 stop bit, RS485 software handshake
RS_INIT
(1,38400,0,8,0,3)
RS_INIT
(2,38400,0,8,0,3)
RS485_SEND
(1,1)
'Send interface 1
RS485_SEND
(2,0)
'Receive interface 2
EVENT
:
val
=
READ_FIFO
(2)
'Read data from interface 2
IF
(
val
= 55)
THEN
RS485_SEND
(2,1)
'Send interface 2
ret_val
=
WRITE_FIFO
(2,44)
'Write data
ENDIF