Servo do it yourself

One question:

I have already looked everywere but found nothing. I want to build a servo with Adruino. I mean, no servo controlled via # include but a motor and a potentiometer. And the Arduino board takes over the control. So that makes it a PWM signal as input and then the engine by means of the potentiometer go to the right position??. Since there must be something, or someone who has done it before.

Thank you!

TEC_MICHL:
One question:

I have already looked everywere but found nothing. I want to build a servo with Adruino. I mean, no servo controlled via # include but a motor and a potentiometer. And the Arduino board takes over the control. So that makes it a PWM signal as input and then the engine by means of the potentiometer go to the right position??. Since there must be something, or someone who has done it before.

Thank you!

Yes it can be done, but it’s not a simple project depending on your electronics and programming experience. A typical solution would utilize a PID control library and lots of code to read and evaluate the potentiometer input and scaling output for the motor driver.

There are lots of R/C servos avalible in all ranges of torque capabilities. What are your goals and reasons for wanting to build a servo from such basic components?

Lefty

Thanks for your answer.

My Problem is, that I have a Linak http://www.linak.de/produkte/linearantriebe.aspx Aktuator. There is only a Voltsignal from .5 - 4,5 Volt (Position output) And two inputs where you can spin the Motor in both directions.

Mayby there is a sample code somewere? I dont need the PWM for input. I just want so set the volt to a value an the aktuator should move to that position.

You simply add a PID control to drive the PWM to a motor controller (H-bridge). You
may find that you can live with just the P-term. This is the most basic nagative-feedback
setup possible and conceptually is just:

void loop ()
{
  actual_position = analogRead (potentiometer) ;
  int error = desired_position - actual_position ;
  int  drive = (int) (error * proportional_gain) ;  // where proportional_gain is a float constant
  digitalWrite (direction, drive < 0) ;
  analogWrite (pwm, abs (drive) > 255 ? 255 : abs(drive)) ;
  delay (DELAY) ;
}

Thanks very much for your answer. I will try it!

There is another Problem, the Actuator dangles after. If you switch of the signal it will take about 1 second to stop. So how can i define a range volt_min - volt_max in within the aktuator position is okay. I dont want, that the act. regulate all the time up an down, cause it wont get the exact posotion an thus volt signal.

Thanks again for your help

Actuators generally move slower than typical hobby servos, so may not need PID for most control operations. Depending on your actuator, you may be able to operate it with relays instead of an h-bridge setup. Does your actuator have in internal pot?

Its a Linak Aktuator http://www.linak-us.com/products/linear-actuators.aspx?product=LA36 with a tr-em-288 control box. There ist only a german datasheet for the controlbox

As i see, the Controlbox is a simple H-Bridge. Two inputs for constant 5 V up and down An a linar output from min=0,5V to max=4,5 Volt to get position.

(Threr is another input for Speed 0-5Volt, but I dont need it jet, just set a Speed with a pot)

TEC_MICHL: I have already looked everywere but found nothing.

Seriously? Combining the word "open" (as-in open source) with the word "servo" (as-in servo motor) didn't come to mind?

http://openservo.com/

Sorry no! Tried things like "sevo c code" "servo do it your self" all that stuff. Trying to find something, if you dont no the right question is a problem. Thank you very much! :-D

http://www.saeco.co.nz/TR-EM-208%20Controller%20Data%20Sheet.pdf
Has all the info needed, adjustable accel and deccel controls down to zero so should be able to stop like brake.

So program needs analog input (1) to measure the postion voltage from the actuator, analog input (2) to read of a potentiometer a voltage representing the desired actuator position.
Compare the two readings, pos or neg difference to dictate direction needed to move motor, check if difference is below a preset hysteresis level.
If below the level, stop motor.
If above level then power the actuator in direction to move towards desired position.
Then do it again and again and ad info nitum.

Tom… :slight_smile:
ps Set deccel to zero to see if it brakes. Also what experience do you have with electronics/programming.

As i see, the Controlbox is a simple H-Bridge.
Two inputs for constant 5 V up and down
An a linar output from min=0,5V to max=4,5 Volt to get position.

Below is some servo/pot test code for standard servos. The code might be modified to compare the values from the actuator pot and the control pot, and set arduino pins high/low to the actuator controller depending on the variation in the two pot values .

//zoomkat dual pot/servo test 12-29-12
//view output using the serial monitor

#include <Servo.h> 
Servo myservo1;
Servo myservo2;

int potpin1 = 0;  //analog input pin A0
int potpin2 = 1;

int newval1, oldval1;
int newval2, oldval2;

void setup() 
{
  Serial.begin(9600);  
  myservo1.attach(2);  
  myservo2.attach(3);
  Serial.println("testing dual pot servo");  
}

void loop() 
{ 
  newval1 = analogRead(potpin1);           
  newval1 = map(newval1, 0, 1023, 0, 179); 
  if (newval1 < (oldval1-2) || newval1 > (oldval1+2)){  
    myservo1.write(newval1);
    Serial.print("1- ");
    Serial.println(newval1);
    oldval1=newval1;
  }

  newval2 = analogRead(potpin2);
  newval2 = map(newval2, 0, 1023, 0, 179);
  if (newval2 < (oldval2-2) || newval2 > (oldval2+2)){  
    myservo2.write(newval2);
    Serial.print("2- ");    
    Serial.println(newval2);
    oldval2=newval2;
  }
  delay(50);
}

TEC_MICHL: Sorry no! Tried things like "sevo c code" "servo do it your self" all that stuff. Trying to find something, if you dont no the right question is a problem.

I'm just winding you up. I found that site purely by accident after multiple failed attempts searching for the same sort of thing you are.

Thank you very much! :-D

You are welcome.

Is thisthis of any help? - Scotty