Modbus-RTUFunktionscode
Testwerkzeug: Xinjiang T-com Serial Port Debugging Tool statt Touchscreen;
Testgerät: Xinjiang PLC;
Die interne Software-Komponentennummer und die Modbus-RTU - Adressnummer der SPS finden Sie im Abschnitt Modbus-Kommunikationsfunktionen der SPS.
Modbus Funktionscode:
| Funktionscode (16Dezimal) | Funktion |
| 01 | Lesen Sie mehrere |
| 03 | mehrere Register lesen |
| 05 | ein einzelnes Bit schreiben |
| 06 | ein einzelnes Register schreiben |
| 0F | mehrere Bits schreiben |
| 10 | mehrere Register schreiben |
Kommunikationsformat: 19200, Par Check (EVEN), 8 - Bit-Daten - Bit, 1 - Bit-Stop - Bit.
Hinweis: Die folgenden Testadressen sind Hexadezimal-Adressen, die tatsächliche Operation muss die Hexadezimal-Adressen in die Dezimal-Adressen in den Touchscreen eingegeben konvertieren.
1. 01 Funktionscode:Lesen mehrerer Spule-Bits
Beispiel: Lesen Sie den Bitzustand der Spule0X4800 ~ 0X4815 Standort des Zustandes.
0X4800 ~ 0X4807: PLC Y0 ~ Y7 0X4808 ~ 0X4815: PLC Y10 ~ Y17
Senden Sie Befehl: 01 01 48 00 00 10 2A66
| Aktion | Gerätennummer (1 Byte) | Funktionscode (1 Byte) | Startadresse hohe (1 Byte) | Startadresse niedrig (1 Byte) | Gesamtzahl hohe (1 Byte) | Gesamtzahl niedrig (1 Byte) | CRC (1 Byte) | (1 Byte) |
| Senden | 01 | 01 | 48 | 00 | 00 | 10 | 2A | 66 |
Rückgabe Befehl: 01 01 02 00 00 B9 FC
| Aktion | Gerätennummer (1 Byte) | Funktionscode (1 Byte) | Anzahl der Bytes (2 Byte) | Bitstatus (On / Off) | Bitstatus (On / Off) | CRC (1 Byte) | (1 Byte) |
| gibt ON | 01 | 01 | 02 | FF | 03 | B8 | 0D zurück. |
| Zurück Off | 01 | 01 | 02 | 00 | 00 | B9 | FC |
2. 03 Funktionscode:Mehrfachlesen(Datenanzeige)
Beispiel:Lesen4x00 bis 4x02 Die Daten.
4X000 ~ 4X003: PLC D0 ~ D2
4x00 = 4, 4x01 = 5, 4x001 = 1, 4x02 = 2
Senden Sie Befehl: 01 03 00 00 00 04 44 09
| Aktion | Gerätennummer (1 Byte) | Funktionscode (1 Byte) | Startadresse hohe (1 Byte) | Startadresse niedrig (1 Byte) | Gesamtbits hohe (1 Byte) | Gesamtbits niedrig (1 Byte) | CRC (1 Byte) | (1 Byte) |
| Senden | 01 | 03 | 00 | 00 | 00 | 04 | 44 | 09 |
Senden Befehl: 0
| Bewegung | Gerätennummer (1 Byte) | Funktionscode (1 Byte) | Anzahl der Bytes (1 Byte) | Registerwert Hoch 4X00 | Registerwert Niedrig 4X00 | Registerwert Hoch 4X01 | Registerwert Low 4x01 | Registerwert Hoch 4X02 | Registerwert Niedrig 4X02 |
| Rückgabe | 01 | 03 | 08 | 00 | 04 | 00 | 05 | 00 | 01 |
| Registerwert Hoch 4X023 | Registerwert niedrig 4X023 | CRC | |||||||
| 00 | 02 | CC | 16 |
3. 05 Funktionscode:Schreiben einer einzelnen Operation(Taste)
z. B.: Setzen ON 0X4800
0X4800: PLC Y0
Senden Befehl: 01 05 48 00 FF00 9B9A
| Aktion | Gerätennummer (1 Byte) | Funktionscode (1 Byte) | Startadresse hohe Position (1 Byte) | Start-Adresse niedrig (1 Byte) | Gesamtzahl der Bits Hoch (1 Byte) | Gesamtzahl der Bits niedrig (1 Byte) | CRC (1Byte) | (1Byte) |
| Senden | 01 | 05 | 48 | 00 | FF | 00 | 9B | 9A |
Gibt Befehl zurück: 01 05 48 00 FF00 9B 9A
| Aktion | Gerätennummer (1 Byte) | Funktionscode (1 Byte) | Startadresse Höhere Position (1 Byte) | Startadresse niedrig (1 Byte) | Gesamtzahl Höhere Position (1 Byte) | Gesamtzahl niedrig (1 Byte) | CRC (1 Byte) | (1 Byte) |
| Gibt | 01 | 05 | 48 | 00 | FF | 00 | 9B | 9A |
Beispiel: SetzenOFF 0X4800
0X4800: PLC Y0
Senden Sie Befehl: 01 05 48 00 00 DA6A
| Aktion | Gerätennummer (1 Byte) | Funktionscode (1 Byte) | Startadresse Hohe (1 Byte) | Startadresse Niedrig (1 Byte) | Gesamtbitt oben (1 Byte) | Gesamtbitt niedrig (1 Byte) | CRC (1 Byte) | (1 Byte) |
| Senden | 01 | 05 | 48 | 00 | 00 | 00 | DA | 6A |
Rückgabe Befehl: 01 05 48 00 00 DA6A
| Aktion | Gerätennummer (1 Byte) | Funktionscode (1 Byte) | Startadresse hohe (1 Byte) | Startadresse niedrig (1 Byte) | Gesamtbits hohe (1 Byte) | Gesamtbits niedrig (1 Byte) | CRC (1 Byte) | (1 Byte) |
| Rückkehr | 01 | 05 | 48 | 00 | 00 | 00 | DA | 6A |
4. 06 Funktionscode:Schreiben eines einzelnen Wortes
z. B.:Adresse4X00Schreiben von Daten8
4X00: PLC D0
Senden Sie den Befehl:
| Aktion | Gerätennummer (1 Byte) | Funktionscode (1 Byte) | Startadresse hohe (1 Byte) | Startadresse niedrig (1 Byte) | Registerwert Höchstwert (1 byte) | Niedriges Registerwert (1 Byte) | CRC (1 Byte) | (1 Byte) |
| Senden | 01 | 06 | 00 | 00 | 00 | 08 | 88 | 0C |
Zurückgabe Befehl: 01 06 00 00 00 08 88 0C
| Aktion | Gerätennummer (1 Byte) | Funktionscode (1 Byte) | Startadresse hohe (1 Byte) | Startadresse niedrig (1 Byte) | Registerwert hohe (1 Byte) | Registerwert niedrig (1 Byte) | CRC (1 Byte) | (1 Byte) |
| Rückkehr | 01 | 06 | 00 | 00 | 00 | 08 | 88 | 0C |
5. 10 Funktionscode:Schreiben von mehreren Wörtern(Dateneingabe Schreiben von DoppelwörternDword)
z. B.:Adresse4X00 Schreiben von Daten 10, 4X01Schreiben von Daten11, 4X02Schreiben von Daten12
4X00 ~ 4X02: PLC D0 ~ D2
Senden Sie Befehl: 01 10 00 00 00 03 06 00 0A 00 0B 00 0C 0F46
| Bewegung | Vorbereitung (1) | Funktionscode (1 | Startadresse hohe (1 Byte) | Startadresse niedrig (1 Byte) | Register-Gesamtzahl hohe (1 Byte) | Register-Gesamtzahl niedrig (1 Byte) | Gesamtzahl der Bytes (1 Byte) | Registerwert Hohe | Registerwert Niedrig (1 Byte) |
| Byte) | Byte) | (1 Byte) | |||||||
| Senden | 01 | 10 | 00 | 00 | 00 | 03 | 06 | 00 | 0A |
| Registerwert Hohe (1 Byte) | Registerwert Niedrig (1 Byte) | Registerwert Hohe (1 Byte) | Registerwert Niedrig (1 Byte) | CRC | |||||
| 00 | 0B | 00 | 0C | 0F | 46 |
Rückgabe Befehl: 01 10 00 00 03 80 08
| Aktion | Gerätennummer (1 Byte) | Funktionscode (1 Byte) | Startadresse hohe (1 Byte) | Startadresse niedrig (1 Byte) | Gesamtzahl der Register hoch (1 Byte) | Gesamtzahl der Register niedrig (1 Byte) | CRC (1 Byte) | (1 Byte) |
| Senden | 01 | 10 | 00 | 00 | 00 | 03 | 80 | 08 |
6. 0f Funktionscode: Schreiben Sie mehrere Operationen
z. B.: Setzen ON 0X4800 ~ 0X4803
0X4800 ~ 0X4807: PLC Y0 ~ Y7 0X4810: PLC Y10
Senden Sie Befehl: 01 0F48 00 00 09 02 FF01AD48
| Aktion | Gerätennummer (1 Byte) | Funktionscode (1 Byte) | Startadresse Hohe (1 Byte) | Startadresse Niedrig (1 Byte) | 239] Bits Gesamtzahl niedrig (1 Byte) | Gesamtzahl von Bits niedrig (1 Byte) | Gesamtzahl der Bytes (1 Byte) | Niedriger Wert (1 Byte) | Höherer Wert (1 Byte) |
| Senden von Daten | 01 | 0F | 48 | 00 | 00 | 09 | 02 | FF | 01 |
| CRC | |||||||||
| AD | 48 |
Zurückgabe Befehl: 01 0F 48 00 00 09 82 6D
| Aktion | Gerätennummer (1 Byte) | Funktionscode (1 Byte) | Startadresse hohe (1 Byte) | Startadresse niedrig (1 Byte) | Bits Gesamtzahl hohe (1 Byte) | Bits Gesamtzahl niedrig (1 Byte) | CRC | |
| Rückgabe | 01 | 0F | 48 | 00 | 00 | 09 | 82 | 6D |
Antwort veröffentlichen