Editing Modbus protokoll rs485

From Chaosdorf Wiki
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
=== Modbus Funktions Codes ===
=== Modbus Rtu 2 ===


{| class="wikitable"
Hardware Resources:
! colspan="5"| Hex Data !! colspan="1"| Funktion
|-
| adr || fc  || ! colspan="3"| data .....  ||
|-
| ..  || 01  || ..  ||  ..  ||..  ||  Lese Ausgangsbit Status
|-
| ..  || 02  || ..  ||  ..  ||..  || Lese Eingangsbit Status
|-
| ..  || 03  || ..  ||  ..  ||..  || Lese Holding-Register Analog Ausgang
|-
| ..  || 04  || ..  ||  ..  ||..  || Lese Input-Register Analog Eingang
|-
| ..  || 05  || ..  ||  ..  ||..  || Schreibe Ausgangsbit
|-
| ..  || 06  || ..  ||  ..  ||..  || Schreibe Holding-Register Analog Ausgang
|-
| ..  || 0F  || ..  ||  ..  ||..  || * Funktion noch offen 
|-
| ..  || 10  || ..  ||  ..  ||..  || wird bei den China Modulen zum Anpassen der UID benutzt
|-
| ..  || 15  || ..  ||  ..  ||..  || Schreibe mehrfach Ausgangsbit 
|-
| ..  || 16  || ..  ||  ..  ||..  || Schreibe mehrfach Holding-Register (Daten für >16-bit) Analog Ausgang
|-
| ..  || 23  || ..  ||  ..  ||..  || *  Funktion noch offen
|-
|}
 
* das sind wohl noch nicht alle Modbus Funktion Codes
es gibt wohl auch Sonderfunktionen die nur bei bstimmten Geräten vorhanden sind hier z.B. 0x10h setzten der UID


  *  RS485 communication interface
  *  TTL communication interface
  *  2 optocoupler isolation input
  *  2 way optocoupler isolation output
  *  A user button
  *  A user LED
  *  A power indicator
  *  A STM32F030F4 microcontroller
  *  2 relay status indicators LED lights
  *  Power supply terminal interface (12V power supply)


<br>
adr  -> device Adress oder auch UID - 1 Byte lang <br>
fc  -> Function Code 1 Byte <br>
data -> n Bytes<br>


Modbus RTU Instructions:
Modbus RTU Instructions:
Line 50: Line 26:
2. Set the address (communication using the device address, the default address is 01)<br>
2. Set the address (communication using the device address, the default address is 01)<br>
<br>
<br>
Set the address from from Broadcast to 0x01 , 0x02 , 0x03
Set the address from 01 to 09 or from Broadcast to 09


{| class="wikitable"
{| class="wikitable"
Line 56: Line 32:
! Hex Byte  !! Funktion   
! Hex Byte  !! Funktion   
|-
|-
| 00 10 00 00 00 01 02 00 01 6A 00 || Broadcast Address Modified to 01
| 01 10 00 00 00 01 02 00 09 66 56 || Current address 01 is changed to 09
|-
| 00 10 00 00 00 01 02 00 02 2A 01  || Broadcast Address Modified to 02
|-
|-
| 00 10 00 00 00 01 02 00 03 EB C1  || Broadcast Address Modified to 03
| 00 10 00 00 00 01 02 00 09 6B C6  || Broadcast Address Modified to 09
|}
|}
<br>
<br>


Read Address at Broadcast Call <br>
 
Read Address<br>


{| class="wikitable"
{| class="wikitable"
Line 70: Line 45:
! Hex Byte  !! Funktion   
! Hex Byte  !! Funktion   
|-
|-
| 00 03 00 00 00 01 85 db  || Send to Device ( Broadcast )
| 00 03 00 00 00 01 85 db  || Send to Device
|-
|-
| 00 03 02 00 01 44 44    || Receive from Device  '''01 for Address'''
| 00 03 02 00 01 44 44    || Receive from Device  '''01 for Address'''
|-
| 00 03 02 00 02 04 45    || Receive from Device  '''02 for Address'''
|-
| 00 03 02 00 03 C5 85    || Receive from Device  '''03 for Address'''
|-
|}
|}
<br>
=== Modbus Rtu 2 ===
Hardware Resources:
Data register address
  *  RS485 communication interface
  *  TTL communication interface
  *  2 Input ( max. DC +12 Volt UB )
  *  2 Relay Output
  *  A user button
  *  A user LED
  *  A power indicator
  *  A STM32F030F4 microcontroller
  *  2 relay status indicators LED lights
  *  Power supply terminal interface (12V power supply)


