View Full Version : Servo motor control : pc parallel port

09-22-2009, 07:52 PM
How do we go about controlling a servo motor using pc parallel port??
Is it even possible??

I came across many links for stepper but no relevant link for a servo motor

09-22-2009, 07:55 PM
Also, the motor i have has 5 wires while on the web, i read of only servos of 3 wires. It is most probably not a stepper ass resistance readings do not comply and are very odd

Also, the motor runs using two wires connected to an adaptor which makes me doubt if it is a servo or not

09-22-2009, 10:53 PM
Its not a servo motor.
Post a pic to remove all the mystery surrounding this mysterious object.


09-22-2009, 11:42 PM

I am new to photo sharing so forgive me if the images are not shown

If you can see the images, then the paired wires can be used to run the motor by an adaptor while the other three do not respond to voltage

09-23-2009, 09:03 AM
its a dc motor with an encoder.

09-23-2009, 09:07 AM
It is possible to interface with PC parallel port, but does you PC have one?
You will need a driver.

where did you get this from? did you rip it off from some old machines, or did a shopkeeper rip you off saying this will give 10Kg torque and can be driven at 3v??

09-23-2009, 02:10 PM
None of the above
Actually my brother got his from his seniors at college
Is this a pseudo servo motor?? What function does this serve??

My PC has a parallel port so it is not a problem

How do we go about interfacing it?? Is it very complicated?? Till now, I have done very few projects (stepper motor pc interface, rc car pc interface)??

09-23-2009, 08:43 PM
@agpraneet: That is 100% a servo motor. To control this kind of servo motor you need slightly complicated circuitry. It can be done using a parallel port, but you will need to be a little clever with the control code and the drive circuitry. I've used the same servo motor in a closed loop vacuum pump (several years ago, so don't ask me for schematics or firmware files), I used a LM629 to control the motor (w.r.t the encoder), a PIC16F72 for positioning, and built a MOSFET drive to power the motor based on the LM629 signals.
Hope this helps.


Debu :)

09-23-2009, 10:18 PM
Thanks for the reply
Can you explain the five wires?? Is it normal as I am confused as 'allbits' said it was a dc motor with encoder. It seemed logical as it also works as a normal dc motor though the rotation is very slow.

Also, What you said about the interfacing, it would take me time to make out as I didn't understand much about it but thanks all the same. It's the best resource I have come across till now.

Please resolve the contention- dc motor with encoder or servo motor


09-23-2009, 10:56 PM
@agpraneet: A DC Motor with an encode is a servo, don't get confused with the Hobby Servos (which use a Potentiometer instead of an encoder). The 5 wires are (not in order):

1) Motor +
2) Motor -
The above two wires are for the motor. These will go into the motor drive.
3) Vencoder
4) Encoder-A
5) Encoder-B
The above 3 wires are for the quadrature encoder. These will go into the LM629.

The LM629 will give the signals to the motor driver. The LM629 will be controlled using pulse width from your uC (like a hobby servo, except there will be continuous rotation). Study the LM629 datasheet well, it requires a lot of external components (OpAmp, DAC etc.) to correctly work (this part is slightly tricky). You can build your motor driver by simply using 2 N-Channel MOSFETs and 2 P-Channel MOSFETs.


Debu :)

Edit: Another thing, the motors which I had used, required 60v! So, get all the facts in order before building anything.

Edit2: Also, the encoder is optical, and probably works on 5v, use a multimeter and treat the encoder leads as LEDs to find out which lead does what. Passing any wrong voltages will destroy your encoder.

09-24-2009, 01:13 AM
Well it seems I would have already fried the encoder for i have tried already tried odd things with it (connected an adaptor to the three encoder wires)

Anyways, is there a way to test if it is working or not??

The LED thing went over my head. Can you explain in detail

Forgive me for me being a novice

09-24-2009, 09:25 AM
Give +5 to the red wire of the encoder and GND to the black wire. (it looked like red, black and white in the pic)

Rotate the motor (the bottom wires) by using a separate power supply - say 6 v. use a multimeter/led and see if pulses are coming out of the white wire. The ground of the multimeter should be connected to the ground of the +5 volt supply.

if you are getting pulses, you are still on. or else, rip off the encoder and research.. Frying things are a good way to learn..

The motor you have has a gearbox and thats why its slow.

If you are still on, come back, and we'll see how to connect it to a parallel port.

