LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make a servo move in a sine curve when plotting angle vs time

I am currently trying to make a servo move with a PWM in such a way so that when i plot angle change vs time it is in the form of a sine curve. I am using this program "http://zone.ni.com/devzone/jsp/largeImage.jsp?imagename=/cms/images/devzone/tut/a/dadc74b4233.jpg&la...". Is there a way to increase the value of the duty cycle every certain incriment of time and have it correspond to a certain angle increase as well.
0 Kudos
Message 1 of 2
(2,672 Views)

Hi Chrisx90-

 

     I found an example on our community that actually creates a square wave that has a dynamically changing pulse width in accordance with a sine wave.  It may be a useful reference for you, and can be found here.

 

     In terms of incrementing your duty cycle with time, you can do this by implementing some logic using the iteration counter on your while loop.  Below is a picture of an example of increasing a voltage over time using a for loop, but the same idea can be incorporated using a while loop.

ramp.gif

 

     In terms of it corresponding to an angle increase, I believe that is decided by your servo.  The servo is set to respond to a specific pulse width.  You will have to determine from the servo specs how the servo angle will respond depending on the pulse width you send it.

 

     I hope this helps.  Best of luck to you!

 

Gary P.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 2
(2,647 Views)