LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read data from an acquisition unit at 1hz using modbus TCP

Solved!
Go to solution

Hello everyone,

I am familiar with Labview but quite a beginner with numerical communication.

I will try to summurise my problem.

I use Labview 2018. I want to read the data from an acquisition unit with 7 sensors plug inside.

My program is not perfect but at this stage I succeed to read the 7 sensor with a frequency of 0.5HZ.

So all the  parameters seems OK.

When I try to read only two sensors, it reaches 1 HZ.

My last try are about structures, firstly I wanted to read my table with a structure "for" but I try to remove this structure to understand better and to see what's happening ?

I join to my post 3 VI and sub-VI and file result.

Is it possible to reach an acquisition at 1 hz or is the PC to slow to manage 7 sensor at 1 HZ?

Thank you very much,

I stay free for any further information.

0 Kudos
Message 1 of 6
(142 Views)

Hi adri,

 


@adri73 wrote:

Is it possible to reach an acquisition at 1 hz or is the PC to slow to manage 7 sensor at 1 HZ?


It's not your PC that limits the execution speed, it's the way you created your VI!

 

I see two major issues ("numeric_7sensors"):

  1. reading 7 values in parallel over the modbus: you have a shared resource, so you need to read sequentially!!!
  2. reading those 7 values by using the "read single register" calls: as those modbus values are in a range of 0x04 to 0x31 you could read them in just one call by using "read multiple registers"!

Other issues:

  • Cleanup the block diagram to make the code more readable!
  • You can resize the IndexArray function, so you need only one node instead of 7!
  • IndexArray starts to index at element 0, so you don't need to wire any index constants!
  • There's no error handling for the file saving functions!

 

"numeric-7sensors-structureFOR" is even worse as you placed the 1s wait inside the FOR loop…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(119 Views)

Hello GerdW,

Thanks a lot for your quick answer. I am sorry for my code, I try to use all of your tips but I still don't manage the frequency. For now, with the last code I try to read using sequence structure, it does'nt work either, still at 0.5HZ. Your second idea was to replace "read holding register.vi" by "read multiple register.vi" but I couldn't find "read multiple register.vi" there is always the "write and read multiple register.vi", Does this VI exist ?


I think the answer is to use only one modbus tools to read the 7 address, which one i need to use.

Thanks again,

 

Adri

PS  : I am sorry for my code I amnot an Labview architect

0 Kudos
Message 3 of 6
(75 Views)
Solution
Accepted by topic author adri73

Hi adri,

 


@adri73 wrote:

I still don't manage the frequency. For now, with the last code I try to read using sequence structure, it does'nt work either, still at 0.5HZ. 


Did I mention "sequence frames" anywhere in my message?

Why do you think using several sequence frames will make your code run faster???

 

As before: you can read several Modubus registers with just one Read funciton call! That's the way to speed up communication!

 

I don't have that Modbus library installed on my (current) computer, so you need to read the help for eaxch Modbus function on your own…

 


@adri73 wrote:

I am sorry for my code I amnot an Labview architect


Me neither…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 6
(58 Views)
Solution
Accepted by topic author adri73

You need to replace read-register(sous-VI).vi with one of these and read multiple registers at once:

cordm_0-1750086594473.png

 

Then, convert your data and keep the stuff that you are interested in, ending up with something like this:

 

reading multiple modbus registers and converting to floatreading multiple modbus registers and converting to float

 

0 Kudos
Message 5 of 6
(49 Views)

Thanks a lot for your help and your time.

I will try as you say.

Regards,

Adrien Bonnefoy

0 Kudos
Message 6 of 6
(32 Views)