Introduction: 1000 Steps Servo

About: DIY projects, CNC, 3D Printing and Arduino

In many project like CNC machines people use stepper motors. They are probably always more expensive than servos. They can rotate 360°, 1 step = 1,8° (mostly). Servos can rotate only from 0° to 180°, 1 step = 1°. But why are they working this way, inside them we will find potentiometer which rotates as servo (up to 180°), but have 1024 steps.

I've started to think about it.

Step 1: What I Have Used

Parts that I've used to make a prototype version:

  • Servo (normal, you can also use microservo),
  • Arduino and USB cable,
  • H-bridge (I have L293D, any other will work too),
  • 100nF capitator (optonal, symbol: 104),
  • Breadbord,
  • Wires,
  • Soldering iron and small screwdriver.

Firstly, let's prepare servo:

Open it and remove the electronics. Leave the potentiometer and DC motor. If your engine don't have capitator I prefer to solder one to it, that is not needed, but with capitator your motor will have more power.

Than solder the wires to engine and potentiometer, so you can put them into breadbord.

Step 2: Breadbord Circuit

Build a circuit like you see in the picture. If you have different H-bridge than I have used you should find how to connect it.

Pins:

  • Analog pin 1 checks the potentiometer,
  • Digital pins 2 and 4 sets the direction of rotation,
  • Digital pin 3 set motor speed (PWM, symbol on Arduino board: ~ ),
  • +5V and GND powering engine and potentiometer (WARNING: in microservo 5V could damage motor).

Step 3: Program

// 1000 steps Servo by TheSuperSewcio

#define pos 500 //servo position, use 10 - 1010, int distance; //potentiometer may have trouble with values > 1010 or < 10

void setup() { Serial.begin(9600); pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); }

void loop() { Serial.println(analogRead(1)); distance = analogRead(1) - pos; if(distance < 0){ distance = -distance; } if(distance == 0){ digitalWrite(3, LOW); }else{if(distance < 100){ //reduces speed 100 steps before target analogWrite(3, distance + 50); //minimum speed: 50 }else{ digitalWrite(3, HIGH); }} if(analogRead(1) > pos){ digitalWrite(4, LOW); //set direction of rotation digitalWrite(2, HIGH); }else{if(analogRead(1) == pos){ digitalWrite(2, LOW); //stops motor digitalWrite(4, LOW); }else{ digitalWrite(2, LOW); digitalWrite(4, HIGH); }} }

Your servo may be different from my, if for some reason something isn't working try to change values in lines 21 and 22.

As you can see here, servo position is sometimes exactly 500, sometimes 499 - 501. It depends on servo gearbox and potentiometer quality.

You can also download .ino file:

Step 4: Done!

Now it is a prototype, in the future I want to put all the electronics inside of the servo on PCB. You can try to build your own, maybe it will be even better than my.

Anyway it's more precise than normal servo.

Please, if you like my instructable, vote for me in the contest!