Domestic PLC—IKON Drive PLC communicates with Beijing Jiemai G100 GSM SMS module

1. Haiwell PLC communication features:

1. Multiple built-in communication protocols: All IKON Drive PLC mainframes have built-in Modbus RTU/ASCII protocol, free communication protocol and IKON Drive Bus high-speed communication protocol;

2. The communication ports can be expanded: IKON Drive PLC’s various types of hosts have 2 communication ports (one is RS-232, the other is RS-485), which can be expanded to 5 communication ports with a communication expansion module. The communication ports can be used for programming and networking. The communication ports are independent of each other, and can be used as a master station or a production slave station;

3. Very convenient communication command system: no matter what communication protocol you use, you can complete complex communication functions with only one communication command. The programming is simple and the program is concise, and there is no need for communication port conflicts, sending and receiving control, and communication interruption. Troubleshoot problems such as processing, you can mix various protocols in the program to easily complete the various data exchanges you need;

2. Beijing Jiemai G100

GSM short message module communication protocol introduction

1. The connection between IKON Drive PLC and Beijing Jiemei G100 GSM SMS module is shown in the figure below:

Haiwell Industrial Automation Industrial Internet of Things

2. Representation of telephone numbers

The phone number is represented by 6 8-bit binary bytes in the data packet, and the upper 4 bits and the lower 4 bits of each byte are represented by BCD code to represent a 1-digit decimal phone number, so that each byte can represent a two-digit phone number, 6 bytes can represent a total of 12 phone numbers, because the current phone numbers are all 11 digits, and 6 bytes can represent a 12-digit decimal BCD number, so when transmitting data to represent a phone number, the front of the phone number should be filled. 0 to make up 12 bits.

Assuming that the phone number is 13501237654, it becomes 01H│35H│01H│23H│76H│54H after being converted into a 6-byte BCD code.

3. Read SMS command: $AAR(CR)

Function: Read the data received by the GSM module.

Syntax structure: $AAR

$ – Delimiter (24H)

R – read data identifier (52H)

AA——The module address in 2-digit hexadecimal number: from 00 to FF. Length 2 bytes.

(CR) – (0DH)

response:

Valid responses: ! AA(long) (data) (cr)

Invalid response: ? AA (cr)

No response: syntax error/communication failure/address error

! – Delimiter of valid response (21H)

? – Invalid Response Delimiter (3FH)

AA——2-digit hexadecimal module address, length 2 bytes.

(long) – The length of single-byte data is up to FFH. 00H means no data.

(data)——data in bytes, the length of the data is determined by (long), content: header D7H + 1 byte data length UDL + 6 bytes source phone number STA + data UD + 6 bytes send timeDATE

UDL: The total data length received except the header D7H. Including STA, UD and its own byte length, because the byte length of STA and UDL is generally fixed, that is, fixed at 1+6=7 bytes, so its length can be calculated by the following formula UDL value=1+6 +UD length. The time byte DATE received by the receiver is not included

SOA: The sender’s phone number, which is the source address.

UD: Valid data sent by the sender. Its total length is less than or equal to 140 bytes.

DATE: The time when the SMS center received the text message, that is, the time when the sender sent the text message. A total of 6 bytes of BCD code, followed by year, month, day, hour, minute, second. The UDL value does not contain these 6 bytes.

(cr) – (0DH)

Example: Suppose the text message in the G100 module whose address is 00 is read, the content of the text message in the module is “1111” (31H│31H│31H│31H, a total of 4 bytes), and the sender’s phone number (source address) is 13912070425, sent at 2003-08-12 13:21:21.

Send command: $00R(cr)——24H│00H│00H│52H│0DH

Module return: 21H│00H│00H│12H│D7H│0BH│01H│39H│12H│07H│04H│25H│31H│31H│31H│31H│03H│08H│12H│13H│21H│21H│0DH

4. Send SMS command: $AAW(long)

(data)

Function: Send SMS.

Syntax structure: $AAW(long)(data)(cr)

$ – Delimiter (24H)

AA – 2-digit hexadecimal module address: from 00 to FF. Length 2 bytes.

W – write data identifier (57H)

(long) – The length of single-byte data can be up to FFH. 00H means to ask whether the send buffer is empty, see 9.5.

(data)——Data with bytes as the potential, the length of the data is determined by (long), content: header D7H + 1 byte data length UDL + 6 bytes destination phone number STA + data UD

UDL: The total data length to be sent except the header D7H. Including STA, UD and its own byte length, because the byte length of STA and UDL is generally fixed, that is, fixed to 1+6=7 bytes, so its length can be calculated by the following formula UDL value = 1+6 +UD length.

STA: The recipient’s phone number, that is, the destination address. The number needs to be formatted.

UD: Valid data you need to send. Its total length is less than or equal to 140 bytes.

(cr) – (0DH)

Response: none

Example: Suppose the SMS “OK” (00H│4FH│00H│4BH total 4 bytes) is sent through the G100 module with the address 00, and the receiver’s phone number (destination address) is 13912070425

The sending data string is as follows:

24H│00H│00H│57H│0DH│D7H│0BH│01H│39H│12H│07H│04H│25H│00H│4FH│00H│0BH│0DH

3. Communication program between IKON Drive  PLC and Beijing Jiemei G100 GSM SMS module

Because Beijing Jiemai G100 GSM SMS module adopts the manufacturer’s independent communication protocol, Haiwell PLC uses a free protocol to communicate with it. In order to facilitate understanding, the data string to be sent is stored in the register in bytes, and it is sent in low-byte mode, that is, using COMM .LB instruction.

The example completes reading a text message every 100mS, and replies a text message if the correct text message “0000” or “1111” is received:

The read SMS command is placed in the “initial register table” (registers V1000-V1004) and downloaded to the PLC together with the program.

V1000: 24H V1001: 00H V1002: 00H V1003: 52HV1004: 0DH

The text message command is placed in the “initial register table” (registers V1100-V1117) and downloaded to the PLC along with the program.

V1100: 24H V1101: 00H V1102: 00H V1103: 57HV1104: 0DH

V1105: D7H V1106: 0BH V1107: 01H V1108: 39HV1109: 12H

V1110: 07H V1111: 04H V1112: 25H V1113: 00HV1114: 4FH

V1115: 00H V1116: 0BH V1117: 0DH

The content of the short message to be compared is stored in the registers V1200-V1203. If the content of the short message is equal to “1111” or “0000”, it will reply the short message “OK”.

SMS content “1111”: V1200: 3131H V1201: 3131H

SMS content “0000”: V1202: 3030H V1203: 3030H

The program diagram is as follows:

Haiwell Industrial Automation Industrial Internet of Things

The COMM free communication command comes with its own communication protocol format to define the terminal Protocol, which can be input in configuration mode by double-clicking the COMM command, as shown in the figure below:

Haiwell Industrial Automation Industrial Internet of Things