Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Sequence programming in serial communication

Good day all,

I am gradually getting used to serial communication in labview and it is getting interesting. I have a sequence of command to send to a motor driver. It goes thus

1) enable motor to drive

2)move motor to an home position

3) check the position using an encoder reading (already attached to the motor)

4)read back position in 3

5) stop motion.

Each of this process or action has there command notation t for the driver to perform the five listed operations above which include for 1)EN for 2) LA for 3)M for 4)POS and for 5)DI

 

Now sirs, I am using advance Serial read and write vi, I am inputting each command by hand and its working fine. Please how do I write the actions together and pass it on to the driver to perform. I mean inside the write column in the advanced serial read and write is it possible to write this actions sequentially and pass it on to the driver to perform making it automated some sort.

Thanks all.

0 Kudos
Message 1 of 5
(3,193 Views)
You should look at the state machine architecture. There are shipping examples and it's one of the design patterns you can select.
0 Kudos
Message 2 of 5
(3,188 Views)

I have one more suggestion to solve your problem.

If you want write those 5 commands one by one forever, Put the write VISA in for loop and give the array constant as input to your write VI with 5 commands. Don't wire the for loop count value and drag the out the array constant out of the loop.

 

Also, you can use state machines as other suggested. 

0 Kudos
Message 3 of 5
(3,180 Views)

Thanks all for your response.

For the state machine, all examples I am getting online and in tutorials relate to the coke/vending machine, please does anyone has a link to another example different from the vending machine for State Machines.

As for the second option, please what do you mean by "If you want write those 5 commands one by one forever."

Once again, thanks all.

0 Kudos
Message 4 of 5
(3,165 Views)

There is 'State Machine Test Sequencer', 'Queued Message Handler' as part of the examples installed with LabVIEW and as I mentioned, one of the design patterns (File>New...).

 

The 'forever' part of the comment is incorrect. As described, the for loop would execute a count equal to the number of elements in the array.

 

Which you use would depend a lot on how much flexibility you need. If you never need to execute more than x number of commands, the array with a for loop is simple to implement. If you need the ability to change the order in which commands execute, error handling, the state machine is better.

0 Kudos
Message 5 of 5
(3,162 Views)