天道酬勤,学无止境

Modbus

Write hexadecimal values into register with leading zeros

I have an string array which contains 16 hexadecimal values. I need to convert them into byte to write them at Modbus's device register(size of each register is 16-bit). We have 8 registers to write 16 hexadecimal values. So, I'm converting them into the short and from short to byte for write them at device's register. Here is my code -- String[] advanceByte = { "00", "00", "00", "00", "07", "46", "46", "07", "01", "00", "02", "02", "02", "03", "00", "00"}; short[] hexToShort = new short[16]; for (int i = 0; i < 16; i++) { hexToShort[i] = Short.parseShort(advanceByte[i], 16); } // Converting

2021-09-05 00:02:19    分类:问答    java   hex   byte   ascii   Modbus

来自 modbus 的十六进制/十进制到日期和时间(HEX/Decimal to date and time from modbus)

问题 我有一个与通风系统的 modbus 连接,当出现问题时它会发出警报。 我可以使用 modbus 接收有关警报的数据。 该部分记录了 ID、日期和时间的寄存器。 所有 tre 接收都包含 2 个字节的数据。 ID 00:13(女巫转换为十进制错误代码 19 = 过滤器警报) 但是我无法弄清楚日期和时间的格式。但是我可以在通风系统中看到这些日期和时间在显示屏上被转换成什么。 我收到的日期以字节为单位(十六进制)= 43:68(十进制为 17256),这在显示屏上等于“13-11-08”(2013 年 1 月 8 日),时间以字节为单位(十六进制)= 34: 71(十进制为 13425)等于显示“06:35” 我尝试与纪元“1970 和 1980”进行比较,并尝试与其他时间翻译 32 位整数等进行比较。 但我无法弄清楚翻译是什么。 也许这里有人看过 simular 并且可以说出这是什么编码。 最好的问候托马斯·尼森 回答1 谢谢 Nanomurf,我搞定了。 我“翻译”并提出了这个工作:) 它给了我以下 08-11-2013 06:35:24 这就是我想要的。 谢谢你的时间。 Dim strDate As String = "17256" Dim year As String = (strDate >> 9) + 1980 Dim month As String =

2021-08-31 17:40:22    分类:技术分享    date   time   Modbus

HEX/Decimal to date and time from modbus

I have a modbus connection to a ventilation system where it generates alarmas when something is wrong. I can with modbus receive data about the alarm. That part is documentated with a register for ID, date and time. All tre receives contains 2 byte of data. ID 00:13 (witch is converted to decimal error code 19 = Filter alarm) But i cannot figure out what format the date and time are in. However i can at the ventilation system see what these dates and times are translated to at the display. The date i received in bytes(hex) = 43:68 (17256 in decimal) and thats equals on the display with "13-11

2021-08-30 17:14:33    分类:问答    date   time   Modbus

CRC-CCITT 到 CRC16 Modbus 实现(CRC-CCITT to CRC16 Modbus implementation)