Meaning of each byte:<br>
Meaning of each byte:<br>
Line 108: Line 61:




[address 1 bzw. UID 0x01]<br>
[address 1]<br>
 
Switch Single


{| class="wikitable"
{| class="wikitable"
! colspan="8"| Hex Data !! colspan="1"| Funktion
|-
|-
| Adresse  || Funktion  || Reghigh || Reglow || Data 1 || Data 2 || CRChigh || CRClow || Funktion 
! Hex Byte  !! Funktion 
|-
| 01 05 00 00 FF 00 8C 3A  || 0 relay ON
|-
| 01 05 00 00 00 00 CD CA  || 0 relay off
|-
|    ||  
|-
| 01 05 00 01 FF 00 DD FA || No. 1 relay ON
|-
| 01 05 00 01 00 00 9C 0A || No. 1 relay off
|-
|   ||  
|-
| 01 05 00 02 FF 00 2D FA || No. 2 relay ON
|-
|-
| 01       || 05       ||  00   ||    00   ||    FF  ||  00     ||    8C  ||  3A  || 0 relay ON
| 01 05 00 02 00 00 6C 0A || No. 2 relay off
|-
|-
| 01      || 05        ||  00  ||    00  ||    00  ||  00    ||    CD  ||  CA  || 0 relay off 
|    ||  
|-
|-
| 01       || 05        ||  00   ||    01   ||    FF  ||  00     ||    DD  ||  FA  || 1 relay ON
| 01 0F 00 00 00 08 01 00 FE 95 || Full off
|-
|-
| 01       || 05        ||  00   ||    01  ||    00   ||  00     ||    9C  ||  0A  || 1 relay off
| 01 0F 00 00 00 08 01 FF BE D5 || all bright
|-
|-
|}
|   ||  
 
 
all Funktion
 
{| class="wikitable"
! colspan="8"| Hex Data !! colspan="1"| Funktion
|-
|-
| Adresse  || Funktion  || Reghigh || Reglow || Data 1 || Data 2 || Data 3 || Data 4 || CRChigh || CRClow || Funktion 
| 01 01 00 00 00 08 3D CC || Send : Read all relay states
|-
|-
| 01       || 0F        ||  00  ||    00  ||    00  ||  08  ||    01 ||  00   || FE    || 95    || Full Relay off
| 01 01 01 00 51 88 || Return : Relay fully closed
|-
|-
| 01       || 0F        ||  00  ||    00  ||    00  ||  08  ||    01  ||   FF  ||  BE    || D5    || Full Relay on
| 01 01 01 03 11 89 || Return : All relays are on
|-
|-
|         ||          ||        ||        ||        ||        ||        ||        ||        ||        ||  
|   ||  
|-
|-
| 01     || 02       ||  00   ||  00   ||  00   ||  08   ||        ||        ||  79     || CC     || Send : Read all input switch status  
| 01 02 00 00 00 08 79 CC || Send : Read all input switch status  
|-
|-
| 01     || 02       ||  01   ||  00   ||        ||        ||        ||        ||  A1     || 88     || Return : 8 input states  
| 01 02 01 00 A1 88 || Return : 8 input states  
|-
|-
|}
|}
 
https://hacktronics.co.in/2-channel-relay-module/modbus-rtu-2-way-relay-output-2-way-input-switch-ttl-rs485-interface-communication
Quelle - https://hacktronics.co.in/2-channel-relay-module/modbus-rtu-2-way-relay-output-2-way-input-switch-ttl-rs485-interface-communication
 
 
 
<br>


=== Modbus Rtu 4 ===
=== Modbus Rtu 4 ===
Line 159: Line 112:
   *  RS485 communication interface
   *  RS485 communication interface
   *  TTL communication interface
   *  TTL communication interface
   *  4 Input ( Switch to GND !!!! NO + UB !!! )
   *  4 optocoupler isolation input
   *  4 Relay Output
   *  4 way optocoupler isolation output
   *  2 user button
   *  A user button
   *  A user LED
   *  A user LED
   *  A power indicator
   *  A power indicator