09-24-2009, 11:13 AM
I connected the motor to a 6v supply and supplied current to the encoder using pc parallel port(couldn't think of any 5v supply) using a previously made circuit

I checked with the multimeter. The voltage provided to the ends was not 5v but 2v

Nonetheless, the voltage reading between white and black wire fluctuated from 0.07 V to 0.11 V in a fixed pattern. I suspect it to be a 'pulse' Is it??

Also the current reading fluctuated

So it makes me feel the encoder is working at least??

09-24-2009, 05:12 PM
@agpraneet: You are doing it slightly wrong. In a 3 wire encoder, you need to pull up the A and B. For each pulse, it will become low. Basically the symbols are Not-A (Ā) and Not-B.


Debu :)

09-24-2009, 10:52 PM
Isn't what i did enough to check if it is working??

If not, could you tell me what steps I need to modify as provided by allbits

09-25-2009, 10:29 PM
DO NOT use pc parallel port for the supply.

use 3 x 1.5 volt AA cells if you dont have a 5 V supply.
I dont think its quadrature. Its just one signal line and power to the encoder.

Connect the output to a CRO. or use a transistor to switch the pulses, and connect an LED to the o/p of the transistor. Move the shaft slowly and see if the LED blinking rate increases as you increase the speed. If so, your encoder is still alive.

10-12-2009, 02:36 PM
Sorry for the delay
I did what you suggested me but the led did not glow at all
When I ckecked with the multimeter, i found that the current was too low(in micro A) so maybe that's why??
I used a bc57 transisitor for the purpose
Do LEDs also have specifications?? If so, what kind of leds should be sed??
So where does it take us to??

10-12-2009, 04:36 PM
Ok so I couldn't resist myself and so i opened the top cap of the motor, expecting to find some complex circuitry at work

But, to my surprise I just found the three wires connected to three concentric circles(probably a potentiometer) and no optical encoders as i previously thought

Is this called an encoder

I will post the pictures shortly

10-13-2009, 05:01 AM
Yes a potentiometer attached to the axle is an encoder. Position of the wheel is measured by potential difference or change in current because of change in resistance.


10-13-2009, 12:00 PM
Thank you sir for replying
As you might have judged, we were trying to make out if it was working
But, as it is not a optical encoder, it does not have much to be fried

So, I assume it should be working

Plus, it makes our task even more difficult to interface it as we will also need to make a circuit to decipher the signals

Correct me if i am wrong

10-13-2009, 12:02 PM
Also, is the information enough to start building a circuit

If yes, then what all components do i need

I will buy them as soon as possible

10-15-2009, 10:42 PM
post the pics.. :D

10-16-2009, 02:23 AM
Ok Sorry for the late reply... do this small experiment to check if it is a potentiometer... connect the outer two wires to 5V supply low amperage. Connect the middle wire and ground to to a multimeter and power the motor slowly so that it rotates slowly..if you are able to see a gradual change in voltage based on the rotation, you have got a pot connected to the axle..

After that .. you need an adc to convert that change in voltage to numbers and carry on your position sensing with that.

Hope that helps..

P.S. I am not "sir"..not yet

