ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus serial communication in LabVIEW

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!

0 Kudos
Message 1 of 7
(3,595 Views)

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

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 7
(3,582 Views)

 

Hi,

 

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

Init.png

 

0 Kudos
Message 3 of 7
(3,577 Views)

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!

Download All
0 Kudos
Message 4 of 7
(3,565 Views)

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
0 Kudos
Message 5 of 7
(3,554 Views)

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!

0 Kudos
Message 6 of 7
(3,552 Views)

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
0 Kudos
Message 7 of 7
(3,546 Views)