LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus

Hello,

I am trying to control a controller manufactured in China, which is used for managing the load of a hysteresis magnetic brake. My goal is to operate this controller via LabVIEW using the Modbus RTU protocol over RS485. However, I am unable to send instructions to the controller successfully. The controller came with only one document, which I have included along with pictures of the controller.

I would greatly appreciate any examples or ideas that could help resolve this issue.

0 Kudos
Message 1 of 10
(595 Views)

What have you tried?

Are you using NI Modbus Library Toolkit for LabVIEW?

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 2 of 10
(545 Views)

I am trying to send the example message "01 10 00 00 00 02 04 00 00 00 14 F3 A0" found in the bottom right corner of the attached image to the controller. The controller operates by sending a specified current, from 0 to 2000mA, to a brake. This example sets the current to 20mA. Once I can send this message successfully, I will be able to adjust the values as needed. I am using the NI Modbus Library Toolkit.

0 Kudos
Message 3 of 10
(535 Views)

Do you get an error message?

 

From what I can read, this should work with the default settings. Function code 0x10 is Write Multiple Holding Registers, code 0x05 is Read Holding Registers.

 

snip.png

The top of the instructions is missing, so I guessed the datatype of the setting is u32. Type casting works because it assumes big-endian encoding ("High in the top")

0 Kudos
Message 4 of 10
(521 Views)

I am not getitng any errors message, but unfortunately, my knowledge of Modbus communication is not sufficient to independently write the code in LabVIEW. Instead, I am using examples from the internet and adapting them to my needs. That’s why I’m seeking help here to find a solution.

I will attach images for reference.

0 Kudos
Message 5 of 10
(504 Views)

The Write Multiple Holding Registers in the snippet above will write that message. Download the snippet, drag it onto the block diagram and take it from there.

cordm_0-1718094046732.png

 

0 Kudos
Message 6 of 10
(472 Views)
Thank you very much for your assistanceit worked. I've placed the entire code in a while loop and set the wait function to 1 second. However, after a variable amount of time (sometimes shorter, sometimes longer), the values on the numeric indicators "before" and "after" display 0, and I'm unable to send new information to the controller. This issue is accompanied by the following error:
Error 56 occurred at RTU Data Unit.lvclass ADU Packet.vi:5030001.
Possible reason(s): LabVIEW: (Hex 0x38) The network operation exceeded the user-specified or system time limit.

 

Do you have any suggestions on how to resolve this?

0 Kudos
Message 7 of 10
(449 Views)

That error means the device fails to answer in time, which could have lots of different reasons. Is it still on?

How did you implement the loop? I would imagine that this error occurs intermittently, so as long as you clear the error after each iteration it should eventually start responding again.

0 Kudos
Message 8 of 10
(429 Views)
The device is always on. The error occurs occasionally. How can I automatically clear the error when it appears so that the system continues to run without interruption?
0 Kudos
Message 9 of 10
(373 Views)

Check the error code and if it matches, clear it. There is a "Clear Error" VI for this. You should make sure that you only clear it a limited number of times in a row, so that you do not miss a permanent disconnect.

0 Kudos
Message 10 of 10
(324 Views)