LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with waveform and digital output

Hey everyone,

I am driving a rotational motor with an example waveform output VI and an example digital output VI. I am able to successfully send a square wave with the desired properties to rotate the motor and I am also able to successfully send a digital output (1 or 0) to change its direction (clockwise/couter-clockwise.

However I need some advices to write a setup such that after the motor runs as desired, I can return the motor back to its original position. I think the simplest way is timing how long it takes to finish its task, and just change the digital output, keep the same wave properties and run for the same amount of time.

So how can I time how long the program runs and with some kind of button, change the digital output and run the program again?

0 Kudos
Message 1 of 3
(2,281 Views)

Hi diishen,

you can use the "Tick Count (ms)" function. Use one block before your code starts and one after. If you subtract the last from the first you will have the duration of your code. Maybe it´s more precise if you know the lenght of your square wave.

 

Mike

0 Kudos
Message 2 of 3
(2,267 Views)

As more of a program architecture tip, this sounds like a great time to be using a State Machine.  I say this because you mention resetting the motor (one state) then running it again (another state) repeatedly.  As a design tip, I would check out this article, along with the Design Pattern Template that comes with LabVIEW.  You can find this by going to File >> New... then expanding the tree to VI >> From Template >> Frameworks >> Design Patterns >> Standard State Machine.

 

Cheers, 

Brian A.
National Instruments
Applications Engineer
0 Kudos
Message 3 of 3
(2,251 Views)