An RS-485 Network
These are the values transmitted in hexadecimal:
3a 69 0a
## $
On a PC that functions as the primary node, an application can send com-
mands, log received data, and take other actions as needed. Application code
can control the RS-485 transceiver’s driver-enable line if needed. If the RS-485
interface uses automatic driver-enable control, you can use terminal-emulator
software to access the nodes by typing commands and viewing responses.
The example code below supports both automatic and software-controlled
driver-enable lines. With automatic control, the transceiver’s receiver-enable
input connects to the driver-enable input to disable the receiver while the PC is
transmitting. With software control, the RS-485 transceiver’s receiver-enable
input is tied low so the PC can read back the data it sends and disable the driver
on detecting that all of the data has transmitted. (See Chapter 6 for more about
driver-enable circuits.)
The routines below assume myComPort is an open SerialPort object.
3
$ 8 "4#
%
For circuits with software driver-enable control, the routine below sets the state
of the driver-enable output. As shown, the routine uses the RtsEnable property
to control the RTS. If the driver-enable line is DTR, change the code to use the
DtrEnable property instead.
Private Sub Rs485DriverEnableControl(ByVal driverDisable As Boolean)
If driverDisable Then
myComPort.SelectedPort.RtsEnable = False
Else
myComPort.SelectedPort.RtsEnable = True
End If
End Sub