Go Down

Topic: feasibility question: turning dc motor to servo? (Read 10165 times) previous topic - next topic


I installed 2 dc motors, one vertically to ground for left-right and the other on top of it horizontally, for up-down movement. My circuit is an Arduino and L298. I put one pot per motor, so I have the position. What I need is that when I break the motor (LOW-LOW), not only get it stopped right at the moment (which is done ok), but also to have it not to move, so if this is an arm that lifted something, it won't fall down!

Is there any hardware(electronics) / software solution, or such a thing must only be done mechanically?



Sure. You will need a way to sense the shaft position so you know when / where to stop.

You can do this with analog parts (comparators for example), or with a digital device (mcu), or mixed (adc + a digital device).


My guess is you're going to have a hard time keeping the motor in position, as gravity will pull on your arm. You can get somewhat of a "braking" effect by shorting both motor leads together using an H-bridge, but that will merely slow or resist turning, it probably won't actually stop it unless you've got a big motor and a lightweight arm. If your motor is geared, that will help a lot.

What you may have to use is software code to continually monitor the position and as soon as the shaft moves away from the desired position, actively move it back. That means that your motors will constantly "jiggle" as they struggle to maintain position. If you add some hysteresis code and if your overall code loop is tight enough (in the kHz range), the effect may be minimal, pretty much the equivalent of PWM.

However this still depends on the quality of your feedback sensor. A pot, for example, has some "noise" as it turns, the resistance will jitter or jump around a bit rather than going smoothly up or down. You may need to add hardware or software smoothing of the pot signal, but such smoothing will also decrease the angular accuracy of your positioning.

So, still do-able, just don't expect stepper or servo class precision and stability.


Thank you,

I think that I did not explain my problem clear enough. I already have the shaft position as I embedded a pot with gears in, so when motor turns, my pot value changes accordingly.

What I exactly meant is that, when I stop a servo motor in a pos, if it is keeping a load on it, say it is an arm and servo lifted something, it keeps the position. I try to move my servo by hand but it resists. Same time, when I break my dc motor in a position (reading the pot as feed back), I can turn it still by hand (it won't resist, as if its power is disconnected) and also if any load on it, will fall down!

I think it could be done only mechanically, that is something keeps the motor from turning in any position while fixed, and just before moving it is being released.

What I would like to know:
1. some google key word to search for the right mechanism,
2. if there is any hardware (electronics) / software solution to this and if os, keywords to google

Please give ideas :)


I don't think this is doable. If you hold a DC motor in position with no power to it, it won't hold position. If you supply power to it, it warms up and eventually burn out the coil. They are simply not meant to hold position. Unless you have a very large screw, and turn the screw to change position, you won't be able to hold position. Stepper motors are designed differently to step and hold.

Well, scrap the above. You didn't say you had a DC servo motor. The servo motor will give you a spec on how much torque it can supply, just read the spec sheet.
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter


Oct 04, 2012, 06:28 pm Last Edit: Oct 04, 2012, 06:33 pm by retrolefty Reason: 1
What I would like to know:
1. some google key word to search for the right mechanism,

'feedback control'

2. if there is any hardware (electronics) / software solution to this and if os, keywords to google

Please give ideas

Your problem is most likely your software. You can't just place the motor controls in the break mode and expect it to be able to continue to respond to changes in the pots output value. If the pot moves as a result of external forces on the motor position then you have to detect that by the change in pot's feedback value and command the motor to move to counter that change in position. A servo is all about 'feedback' control, all the time checking for actual position Vs last valid commanded position and adjusting motor commands until the difference error is zero. A true servo loop would never have a 'break mode', but rather it's always active reading the pot and making motor correction commands as needed. There are three key variables in such a software loop, the pot's position value, often called the process variable, the desired position, often called the setpoint variable, and the (motor) output signal, often called the error signal. PID control libraries are often used for those building their own roll-your-own servo loops.

That make sense?



Oct 04, 2012, 06:48 pm Last Edit: Oct 04, 2012, 06:56 pm by ironbot Reason: 1
First I correct a mistake I may had in some place above:

