cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus serial communication in LabVIEW

vile9495
Member

Modbus serial communication in LabVIEW

Message contains an attachment

Hi all,

How to write single register (with the function code is 06) in the LabVIEW? 

I made an example and in this example, for the function code 06, my slave didn't get byte 5 and byte 6. 

Thank you!

6 REPLIES 6
pincpanter
Trusted Enthusiast

Rif.: Modbus serial communication in LabVIEW

The Data array (U16) is empty. Set the first element to the desired register value.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
jay0909
Member

Re: Modbus serial communication in LabVIEW

Message contains an image

 

Hi,

 

         Initialise the Register array index up to 65535 with '0'.

Init.png

 

vile9495
Member

Rif.: Modbus serial communication in LabVIEW

Message contains an attachment

Thank you for your help.

This is my simulation result after checking 2 frames 03 and 06.

For function code 03, the results are very accurate.

For function code 06, I was having problems at byte 5 and 6.

Can you help me edit the diagram in LabVIEW? 

Thank you!

pincpanter
Trusted Enthusiast

Rif.: Modbus serial communication in LabVIEW

For command 6, bytes 5-6 would contain the register value you want to write. What do you expect to receive?

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
vile9495
Member

Rif.: Modbus serial communication in LabVIEW

For example, I want to write the value is 0001 (byte 5,6) on the address register is 0001 (byte 3,4). So, I couldn't receive the value on the transfer frame. 

Thank you for you help!

pincpanter
Trusted Enthusiast

Rif.: Modbus serial communication in LabVIEW

I already answered. The blue array named Data in the Modbus Command cluster must contain the register value(s) you want to write.

Click on element 0 and input 1, or, even better, use a Bundle By Name node to set the value. You are now setting to 1 the Quantity member instead, which is only relevant when doing multiple registers or coils read/write, for example the Write Multiple Registers command.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021