weird servo problem
Robot Freak
Posts: 168
i've made the following program:
but when it reaches 130, the servo isn't rotating in the same direction as in the wollowing program:
Why is this? Variables don't work???
import stamp.core.*; public class servo_test { public static DAC pin14 = new DAC(CPU.pin14); public static DAC pin15 = new DAC(CPU.pin15); public static void main() { int tempa = 0; while (true) { pin14.update(tempa); pin15.update(tempa); System.out.println(tempa); CPU.delay(25000); if (tempa == 250) { tempa=0; } else { tempa+=10; } } } }
but when it reaches 130, the servo isn't rotating in the same direction as in the wollowing program:
import stamp.core.*; public class servo_test { public static DAC pin14 = new DAC(CPU.pin14); public static DAC pin15 = new DAC(CPU.pin15); public static void main() { while (true) { pin14.update(130); pin15.update(130); } } }
Why is this? Variables don't work???
Comments
regards peter
The problem is in the first script.
at 130, it is rotating in the same direction as 255
I'm pretty new at this, but from the examples in the "What's a microcontroller" Stamp-in-class course, in the servos excercises, a value of 750 was "center", anything below that would turn the servos counter clockwise, and over 750 would turn clockwise.
-Ben
For servos I think PWM should be used.
Attached is the ServoControl example from the manual.
You'll notice different numbers (173 instead of 750)
because of the different timebase (173*8.68usec = 750*2usec)
The difference monitored from the two programs in the first post might
be due to the fact that the pulse dutycycle is increased from 0 to about 50%,
whereas the 2nd is about 50% immediately.
regards peter
Post Edited (Peter Verkaik) : 12/26/2006 3:33:22 PM GMT
Thanks!