Mitsubishi FX0N series PLC programming port communication protocol example

Mitsubishi FX0N series PLC programming port communication protocol example



 The communication between the PC and Mitsubishi FX series PLC described in this article is carried out through the programming port of the PLC and the serial port of the PC. The SC-09 programming cable is used as the connection between the computer and the PLC. The 9-core D-shaped plug of the cable is connected to the computer serial port, and the other end is connected to the RS-422 programming port of the PLC.

The communication program of the PC can be written in assembly language, various high-level languages, industrial control configuration software or the communication software of the PLC manufacturer can be used directly. This article uses VB6. 0 Software, it must write the communication protocol according to the communication procedures of the connected PLC, so first briefly introduce the communication protocol of the FX series PLC.

1. Communication protocol of FX series PLC

1 . Data transmission format

FX series PLC adopts asynchronous format, which is composed of 1 start bit, 7 data bits, l even parity bit and l stop bit. The baud rate is 9600bps and the characters are ASCi Ⅱ codes.

2 . Communication command

FX series PLC has 4 communication commands, namely read command, write command, forced on command and forced off command. In Table 1, X is the input relay; Y is the output relay; M is the auxiliary relay; S is the status element; T is the timer; C is the counter; D is the data register.

3. Communication control characters

FZ series PLC adopts character-oriented transmission procedures, and uses 5 communication control characters, as shown in Table 2.

4. Message format

The message format sent from the PC to the PLC is shown in Table 3. Among them, STX is the start mark; ETS is the end mark; CMD is the ASC Ⅱ code of the command: SUMH and SUML are the cumulative sum of bytes from CMD to ETX, overflow is not counted. Since each byte of hexadecimal number becomes a two-byte ASC Ⅱ code, the checksum is SUMH and SUMI.

The format of the reply message sent from PLC to PC is shown in Table 4.

2. Writing of PC communication program

1 . Communication port initialization

, Introduction to MSComm control: VB comes with MSComm control for managing serial communication. Only need to set a few main parameters to realize the serial communication between PLC and PC. To complete the communication, the relevant attribute value of MSComm must be set, that is, the communication port is initialized. The steps are as follows:

(1)CoinmPort: Set or return the communication connection port code.

(2) Settings: Set initialization parameters. Set or return 4 parameters in the form of word-string, such as connection speed, parity, data bit, and stop bit.

(3) PortOpen: Set or return the status of the communication connection port.

(4) Input: Return and remove characters from the input register.

(5) Output: Write a character string to the output register.

(6) InputLen: Specify the length of the string read in by the serial port.

(7) InBufferCount: Return the number of characters in the receiving register.

2 . Communication program example

1. before the form starts to design, add MSComm controls and buttons, text boxes, labels, etc.

(1) PC reads data from PLC

Suppose that the PC wants to read 4 bytes of data starting from D123 from the PLC (occupies two data registers: D123, D124), and the message is shown in Table 5.

According to the Mitsubishi FX series PLC programming port communication protocol, the address algorithm is

address=address×2+1000h

The address 123 is converted to hexadecimal as 7Bh, so the first address is:

address=addressx2+1000h=7Bhx2+1000h=10F 6h.

Then converted to ASCII code 31h, 30h, 46h, 36h

Checksum SUM=30H+31H+30H+46H+36H+30H+34H+03H=174H, the overflow part is not counted, so SUMH is "7", SUML is "4", and the corresponding ASC Ⅱ code is "37H" and "34H".

The response message format of PLC is shown in Table 6.

(2) Write data to PLC

For example, the message format for writing data "1234ABCD" to the D123 data register of the PLC is shown in Table 7

The use of VB6 introduced in this article. O The basic method to realize the communication between PC and Mitsubishi PLC is practical and has a wide range of practical value. Very helpful for beginners.

 

Mitsubishi FX series PLC programming port communication protocol example

 
 

1. DEVICE READ (read the value of the software device status)

 

The computer sends to the PLC:

                                                               
   

beginning


   
   

command


   
   

First address


   
   

Digits


   
   

end


   
   

Sum check


   
   

STX


   
   

CMD


   
   

GROUP ADDRESS


   
   

BYTES


   
   

ETX


   
   

SUM


   
 

Example: Read 4 bytes of data from D123


                                 
   

02h


   
   

30h


   
   

31h,30h,46h,36h


   
   

30h,34h


   
   

03h


   
   

37h,34h


   
 

