Showing results for 
Search instead for 
Did you mean: 

Servo timing (LabVIEW, Linx & Arduino)

Go to solution

Hello there, you lovely people!


This forum has been so helpful to me, nearly every time I have a problem it turns out someone else had it before me and one of you brilliant folk solved it. With that in mind, I was wondering if anyone could explain to me why this isn't working. I'm ultimately trying to get multiple servos to move to certain positions at preset times, but this is my single-servo test and it's not working at all. (I've set the "False" case to a toggle that moves the servo between two positions, largely just to check that the servo works. It does).


I've tried to label stuff so it makes sense, but if there's anything that's not clear, just ask!


Thank you!


Timing Test.PNG

0 Kudos
Message 1 of 8

Turn on Highlight Execution (the light bulb button) and watch how the data flows!


In every iteration of your outer while loop, you only write to the device once.  It will be the last value that comes out of the inner For Loop.  The For Loop doesn't finish until it is done going through all the iterations of the various waits, and only then is the last value passed to the write function of the device.


This is basic LabVIEW dataflow concept, so I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
Learn LabVIEW


If that servo Write was inside the For Loop, it would probably run more like you are expecting.

0 Kudos
Message 2 of 8

Hi RavensFan,


Thank you for the reply. I tried the light bulb, but it just immediately opened the Linx Start subvi and just kind of stopped there. 


Moving the Servo Write block worked, thank you!


But now, I've hooked up two more servos that I want to run simultaneously, and hooked up the Boolean local variable to the case structures in the hope that it'd activate them at the same time, but no luck, they're running one after the other (which makes sense because of the dataflow thing). Any ideas how I make them run together?Timing Test 2.PNG

0 Kudos
Message 3 of 8
Accepted by kathmonkey

Any ideas how I make them run together?

Yes. Understand the core principle of LabVIEW, data flow! A node will not execute before all input wires have values present. A node will only output data when it has finished execution.


And then check again on your three case structure. You created a dependency between all of them, using a purple and yellow-black/error wire. The second case structure e.g. cannot execute before the first one has finished. I don't know what you wan to create in the end and how your servo API works. You could try wiring all your three case structures to the same source (coming from top left in your screenshot), then being in parallel. You'll need the "Merge Erros" function afterwards to sync everything happening afterwards.


As said, I don't know how the Servo subVIs work, maybe they will not support parallel execution this way. Then it would get a little more complicated to set it up.



Ingo – LabVIEW 2013, 2014, 2015, 2016, 2017, 2018, NXG 2.0, 2.1, 3.0
0 Kudos
Message 4 of 8

ikaiser, you amazing human, that worked, thank you!


I'm a third-year engineering student working on my final project, we've been using LabVIEW for two years, but it would seem our education has been a bit lacking!


You people are brilliant, thank you again!

0 Kudos
Message 5 of 8

I am happy to help (-:

Ingo – LabVIEW 2013, 2014, 2015, 2016, 2017, 2018, NXG 2.0, 2.1, 3.0
0 Kudos
Message 6 of 8

@kathmonkey wrote:

Any ideas how I make them run together?

With LabVIEW it's helpful to invert your thinking a bit- with dataflow, *everything* runs together unless it *can't*. Glad you got your problem solved.

Heads up! NI is moving LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 7 of 8

I like your way of phrasing it so much that I want to quote just to have it stated once more: 


With dataflow, *everything* runs together unless it *can't*.


Ingo – LabVIEW 2013, 2014, 2015, 2016, 2017, 2018, NXG 2.0, 2.1, 3.0
0 Kudos
Message 8 of 8