Parallel Port Question

kevinthenerd

Platinum Member
Jun 27, 2002
2,908
0
76
I'm designing a stepper motor controller for a homebuilt CNC mill. What's the maximum safe current that I can sustain on a single pin from an onboard parallel port? I'm wondering... if I don't draw too much... whether I can run the stepper motor directly off of the port. I see a lot of low-power devices running directly off the port, but I wonder whether more than a couple of mA is going to be too much.

If not, I think I'll just use a relay and run a lot of current to get a good stiff and predictable motion. I really don't feel like bothering with a stepper motor controller unless it can be made very easy to use. I'm planning on coding my own controller software in QuickBASIC on a junk computer. These motors are rated to 2.9A, so let me know what you think. I've seen a motor operate at double of its rating, but I'm not going to push my luck here.
 

phisrow

Golden Member
Sep 6, 2004
1,399
0
0
I would definitely use a relay, and possibly a few other measures. From what I've read, source is less than 5ma per pin, sink less than 30. A 3 amp motor probably wouldn't run, and might well be seen by the port as a dead short. It isn't exactly impossible to kill the port that way. If you can, an intermediate layer of transistors, and maybe optoisolators, would really be a nice thing to do, for the sake of your port.
 

kevinthenerd

Platinum Member
Jun 27, 2002
2,908
0
76
only 5mA?? Wow. You're right... that might not be enough to run the relays! Transistors seem to be the way to go... maybe a class D amplifier sort of thing to run a relay which in turn runs the motor. I might be able to get away with running the transistor directly into the motor, but that might be pushing it.
 

PottedMeat

Lifer
Apr 17, 2002
12,363
475
126
What kind of motors are you using? Bipolar or Unipolar? If they're unipolar you just need a NPN BJT or N Power MOSFET to switch the current through the coil. An optoisolator would be nice ( maybe a driver for the MOSFET too for faster switching ), but not really necessary between the port and the switching transistor. This way you can just use any supply ( +12/+15/whatever ) to run as much current as you please though the coil.

You can use a single IC like the ULN2003 which has enough drivers for 7 coils.( these are only 500mA max, you can probably find much higher rated ICs ) It's even got the integrated diodes to kill inductive kickback.

Bipolar steppers will need an H-Bridge for each coil to switch current in both directions. The L298 from STMicroelectronics can do this ( http://www.st.com/stonline/books/pdf/docs/1773.pdf )

For unipolar with the transistors you're basically just using the small current of the parallel port into the base of the switching transistor to control the amps through the coil.
 

kevinthenerd

Platinum Member
Jun 27, 2002
2,908
0
76
To kill inductive feedback, provided response time isn't a top priority, could I just use a capacitor to make it more of a resistive load (to lessen the imaginary component of impedance)?
 

kevinthenerd

Platinum Member
Jun 27, 2002
2,908
0
76
I'm not sure what I really have on my hands here, but it works just fine in unipolar configuration. I tested all the possible wire combinations to discover two sets of V-shaped circuits (two grounds on a total of four coils). I decided that the easiest thing to do would be to just short the two grounds and switch the positive sides. While it has four coils, it has 50 sets of coils (200 steps), which is more than enough for my application. After gearing, this will give me a resolution of a thousandth of an inch. If I decide to use combinations of coils (for smoother operation and finer precision), I can get resolution of 0.0005 of an inch, which is pretty cool considering I didn't spend anything on the stepper motors or other parts of the setup. I once wondered why this base is so heavy, but now, realizing that the resolution is so fine, I can see why... you have to fight hard against vibrations with something like this.
 

kevinthenerd

Platinum Member
Jun 27, 2002
2,908
0
76
I've been doing some reading, and I have a question. Why are you recommending a MOSFET instead of a plain old BJT?
 

jmcoreymv

Diamond Member
Oct 9, 1999
4,264
0
0
Originally posted by: kevinthenerd
I've been doing some reading, and I have a question. Why are you recommending a MOSFET instead of a plain old BJT?


I'm not 100% certain, but MOSFETs can have lower on-resistance, virtually no gate current, and they have built-in reverse diode protection (although I'm not sure they will provide adequate performance).
 

kevinthenerd