Line 169: Line 122:




Modbus RTU command


[address 1 bzw. UID 0x01]<br>
Baud Rate: 9600 8 NONE 1
 
Switch Single


{| class="wikitable"
{| class="wikitable"
! colspan="8"| Hex Data !! colspan="1"| Funktion
|-
|-
| Adresse || Funktion  || Reghigh || Reglow || Data 1 || Data 2 || CRChigh || CRClow || Funktion   
! Hex Byte !! Funktion   
|-
|-
| 01      || 05        ||  00   ||    00   ||    FF  ||  00     ||    8C || 3A  ||  0 relay ON
| 00 06 40 00 00 01 5c 1b || Setting address is: 01
|-
|-
| 01      || 05        ||  00   ||    00  ||    00   ||  00     ||    CD || CA  ||  0 relay off 
| 00 06 40 00 00 02 1c 1a || Setting address is: 02
|-
|-
| 01      || 05        ||  00   ||    01   ||    FF  ||  00    ||    DD || FA  ||  1 relay ON
| 00 03 40 00 00 01 90 1b || Read address
|-
|-
| 01      || 05        ||  00  ||    01  ||    00  ||  00    ||    9C  ||  0A  ||  1 relay off
|                         || Read the software version
|-
|-
| 01      || 05        ||  00   ||    02  ||    FF  ||  00     ||    xx ||  xx  ||  2 relay ON
| 00 03 00 04 00 01 c4 1a ||  [month] broadcast read (only by one device to address all practical, easy to test)
|-
|-
| 01      || 05        ||  00  ||    02  ||    00  ||  00    ||    xx  ||  xx || 2 relay off
|  ||Read the hardware version (PCB version)
|-
|-
| 01      || 05        ||  00   ||    03   ||    FF  ||  00     ||    xx  ||  xx  ||  3 relay ON
| 00 03 00 04 00 01 c4 1a ||  broadcast read (only by one device to address all practical, easy to test)
|-
| 01       || 05        ||  00  ||    03  ||    00  ||  00    ||    xx  ||  xx ||  3 relay off
|-
|-
|}




[address 1]<br>


 
{| class="wikitable"
 
|-
! Hex Byte  !! Funktion 
|-
| 01 05 00 01 01 00 9d 9a || No. 1 relay ON
|-
| 01 05 00 01 00 00 9c 0a || No. 1 relay off
|-
|    ||
|-
| 01 05 00 02 01 00 6d 9a || No. 2 relay ON
|-
| 01 05 00 02 00 00 6c 0a || No. 2 relay off
|-
|    ||
|-
| 01 05 00 03 01 00 3c 5a || No. 3 relay ON
|-
| 01 05 00 03 00 00 3d ca || No. 3 relay off
|-
|    ||
|-
| 01 05 00 04 01 00 8d 9b || No. 4 relay ON
|-
| 01 05 00 04 00 00 8c 0b || No. 4 relay off
|-
|    ||
|-
| 01 05 00 ff 00 00 fd fa || Quanmie
|-
| 01 05 00 ff ff ff fc 4a || All light
|}
|}


 
[address 2]<br>
all Funktion


