09-19-2013 11:58 AM
Hey Nishant,
My first recommendation is that for something simple, it really is worth it to use the Modbus I/O servers included in LVRT and LVDSC. If you have either of those products you can use the I/O servers. The benefit to this is that it provides a background process which handles the modbus for you--you just need to look up the registers that your slave sensor is using and it will work.
This library is useful if you need lower level control. In the case of Tarsel, he is trying to test a slave device he created. In my case, I've used the library to meet my performance needs. If you need either low level control or higher performance, you can and should use this library, but you'll need to basically do the following:
09-23-2013 10:56 AM
Hi all!
Is there any more detailed tutorial on how to use this library? I see those examples, but still have no idea where to start from
Problem description:
I have NI 9871 module, with 5 devices (ABB network analyzers DMTME-I-485) connected in series via RS485 in a single NI 9871 port (Port 1). Each of these devices are assigned with unique address 1-5 (via device settings), and I'm trying to read some values from these analyzers (in device communication protocol manual, it says that holding registers are starting from address 0). However, I don't know what is the procedure: do I have to initialize slave device, or do I have to initialize the master device first, how to show obtained values on front panel (i tried to create indicator, but without any success), who sends the read query - labview application on my crio or initialized master etc.
Thanks in advance!
Best regards,
Marko Gulin
09-23-2013 12:06 PM
mgulin wrote:
Hi all!
Is there any more detailed tutorial on how to use this library? I see those examples, but still have no idea where to start from
Problem description:
I have NI 9871 module, with 5 devices (ABB network analyzers DMTME-I-485) connected in series via RS485 in a single NI 9871 port (Port 1). Each of these devices are assigned with unique address 1-5 (via device settings), and I'm trying to read some values from these analyzers (in device communication protocol manual, it says that holding registers are starting from address 0). However, I don't know what is the procedure: do I have to initialize slave device, or do I have to initialize the master device first, how to show obtained values on front panel (i tried to create indicator, but without any success), who sends the read query - labview application on my crio or initialized master etc.
Thanks in advance!
Best regards,
Marko Gulin
I have found my approach to be pretty robust (using the old Modbus Library - cRIO being the Master / Client - other devices being the Slave / Server).
Timed loop with case statement within. Three states Dial, Talk, Hangup.
Dial state: TCP Open Connection FB (Or the equivalent in this library), pass the refnum to a shift register to be used by subsequent states. If no errors, go to Talk State - otherwise go to Hangup state.
Talk state: Initialize arrays outside of the timed loop and wire them in. MB Ethernet Master Query FBs (Read and Write flavors, again equivalent FBs from this API) If no errors, go to Talk state. Otherwise, go to Hangup.
Hangup: TCP Close Connection FB - and back to Dial State
For unpacking the array, a For loop tied to the returned array's size and combine / manipulate the U16s as required.
Message was edited by: S1ack
09-23-2013 11:22 PM
mgulin wrote:
Hi all!
Is there any more detailed tutorial on how to use this library? I see those examples, but still have no idea where to start from
Problem description:
I have NI 9871 module, with 5 devices (ABB network analyzers DMTME-I-485) connected in series via RS485 in a single NI 9871 port (Port 1). Each of these devices are assigned with unique address 1-5 (via device settings), and I'm trying to read some values from these analyzers (in device communication protocol manual, it says that holding registers are starting from address 0). However, I don't know what is the procedure: do I have to initialize slave device, or do I have to initialize the master device first, how to show obtained values on front panel (i tried to create indicator, but without any success), who sends the read query - labview application on my crio or initialized master etc.
Thanks in advance!
Best regards,
Marko Gulin
Hey Marko,
I think S1ack did an excellent job of describing the basic process for using the code--a state machine of some form or another really is usually the best way to handle modbus, simply because it is a network process. The function he described is also what we'd use for normal TCP or UDP, so it makes sense to do the same with modbus.
To give you a slightly different view, I wanted to point out a few things:
Not to sound like a broken record, but I would highly recommend you contact our support or sales staff and talk to them about modbus I/O servers. I/O servers have their disadvantages, but for the most common use case they are well worth the money--especially if you already have LabVIEW Real-Time or DSC. For example (from the help: http://zone.ni.com/reference/en-XX/help/371618J-01/lvmve/dsc_modbus_using/ ) you can specify a shared variable as being bound to a single-precision floating point register F3000046 and simply read (or write) that value in the code. To do the same with this library, you'd have to follow the process outlined in post 40 above.
09-24-2013 07:49 AM
S1ack, smithd,
First, thank you for your quick and excellent answers! I have one more question - since NI MAE (Measurement & Automation Explorer) cannot list slaves connected in certain COM port, is there any other way to check whether or not slave is alive? I have 4 slaves all connected in a single COM port and assigned (by device settings) with unique address 1-4. I'm afraid that slaves are not properly connected, but couldn't find the way how to check this in LV, i.e. I tried to initialize slave with some random address (lets say 50), and program didn't threw any warning/error, e.g. "slave could not be found".
Also, I checked devices factory settings (baud, parity etc.), and they all agree with the ones in MAE for COM port they are connected in.
P.S. I found out that we have install Modbus I/O Server on our cRIO 9074 - what would you suggest that we use for reading from slaves (i.e. devices) - MODBUS library or Modbus I/O Server?
Thank you!
Best regards,
Marko.