incremental servo

We can’t get a solid code for making the servo incremental. Any suggestions?

Not sure about anyone else but I have difficulty understanding exactly what you are asking for. Could you rephrase or clarify your question. Also please provide the programming software you use or have available. Guesses of your question below.

How do I make a servo run for 20 degrees and stop?
How do I make a button on my joystick run a servo for exactly x degrees no matter how long I hold it down?

We are using a servo on a wrist. We need the servo to adjust clockwise incrementally while holding button R on channel 8 down, then when R is released have the servo stop at that position. We need the servo to adjust counter clockwise incrementally while holding button L on channel 8 down, then when L is released have the servo stop at that position. We are using EasyC

I’ll be honest when I say that I know no EasyC, but, I’m sure the concepts are similar.

Create an integer variable where the starting value is the position at which you would like your wrist to start. When you want to increase or decrease the angle of the wrist, change the value of that variable. At the end of everyone of your drive loops, write the value straight from the variable to the servo value. Just make sure that the value of the variable is only changing when one of the buttons is held.

Problems with a servo in vex competitions:

  • no control over initial position, must be zero
  • when switching from auto to driver, servo may twitch
  • no control over ending position
  • no way to know/query the current position of the servo

What is a servo? Inside the case there is :

  • A motor
  • a potentiometer for feedback
  • a cpu running a PID algorithm to drive motor to minimized error in feedback

My recommendation is:

  • Discard the servo,
  • use a motor
  • use a pot for feedback
  • program the cortex to do the cpu servo function itself
  • Now it is just the same as pre-programmed arm position control
    You’ll learn a lot about feedback, and have a much more capable system, capable of +/-720 rotation if you need that, and much higher torque, if you need that.

But on your original question, remember that the servo tries to move to and hold a position of -45 degrees to +45 degrees, corresponding to -127…+127 sent to it by SetMotor(). Obviously you can set the servo position to be a variable, and use the buttons to increment or decrement the variable in the event loop. The common problem is that the event loop increments the variable faster than the servo can change, so the servo keeps moving when you release the button. Without using additional feedback, a common solution is to decrease the speed at which you change the wrist position variable to match the speed of the mechanism.
One way to do that is to use a floating point variable, and make the increment/decrement amount smaller than 1. Keep making the incr/decr amount smaller until the servo stops moving when you release the button.

http://t3.gstatic.com/images?q=tbn:ANd9GcQz4APiMYah_Kiwy43kczWtbwmPNISEuQlw34EuDId0CUy5AK75Lphno9jP

Perhaps it would have been good here to type out Potentiometer. “Use a pot for feedback” may cause confusion.