RS485 communication with a battery-pack
There isn't an automatic control of the 2 wire "echo" when using PRINT and GET. The programmer must read the echo and discard those characters.
Use SETCOM(9600, 8, 1, 0, 2, 0) ' no xon/xoff
Don't set the 2-wire flag because that is only for Modbus.
This example will suppress the echoed characters.
' look for Echo of the sent string (12 characters)
WHILE TRUE
WAIT UNTIL (TICKS <= 0) OR (KEY #2)
IF TICKS > 0 THEN
GET #2, byte_in
' look for the first character $A5
IF byte_in = $a5 THEN
' read in all the sent characters which are echoed on the 2 wire line
FOR lc = 1 TO 11
GET #2, byte_in ' read and discard the character
NEXT lc
EXIT_LOOP ' exit this while loop and start reading the reply
ENDIF
ELSE
' timed out with no valid data
PRINT #5, "RS485 error - timeout no echoed characters"
byte_in = 500
ENDIF
WEND
Related Articles
Wiring for RS485
The Motion Coordinator has a 4-wire RS422 port. This can be set as a 2-wire RS485 port by wiring the Tx and Rx together. MC664 is shown. All Motion Coordinators have the same port pin configuration. For some protocols it will be necessary to set up ...
AN-318 MC2xx Battery backed RAM
This document explains about the battery backed RAM of MC2xx series controller The MC224 has a non-rechargeable Lithium Ion battery. The nominal lifetime is 10 years before replacement is necessary. See AN-257 “Replacing MC224 battery”
AN-429 Replacing Lithium battery on UNIPLAY HMI
The UNIPLAY HMI takes one CR2032 / CR1225 / CR1220 coin lithium battery to keep the RTC running. Battery specification: CR2032 / CR1225 / CR1220 3V lithium battery. This document explains how to change this battery
Uniplay Issues After Low Battery Condition - Checks & Corrective Actions
When the original battery in the Uniplay HMI expires at the end of its serviceable life the start sequence of the Uniplay may start to exhibit some issues. The UNIPLAY HMI takes one CR2032 / CR1225 / CR1220 coin lithium battery to keep the RTC ...
Serial ports on PC-MCAT for Motion Coordinator Channels
The PC-MCAT API brings channels 1 and 2 out into the API, but does not map them to anything. The attached little program is an example which will do that for you. It is a 7z folder encrypted with password abc123. A USB to RS232 converter will be ...