Generate Sinosoid signal into a PWM signal to drive a servo
Edmond
Posts: 7
I am trying to use the Basic Stamp to generate a sinosoid signal into a PWM signal to drive a servo so it will move along with the shape of the sinosoid signal. It seems there is no way I can generat a sinosoid signal using BS. Have any ones done that before? Any ideas ?
Comments
Bottom line -- you don't really WANT a "sinusoid" signal, because the Servo wouldn't know what to do with a "sinusoid" signal. Now, what you CAN do is vary the pulse-width you're sending to the Servo in a "sinusoid" pattern.
Assuming that's what you want to do, you can 'simulate' this with more or less precision. I've done something similar just by implementing a "triangle" pattern -- 1 mSec to 2 mSec, then 2 mSec down to 1 mSec, and repeat. I believe there ARE "sine" functions in the BS2, though I've never used them.
May be I didn't make it clear on my first post but what you said is exactly what I tried to do. I am not sending the sinusoid signal directly to the servo. Instead, as you mentioned, I need to vary the pulse-width of the PWM signal such that the ultimate output of the servo is a sinusoid signal.
I looked at the BS2 command list, it doesn't have any command to generate a sinusoid signal. I may able to write a program to simulate a sinusoid signal but I am afraid
that is not very accurate and easy to implement a sinusoid signal artificially. However, if that is the only way I can do it, that may be I have to live with that.
Thanks !
Edmond, If you wish to move the servo as fast as possible from one end to the other, then as allanlane5 said, two or three identical command pulses will quickly and smoothly move the servo from one end to the other in a sinusoidal pattern. One end would be two or three 2ms pulses every 20ms, and the other end of travel would be two or three 1ms pulses every 20ms. Center position is 1.5ms. Few, I hope your not confused by all this Edmond.