Platinum Member
Jun 27, 2002
2,908
0
76
I've been using this to start with: http://www.kpsec.freeuk.com/trancirc.htm

There's a section in there: "Connecting a transistor to the output from a chip"
I'm working with these specs/assumptions:
Stepper motor: R=1.2 ohms, rated to 3.4V/2.9A
External input voltage for the circuit (to run the stepper motor): 3 V
Parallel port: I max=5mA, V=5V
Ic=2.5A
hfe min = 2500 (which is rather high)

This is where I'm a bit stuck. The only good way to get that kind of gain, from what I've seen, is to use a Darlington pair or something.
 

kevinthenerd

Platinum Member
Jun 27, 2002
2,908
0
76
Originally posted by: jmcoreymv
Rather than trying to build your own H-Bridge, you might want to take a look at something like this: http://www.sparkfun.com/commerce/product_info.php?products_id=748

Also Allegro Micro makes some really good stepper motor drivers that can do more precise movements via microstepping. I've used one on an auto-alignment system before.

I don't think an H-bridge is necessary for a unipolar stepper motor, which is what I think I have.
 

kevinthenerd

Platinum Member
Jun 27, 2002
2,908
0
76
Originally posted by: jmcoreymv
Rather than trying to build your own H-Bridge, you might want to take a look at something like this: http://www.sparkfun.com/commerce/product_info.php?products_id=748

Also Allegro Micro makes some really good stepper motor drivers that can do more precise movements via microstepping. I've used one on an auto-alignment system before.

Microstepping is not very repeatable and certainly not linear. Even quarter-steps aren't a good idea. Half-stepping is about the only way to go when accuracy counts more than precision.
 

kevinthenerd

Platinum Member
Jun 27, 2002
2,908
0
76
Ok, let me know what you think of this....

I'm thinking of using the TIP-120 NPN Darlington transistor
hFE min = 1000, but at the operating conditions I'm expecting, it should be closer to 4000 according to the datasheets
Ic max = 5A, well within the 2.5A I'll be using

So, designing it....
Icmax = VS/RL = 3 V / 1.2 A = 2.5 A
hFEmin = 5*Ic/Ii = 2500
I'll assume from here on out that the transistor has an hFE of exactly the design requirement of 2500, since it could be anywhere from 1000 to 4000 depending on operating conditions, which are hopefully favorable.
(Ic = collector current, Ii = input current from the parallel port)
RB = resistor in series with the base of the transistor = (Vi*hFE)/(5*ICmax)=0.4*hFE=400 Ohms

Let me know where I've gone wrong here.
 

kevinthenerd

Platinum Member
Jun 27, 2002
2,908
0
76
I think I have things sorted out so far to use the SLA4031 Darlington Array. Does that look like a good choice? It's got a good gain and current rating, and I might not even have to use a heatsink if I can get it to switch properly.

Someone mentioned putting a resistor in series with the stepper motor and running a higher voltage at the source, keeping a constant current but allowing the stepper motor to turn on more effectively. I would suppose this would simulate a resistive load without inductive problems. Is there any truth to this?
 

kevinthenerd

Platinum Member
Jun 27, 2002
2,908
0
76
(so right now I need to source that darlington array, a breadboard, a paralllel socket, and some resistors, make the vertical axis, and get soldering)
 

kevinthenerd

Platinum Member
Jun 27, 2002
2,908
0
76
Ok, can someone verify this?

I want to use (3) SLA4031 Darlington arrays. I'm going to use 12 data lines on the parallel port (X,Y on data and Z on control). I'm going to use half-stepping for quasi-gray encoding: 0001, 0011, 0010, 0110, 0100, 1100, 1000, 1001. Between the port and the chip will be a 1.2k resistor. The outputs of the chips will have a 5.6 ohm resistor in series with the 1.2 ohm load, and the supply voltage will be 17V from an old laptop power supply. My resistors perfectly match the E12 series, assuming I can find them. The trick will be cheaply finding 5.6 ohm resistors that can handle the 2.5 amps running to the motors.

(My software will account for the fact that the control line has bits 0, 2, and 3 inverted. I'll write it on QuickBASIC for operation on a crappy old machine.)