Professional Documents
Culture Documents
RS485 Delta Muito Bom
RS485 Delta Muito Bom
Operands:
S: Start device for the data to be transmitted m: Length of data to be transmitted D: Start device for receiving
data n: Length of data to be received
Explanations:
1. Range of m: 0 ~ 256
2. Range of n: 0 ~ 256
3. See the specifications of each model for their range of use.
4. ES series MPU does not support E, F index register modification.
5. This instruction is a handy instruction exclusively for MPU to use RS-485 serial communication interface. The
user has to pre-store word data in S data register, set up data length m and the data receiving register D and
received data length n. If E, F index registers are used to modify S and D, the user cannot change the set values
of E and F when the instruction is being executed; otherwise errors may cause in data writing or reading.
6. Designate m as K0 if you do not need to send data. Designate n as K0 if you do not need to receive data.
7. There is no limitation on the times of using this instruction in the program, but only one instruction is allowed to
be executed at a time.
8. During the execution of RS instruction, changing the data to be transmitted will be invalid.
9. If the peripheral devices, e.g. AC motor drive, are equipped with RS-485 serial communication and its
communication format is open, you can use RS instruction to design the program for the data transmission
between PLC and the peripheral device.
10. If the communication format of the peripheral device is Modbus, DVP series PLC offers handy communication
instructions API 100 MODRD, API 101 MODWR, and API 150 MODRW, to work with the device. See
explanations of the instructions in this application manual.
11. For the special auxiliary relays M1120 ~ M1161 and special data registers D1120 ~ D1131 relevant to RS-485
communication, see remarks for more details.
Program Example 1:
1. Write the data to be transmitted in advance into registers starting from D100 and set M1122 (sending request
flag) as On.
2. When X10 = On, RS instruction will be executed and PLC will start to wait for the sending and receiving of data.
D100 starts to continuousl send out 10 data and when the sending is over, M1122 will be automatically reset to
7-80 D V P - P L C A P P L I C AT I O N M A N U A L
7 Application Instructions API 50-99
Off (DO NOT use the program to execute RST M1122). After 1ms of waiting, PLC will start to receive the 10 data.
Store the data in consecutive registers starting from D120.
3. When the receiving of data is completed, M1123 will automatically be On. After the program finishes processing
the received data, M1123 has to be reset to Off and the PLC will start to wait for the sending and receiving of
data again. DO NOT use the program to continuously execute RST M1123.
M1002
Set up communication protocol 9600,7,E,1
MOV H86 D1120
Program Example 2:
Switching between 8-bit mode (M1161 = On) and 16-bit mode (M1161 = Off)
1. 8-bit mode:
The head code and tail code of the data are set up by M1126 and M1130 together with D1124 ~ D1126. When
PLC is executing RS instruction, the head code and tail code set up by the user will be sent out automatically.
M1161 = On indicates PLC in 8-bit conversion mode. The 16-bit data will be divided into the higher 8 bits and
lower 8 bits. The higher 8 bits are ignored and only the lower 8 bits are valid for data transmission.
M1000
M1161
X0
RS D100 K4 D120 K7
Head source data register, starting from Tail code Tail code
code the lower 8 bits of D100 1 2
length = 4
D V P - P L C A P P L I C AT I O N M A N U A L 7-81
7 Application Instructions API 50-99
Head received data register, starting from Tail code Tail code
code the lower 8 bits of D120 1 2
length = 7
When receiving data, PLC will receive the head code and tail code of the data from the external equipment;
therefore, the user has to be aware of the setting of data length n.
2. 16-bit mode:
The head code and tail code of the data are set up by M1126 and M1130 together with D1124 ~ D1126. When
PLC is executing RS instruction, the head code and tail code set up by the user will be sent out automatically.
M1161 = Off indicates PLC in 16-bit conversion mode. The 16-bit data will be divided into the higher 8 bits and
lower 8 bits for data transmission.
M1001
M1161
X0
RS D100 K4 D120 K7
Head source data register, starting from Tail code Tail code
code the lower 8 bits of D100 1 2
length = 4
Head received data register, starting from Tail code Tail code
code the lower 8 bits of D120 1 2
length = 7
When receiving data, PLC will receive the head code and tail code of the data from the external equipment;
therefore, the user has to be aware of the setting of data length n.
Program Example 3:
Connect PLC to VFD-B series AC motor drives (AC motor drive in ASCII Mode; PLC in 16-bit mode and M1161 = Off).
Write in the 6 data starting from parameter address H2101 in VFD-B in advance as the data to be transmitted.
7-82 D V P - P L C A P P L I C AT I O N M A N U A L
7 Application Instructions API 50-99
M1002
MOV H86 D1120 Set up communication protocol 9600,7,E,1
D V P - P L C A P P L I C AT I O N M A N U A L 7-83
7 Application Instructions API 50-99
Program Example 4:
Connect PLC to VFD-B series AC motor drives (AC motor drive in RTU Mode; PLC in 16-bit mode and M1161 = On).
Write in H12 to parameter address H2000 in VFD-B in advance as the data to be transmitted.
7-84 D V P - P L C A P P L I C AT I O N M A N U A L
7 Application Instructions API 50-99
M1002
MOV H86 D1120 Set up communication protocol 9600,7,E,1
Remarks:
1. Flags for the RS-485 communication of RS/MODRD/MODWR/FWD/REV/STOP/RDST/RSTEF/MODRW
instructions
D V P - P L C A P P L I C AT I O N M A N U A L 7-85
7 Application Instructions API 50-99
7-86 D V P - P L C A P P L I C AT I O N M A N U A L
7 Application Instructions API 50-99
D V P - P L C A P P L I C AT I O N M A N U A L 7-87
7 Application Instructions API 50-99
b15 b0
D1120 0 0 0 0 0 1 1 1 1 0 0 0 1 0 0 0
0
7 8 8
Don t care
7-88 D V P - P L C A P P L I C AT I O N M A N U A L
7 Application Instructions API 50-99
When STX, ETX1 and EXT2 are in use, please be aware of the On and Off of the special auxiliary relays M1126
and M1130.
6. M1143 is for the selection of ASCII mode or RTU mode. On = RTU mode; Off = ASCII mode.
Take the standard Modbus format for example:
In ASCII mode (M1143 = Off)
STX Start word = ‘:’ (3AH)
Address Hi Communication address:
Address Lo The 8-bit address consists of 2 ASCII codes
Function Hi Function code:
Function Lo The 8-bit function code consists of 2 ASCII codes
DATA (n-1)
Data:
…….
The n × 8-bit data consists of 2n ASCll codes
DATA 0
LRC CHK Hi LRC checksum:
LRC CHK Lo The 8-bit checksum consists of 2 ASCll code
END Hi End word:
END Lo END Hi = CR (0DH), END Lo = LF(0AH)
The communication protocol is in Modbus ASCII mode, i.e. every byte is composed of 2 ASCII characters. For
example, 64Hex is ‘64’ in ASCII, composed by ‘6’ (36Hex) and ‘4’ (34Hex). Every hex ‘0’…’9’, ‘A’…’F’
corresponds to an ASCII code.
Character ‘0’ ‘1’ ‘2’ ‘3’ ‘4’ ‘5’ ‘6’ ‘7’
ASCII code 30H 31H 32H 33H 34H 35H 36H 37H
D V P - P L C A P P L I C AT I O N M A N U A L 7-89
7 Application Instructions API 50-99
7-90 D V P - P L C A P P L I C AT I O N M A N U A L
7 Application Instructions API 50-99
D V P - P L C A P P L I C AT I O N M A N U A L 7-91
7 Application Instructions API 50-99
M1002
MOV H86 D1120 Set up communication protocol 9600,7,E,1
SET M1122 X0
Execution of RS instruction X10
Transmission ready M1121
Sending request M1122 Auto reset after the data transmission is completed
Receiving completed M1123 The user has to do the reset in the program.
Communication status cleared M1125 Using this in the program will return the
status to the initial transmission ready status.
MODRD/RDST/MODRW data
receiving and conversion M1127 ASCII data being converted to hex
completed takes less than 1 scan period.
Changing direction
immediately
Transmitting and receiving M1128 1 2 3 1 2 3 4 5 6 7 8
Receiving time-out M1129 On when receiving message from the time-out counter
7-92 D V P - P L C A P P L I C AT I O N M A N U A L