LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timed Servo Movement

Hello,

 

I've been trying to get a single servo to move between four different angles, staying at each angle for a given amount of time. I've had some luck using timed sequences but my servo is acting wild because (I'm guessing) there's an argument between which angle it should be at. Is there any easy way to make a command (i.e 'write servo angle') run for a specified amount of time and then stop and proceed to the next command?

 

I've attached a screenshot of my block diagram.

 

Thanks in advanced.

0 Kudos
Message 1 of 4
(2,890 Views)

Hi Matt,

 

Instead of using while loops, you should be able to use a simple state machine to tell the motor to when to move to a certain position. Once the move motor command has been called, the motor will hold that position until another move command is called. 

 

What is happening in your current code is that the motor is being told to move to position 15 every time the inner loop executes, so if it is off by even a little bit it will overcorrect which is what is probably causing the strange behavior you are seeing, 

 

-N

National Instruments
Staff Certification Engineer
0 Kudos
Message 2 of 4
(2,847 Views)

what exactly is a simple state machine? sorry i'm very new to this.

 

0 Kudos
Message 3 of 4
(2,844 Views)

Hi Matt, 

 

Here's some documentation on a state machine:

https://www.ni.com/en/support/documentation/supplemental/16/simple-state-machine-template-documentat...

 

Basically what you want to do with this code is start up in an idle state, then move to a location and return to your idle state. Wait in this idle state until a timer has expired, then after that occurs, command the motor to move to the next position. You might want to look into some of the LabVIEW training, there is a 3-hour and 6-hour getting started courses that can be found here:

https://www.ni.com/en-us/shop/category/courses.html

National Instruments
Staff Certification Engineer
0 Kudos
Message 4 of 4
(2,841 Views)