问题 我在使用 PHP 生成 modbus CRC16 代码时遇到了很多麻烦。 我在互联网上找到了很多不同的代码,但我已经尝试过,但由于某种原因我没有得到正确的结果。 我找到了一个用于生成 CRC16-CCITT 的 PHP 代码。 我已将查找表更改为 modbus CRC 对应表,但结果仍然不正确。 代码如下。 我还需要做什么才能将 CRC16-CCITT 代码转换为 CRC16-MODBUS 代码。 <?php /************************************************************************* * phpCrc16 v1.1 -- CRC16/CCITT implementation * * By Matteo Beccati <matteo@beccati.com> * * Original code by: * Ashley Roll * Digital Nemesis Pty Ltd * www.digitalnemesis.com * ash@digitalnemesis.com * * Test Vector: "123456789" (character string, no quotes) * Generated CRC: 0x29B1 * *****************************

2021-08-12 04:33:46    分类:技术分享    php   Modbus   crc16

Modbus-tk RTU Slave holding register read signed integer

I created a modbus slave using modbus-tk as below. I use Simply modbus master software(http://www.simplymodbus.ca/RTUmaster.htm) as the master. How to set the slave to represent a signed integer instead of an unsigned. For example, when I send a 16 bits data, (FC19) HEX should represent -999 decimal , but now I get 64537. Try to use the example here https://github.com/ljean/modbus-tk/blob/master/examples/tcpmaster_example.py. It seems to only work for Master. import sys import modbus_tk import modbus_tk.defines as cst from modbus_tk import modbus_rtu import serial PORT = 0 #PORT = '/dev/ptyp5'

2021-08-11 06:35:57    分类:问答    python   python-3.x   Modbus   modbus-tk

CRC-CCITT to CRC16 Modbus implementation

I am having a lot of trouble on generating a modbus CRC16 code using PHP. I have found a lot of different codes over the internet but i have tried them and for some reason i didnt get right results. I have found a PHP code for generating CRC16-CCITT. I have chenge the look up table to the modbus CRC corresponding table but the result is still not the right one. The code is bellow. What do i need to do more in order to transform a CRC16-CCITT code into CRC16-MODBUS code. <?php /************************************************************************* * phpCrc16 v1.1 -- CRC16/CCITT

2021-07-31 16:12:07    分类:问答    php   Modbus   crc16

pymodbus Exception Response(131, 3, IllegalAddress)

I'm trying to run this piece of code: from pymodbus.client.sync import ModbusSerialClient as ModbusClient import logging logging.basicConfig() log = logging.getLogger() log.setLevel(logging.DEBUG) client = ModbusClient(method='rtu', baudrate=9600, parity='E', port='/dev/ttyUSB0', timeout=1) client.connect() rr = client.read_holding_registers(40000, 7, unit=0x01) print rr client.close() But I get only this: DEBUG:pymodbus.transaction:Running transaction 1 DEBUG:pymodbus.factory:Factory Response[131] DEBUG:pymodbus.transaction:adding transaction 0 DEBUG:pymodbus.transaction:getting transaction 1

2021-07-30 23:58:32    分类:问答    python   Modbus   pymodbus

从 Android 向 PLC 发送布尔值(Sending a boolean value to a PLC from Android)

问题 我能够与 PLC 建立连接以从中读取数据。 现在有一个问题,那就是我必须编写一种方法来修改来自 PLC 的数据。 为此,我必须向 PLC 发送两个值:一个整数值和一个布尔值。 我通过 net.wimpi.modbus 包中的类得到了 int 值。 但是当涉及到布尔值时,我不知道该怎么做。 如果有人和我现在遇到同样的问题,能否请您给我发一份参考资料,我可以在其中找到解决方案或解决我的问题的非常好的教程链接? 有人在这个问题中发布了几个链接,但它向我发送了与与 PLC 的通信以及如何处理 PLC 的数据没有太大关系的教程。 编辑 我与 Modicon M340 PLC 建立了连接,对于连接,我使用了 net.wimpi.modbus 包的类。 我发过班,我的代码连接ModbusTCPTransaction和TCPMasterConnection ,和我在班念值ReadMultipleRegistersRequest和ReadMultipleRegistersResponse 。 我为连接制作的代码: private InetAddress m_Address; private ModbusTCPTransaction m_Transaction = null; private TCPMasterConnection m_Connection = null; int port =

2021-07-10 09:45:09    分类:技术分享    java   android   boolean   plc   Modbus

pymodbus: Issue reading String & multiple type of data from Modbus device

I am trying to read String (Usecase-1) & multiple type of data in one request (Usecase-2) data from Modbus TCP device but, it failed to decode it correctly. System Configuration: Python 3.6.5 Pymodbus: 2.1.0 Platform: Windows 10 64-bit Modbus TCP Server: import logging from pymodbus.constants import Endian from pymodbus.datastore import ModbusSequentialDataBlock from pymodbus.datastore import ModbusSlaveContext, ModbusServerContext from pymodbus.device import ModbusDeviceIdentification from pymodbus.payload import BinaryPayloadBuilder from pymodbus.server.sync import StartTcpServer class

2021-06-28 07:54:14    分类:问答    python   python-3.x   Modbus   modbus-tcp   pymodbus

Modbus Serial Port Data Reading in C#

Hi I am trying to read the Serial Port Data. I used NModbus library for the modbus communication. Code works fine for read and write purpose. But sometimes i am having some unknown errors and i wanted to see the serial port activity. I tried using the SerialDataReceivedEventHandler but i am not getting anything from the port but still i am able to read the value of the holding registers. Here is my code. All i want to see the data packet being sent / received over the serial port. namespace ModbusMaster { public partial class Form1 : Form { public Form1() { InitializeComponent(); this.Load +=

2021-06-27 13:35:41    分类:问答    c#   forms   serial-port   Modbus