Address algorithm: address=address*2+1000h, convert 123 to hexadecimal*2 to get F6, 10F6

 

Convert to ASCII

 

31h,30h,46h,36h

 

PLC return


                                     
   

STX


   
   

1ST DATA


   
   

2ND DATA


   
   

.....


   
   

LAST DATA


   
   

ETX


   
   

SUM


   
 

Note: Up to 64 bytes of data can be read

 

Example: read 3584 data from the specified memory unit


                                     
   

02h


   
   

33h


   
   

35h


   
   

38h


   
   

34h


   
   

03h


   
   

44h,36h


   
 

2. DEVICE WRITE (write value to PLC soft device)


                                                                                      
   

beginning


   
   

command


   
   

First address


   
   

Digits


   
   

data


   
   

end


   
   

Sum check


   
   

STX


   
   

CMD


   
   

GROUP ADDRESS


   
   

BYTES


   
   

1ST DATA


   
   

2ND DATA


   
   

......


   
   

LAST DATA


   
   

ETX


   
   

SUM


   
 

Example: Write 1234,ABCD to the two memories starting from D123


                                     
   

02h


   
   

31h


   
   

31h,30h,46h,36h


   
   

30h,34h


   
   

33h,34h,31h,32h,43h,44h,41h,42h


   
   

03h


   
   

34h,39h


   
 

PLC return

 

ACK (06H) Accepted correctly

 

NAK (15H) acceptance error

 

3. Forced setting/reset of bit device

 

FORCE ON set


                                                                                 
   

beginning


   
   

command


   
   

address


   
   

end


   
   

Sum check


   
   

STX


   
   

CMD


   
   

ADDRESS


   
   

ETX


   
   

SUM


   
   

02h


   
   

37h


   
   

address


   
   

03h


   
   

sum


   
 

FORCE OFF reset


                                                                                 
   

beginning


   
   

command


   
   

address


   
   

end


   
   

Sum check


   
   

STX


   
   

CMD


   
   

ADDRESS


   
   

ETX


   
   

SUM


   
   

02h


   
   

38h


   
   

address


   
   

03h


   
   

sum


   
 

PLC return

 

ACK(06H) Accepted correctly

 

NAK(15H) accept error

 

Address formula in device enforcement: Address=Address/8+100h

 

Description:

 

1. BYTES in the frame indicates the number of bytes that need to be read or written.

 

2. There are instructions on the address algorithm.

 

3. The accumulated sum is the sum accumulated from one byte after STX to ETX.

 
 

Mitsubishi FX series PLC programming port communication protocol overview

 
 

This protocol is actually suitable for the communication of PLC programming port and FX-232AW module. Thanks to netizen visualboy providing.

 

Communication format:

                                                                                             
   

command


   
   

Command code


   
   

Target device


   
   

DEVICE READ CMD


   
   

"0"


   
   

X,Y,M,S,T,C,D


   
   

DEVICE WRITE CMD


   
   

"1"


   
   

X,Y,M,S,T,C,D


   
   

FORCE ON CMD


   
   

" 7"


   
   

X,Y,M,S,T,C


   
   

FORCE OFF CMD


   
   

"8"


   
   

X,Y,M,S,T,C


   
 

Transmission format: RS232C  Baud rate: 9600bps
 Parity: even
 Check: Accumulation (sum check)
 Character: ASCII 

 

Hexadecimal code:


                                                                                             
   

ENQ


   
   

05H


   
   

request


   
   

ACK


   
   

06H


   
   

PLC responds correctly


   
   

NAK


   
   

15H


   
   

PLC error response


   
   

STX


   
   

02H


   
   

Message start


   
   

ETX


   
   

03H


   
   

End of message


   
 

 Frame format:


                                         
   

STX


   
   

CMD


   
   

DATA


   
   

......


   
   

DATA


   
   

ETX


   
   

SUM(upper)


   
   

SUM(lower)


   
 

example:

 

STX ,CMD ,ADDRESS, BYTES, ETX, SUM

 

02H, 30H, 31H,30H,46H,36H, 30H,34H, 03H, 37H,34H

 

SUM=CMD+......+ETX;

 

30h+31h+30h+46h+36h+30h+34h+03h=74h;

 

Accumulate more than two digits, take the lower two digits


Source content: https://blog.katastros.com/a?ID=00600-dc9d9ec0-fe00-4aec-81ce-58b997dcd4a2

No comments:

Post a Comment