It is an ordinary dc motor, not a servo type, so no torque report available :-(

Next, well yes, I had experience with Kalman filter and I can put there IMU (cheapest to implement for me) etc. and keep the motor in pos, but...

I was trying to find 1 mechanism to use both for arms and head, in arms it is ok to have the motor slightly move left / right to keep with pos, but for head, no.

So as I understand, I must go to feedback and correct motor position if arm, and for the head I must use a mechanical solution like:
1. move motor to the desired position and stop it
2. apply a mechanism that mechanically prevent it moving
3. to move it again, first release that

Also I don't want to go to servos for cost: the head will be from fiberglass material and not really at the weight that my hobby servos could handle and don't like to take model airplane servos each by 30$ (need 2 motors for head).

It will be very helpful if you could please suggest a cheap idea to implement in a small robot neck for this (up-down movement on 1 motor is enough).

Thanks again.

The bot has a router with 400Mhz Broadcom processor running on and in case of using a filter for noise or heavy PID algorithms there is no load to Arduino processing power from it.  


I must go to feedback and correct motor position if arm, and for the head I must use a mechanical solution like:

No. All you need is to implement a form of negative feedback.

For example, if the motor moves past the right of your desired position, turn the shaft left; and vice versa. With the negative feedback, the shaft/arm will hold (likely vibrate slightly around the target), mechanical limitations not withstanding.

One area of leading edge research, almost directly comparable to what you are trying to do, is to use brushless motors as steppers.

It is definitely doable. However, getting the whole system stable and responsive isn't simple.


What I would like to know:
1. some google key word to search for the right mechanism,
I'd say "brake". ;)

But, I have no idea how to build a miniature brake.   Maybe a friction device of some sort, or something poking through holes to stop rotation?    I suppose it would use a solenoid.    If you want to engage the brake when power is off, you'd need a spring to engage the brake and the solenoid would pull against the spring to release the brake when the servo is operating.

A stepper motor can make a pretty good brake, but they are not that cheap and they can only "brake" while powered-up.


There's nothing stopping you from putting a feedback loop on your motor control, and it would solve this problem completely.

Essentially, rather than switch the motor on to move it and switching it off when it reaches the required position, you would specify the desired motor position and continually compare the current position with the desired position and apply power to the motor to move it to the desired position. You could hard-code this feedback quite easily using a simple proportional algorithm, but if you have moving assemblies involved with inertia to deal with then a PID control algorithm would be ideal since it would take care of all of that for you. There is already a PID library for the Arduino. The error signal would be the difference between desired and actual position and the output would be PWM duty cycle and direction.


You probably could use the internals of a small servo to drive the L298 for your motors. below is a search for "monster servo". If your motors have to hold a load, you probably need to use motors with worm gears.

Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0


Thank you all! I Attach my design and you could see pots beside the neck and on top of head motor. I'm thinking may be good idea to double pot per motor, then feed each pair to a filter and get rid of error, then try a PID (don't have skills for).
I'd study the search, sure I must know in detail the internals of servo and hope it ends to learn to hold the load with dc motor.

There's nothing stopping you from putting a feedback loop on your motor control

Well, unfortunately what is stopping me is lack of skills in control theory: I've not done the homework, not finished a single control theory book (but have chosen what to read, it has matlab simulations to pass to hopefully couple theoretical understanding with some intuition). I'd give a try to the PID lib you kindly suggested but hardly imagine that in this concept any good result comes without sound theoretical background and gained intuition in putting them to work.

I want to create a friction device but have nothing to start from other than my own idea. I learned that better to find examples of others, before realizing own idea, so not to reinvent the wheel. I don't know any similar project or what to google for. If you got something, please kindly leave me some links.

I have a small experience in feedback: I used an IR-range finder sensor and programmed it so that:
1. servo on which the sensor is installed, turns right all the time until detecting an object
2. when detected, servo turns to left edge of object until losing it, back to 1.
The result was not bad: robot could follow the object by edge.
I think with pots on the neck I'd have the same story: motor turns toward set point and sure won't stay on it but pass it over, then returns. The error of pot will make problems I think.


ironbot, do you have some kind of continuously-rotating pots? Most have somewhat less than 360° of rotation before they hit an internal stop. If you are gearing your motor to your pot with a 1:2 ratio, your motor will not be able to move more than 180° before it hits the stop in the pot.


Rotary encoders would allow a full 360°with the added bonus of a digital output.  Although exactly type depends on how much you are willing to spend.  There rotary encoders specifically designed for use with motors but expect to pay between $30 to over $100 (at least for low volume orders) a piece.  There are others intended for much lighter duty, like input knobs those can be less than a $1.00.  Here's some of the selection avaialble at from one major supplier.

Go Up