From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
07-18-2017 08:08 AM
Hi, I'm a new LabVIEW user trying to control a linear actuator with an analogue voltage being supplied from a DAQ connected to LabVIEW. The whole program is too large to show in a single screen but I attached a sample that shows a very basic version of my serial setup within a loop. In the actual program there are case structures, various other outputs, calculation, and string conversions also within the same loop.
Currently each loop takes about 0.1 seconds to execute leading to choppy actuator motion which is not suitable for my application. While troubleshooting I made a version of the program that performs all of the same operations but doesn't include a live serial output and it runs smoothly with each loop taking about 0.007s to execute. This leads me to believe the delay is caused either by the way I have written my code to interact with the serial connection or by the serial connection itself.
Is there a way to speed up the loop execution/serial connection or is the problem with my hardware?
Solved! Go to Solution.
07-18-2017 08:21 AM
Show us an image of the code that runs "faster' so we can see the difference and understand exactly you want to change.
Could be...
Use faster baud rate,
Set serial for async,
OR
Other depending on what you share and how this question shapes up in the end.
Ben
07-18-2017 08:26 AM
That is sounding like your serial instrument only sends updates every 100ms. There might be a command to tell it to send out updates more often.
I like to separate my instrument reading loops to avoid issues like this. So just from your sample, I would have a DAQ loop and a Serial loop. These loops can send updates to whoever needs the data via Notifiers, Global Variables, Queues, User Events, etc.
07-18-2017 08:35 AM
Once again the program is too large to fit on one screen so I've made changes to the sample I posted to hopefully show you what I mean when I say I removed the serial connection.
Basically instead of asking the actuator for its position I am calculating it using where is should be according to the voltages I put in. Of course this is less accurate because there is error in the calculations, but the motion of the actuator is smoother.
07-18-2017 09:00 AM
07-18-2017 09:17 AM
@H2lloTh3r3 wrote:
The whole program is too large to show in a single screen
That is a huge red flag in any LabVIEW program.
Without seeing all of your code we can not really advise you in how to fix it.
07-18-2017 11:07 AM
Thanks a lot. Separating the serial from the rest of the loop seems to have put me on the right track. I'm sure after I figure out how to work with notifiers, global variables, queues, and user events I will get the results I'm looking for.