10-16-2009, 01:13 PM
I connected the motor to a 6v supply and supplied current to the encoder using pc parallel port(couldn't think of any 5v supply) using a previously made circuit

I checked with the multimeter. The voltage provided to the ends was not 5v but 2v

Nonetheless, the voltage reading between white and black wire fluctuated from 0.07 V to 0.11 V in a fixed pattern. I suspect it to be a 'pulse' Is it??

Also the current reading fluctuated

So it makes me feel the encoder is working at least??

Is this sufficient??

I m trying to take the pics but till now, i have no been able to get a single picture with all the details
Will post them as soon as possible

Thank you for the reply

10-16-2009, 08:42 PM
Ok.. Sorry for not going through your previous posts carefully..

did you see anysort of change in the output of the encoder when you increased or decreased the speed of the motor ?


10-19-2009, 12:07 AM

10-19-2009, 12:08 AM
Oh, I think I saw the frequency increase, but it may be a mistake

Can't say for sure

10-19-2009, 04:53 AM

That doesnt look like a potentiometer. and the focus is messed up.. please get some pics with the focus set right and also showing where the wires come out of.

that would be helpful. It sucks when something as controlling a motor takes that much of your time and effort because of lack of information. Well, if you know the rpm ratings of the motor, you can do a software based encoder where you calculate the distance based on the speed based on the voltage provided.Its a long shot and comparatively less accurate but gets the job done and you have a direction to go.. or how about buying an encoder module?

I would suggest not wasting your time on junk and working towards the larger picture.

Just a suggestion no offence.


10-19-2009, 07:47 PM

So, I uploaded some seemingly better pics

three concentric circles are visible and the 3 wires are connected to them

That's what made me think it was a potenetiometer

Well, I quite agree I shouldn't be wasting time on junk like this but actually, i dont have any larger picture

I just pass time trying to understand things around me. I dont know much in this field and am only beginning to take interest. I dont want to go on a shopping spree without knowing anything!!

Anyways, I'm trying to make a helicopter kind of a thing but I have got no headaway
I guess I need to scrap that as I can't find many resourcces for it!!!

But thanks for the guidance and for everything

10-20-2009, 05:23 AM
Hey Praneeth

The image link leads to a private page requiring password..
If you are just trying to understand then nothing better than that, I remember spending three months on a weird British motor with 5 cables for just the motor sans the encoder. I remember bugging Doc a lot regarding the motor. So yeah all that gives you a lot of info. I thought that you were actually working on a project and were stuck with the motor control. and thought why waste time figuring a motor when you can just buy a new one and get on with other aspects of the project.

Keep asking doubts and we will answer them to the best of our knowledge.


10-20-2009, 01:13 PM
ohh sorry
The password is "pictures"
I will edit the post after you see the password

Also, if possible have a look at my other post "making a motor lift on its on"

I cant get any headway in that

10-21-2009, 07:53 PM
hi hi

Its surprising that you got any kind of voltage, from those wires. Looking at your pictures, it looks like you have a gray code encoder disc.

What you have, is a slip ring. 3 slip rings in fact. But it is not clear from the picture if the 3rd ring is coded. In simple words, its a rotary encoder. If the code is gray or not, i dont know, but it looks very much like a 3 bit gray code disk.

What happens is, when the shaft moves, the shaft gets contact with the track - and the track is connected to the wires. These are simple switches. Google for gray code rotary encoders, and you will know what i mean.

It would have been better if the pictures shows the connection of wires to the disk. chose a different angle. But i guess, you must be able to make out how to go from here. Try thinking, rather than asking every little thing here. NO offence, but its a better way to learn.


10-21-2009, 11:53 PM

Have a look at this
This is only a rough sketch. Please ignore the lighter lines
W goes to white wire, b to black and r to red
However, the projections on the outer and inner rings are somewhat placed like this only. no symmetry

I guess it is some encoding after all
Also, the part that moves on the rings has been marked red to show that it moves on the projections but not on the rings i.e its width is such

My theory is that the part that moves on the surface when comes in contact with the projections makes connection between the inner and middle and the outer and the middle

This is some kind of signal for the position. Maybe it is gray code as allbits described

10-22-2009, 09:50 PM
its no gray code, its just a custom made encoder. (for that particular appication from which you ripped off the motor.)

It would have saved a lot of time if you have posted things in detail in one of the previous posts..

If you are doing your graduation, you must be having enough common sense to make out how this thing works. !!!

If not, you should be trying to build it(common sense), before venturing into anything else.

Just look at the contacts and THINK what happens when the shatf rotates.

It will solve all the mysteries surrounding it.

10-22-2009, 11:29 PM
forgive me for my folly
I only realised yesterday that a camera could never convey the full thing that I see

Again, please forgive me for making this 33 post s long!!! I could have wrapped it up in 3 posts. I am really sorry

What I inferred, I conveyed in my last post. I verified by an ohmeter and it confirms my theory

But, what I still dont get is how to read resistances/voltage/current fluctuations using an electronic circuit??? If I take the middle ring as ground, then it may be possible to take resistance readings but can they be used to infer position

Also, as you say it is custom made, can it tell the location cause i think it cant tell it exactly

Yes it can tell when one complete rotation takes place using the inner most ring but not the exact location. So, it could tell you the speed at least (considering no angular acceleration)

How can we take input from the inner ring??

Again I apologise for troubling you.
Being a complete novice, I look upto you people to understand things better

10-23-2009, 05:45 AM

just give it 5 volts. that will give 5v pulses at times, make your micro read the pulses, make it calculate the time between two pulses. Simple.


10-26-2009, 11:49 PM
Thanks for the reply

Can you give me some links regarding reading the voltage/current reading using pc parallel port

Also, I am planning t buy the arduino/freeduino board offerred by roboticsindia. Would it help in this regard????

10-27-2009, 06:07 AM
If you look through the topics link in the navigation bar, you will find awesome parallel port tutorials written by gerry.

Yes the board will help you obviously, as a matter of fact you will have an easier time doing ADC and other compare operations with it.


11-16-2009, 04:09 PM
Thanks for the help
This is just for a formal closure of the topic as I have been able to do what i wanted to

I connected the red and white wires to two input pins on the parallel port(pin 11 and 12) and the black one to ground

And the motor wires i connected to parallel port using l293d. And using timer in VB, i am able to determine the rpm and to some accuracy the position of the rotor. that is quite useless at high rpms but somewhat useful at low rpms

And in the process, I fried two parallel port pins which are now grounded

Again thanks to allbits,rao and all