03-16-2021 06:03 AM
Hi,
I am working on a project where I am working with 2 Micro Motion Flow meters. I would prefer to use modbus on this instead of analog output signal. I connect modbus through Serial Port on my laptop.
I read through the forum and downloaded examples posted, and watched youtube videos. I am able to see data from a single address in the holding registers. However, I am not sure how to move forward to view multiple other addresses, and also the second flow meter. Then log this data.
I built the attached VI following steps in a youtube video. I would appreciate any help I can get on this.
Thanks.
03-16-2021 08:43 AM
When you talk about multiple addresses, are you talking about multiple holding register addresses? Or multiple slave addresses? Or both.
If you are using multiple slaves, then you use multiple Create Serial Master subVI's. You can put them in a For Loop auto-indexing on an array of slave addresses, it will then output and array of master class objects. Later you can do the Read's on each of those array elements in a loop.
If you are talking about multiple register addresses, just put down additional Read Holding Register subVI's with the appropriate register starting addresses and quantities.
I'm not sure why you have all the additional array manipulation going on with the data you get back from the Modbus Read. All of the that is being done internally by the Modbus library. I can only guess that you wanted to visualize what the raw Modbus message looks like for debugging purposes.
03-16-2021 09:15 AM - edited 03-16-2021 09:18 AM
There are VI's in the MODBUS library for reading or writing single holding registers and VI's for reading or writing multiple holding registers. The Read Multiple VI works by giving it a starting register address and telling it how many consecutive registers to read and returns an array containing the register values.
I know you are just starting to figure things out but take a step back and think about this from a higher level. Figure out the commands you are going to use most often and create your own set of VI's that use the MODBIS library to run the commands you need to read and write the registers.
03-16-2021 10:51 AM
Thanks for the reply.
I am trying to read and log multiple holding registers from two separate slave devices. I have no idea what most of the components in my VI do. I have been trying to figure that out. My experience with LV has been just to build primitive read, visualize and log analog signals VI's.
When I tried building one following the manuals on NI, I couldn't communicate with my devices at all. And this VI seems like its the only one that has communicated so far. I will go with duplicating the loop to get all the registers then log that.
I was looking at the Raw data in HEX to compare with what I see on ModScan32 to verify that I am reading the correct register and value.
03-16-2021 01:20 PM - edited 03-16-2021 01:21 PM
Okay to begin with you might want to read up on MODBUS as it is a little weird when you first start out. But in a nutshell to get reading out of your device you "read holding registers" to setup your device to so something you "write holding registers or coils".
Holding registers are basically memory address that store values. Since registers are often limited to 16 bit signed integers. To get precise values you often have to read multiple registers then convert and combine them. Your devices manual should have a register map and give you all the scaling and conversion information.
Multiple MODBUS devices are handled by the MODBUS library. Every device on the MODBUS should have a unique address (1-255)
I have a system with 12 power meters on MODBUS each is set to its own address and initialize them like this.
This is what's inside "Init Serial Master"
For taking readings I built a set of custom VI's for my devices using the MODBUS library
Here's an example that reads multiple holding registers
What's inside "Get Primary Measurement"
03-17-2021 01:43 PM
Hi RTSLVU,
Thank you for your extensive reply. I have a whole lot of questions. And again I appreciate all the help with this.
The second image is the standard create modbus instance sub vi.
From your first image I am not sure about a few things.
I believe 1 is a control for error.
2- Number of devices? You said you have 12 devices.
3- I dont know what this is or where it would go in the subvi? I am guessing Unit ID for the 12 devices.
I couldnt get the controls in 4 and 2. And I believe 3 is Type Cast function as below.
And for 1 I have no idea. When I placed constant it was orange and didnt have the x in the box.
Here I am pretty clueless. I created a second event case. I am reading up on what these items are.
Also when I use DBL in 7 I get broken wires.
Thank you.
03-17-2021 03:28 PM
@omerengineer wrote:
Hi RTSLVU,
Thank you for your extensive reply. I have a whole lot of questions. And again I appreciate all the help with this.
The second image is the standard create modbus instance sub vi.
From your first image I am not sure about a few things.
I believe 1 is a control for error.
2- Number of devices? You said you have 12 devices.
3- I dont know what this is or where it would go in the subvi? I am guessing Unit ID for the 12 devices.
I couldnt get the controls in 4 and 2. And I believe 3 is Type Cast function as below.
And for 1 I have no idea. When I placed constant it was orange and didnt have the x in the box.
Here I am pretty clueless. I created a second event case. I am reading up on what these items are.
Also when I use DBL in 7 I get broken wires.
Thank you.