From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending a hexadecimal command through Modbus Ethernet

Solved!
Go to solution

I want to use the Modbus Ethernet Master Query Write function to send a hexadecimal command over ethernet. My problem is that the registers are numeric u16 and thus won't accept letters, but my command contains letters. As a hex my command is 4B 52 44 47 3F 20 30 0D 0A, so each pair is in one register, so I need to be able write a mixed number and letter in some of the registers. Is there a way to do this?

0 Kudos
Message 1 of 7
(2,375 Views)

You could write

19282 = 0x4B52

17479 = 0x4447

16160 = 0x3F20

12301 = 0x300D

2560 = 0x0A00

to 5 U16 registers.

 

Regards, Jens

Kudos are welcome...
Message 2 of 7
(2,355 Views)
Solution
Accepted by topic author Nadweb

Make your control or constant show the radix.  Set it to be Hex display.  Now you can type those hex values in using 0-9,A-F.

 

Message 3 of 7
(2,334 Views)

Hi Nadweb,

 


@Nadweb wrote:

As a hex my command is 4B 52 44 47 3F 20 30 0D 0A, so each pair is in one register, so I need to be able write a mixed number and letter in some of the registers. Is there a way to do this?


You can also use a string constant like this:

Are you sure it's a "hex command for Modbus"?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 7
(2,325 Views)

I guess its a string serial command, KRDG? 0\r\n, that I have converted to hex for use with modbus tcp/ip

0 Kudos
Message 5 of 7
(2,308 Views)

Modbus TCP/IP does not have any "commands" that look like that.

 

Perhaps you mean just TCP/IP communications with an instrument.  But it is not Modbus.

 

You can find details about Modbus communication here.  https://modbus.org/tech.php

0 Kudos
Message 6 of 7
(2,305 Views)

It is an instrument specific RS232 command that I would normally send as a string using VISA write, so I was incorrect calling it a Modbus command. My understanding from the application engineer is that I can convert this command to a hex, and send it via Modbus TCP/IP Ethernet to our programmable automation controller, which should be able to send this to the instrument and read the response, via a boot program. I am very new to Modbus, so I'm learning as I go.

0 Kudos
Message 7 of 7
(2,300 Views)