10-19-2016 06:44 AM
Hi there,
I am tried to sum the amount of fluid I am pumping into my system. To do so I am using a small piece of code (on the bottom left corner of my VI) that really just add stuff and displays it into a numerical indicator.
the problem is that my code doesn not iterate every 1000ms really. it's a bit slower, probably beause of the commands I send right before I am doing this calculation. BUT I need to get this flow rate in order to sum it...
Does someone encountered this kind of issue and had it solved ?
ps: I recreated this in a very simple VI as well to check is it could be my iteration that could slowdown the summing proccess, and it is definitly slower.
Flo
10-19-2016 07:00 AM - edited 10-19-2016 07:02 AM
Hi ICCR,
your BD is so big your computer cannot execute it in less than a second… 😄
You have timeouts of 1000ms on those two event structures. (Why are there two event structures, in one VI, in one loop?)
Additionally there are VISA functions which take their time.
Additionally your devices need time to response on commands.
Additionally the transmission of bigger VISA data strings (you request upto 1000 bytes!) takes it time depending on baudrate. (With 9600 baud you can transfer ~1000Bytes/s!)
- Check the tiing for all those functions/subVIs in your snippet. Determine which of them take the most time and try to speed them up.
- Use producer-consumer scheme to separate DAQ/VISA from other tasks in your VI…
10-19-2016 07:17 AM - edited 10-19-2016 07:18 AM
Hello ICCR,
Here are some remarks about your code :
1) You are working on Windows OS so time is not deterministic. 1s will never last 1s exactly. Use RT or FPGA hardware to work with deterministic timestamp. Moreover you are doing VISA Read/Write which spend time and i can guess more.
2) You have to follow free LabVIEW course. Try to get
- straight wires
- only one error wire
- don't use multiple event structure into a while loop !! Why do you have timeout case ?
- get your VI into one screen without scrooling horizontal or vertical (your current VI couldn't be seen)
-get some comments to explain what you are doing (It will help you and futur maintenance 🙂 )
Best Regards
Vincent
10-19-2016 07:24 AM
1) You should only have 1 event structure.
2) I would seperate your code to be in multiple loops. I am currently picturing 3 loops: 1) Instrument A polling, 2) Instrument B polling, 3) User interface. It will become a lot easier to time your loops this way.
10-19-2016 07:36 AM
Thanks everyone, It's more or less what I thought. My VI slow down the time 😄
The two event case will be put in one, it's just a relica of a past VI which has been merged to that one.
For the multiple loops thing, I have no idea on how to do that. My principal aim is to be able to constantly update few indicators. May I ask you an example of VI that would do those multiple loops thing?
Flo
10-19-2016 08:04 AM
10-19-2016 08:05 AM
Please, do not attach a picture of a Block Diagram, particularly a huge one (it makes the print too small to view). Rather, attach a VI that we can Open in LabVIEW, move around, look "behind" the Case Structure, get LabVIEW Help if we forget "just what that function is, and does", and can even execute (or modify) pieces of the code.
LabVIEW has the ability to have multiple independent loops running more-or-less at the same time, so if one is "slow", it doesn't slow down the rest of them. To get an idea of where this is useful, open a new VI, go to the Block Diagram, click on File, New ... (the dots are important), look for From Templates, look for Producer/Consumer Design Pattern (either one), and click it. It will build a classic Producer/Consumer two-loop example VI with explanation of what, how, and why it works.
Bob Schor
10-19-2016 08:52 AM
I don't find the project (producer-customer) discussed above.
Also, here is my VI (a bit simplified)
10-20-2016
06:26 AM
- last edited on
05-14-2025
07:10 PM
by
Content Cleaner
You can check this White paper on Application Design Patterns: Producer/Consumer : https://www.ni.com/en/support/documentation/supplemental/21/producer-consumer-architecture-in-labvie...
LabVIEW comes with inbuilt templates for basic Application design patterns(One among them is Producer-Consumer). Please learn how to create vi from the templates in below link
Creating VIs from Templates: https://www.ni.com/docs/en-US/bundle/labview/page/creating-vis-from-templates-and-sample-projects.ht...