Showing results for 
Search instead for 
Did you mean: 

How to create a queued sequencer for motion commands that needs to send to a serial port?

Go to solution

Hello All,


I am trying to create a queued state machine that creates the series of commands based on the excepted move sequence. I am a newbee. So could some one please guide me on show I should begin?




Tushar Goyal

0 Kudos
Message 1 of 11

What have you tried so far? Have you looked at any of the training materials? Have you looked at any of the examples that ship with LabVIEW? 

0 Kudos
Message 2 of 11

Yes, I have been going through different examples. But none of them explains in detail that, when I receive a string from my python code say "STouch(arg1, arg2, arg3, arg4, arg5)" and parse that code based on the 'Touch' and create a motion sequence based on 'touch'. For example, STouch it requires to move the axes from origin to target point and then press and come back. So, I want the sequencer to plan the ASCII command code array having 0- Move, 1-Click, 2-return.

0 Kudos
Message 3 of 11

I think you just answered your question. Parse the string. If you get STouch then queue up "Move", "Click", and "Return" in your QSM with the appropriate parameters. You can use a string as an input to a case structure so you can have cases for each potential 'touch' that you might receive.

0 Kudos
Message 4 of 11

Yeah, I know this. But what I am thinking is separating the action event structure and the planning structure. I want then the string 'Stouch' comes it should allow me to generate a series of commands (in other words queue up all the required command lines). Then these commands are passed to an event structure where each command is sent to a Copley Controls drive through RS232 and performs the action (here the action can vary up from initializing the registers to changing the direction of axes)

0 Kudos
Message 5 of 11

I would generate an array of commands within the case structure then use a For loop to put the commands into the queue sequentially. Not sure what you're doing with an event structure. Dequeue the commands at the state machine.

0 Kudos
Message 6 of 11

The Event structure is for the calculation of the values. for example distance between the origin and target, will convert from pixels to a number of counts which is required by the drive. So for that, I would require an event structure. 


Would you be able to provide me a small flow-through of the VI? Or a flow-chart for my better understanding?

0 Kudos
Message 7 of 11

I'm still clueless about why you need an event structure. An event structure is designed to react to events - such as a UI button press, not for calculation of values. You should do your value calculation where you parse your string (perhaps inside the case structure) and then send the data along with your message in the queue. Perhaps there's something that I'm missing here. Could you attach your vi?

0 Kudos
Message 8 of 11

I haven't started creating the VI, I am struggling with the architecture of the complete system. That's the reason I published this thread if some could guide me on the architecture. I am struggling with the method of algorithm writing which is confusing me a lot on what I have to do.  

0 Kudos
Message 9 of 11
Accepted by topic author tushar1209

You will have two loops. Your first loop will read your data, parse your data, and then send your data to the state machine. Your second loop is the state machine. You could possibly use a third loop for UI events, if necessary. Look at the Queued Message Handler as an example - but replace the event structure with your code to read your data, parse the string, and queue up events. Based on what you've said a queued message handler is the right basic structure. Why don't you give it a try and see how far you can get. 

0 Kudos
Message 10 of 11