{| class="wikitable"
{| class="wikitable"
! colspan="8"| Hex Data !! colspan="1"| Funktion
|-
|-
| Adresse || Funktion  || Reghigh || Reglow || Data 1 || Data 2 || Data 3 || Data 4 || CRChigh || CRClow || Funktion 
! Hex Byte !! Funktion   
|-
| 02 05 00 01 01 00 9d a9 || No. 1 relay ON
|-No. 1 relay 1 channel status
| 02 05 00 01 00 00 9c 39 || No. 1 relay off
|-
|-
| 01      || 0F        ||  00  ||    00  ||    00  ||  08  ||    01  ||  00  ||  FE    || 95    || Full Relay off
|    ||  
|-
|-
| 01       || 0F        ||  00  ||    00  ||    00 ||  08  ||    01  ||  FF  ||  BE    || D5    || Full Relay on
| 02 05 00 02 01 00 6d a9 || No. 2 relay ON
|-
|-
|         ||          ||        ||        ||        ||        ||        ||        ||        ||        ||  
| 02 05 00 02 00 00 6c 39 || No. 2 relay off
|-
|-
| 01      || 02        ||  00   ||   00    ||  00    ||  08    ||        ||        ||  79    || CC    || Send : Read all input switch status
|    ||  
|-
|-
|  01      || 02       ||  01   ||  00   ||        ||        ||        ||        ||  A1    || 88    || Return : 8 input states
| 02 05 00 03 01 00 3c 69 || No. 3 relay ON
|-
|-
| 02 05 00 03 00 00 3d f9 || No. 3 relay off
|-
|    ||
|-
| 02 05 00 04 01 00 8d a8 || No. 4 relay ON
|-
| 02 05 00 04 00 00 8c 38 || No. 4 relay off
|-
|    ||
|-
| 02 05 00 ff 00 00 fd c9 || Quanmie
|-
| 02 05 00 ff ff ff fc 79 || All light
|}
|}
<br>
<br>
[address 1]<br>
{| class="wikitable"
|-
! Hex Byte  !! Funktion 
|-
| 01 01 00 01 00 04 6c 09 || Send : No. 1 relay 1 channel status
|-
| || Return ......
|-
| 01 01 00 02 00 04 9c 09 || Send : No. 1 Relay 2 channel status
|-
| || Return ......
|-
| 01 01 00 03 00 04 CD C9 || Send : No. 1 Relay 3 channel status
|-
| || Return ......
|-
| 01 01 00 04 00 04 7C 08 || Send : No. 1 Relay 4 channel status
|}


