User`s manual

Chapter 3
Operation
Introduction and Programming Example
After installation, the CYCOM 485 operates just like any other COM port. Using the serial drivers supplied with
DOS, Windows, Languages or applications programs, the C
YCOM 485 handles communications with other
RS422 or RS485 devices.
Here is a simple example in QuickBasic 4.5 showing how to use the C
YCOM 485 board.
'Program to communicate with a remote temperature module. 'First configure CyCOM 485 then
configure and communicate with the module.
BASE = &H3F8 'Base address for COM1. TXRX = 7 + BASE 'Address of the transmit/receive
register. TX = 2 'Bit to turn on transmitter. RX = 1 'Bit to turn on receiver. OPEN
"COM1:9600" AS #1 'Set up CyCOM 485 as standard
COM1. OUT TXRX, TX 'Enable COM1 at a transmitter. CMD$ = "%01020E0600" 'Configure module.
PRINT #1, CMD$ 'Send the configuration data. OUT TXRX, RX 'Set CyCOM 485 to receive. GOSUB
DELAY 'Wait for module to configure. RESULT$ = INPUT$(4, #1) 'Read back configuration
result. OUT TXRX, TX CMD$ = @02LO+090.00" 'Configure low alarm limit to 90oC. PRINT #1,
CMD$ GOSUB DELAY
The remote module is also an RS485 device. While idle, it is configured as a receiver. After it receives a
command (and if that command entails a response) the module becomes a transmitter, transmits status or data,
then switches back to the receiver mode.
You can see from the program flow that the C
YCOM 485 has to switch back and forth from transmitter to
receiver. Also, you must be aware of the constraints of the remote device(s) you are working with. In this case,
a subroutine called DELAY provides an adequate delay to allow the remote module to settle back into receiver
state.
RS485 communications require that you understand the devices you are working with and program accordingly.
Transmitter/Receiver Enable Register
The BASE + 7 Transmitter/Receiver Enable Register controls the transceivers on the CYCOM 485. There are
only two bits in this 8-bit register which control the orientation of the C
YCOM 485 transceivers.
Setting the first bit to one turns on the receivers. Setting the second bit to one turns on the transmitters.
Turning both on (writing a “3” to the register) turns on both the receiver and transmitter. This mode will echo
back everything written even when no cable is in place.
Note: the default value for this register is 0.
You must write to BASE + 7 and enable one of the transceivers before the C
YCOM 485 can communicate with
other RS485 devices.
BASE + 7 -Control Register (Byte, Write Only)
7 6 5 4 3 2 1 0
X X X X X X XMTR RCVR
12