Showing results for 
Search instead for 
Did you mean: 

Instrument Control using sequence structure


Hi Guys,

I am trying to control a three axis machine movements using a sequence structure.


Suppose If I have to move x-axis from the current position to end position I make the machine to reach end position at 5 intervals, in case if I change the count to 3, it reaches the end position at 3 intervals. 


The problem is I can do this by changing the code every time, but I have to make it user-defined. I use a sequence structure inside a state machine. And based on the no of intervals the sequence structure has to be placed. now the issue is I can change the x,y and z to move at any positions but not the intervals and make them stop at different no of positions as it is fixed. Example now I want the machine to reach end position at 4 intervals not at 5.  And I use a for loop and control the no of iterations for the intervals. I have also attached my VI, is there any other way to get around this and able to control the no of intervals.


Thanks in advance for any assistance.

0 Kudos
Message 1 of 9

I don't know too much about the application but it looks like you might want each one of those frames to be its own state in the state machine. Then you could iterate through an array of states

Matt J
National Instruments | CLA
0 Kudos
Message 2 of 9

hate looking at tiny pictures of large Block Diagrams.  [I don't like large Block Diagrams either, but if they are part of a VI, I can at least use the Navigation Window and scroll around without eyestrain].  So I won't comment on the code I looked at for 2 seconds at most.


You have a three-axis machine, and it sounds like you want to control the axes independently.  This suggests a State Machine for each Axis, all running in parallel (easy to do with LabVIEW).  Each State has a single, simple "rule" -- Do Movement X and stay there for time T.  That's one State, characterized by two parameters, so with an array of Parameters, you could have a three-state State machine, "Initialize", "Do Move", and "Shut Down".


Bob Schor

0 Kudos
Message 3 of 9

Hi Guys,

Yes sorry for my big program.

The thing is controlling them seperately is not my issue, Infact I want to control them together. But the issue is to control the intervals, how do I configure the intervals each time to change the intervals. As I use 6 sequence structure is because that I need 6 intervals, is there any alternative to that 6 sequence structure, because now i cant change the intervals to 5 or 4 or 3 as there is already 6 sequence structure.

0 Kudos
Message 4 of 9

Yes.  It is called a For Loop.

0 Kudos
Message 5 of 9

More specifically, it's a For Loop with a Case Statement inside it, wired to the Index ("i") element of the For loop so you first do Case 0, then Case 1, then Case 2, with common wires (like the Error Line) running in Shift Registers attached to the For loop and brought into the Case using Tunnels.  Common data (arrays, DAQmx I/O channels, File Paths, etc.) can also be run through Shift Registers if they are used in this "sequence".  Note you'll need a "default" case (unless you want to separately specify all possible LabVIEW integer case numbers).


Bob Schor

0 Kudos
Message 6 of 9

Since you didn't post any code, we can't see what's inside the subVI's.  I'm can only assume that the X subVI moves in the x direction, Z subVI moves in the z direction but what does Y, Y1, Y2, Y3, Y4, Y5 and Y6 do that is so different that you need 7 different subVIs.  This is the crux of your problem since you think you need a different subVI for each additional interval. 

LabVIEW 2017
LabVIEW Programming
0 Kudos
Message 7 of 9

Yes now I understand it.


Thank you.



0 Kudos
Message 8 of 9

I know this is no help but your program is a prime example of why sequence structures (flat and stacked) should be deprecated and no longer taught in LV training. 


For future reference, whenever you find yourself reaching for a Sequence structure...


Take a step back and think about what you are doing, because there is probably a better way.


One more thing...

The Flat Sequence structure in your code looks superfluous to begin with, you can remove it and the code will execute the same.  

Unfortunately, most readers of this Forum, including some real Experts, have not mastered the skill of being able to read the code that Posters fail to post. If we cannot see "what you did wrong", we are unable to tell you how to fix it. (Bob Schor 28 August 2018)
0 Kudos
Message 9 of 9