[https://hacktronics.co.in/4-channel-relay-module/4-channel-relay-module-programmable-w-opto-isolated-rs485-stm8s103f3 hacktronics.co.in/4-channel-relay-module]
<br>
<br>
[https://github.com/TG9541/stm8ef/wiki/Board-C0135 github Board-C0135]
https://hacktronics.co.in/4-channel-relay-module/4-channel-relay-module-programmable-w-opto-isolated-rs485-stm8s103f3


[https://wiki.chaosdorf.de/images/1/14/Modbus_RTU_4_Way_Relay_Module.pdf Modbus_RTU_4_Way_Relay_Module.pdf]


===  DDS578R Energy Meter ===
===  DDS578R Energy Meter ===
Line 250: Line 261:


{| class="wikitable"
{| class="wikitable"
! colspan="4"| Data register address !! colspan="6"| Register Description
! colspan="2"| Data register address !! colspan="4"| Register Description
|-
|-
| adr || fc || highByte || lowByte || Description    || unit ||  Format        || Mode
| highByte || lowByte || Description    || unit ||  Format        || Mode
|-
|-
| xx  || 03  || 00        ||   00   || A phase voltage || V    || Floating point || Read-only
| 00        || 00     || A phase voltage || V    || Floating point || Read-only
|-
|-
| xx  || 03  || 00        || 02      || B phase voltage || V    || Floating point || Read-only
| 00        || 02      || B phase voltage || V    || Floating point || Read-only
|-
|-
| xx  || 03  || 00        || 04      || C phase voltage || V    || Floating point || Read-only
| 00        || 04      || C phase voltage || V    || Floating point || Read-only
|-
|-
| xx  || 03  || 00        || 08      || A line current  || A    || Floating point || Read-only
| 00        || 08      || A line current  || A    || Floating point || Read-only
|-
|-
| xx  || 03  || 00        || 0A      || B line current  || A    || Floating point || Read-only
| 00        || 0A      || B line current  || A    || Floating point || Read-only
|-
|-
| xx  || 03  || 00        || 0C      || C line current  || A    || Floating point || Read-only
| 00        || 0C      || C line current  || A    || Floating point || Read-only
|-
|-
| xx  || 03  || 00        || 10      || Total active power || KWh || Floating point || Read-only
| 00        || 10      || Total active power || KWh || Floating point || Read-only
|-
|-
| xx  || 03  || 00        || 12      || A phase active power || KWh || Floating point || Read-only
| 00        || 12      || A phase active power || KWh || Floating point || Read-only
|-
|-
| xx  || 03  || 00        || 14      || B phase active power || KWh || Floating point || Read-only
| 00        || 14      || B phase active power || KWh || Floating point || Read-only
|-
|-
| xx  || 03  || 00        || 16      || C phase active power || KWh || Floating point || Read-only
| 00        || 16      || C phase active power || KWh || Floating point || Read-only
|-
|-
| xx  || 03  || 00        || 18      || Total reactive power || KWh || Floating point || Read-only
| 00        || 18      || Total reactive power || KWh || Floating point || Read-only
|-
|-
| xx  || 03  || 00        || 1A      || A phase reactive power || Var || Floating point || Read-only
| 00        || 1A      || A phase reactive power || Var || Floating point || Read-only
|-
|-
| xx  || 03  || 00        || 1C      || B phase areactive power || Var || Floating point || Read-only
| 00        || 1C      || B phase areactive power || Var || Floating point || Read-only
|-
|-
| xx  || 03  || 00        || 1E      || C phase reactive power || Var || Floating point || Read-only
| 00        || 1E      || C phase reactive power || Var || Floating point || Read-only
|-
|-
| xx  || 03  || 00        || 2A      || A phase power factor ||  || Floating point || Read-only
| 00        || 2A      || A phase power factor ||  || Floating point || Read-only
|-
|-
| xx  || 03  || 00        || 2E      || B phase power factor ||  || Floating point || Read-only
| 00        || 2E      || B phase power factor ||  || Floating point || Read-only
|-
|-
| xx  || 03  || 00        || 2C      || C phase power factor ||  || Floating point || Read-only
| 00        || 2C      || C phase power factor ||  || Floating point || Read-only
|-
|-
| xx  || 03  || 00        || 36      || frequency || frequency  || Floating point || Read-only
| 00        || 36      || frequency || frequency  || Floating point || Read-only
|-
|-
| xx  || 03  || 01        || 00      || Total active electricity power  || KWh  || Floating point || Read-only
| 01        || 00      || Total active electricity power  || KWh  || Floating point || Read-only
|-
|-
| xx  || 03  || 04        || 00      || Total reactive electricity power|| KWh || Floating point || Read-only
| 04        || 00      || Total reactive electricity power|| KWh || Floating point || Read-only
|-
|-
|}
|}
The second category register (parameter register) read and operate read the meter Address:<br>
(HEX):01 03 00 08 00 02 45 C9<br>
Date descriptions
{| class="wikitable"
|-
! Data      !! Detailed description
|-
| 0x01      || Instrument address ( adr )
|-
| 0x03      || Function code, read parameter register ( fc )
|-
| 0x00 0x08 || reading the data from the 00 08 meter internal register address
|-
| 0x00 0x02 || Read data length for two words( four bytes )of data
|-
| 0x45 0xC9 || CRC checksum data for the front, where the high front and low in the post
|-
|}
Returns Data (HEX) 01 04 03 40 00 00 00 EF F3
{| class="wikitable"
|-
! Data      !! Detailed description
|-
| 0x01      || Instrument address
|-
| 0x03      || Function code, read parameter register
|-
| 0x04      || Returned data length is 4 bytes of data length
|-
| 0x40 0x00 0x00 0x00 || TUSB To RS485 Converterhe data returned as a 4-byte data type float
|-
| 0xEF 0xF3 || CRC checksum data for the front, where the high front and low in the post
|-
|}
<br>
<br>
<br>
===  USB To RS485 Converter ===
<br>
[https://www.ebay.de/itm/USB-To-RS485-Converter-Industrial-Upgrade-Protection-RS-485-USB-2-0-Converter/401720933781 USB-To-RS485-Converter] 
<br>
<br>
''ll /sys/class/tty/*/device/driver''<br>
lrwxrwxrwx 1 root root 0 Dez 21 19:30 /sys/class/tty/ttyUSB0/device/driver -> ../../../../../../../../bus/usb-serial/drivers/pl2303/<br>
<br>
''lsusb''<br>
Bus 003 Device 014: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port<br>
<br>
<br>
https://developer.toradex.com/knowledge-base/uart-(linux)
Please note that all contributions to Chaosdorf Wiki are considered to be released under the Attribution 3.0 Unported (see Chaosdorf Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)