Example of Programming for User Communications
The following shows an example of configuration of communication system and frame between a CIMON-PLC and other manufacturer’s PLC to explain the programming method for user communication. It is the case that the 18-byte data in Memory D0000 of the CIMON-PLC are written to other manufacturer’s PLC and the 24-byte data of other manufacturer’s PLC are read and stored in Memory D0020 of the CIMON-PLC.
PLC protocol of other manufacturer,
Frame requesting to write (CIMON-PLC -> Other manufacturer’s PLC)
Header | Station (H) | Station (L) | Command | Size (H) | Size (L) | Data | Tail | Error Check(H) | Error Check(L) |
ENQ | 0 | 1 | W | 1 | 2 | 18Byte | EOT | ? | ? |
Frame responding to request to read (Other manufacturer’s PLC -> CIMON-PLC)
Header | Station (H) | Station (L) | Command | Size (H) | Size (L) | Data | Tail | Error Check (H) | Error Check (L) |
STX | 0 | 1 | R | 1 | 8 | 24Byte | ETX | ? | ? |
Description for Protocols,
Frame Requesting to Write
ENQ and EOT, which are the control letters of ASCII code, are used at the header and the tail. Command ‘W’ is used.
The length of data indicates 18 bytes(12h).
Order of Sending | Start -------------------------------------------------------> End | |||||||||
Type of Frame | Header | Fixed Value (Others) | Data | Tail | Error Check | |||||
Frame sent | ENQ | 0 | 1 | W | 1 | 2 | Variable Data | EOT | H | L |
Binary | 05h | 30h | 31h | 57h | 31h | 32h | D0000 | 04h |
|
|
ASCII |
| ‘0’ | ‘1’ | ‘W’ | ‘1’ | ‘2’ | D0000 |
|
|
|
12-byte data in the memory for sending data of CPU (CIMON-PLC D0000) are sent.
The error check is to binary-sum ASCII code values from the header to the tail. Calculated data is varied according to frame.
To make the above frame sent in a protocol editor, binary or ASCII can be selected as fixed value. In case of binary like the above table, enter a hexadecimal value. In case of ASCII, enter letters. But, hexadecimal 2-digit number occupies 1 byte and a letter occupies 1 byte.
Using the protocol editor, make the frame sent of other manufacturer’s protocol as the following procedure.
Fixed Value (Header): This is the first data of a frame.
Binary 05h is ENQ. Hexadecimal 2-digit number occupies 1 byte.
Fixed Value (Others): As a data is displayed in ASCII, a letter occupies 1 byte.
Binary data (30 31 57 31 32) can be displayed.
Memory Link: If an address is selected as D0000 with the length of 18 bytes, the 18-byte data stored in D0000 will be sent without ASCII conversion.
Convert to ASCII Data :
No(Binary): The data stored in the memory of CPU is sent without conversion. For example, if the length of a data is 2 bytes and the value is 0x1234(2Byte), Data 1234 will be sent.
Hexadecimal Integer: A data is converted to ASCII data and the result is sent. As actually sent data are ‘1’,’2’,’3’,’4’, in case that a data value is 0x1234, 4 bytes is to be set up as the length of the data.
Decimal Integer: 0x1234 is equivalent to decimal 4660. As actually sent data are ‘4’,’6’,‘6’,’0’, 4 bytes is to be set up as the length of the data.
Real Number: In case that scaling is 10, Data Value 0x1234 is divided by 10 and the result is sent in binary data. The actual sent data is 0x01D2.
Fixed Value (Tail): This is the last data of a frame.
Binary 04h is EOT. Hexadecimal 2-digit number occupies 1 byte.
Error Check: The data of the frame sent are binary-summed as much as a set value in the range of error check. Refer to the memory link for ASCII data conversion.
The frame sent has been edited.
Frame Responding to Request to Read
Order of Sending | Start ----------------------------------------------------------------------------> End | |||||||||
Type of Frame | Header | Fixed Value (Others) | Data | Tail | BCC | |||||
Frame sent | STX | 0 | 1 | R | 1 | 8 | Variable Data | ETX | H | L |
Binary | 02h | 30h | 31h | 57h | 31h | 38h | D0000 | 03h |
|
|
ASCII |
| ‘0’ | ‘1’ | ‘R’ | ‘1’ | ‘8’ | D0000 |
|
|
|
STX and ETX, which are the control letters of ASCII code, are used at the header and the tail. Command ‘R’ is used.
The length of a data displays 24 bytes(18).
24-byte data in the memory for sending data of CPU are sent.
Error check is to binary-sum ASCII code values from the header to the tail. A calculated data is varied according to frame.
To make the above frame received in a protocol editor, binary or ASCII can be selected as fixed value. In case of binary like the above table, enter a hexadecimal value. In case of ASCII, enter letters. But, hexadecimal 2-digit number occupies 1 byte and a letter occupies 1 byte.
Using a protocol editor, make the frame sent of other manufacturer’s protocol as the following procedure.
Fixed Value (Header): This is the first data of a frame.
Binary 02h is STX. Hexadecimal 2-digit number occupies 1 byte.
Fixed Value (Others): As a data is displayed in ASCII, a letter occupies 1 byte.
Binary data (30 31 52 31 38) can be displayed.
Memory Link: As D0020 is selected as address, 24-byte data is sent without ASCII conversion.
Convert to ASCII Data
No(Binary): A received data is stored in the memory of CPU without conversion. For example, if the length of a data is 2 bytes and the value is 0x1234(2Byte), Data h1234 will be stored in the memory of CPU.
Hexadecimal Integer: A received data is converted to hexadecimal integer and the result is stored. And Data ‘1’,’2’,’3’,’4’ are received. In this case, the actually stored data is 0x1234. But, 4 bytes are set up as the length of the data.
Decimal Integer: A received data is converted to decimal integer and the result is stored. And Data ‘4’,’6’,‘6’,’0’ are received. In this case, the actually stored data is 0x1234. But, 4 bytes are set up as the length of the data.
Real Number: In case that scaling is 10, Data Value 0x1234 is multiplied by 10 and the result is received in binary data. The actual sent data is 0xB608.
Fixed Value (Tail): This is the last data of a frame.
Binary 04h is ETX. Hexadecimal 2-digit number occupies 1 byte.
Error Check: The data of the frame sent are binary-summed as much as a set value in the range of error check. Refer to the memory link for ASCII data conversion.
Range of Error Check (Segment) : Start: 0 / End: 3
Segment 0 | Segment 1 | Segment 2 | Segment 3 |
Error Check = Segment 0 + Segment 1 + Segment 2 + Segment 3
The frame received has been edited.
PLC Program: Use a protocol editor to send a registered frame every second. If the frame is sent, M0000 is turned on for one scan to execute Receive command. Send/Receive command is to be turned on for one scan.