ADwin-Gold II
, Manual February 2013
37
RSxxx Interface
ADwin
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