Overview
In a serial interface, the data bits are sent in sequence through a communication channel or link. Several technologies use the serial communication for data transfer, including interfaces RS485.
Configuration
Some parameters need to be configured to perform the RS485 communication; to do so, check the item RS485.
There are three operating modes of the RS485 communication.
| • | Mode 0: Modbus Slave; |
| • | Mode 1: Modbus Master; |
| • | Mode 4: Generic telegrams. |
|
NOTE! Modes 2 and 3 are reserved. |
Mode 0: Modbus Slave
Refer to manual PLC300 - Modbus RTU Communication, available at http://www.weg.net/br.
Mode 1: Modbus Master
Refer to manual PLC300 - Modbus RTU Communication, available at http://www.weg.net/br.
Mode 4: Generic telegrams
Functionality developed to send and receive telegrams by means of serial communication RS485.
Involved command variables:
| • | RS485_MODE: BYTE marker; defines the operating mode of the RS485: |
| o | 4: telegrams via RS485. |
| • | RS485_TIMEOUT: WORD marker; indicates the maximum waiting time (in ms) for a response, preventing new telegrams to be sent before this time has elapsed. |
| • | RS485_END_CHARACTER: defines a character that can end a telegram, for example, ETX (03H). Upon the receipt of this character, the PLC300 considers that the bytes received up to it are the ones necessary; the others are ignored. |
| • | RS485_ENABLE_END_CHARACTER: BIT marker; system marker that enables the use of telegram end character specified in RS485_END_CHARACTER; |
| o | 0: disabled; |
| o | 1: enabled. |
| • | RS485_START_TX: BIT marker; the telegram is sent on the leading edge of this marker; |
| • | RS485_TX_ADDRESS: WORD marker; indicates the initial address of the data to be transferred; |
| • | RS485_TX_LENGTH: BYTE marker; indicates the number of bytes of the information to be sent; |
| • | RS485_RX_ADDRESS: WORD marker; indicates the initial address of the received data; |
| • | RS485_MAX_RX_BUFFER_LENGTH: BYTE marker; indicates the maximum number of bytes that can be received; |
Involved status variables:
| • | RS485_TX_TELEGRAM_COUNTER: WORD marker; counts the number of sent telegrams; |
| • | RS485_RX_TELEGRAM_FINISHED: BIT marker; indicates that a data package is available in the memory from the address indicated in RS485_RX_ADDRESS. |
| • | RS485_TX_FINISHED: BIT marker; indicates that a data package was completely sent. |
| • | RS485_TIMEOUT_INDICATOR: BIT marker; indicates if the time specified in RS485_TIMEOUT has elapsed. |
| o | 0: there was no overflow; |
| o | 1: there was time overflow. |
| • | RS485_RX_TELEGRAM_COUNTER (status): WORD marker; counts the number of received telegrams; |
| • | RS485_RX_BYTE_COUNTER (status): WORD marker; counts the number of received bytes; |
How to use the RS485 to send and receive telegrams:
| 1. | Select Send and receive telegrams via RS485 by setting RS485_MODE = 4 in the Ladder; |
| 2. | Configure the initial address of the telegrams to be sent and received in, respectively, RS485_TX_ADDRESS and RS485_RX_ADDRESS; |
| 3. | Specify the size (in bytes) of the telegram to be sent by means of marker RS485_TX_LENGTH; |
| 4. | Specify the maximum size (in bytes) of the telegram that can be received by means of RS485_RX_LENGTH marker; |
| 5. | Specify the timeout in RS485_TIMEOUT; |
| 6. | If applicable, configure the telegram end characters of the markers respectively in: RS485_ENABLE END_CHARACTER and RS485_END_CHARACTER; |
| 7. | Reset the RS485_RX_TELEGRAM_FINISHED flag to be ready to receive a telegram; |
| 8. | Give a pulse in RS485_START_TX to send a telegram. |
|
NOTE! It will be considered the end of receipt of telegram, the receipt of the special character when configured in RS485_END_CHARACTER with the RS485_ENABLE_END_CHARACTER flag enabled or, also, when the timeout is equal to twice the transmission time of a byte. |
Compatibility
Device |
Version |
PLC300 |
Mode 0: 1.00 or higher |
Mode 1: 1.00 or higher |
|
Mode 4: 1.50 or higher |