08-06-2015 11:43 AM
Hi Guys,
Im new to labview (started back one week) and im trying to create a VI module (Modbus Protocol) for writing and receiving to a single register .
I have worked on C# and below is the application (Modbus C#.png) what im trying to implement in Labview.
I went through the tutorials and downloaded nimodbus library. There are many VI available in the library and i used "MB Serial Init.vi" to setup the serial port settings (Baud rate, parity etc) and i was able to execute it successfully.
Please guide me on how to send the below parameters to write to the register in labview. I tried using "MB Serial Master Query Write Single Register.vi" and "MB Serial Transmit.vi" but im not able to get it working.
Parameters:-
Register Address:- 00 (Upper) and 7D (Lower)
Value:- 00 (upper) and 00 (lower)
CRC:- 19 (upper) and D2 (lower)
Where does the register address (upper and lower) needs to be entered in the vi modules?
Where does the Value (upper and lower) needs to be entered in the vi modules?
Whether the CRC value will be calculated automatically?
Thanks,
Krish
Solved! Go to Solution.
08-06-2015 12:16 PM
Address is the register you want to write to: Enter 007D in that. (If it turns out to be wrong, try 007C) The controls are U16, so you enter both the upper and lower values.
Holding register is the data you want to actually write. (I think that may be poorly named in this VI and could be confusing.) You want to write 0 in there.
The CRC is calculated automatically.
This is all in MB Serial Master Query VI.
(I am not familiar with the VI MB Serial Transmit. Where did you see that? Maybe it is a subVI within the library.)
08-06-2015 10:54 PM
Krish,
I would follow all of RavensFan's suggestions, but if you are planning on doing more Modbus development in LabVIEW and have LabVIEW 2012 or later I would suggest moving from the NI Modbus Library to the Modbus API which was intended as its replacement.
https://decibel.ni.com/content/docs/DOC-30140
I think the API is much more straightforward in use. It follows a more standard LabVIEW approach of open, read/write, close. A basic program with the API can be created by using the create modbus master function, followed by the read holding register function and a close session (the names are not correct, I'm going from memory here on my home computer).
08-06-2015 11:56 PM
Thanks Ravenfan,
Its working now. Initially when i entered "007D" in the address it wasnt accepting but when i changed the data format to hexadecimal it started working fine.
P.S:- MB Serial Transmit.vi was available with the Modbus library and it looks like all 8 functions are merged to a single VI. I have attached a snapshot for your reference.
Thanks,
Krish
07-31-2019 09:27 PM
Super helpful! This worked!!