DIY Servo Service

Update: OpenSCAD and STL files have been posted to github for those who want to try it out!

It's worky!  Testing out Mats new DIY Servo service.  This uses a 3D set of printed gears, a 12V DC motor, an LN298N dual hbridge motor controller and a 10k ohm linear trim rotary potentiometer.  Woohoo,  the power of PID controls you!  The power of PID controls you!



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
moz4r's picture




So happy to ear that

pedro's picture

really thanks kwatters, cant

really thanks kwatters, cant w8 to try with the GNK legs

Mats's picture

My simple testbed


Just to show my simple testbed. Not at all as advanced as kwatters.



mayaway's picture

PotGear / ShaftGear

I'm getting a "non-manifold" warning - a hole in the part for both the Pot Gear and the Shaft Gear in Slic3r

Are there printable versions of those two gears anywhere?

Mats's picture

DiyServo cogwheels

I cleaned up the gears. You can find them here:

mayaway's picture

Shaft Gear

I'm afraid the Shaft gear v2 appears like a sinking ship in Meshmixer and won't print correctly.
The plane of one half of the top of the gear is just above the zero horizon, and the other half submerged.
Slic3r get very confused...

The other one printed just fine!

Is Gael using this as his knee, only scaled up?

Mats's picture


Seems like I was a bit tired when I creted it. I replaced the file on

I sliced and printed both without any complaints from Repetier / Cura. 

I don't think Gael is using this construction for the knee. This is more a proof of concept than a final construction. So I think he will use the concept of a motor and a potentiometer, but the mechanical construction will be different.

But that is just my guess. 

hairygael's picture

Oh waoooooooo! This so cool,

Oh waoooooooo!

This so cool, we are going to be able to have powered legs!!

SylvainJeanneton's picture

Both forward_backward and speed ?

Does this mean that at the same time it controls the direction (forward backward) and the speed of movement ? If yes it's fantastic.



moz4r's picture

Yes Sylvain , it is

Yes Sylvain , it is correct.
Like a classic servo, when you set a position X between 0>180 all is automatic no need to worry about direction and speed.


Mats's picture


Yes. It controls both direction and speed.

But it's not 100% finished yet. You can run it at full speed, and control the PID parameters to make it run at different speeds. But I also want to implement the new speed and acceleration parameters. I think they should control the input to the PID. I'm currently printing the DiyServo parts that kwatters provided, so that I can test with a full scale DiyServo.

And you should be able to use it the same way as you do with a normal RC servo, but with real position feeback and more control over the different parameters. 



SylvainJeanneton's picture

This is great coz I was

This is great coz I was "working" :0) on an electronic sys to manage speed and direction on the same engine it was not easy and expensive
A big thank-you. an thanks to reply so fast.


SylvainJeanneton's picture

To add to the previous mail

To add to the previous mail

Why 0> 180° and not 0> 360° ?
I would have liked that the trunk turns (the hands, the head) to 360° like some others bots (see Shaft or Hubo). It would be really very practical and will save a lot of movement for/of the bot (walk to turn around, keep its balance etc). With "normal" engines it is possible.
In fact it would be great also to be able to control the movements of the bots by hand or with a potentiometer, opto or else, as do Poppy, Nao and others small bots.
Ex: I choose a place for the hand i record the position, with MRL, i place my hand at another place i record the position, etc.
MRL registers/mémorizes and creates a path. All by hand no need code, that's the difference with your function "gesture". The children would be very happy because very easy, funny, customizable for everyone, but especially easy to use. That's the goal, is not it ? Otherwise it will be a bot, like the mutlitude of others bots for specialists.
Friendly and thanks for your hard work.

Mats's picture

0-360 degrees

The 0-180 is just the default range to be compatible with the range we normally use for RC servos. You can reconfigure it to use the 0-360 range if that is what you prefer. It's just a question of how you mount the potentiometer.

And you should also be able to control the servo using any sensor. The potentiometer on the servo is there to provide feedback. But you can add one more potentiometer to change the position manually. So many possibilities :)


SylvainJeanneton's picture


Pfiuuuuuuu ! Great.. The potentiometer ? On the "skin" in a plug to get an easy access. My bot fall ! No trouble ! I easy use my little pot and adjust the legs, arms etc


SylvainJeanneton's picture


I am very excited to see this "service" finished ... I started to build legs for InMoov, I have the engines finally solid, elastic, springs, my daughter is ready to leap with her small screwdriver , An atomic submarine is near the coast ready to send reinforcements we evacuated the city of Paris. : 0) We are all ready to move us legs by hand and memorize everything in angles, centimeters, feet, inches, gallons, with MRL You can imagine the time to win with this DIY-servo service ... Pfiuuuu ...



SylvainJeanneton's picture

Potentiometer and position memory.

In the current state is it possible to memorize in MRL positions that I will choose myself ? (With MRL or an external potentiometer)
I have built legs for InMoov but Schaft or Hubo type easier to balance ..

I have the code of your service
# webgui = Runtime.createAndStart("webgui","WebGui")
# Start of script for DiyServo
# Analog input A0 is the same as digital 14 on the Arduino Uno  
A0 = 14
# Start the Arduino
arduino = Runtime.createAndStart("Arduino","Arduino")
# Start Servo
servo = Runtime.createAndStart("Servo","DiyServo")
servo.attach(arduino)      # Attach the motorcontroller
servo.attach(arduino,A0) # Attach the analog pin 0
# End of script for DiyServo

But for the moment I am incapable of having other disturbing tremors followed by some strained leg stiffening style horror movie: 0).
So if we can use service DIY servo service. Can you help me to start well by sharing or a method or code. I will finally walk these legs and will of course share my results. If you have time of course.

Mats's picture


Hi Sy

Did you mount the potentiometer so that it moves when the joint moves  like kwatters show in the video above ?

Did you also connect the potentiometer  as decribed in the sketch ? 

If you have that then you should be able to move it using the GUI.

It would be very nice to see how far you have come to understand how I we can help with the next step(s) are the quest of making an InMoov robot take his first steps.

Are you trying to make a walking pattern ?