Computer Controlled Stepper Motor

Published 02 November 07 05:29 PM | Coding4Fun 

In this article, we will connect a stepper motor to our computer's parallel port, and then we will write some code to control it with the scroll wheel on a mouse (video). If you have never worked with stepper motors, you will surely have a lot of fun with this project. With stepper motors, you can build things such as robots, automatic fish feeder, or even a computerized etch-a-sketch! I'll start off by discussing the basics of parallel ports and stepper motors. Then, we will build the driver circuit required for connecting a stepper motor to a parallel port. In the final section, we will learn how to communicate with parallel ports and how stepper motors are controlled.
Ashish Blog

Difficulty: Easy
Time Required: 1-3 hours
Cost: Less Than $50
Software: Visual C# or Visual Basic Express Editions
Hardware: A 5-wire unipolar stepper motor (these could also be salvaged from old 5¼" floppy disk drives), ULN2003 IC (stepper motor driver), wire, stripboard (or a solderless breadboard ), solder and DB-25 Male connector (buy these two if you can solder. Soldering is not necessary for doing this project, but it will ensure that your connections are secure), DB25 (female/male) parallel port cable, a multimeter, a power adapter (with voltage rating depending on your motor's requirements)
Download: Download

WARNING: Before we begin, I would warn you that the PC parallel port can be damaged quite easily if you make incorrect connections. If the parallel port is integrated to the motherboard, repairing a damaged parallel port may be expensive, and in many cases, it is cheaper to replace the whole motherboard than to repair that port.

         Your safest bet is to buy an inexpensive I/O card which has a parallel port and use it for your experiment. If you manage to damage the parallel port on that card, replacing it will be easy and inexpensive.
Don't let that warning worry you too much, because there is a lot of fun to be had with these types of projects. Find yourself an 'antique' PC, if you can, or just buy an I/O card which has a parallel port.

Parallel Port Basics
A parallel port is a socket found in personal computers for interfacing with various peripherals such as printers, scanners and even some webcams. On many computers, particularly laptops, the parallel port is omitted for cost savings, and is considered to be a legacy port. However, in laptops, access to the parallel port is still commonly available through docking stations. Here's a picture of a DB-25 parallel printer port on the back of a laptop.

When a PC sends data to a printer or other device using a parallel port, it sends 8 bit of data (1 byte) at a time. These 8 bits are transmitted parallel to each other, as opposed to the same eight bits being transmitted serially through a serial port.
The pin assignments on a parallel port are as follows:

clip_image002  clip_image002[8]

Pin No.

Pin Name

Description

1

Strobe

Usually remains high but is pulled low whenever
the computer sends a byte of data. This drop in
voltage tells the printer that data is being sent.

2 - 9

D0 - D7

The eight data ports. We will be using these in our
project

10

nAck

Sends the acknowledge signal from the printer to
the computer.

11

Busy

If the printer is busy, it will set this pin to high.
Then, it will pull to let the computer know it is
ready to receive more data.

12

Paper Out

The printer lets the computer know if it is out of
paper with this pin.

13

Select

Device indicates it is ready by pulling high.

14

Autofeed

The computer sends an auto feed signal to the
printer through Pin 14.

15

Error

If the printer has any problems, it drops the voltage
to less than 0.5 volts on Pin 15 to let the computer
know that there is an error.

16

Initalize

This pin is pulled low by the computer whenever a
a new print job is ready for the printer.

17

Select-In

Pin 17 is used by the computer to remotely take
the printer offline.

18-25

Ground

These are mostly used for competing circuits

What are stepper motors?
Stepper motors are brushless, synchronous electric motors which can divide a full rotation into several steps. While conventional electric motors spin continuously, stepper motors only move one step at a time. They can be used for precise motion and position control as they can be turned to a precise angle.
The simplest way to think of a stepper motor is a bar magnet and four coils:

clip_image002[10]

    When current flows through coil "A" the magnet is attracted and moves one step forward. Then, coil "A" is turned off and coil "B" is turned on. Now, the magnet takes another step, and so on. A similar process happens inside a stepper motor, but the magnet is cylindrical and rotates inside the coils. For a stepper motor to move, these coils should be activated in a correct sequence. These sequences are called stepping modes:

1. Single Stepping (Single-Coil Excitation): This is the simplest stepping mode. In this mode, each successive coil is energized and the motor moves one full step at a time. Therefore, a motor with a step angle of 7.5 degrees will rotate through 7.5 degrees with each step. Here's how single stepping works:

Pulse

Coil 1

Coil 2

Coil 3

Coil 4

1

1

0

0

0

2

0

1

0

0

3

0

0

1

0

4

0

0

0

1

clip_image002[12]

2. Half Stepping: The difference between single stepping and half stepping is, that for the same step rate, half stepping gives you half the speed but twice the resolution of a single step. For a motor with a step angle of 7.5 degrees, half stepping it would result in approximately 3.75 degrees of rotation. Here's how it works:

Pulse

Coil 1

Coil 2

Coil 3

Coil 4

1

1

0

0

0

2

1

1

0

0

3

0

1

0

0

4

0

1

1

0

5

0

0

1

0

6

0

0

1

1

7

0

0

0

1

8

1

0

0

1

clip_image002[14]

3. High Torque Stepping (Two-Coil Excitation):

As the name suggests, this stepping mode would result in higher torque:

Pulse

Coil 1

Coil 2

Coil 3

Coil 4

1

1

1

0

0

2

0

1

1

0

3

0

0

1

1

4

1

0

0

1

Now that we know a little about parallel ports and stepper motor, its time to get started!


Building the electronics
The electronics for controlling a stepper motor with a parallel port is very simple. We will be making use of the ULN2003 driver IC, which contains an array of 7 darlington transistors with integrated diode protection, each capable of driving 500mA of current. The easiest method of building the circuit is on an electronic breadboard. They are available at all electronics shops. Here's the circuit:

clip_image002[16]

As you can see in the diagram, D0 (Pin 2) on the parallel port is connected to Pin 1 on the ULN2003 stepper driver IC,
D1 (Pin 3) is connected to Pin 2 on the IC,
D2 (Pin 4) is connected to Pin 3 on the IC, and
D3 (Pin 5) is connected to Pin 4 on the IC.
Wires on a stepper motor are color coded. For identifying which wire belongs to which coil, you could try searching for your motor's specs on the Internet. If you are unable to find detailed information for your motor (like me), then you could simply use a multimeter for identifying the wires on your stepper. First of all, identify the common power wire of your stepper by checking the resistance between pairs of wires using a multimeter. The common power wire will be the wire with only half as much resistance between it and all the others. For my motor, the red wire is the common power wire:

clip_image002[18]

Yellow wire - Coil 1
Brown wire - Coil 2
Red wire - Common power wire
Orange wire - Coil 3
Black wire - Coil 4

However, if your guesses are not right, the motor will not rotate, but will only wiggle from side to side. So, I would recommend reading this article if you're not sure. After you've recognized the wires, just build the circuit on a breadboard or a stripboard. I initially built everything on a breadboard, but in the end, I soldered everything on a stripboard.

clip_image002[20]

   In the picture above, notice that I've inserted the wires from the IC directly into my parallel port. This is a very clumsy thing to do. So, I soldered a DB-25 MALE connector so that it would be easier to plug/unplug the circuit to the parallel port cable:

clip_image002[22]

   Test the circuit with a multimeter and make sure all the connections are correct and that there are no short circuits. Then, plug one end of the parallel port cable to the circuit and the other end to the parallel port socket on your computer. That's it! Its time to write some code! :)

Let the code do the rest...
Accessing the parallel port was much easier in versions of Windows that did not use the Windows NT kernel. In the DOS and Win9x days, programs could access the parallel port using simple inportb() and outportb() subroutine commands. The OS would happily let programs input and output data to the parallel port in the form of 16-bit integers. However, in operating systems such as Windows XP, access to the parallel port is inhibited. This is when the InpOut32.dll project came. This free library quickly became the standard way to access the parallel port in any version of Windows among people interested in parallel port interfacing and programming.
For using inpout32.dll with your code, place the dll in your System32 folder. Now we'll use P/Invoke as shown below:

C#:
 1: private class PortAccess
 2: { 
 3: [DllImport("inpout32.dll", EntryPoint="Out32")]
 4: public static extern void Output(int address, int value);
 5: }
VB:
 1: Private Class PortAccess 
 2: Public Declare Sub Output Lib "inpout32.dll" Alias "Out32" (ByVal address As Integer, ByVal value As Integer)
 3: End Class

The PortAccess.Output method takes in two parameters, address and value. For knowing your parallel port address, go to Control Panel > System > Hardware > Device Manager > Ports (COM & LPT) > Printer Port (LPT1/LPT2) > Properties > Resources > Resource Settings. Here, you'll see your parallel port address in hexadecimal format:

clip_image002[24]

As you can see in the screenshot above, my I/O range is "0378 - 037F". Hexadecimal "0x378" is equivalent to "888" in decimal. If you are using LPT2, your address would probably be "0x278" (Decimal equivalent is "632").
Now, a possible call from managed code might look like this:

C#:

PortAccess.Output(888, 255);

VB:
PortAccess.Output(888, 255)

Here, decimal "255" is equivalent to "1111 1111" in binary. Sending "255" would set all output ports on your parallel port (D0 - D7), to high. Similarly, sending "0" would set all of them to low.
Lets write some code to move our stepper motor one full step at a time. Recall that in single stepping, each successive coils in the motor are energized in the following sequence, one coil at a time.

Here's a sample code for executing this sequence and moving the stepper in one direction:

C#:

 1: PortAccess.Output(888, 1); // 1 decimal = 0001 binary. This will set D0 to high
 2: System.Threading.Thread.Sleep(100); // delay
 3: PortAccess.Output(888, 2); // 2 decimal = 0010 binary. This will set D1 to high
 4: System.Threading.Thread.Sleep(100); // delay
 5: PortAccess.Output(888, 4); // 4 decimal = 0100 binary. This will set D2 to high
 6: System.Threading.Thread.Sleep(100); // delay
 7: PortAccess.Output(888, 8); // 8 decimal = 1000 binary. This will set D3 to high

VB:

 1: PortAccess.Output(888, 1) ' 1 decimal = 0001 binary. This will set D0 to high
 2: System.Threading.Thread.Sleep(100) ' delay
 3: PortAccess.Output(888, 2) ' 2 decimal = 0010 binary. This will set D1 to high
 4: System.Threading.Thread.Sleep(100) ' delay
 5: PortAccess.Output(888, 4) ' 4 decimal = 0100 binary. This will set D2 to high
 6: System.Threading.Thread.Sleep(100) ' delay
 7: PortAccess.Output(888, 8) ' 8 decimal = 1000 binary. This will set D3 to high

Switch on your motor's power supply by connecting the power adapter. Then try running this piece of code to see if it works!
I like using the scroll wheel on my mouse for controlling the motor. For doing this, first create an enumeration for the different stepping modes:

C#:

 1: private SteppingMode stepMode;
 2:  
 3: private enum SteppingMode
 4: { 
 5: SingleStep, 
 6: HalfStep, 
 7: HighTorqueStep
 8: }

VB:

 1: Dim stepMode As SteppingMode
 2:  
 3: Private Enum SteppingMode 
 4: SingleStep 
 5: HalfStep 
 6: HighTorqueStep
 7: End Enum

The form level variable, stepMode stores the selected stepping mode.
Next, we'll wire the form's MouseWheel event to an event handler. Write the following code the InitializeComponent function or the form's constructor:

C#:
this.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseWheel);
VB:
AddHandler Me.MouseWheel, AddressOf Me.Form1_MouseWheel

Now, we will provide the implementation of Form1_MouseWheel in our form. I've used a StatusStrip with four labels for displaying the stepping mode, direction of movement, and the decimal value being sent to the parallel port along with its binary representation. For determining the direction in which the scroll wheel rotates, we'll use the MouseEventArts.Delta property, which, in the words of MSDN, gives a signed count of the number of detents the mouse wheel has rotated. A detent is one notch of the mouse wheel. Here's a sample code for single stepping the motor with the scroll wheel:

C#:

 1: private int output = 0;
 2:  
 3: private void Form1_MouseWheel(object sender, MouseEventArgs e)
 4: {
 5: switch (stepMode)
 6: {
 7: case SteppingMode.SingleStep:
 8: // Single Stepping
 9:  
 10: if (e.Delta > 0)
 11: {
 12: if (output == 1) output = 2;
 13: else if (output == 2) output = 4;
 14: else if (output == 4) output = 8;
 15: else if (output == 8) output = 1;
 16: else output = 1;
 17:  
 18: directionStatusStripLabel.Text = "Direction: 1";
 19: decimalStatusStripLabel.Text = "Decimal: " + output.ToString();
 20: binaryStatusStripLabel.Text = "Binary: " + ConvertToBinary(output);
 21: PortAccess.Output(888, output);
 22: }
 23: else
 24: {
 25: if (output == 1) output = 8;
 26: else if (output == 8) output = 4;
 27: else if (output == 4) output = 2;
 28: else if (output == 2) output = 1;
 29: else output = 1;
 30:  
 31: directionStatusStripLabel.Text = "Direction: 0";
 32: decimalStatusStripLabel.Text = "Decimal: " + output.ToString();
 33: binaryStatusStripLabel.Text = "Binary: " + ConvertToBinary(output);
 34: PortAccess.Output(888, output);
 35: }
 36: break;
 37: }
 38: }
 39:  
 40: private string ConvertToBinary(int DecimalValue)
 41: {
 42: // Decimal -> Binary conversion
 43:  
 44: int digit;
 45: string binaryForm = "";
 46: char[] binaryArray;
 47:  
 48: do
 49: {
 50: digit = DecimalValue % 2;
 51: binaryForm += digit;
 52: DecimalValue /= 2;
 53: } while (DecimalValue != 0);
 54:  
 55: //The digits in the variable, binaryForm, are in reverse order
 56: // We will reverse it back to normal.
 57: 
 58: binaryArray = binaryForm.ToCharArray();
 59: Array.Reverse(binaryArray);
 60:  
 61: binaryForm = new string(binaryArray);
 62:  
 63: return String.Format("{0:0000}", int.Parse(binaryForm)); ;
 64: }

VB:

 1: Dim output as Integer = 0
 2: Private Sub MainForm_MouseWheel(ByVal sender As Object, ByVal e As MouseEventArgs)
 3: Select Case (stepMode)
 4: Case SteppingMode.SingleStep
 5: ' Single Stepping
 6: If (e.Delta > 0) Then
 7:  
 8: If (output = 1) Then
 9: output = 2
 10: ElseIf (output = 2) Then
 11: output = 4
 12: ElseIf (output = 4) Then
 13: output = 8
 14: ElseIf (output = 8) Then
 15: output = 1
 16: Else
 17: output = 1
 18: End If
 19:  
 20: directionStatusStripLabel.Text = "Direction: 1"
 21: decimalStatusStripLabel.Text = ("Decimal: " + output.ToString)
 22: binaryStatusStripLabel.Text = ("Binary: " + ConvertToBinary(output))
 23: PortAccess.Output(888, output)
 24:  
 25: Else 'If (e.Delta < 0)
 26:  
 27: If (output = 1) Then
 28: output = 8
 29: ElseIf (output = 8) Then
 30: output = 4
 31: ElseIf (output = 4) Then
 32: output = 2
 33: ElseIf (output = 2) Then
 34: output = 1
 35: Else
 36: output = 1
 37: End If
 38:  
 39: directionStatusStripLabel.Text = "Direction: 0"
 40: decimalStatusStripLabel.Text = ("Decimal: " + output.ToString)
 41: binaryStatusStripLabel.Text = ("Binary: " + ConvertToBinary(output))
 42: PortAccess.Output(888, output)
 43: End If 
 44:  
 45: End Select
 46: End Sub
 47:  
 48: Private Function ConvertToBinary(ByVal decimalValue As Integer) As String
 49: ' Decimal -> Binary conversion
 50:  
 51: Dim binaryForm As String = ""
 52: Dim digit As Integer
 53:  
 54: Do
 55: digit = decimalValue Mod 2
 56: If digit = 0 Then
 57: binaryForm = "0" + binaryForm
 58: Else
 59: binaryForm = "1" + binaryForm
 60: End If
 61:  
 62: decimalValue = decimalValue \ 2
 63: Loop Until decimalValue = 0
 64:  
 65: Return CLng(binaryForm).ToString("0000")
 66: End Function

In the MouseUp event of the form, we'll write some code which will allow us to switch between different stepping modes by right clicking on the form. Left clicking on the form would release the motor (i.e. de-energize the coils).

C#:

 1: private void Form1_MouseUp(object sender, MouseEventArgs e)
 2: {
 3: if (e.Button == MouseButtons.Right)
 4: {
 5: // Switch between different stepping modes
 6:  
 7: switch (stepMode)
 8: {
 9:  
 10: case SteppingMode.SingleStep:
 11: stepMode = SteppingMode.HalfStep;
 12: steppingModeStatusStripLabel.Text = "Step Mode: Half";
 13: break;
 14:  
 15: case SteppingMode.HalfStep:
 16: stepMode = SteppingMode.HighTorqueStep;
 17: steppingModeStatusStripLabel.Text = "Step Mode: High Torque";
 18: break;
 19:  
 20: case SteppingMode.HighTorqueStep:
 21: stepMode = SteppingMode.SingleStep;
 22: steppingModeStatusStripLabel.Text = "Step Mode: Single";
 23: break;
 24:  
 25: }
 26: }
 27: else if (e.Button == MouseButtons.Left)
 28: {
 29: // Release the motor
 30:  
 31: output = 0;
 32: PortAccess.Output(888, output);
 33: decimalStatusStripLabel.Text = ("Decimal: " + output.ToString);
 34: binaryStatusStripLabel.Text = ("Binary: " + ConvertToBinary(output));
 35: }
 36: }

VB:

 1: Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs)
 2:  
 3: If (e.Button = MouseButtons.Right) Then
 4: 'Switch between different stepping modes
 5: Select Case (stepMode)
 6:  
 7: Case SteppingMode.SingleStep
 8: stepMode = SteppingMode.HalfStep
 9: steppingModeStatusStripLabel.Text = "Step Mode: Half"
 10:  
 11: Case SteppingMode.HalfStep
 12: stepMode = SteppingMode.HighTorqueStep
 13: steppingModeStatusStripLabel.Text = "Step Mode: High Torque"
 14:  
 15: Case SteppingMode.HighTorqueStep
 16: stepMode = SteppingMode.SingleStep
 17: steppingModeStatusStripLabel.Text = "Step Mode: Single"
 18:  
 19: End Select
 20:  
 21: ElseIf (e.Button = MouseButtons.Left) Then
 22: 'Release the motor
 23: output = 0
 24: PortAccess.Output(888, output)
 25: decimalStatusStripLabel.Text = ("Decimal: " + output.ToString)
 26: binaryStatusStripLabel.Text = ("Binary: " + ConvertToBinary(output))
 27: End If
 28:  
 29: End Sub

Releasing the motor and letting it free-wheel is important, because I've noticed that stepper motors heat up very quickly. I don't know whether one can burn out a stepper motor or not, but the safest way to turn off the motor completely would be to disconnect its power supply.

Conclusion

We have reached the end of this article, but I sure hope it inspires you to start your own experiments with parallel port interfacing and programming. You can use this port to play with a lot of other things like LEDs, relays, etc. Over the last couple of months, I have been using my computer's parallel port for controlling several things, such as lights, fans, RC cars, robots and whatnot. There are things which could be extended, and added to this stepper motor project. You could, for example, use it as a web controlled camera panner. I have used mine as a camera panner which tracks moving objects using a webcam and lasers (video). Just remember that your imagination is the only limit. So, unleash your imagination and the sky is the limit. Have fun!

About the Author

Ashish Derhgawen is an IT student, currently living in New Delhi, India. He has been coding since fourth grade. Some of his other interests are harmonica playing, wildlife and cricket. When he’s not at school, he spends his time working on unusual projects related to robotics, webcams, and electronics besides others. You can reach Ashish through his blog at http://ashishrd.blogspot.com.

Filed under: ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# dNetGuru said on November 11, 2007 1:03 AM:

Great Posting (the first part) ! Happy to know about stepper motors ;)

# Steve said on November 13, 2007 10:48 AM:

Nice work : )

You didn't say much about your power supply or how you wired it up. going from your diagrams I assume you just had a normal 12v 500mA power supply.  Then you wired the positive to the motor +ve and +ve pin on the chip and the negative to the -ve pin on the chip and then to the printer port?

Looking forward to your next project : D

STe

# chad said on November 16, 2007 10:47 PM:

hey i was wondering if u could male it with a 2 coil stepper motor and ya more info on the power supply wiring would be great

# Ankur Saxena said on November 29, 2007 11:59 PM:

hi . i was wondering how do i control 3 motors using a single parallel port ?

do i require a micro-processor in between to control more no. of motors using a single port ? plz guide me on this ... thnx ..

if it is possible kindly get in touch wid me on iamtheone.ankur@gmail.com

Thnx.

# Aruna Dissanayake said on December 8, 2007 3:47 AM:

Hi Ashis

i am very happy after showed your blog. becourse i am very interesting in this subject. i have learned many theaorytical things of your artical.

i wish you all the best.

thank you.

aruna

sri lanka

# Ross Libby said on December 12, 2007 5:39 PM:

For some reason when I printed this, only the first page prints, and 12 blank pages follow.  I had to do 30 screen prints to get this incrediblely VAULABLE information.

I have been looking for exactly this kind of information - output protocol, pin diagrams, and the stepper information was an unexpected bonus.  Great idea also to use "OLD PC" since it is just gathering dust, make it do something useful.  Control solar panels, control room lights, anything.

Great article

# Ashish said on December 23, 2007 9:12 AM:

I'm glad you all liked the article.

Steve, I used a normal 500 mA, 12V power supply.

Ashish

# Cars » Coding4Fun : Computer Controlled Stepper Motor said on December 30, 2007 3:47 AM:

PingBack from http://cars.oneadayvitamin.info/?p=726

# Chuck Sterling said on December 30, 2007 11:18 AM:

Should this also work with a USB-Parallel interface converter? My laptop has only USB. Also, would adding opto-isolation to protect the parallel port be practical and useful?

csterlin at zianet dot com (New Mexico, USA)

# Coding4Fun said on December 30, 2007 6:30 PM:

it should.  I do almost all my dev with a USB to Serial adapter when I deal with hardware.

# Coding4Fun said on January 7, 2008 2:35 PM:

In my last article, we saw how a stepper motor could be controlled with a computer by connecting it to

# Noticias externas said on January 7, 2008 3:01 PM:

In my last article, we saw how a stepper motor could be controlled with a computer by connecting it to

# MSDN Blog Postings » Laser Tracking Camera said on January 7, 2008 3:56 PM:

PingBack from http://msdnrss.thecoderblogs.com/2008/01/07/laser-tracking-camera/

# MSDN Blog Postings » Laser Tracking Camera said on January 7, 2008 3:57 PM:

PingBack from http://msdnrss.thecoderblogs.com/2008/01/07/laser-tracking-camera-2/

# Sharon said on January 17, 2008 4:01 PM:

Hello,

I am currently working on a project to control a stepper motor using the computer parallel port.  I have all of the equipment exactly as you have in your pictures and specifications.  I have tried to use your code to make the computer run, but no luck.  Can you offer some insight on what I can do to make my program work properly?  Note:  I am using VB 2005 express edition.

# Eleazar Herrera Gòmez said on January 17, 2008 6:01 PM:

Hello Ashish sir!!

I wish you to send me an executable  program or a code which runs on Wndows XP for making run a step motor using the ULN2003A here in Mèxico. Please.

I am so desperated and it is part of my therapy for healing of my craneoencefallic traumatism caused 4 years ago here and it sent me to Cuba`s CIREN for my healiing. I keep here doing the neuro healing assisted by a cuban sir, my family, friends, God, etc.

please send me the program, circuit, etc. All I need to do it. Thanks!!!!.

# Ruben said on January 19, 2008 10:37 AM:

Hey man, good stuff.

I was just wondering how the power from the adapter is connected. Is the + to br connected to both the motor common and number 9 on the IC? And where do the - from the adapter go?

Thanx

# Josh said on January 24, 2008 4:19 PM:

inspiring...

But I think that the VB invocation of inpout32.dll should be a private  rather than a public declare shouldn't it?

# Mostafa said on January 24, 2008 8:46 PM:

Hi Ashishrd

I am  Mostafa

I am an engineering student and I am not an expert programmer, so my gradution project is about how to control a stepper motor using a parallel port and I am using C#.The problem is i want the motor"COntrol it" to take it's steps from a text box not with the mouse wheel.So plaese Could you help me.please connect me at my e-mail(mostafaabdelhaliem@gmail.com)

Thank you alot

# Simmy said on January 26, 2008 1:52 PM:

Thanks for the usefull information in this article.

Cheers

# Josh said on February 2, 2008 9:10 AM:

RUBEN

to answer your question....

connect your power supply + to the following:

*The  common power wire (RED on the motor demonstrated above)

* AND to Pin 9 on the IC

connect your power supply - to the following:

pin 8 on the IC (to which pin 25 on the parallel port is also connected.)

i have assumed you are using pin 25 as ground. you could equally use any pin from 18 onwards

the following may assist:

http://electronics-diy.com/electronics/stepper_motors.php

# Derek said on February 2, 2008 1:51 PM:

I can't get the DLL to send the data to the port. I kepp getting the same error message.

SEHexception was unhandled

External component has thrown an exception

# Ravi said on February 2, 2008 9:55 PM:

I like the project, I would like to know which software you use to write your code. I use Visual c# 2005, part of the visual studio package and I can't get my code to work.

I got it to work in linux.

Thanks

Ravi

# chuck sterling said on February 4, 2008 12:26 AM:

Having trouble using a USB-Parallel adapter. Any idea how to discover what port number to use?

# Chuck Sterling said on February 5, 2008 10:57 AM:

I posted a note about port number assignment for the parallel port associated with a usb-parallel adapter, and have since been given to understand that control of the usb-parallel port pins as described here is not generally available, and that special hardware and software is necessary. I'm shelving this project for now. If anyone has relevant information about getting such an interface to work in the manner described here, please let us know.

# Hani said on February 8, 2008 1:24 PM:

Hi Ashish,

Very nice article, I am following your example. I can not seem to get the right voltage out of the ULN2003. I measured the input to ULN2003; it is 0,4.3V for logic 1). The corresponding output is 0, .6V. I am using 12V VCC from an 350 ATX Computer power supply. I  test a 5V input from the power supply. I tried different computers, different ICs with not luck. I can not figure this out. I really appreciate your help.

# JOsH (again) said on February 20, 2008 2:15 PM:

ashish says have a multimeter available and there's a good reason for it! newer computers often TRASH the standards agreed industry-wide in 2001 and output 3.3volts instead of 5volts on the parallel port. since the ULN2003 generally reacts only signals above 4.3volts you might find you have everything set up correctly and yet nothing will work. so..having a multimeter available to measure the output of your parallel port is pretty useful.

in the UK (where i am)  theyre really cheap. www.maplin.co.uk currently sells a basic one for £6 ($12 USD) and you even get another one free with your purchase.

if you're new to this sort of project, keep going guys! you'll get there in the end and good luck.

# Viva said on February 26, 2008 5:49 AM:

Hi Ashish ..

I need a favour on step motor .. I am repairing a laser light wherby the pattern is drive by 2 step motor . This 2 step motor perform as X and Y scanner . This step motor is drive by ULN2803 . So i need a 4 bit input for each step motor . Now i am stuck to convert the logic into pattern . Please help me to solve this .

Please email me to viva@ohmsent.com

thank you

viva

# anjosoviaj said on February 26, 2008 8:22 PM:

Thanks for such a good write up.We are currently doing a webcam project which has stepper motor motion tracking using the PC's parallel port.

I tried to import the inpout32.dll using

[DllImport("inpout32.dll", EntryPoint="Out32")]

after placing the dll in the system32 folder.

But C# is showing error. that 'a reference or assembly directive is missing'

so i tried to add a reference to the dll using the add refernce. But it says...

'A reference to C:\WINDOWS\System32\inpout.dll could not be added.Make sure that the file is accessible,and that it is a valid assembly or COM component.'

could you please help me..

thanks...  

# james said on March 18, 2008 7:49 AM:

hi ashish,

am having trouble designing an autotracking solar panel using a phototransistor,stepper motor,uln 2803,adc0808,and the coding,please do help???

# mah said on April 17, 2008 6:39 AM:

heey .. can anyone please help me in how to controll a stepper through PIC16F84A using 2 ULN2003A ICs ????

thanks in advance ..

# praveen said on May 7, 2008 1:48 AM:

In the Laptop i am using USB to Parallel converter.

where to get Port address ?

# SAGNI SAY said on May 7, 2008 5:55 PM:

hi Ashish you have developed an embellish and garnishfull work on computer enterfacing aspect .but one thing that i am indoubt is how can the bit sent through the port to the circuit activates the stepper to move to a desired angle. and if we have requested the stepper to rotate to some other angle before completing the first instruction ,what will be the expected rotational anlge?

thank you. gentle

# MERED MULUGETA said on May 16, 2008 2:38 AM:

hi,Ashish

how u doing i am very delight for having your website and impression for what u wrote.

Thanks

# Joe said on May 31, 2008 8:24 PM:

Hi, excellent project, ive learned alot from your article, i already have all working in an old pc.

now want to make it work on my laptop but only has USB, i bought a usb-parallel adaptor but does not work? which brand do u use?   mine is recognize as usb parallel emulator but no lpt address so not usefull and i send it back to shop. thanks for help

# Vacky said on June 20, 2008 8:08 AM:

Hi Ashish !

I just maked your project but program not work very good, can you add project for VB2008 on internet.

# Coding4Fun said on June 20, 2008 7:57 PM:

@Vacky  The download contains both vb and c#.  Both are for Visual Studio 2008.

# ieeedo said on July 5, 2008 2:11 PM:

dear asish , I'm very enjoing whith your funs and ideas.

I need more information about accessing parallel port in winxp version

# Vacky said on July 7, 2008 9:05 AM:

Hi Ashish !

I just purchased notebook.There are no parallel port,

i wont to buy USB printer to parallel port converter, but i dont know how i programm parallel port in VB like on my PC or no ?

# Ashish Derhgawen said on July 17, 2008 11:39 AM:

Wow..there are a lot of comments on this page! I'm checking after a long time...I'm really happy to know that you all liked the article! :D

Regarding USB to parallel port converters: I've never used them, and I'm not sure if they work or not. Some people have emailed me that converters don't work...and some say that they do do work. So, I'm really confused.

If your circuit doesn't work on the first attempt..don't worry. That happens all the time. Check your circuit with a multimeter, and make sure that all your connections are right.

Good luck! :)

- Ashish Derhgawen

# AMIN said on July 23, 2008 3:57 AM:

Hi Ashish !

nice,easy,and full of knwoledge article

I made and it is working successful

i appriciat to you

# farhan said on August 2, 2008 10:46 AM:

hi ashish sir....h r u???

can u plz tell me that how can i run 4 stepper motot with a single parallel port...or is it possible??if it isnt than plz let me know how can i run them...i m in mechanical engg....in 3rd year..i have taken a project to run a small crane...plz mail me about the thing...at sfcd_123@hotmail.com......thnx...

# T.PANNEER SELVAM said on October 10, 2008 5:13 AM:

Hello Brother

                    Very good project ! Greate Thinking

I am past 1 year Searching this project .Now Iam Happy Thak u So much...............

# tsegay21@gmail.com said on November 24, 2008 10:46 AM:

It is really a project to be appreciated.

Which programming part did you find interesting?

# alin.nojea@gmail.com said on December 22, 2008 3:46 PM:

Please!!!

If i have 4 motors?

please show me the drow

Thankyou very much!

# wahma said on January 2, 2009 8:57 PM:

i got project from my lecturer to control the stepper motor using usb port from computer. do you know how or can i use PIC or other driver??

# Hans Schaer said on January 15, 2009 3:10 PM:

Can a stepper and your schematic work for me I am envisioning a remote controlled system RF controlled preferable, so I can switch on and of several TV.s on a TV Wall as to the sound .Again preferably pointing with a laser light or RV device, or a laser on a RV device to silence or activate the particular TV on my TV wall. Do you know if a commercially available item is available?

Greetings Hans

# Naldo said on January 21, 2009 8:42 PM:

Of what you're showing above, can it control 4 motors using wireless?

# Naldo said on January 21, 2009 8:47 PM:

Of what you're showing above, can it control 4 motors using wirelessly by means of PC through its parallel connection?

# NovaShenlong said on February 14, 2009 1:45 PM:

I've made the project above and work fine on my PC.I even get a dll from www.logix4u.com that get my paralel port automaticaly.If someone want the dll search for hwinterface32.dll.But my problem is this:i made this project for school,but on that PC don't work.y function can't read the address,so i got it manualy,but didn't work.I search on internet and i find that the problem could be the "Sharing port".It is true that the pc are connected on local network ,and i run the machine from guest mode.My question is:can someone tell me how can i avoid that setting and read the address.I want to do this from my code.It doesn' matter if the code is in basic, c++,delpi,or c#.I want to know how  could i avoid this,because i haven't adiministrator acces,and even if i had i don't know how to modify this,because i don't have enowgh information.Please forgive my poor english.

# Greg said on February 16, 2009 11:45 AM:

hello

good job !!!

very great !

i use this freeware to do what i wan't with the // port :

http://www.sonelec-musique.com/logiciels_freewares_progseq.html

it is in french ( my language... ) but it's easy to understand

personnaly i try to use stepper motor in an astronomical project to drive an APN optic

by

Gregoire

# Dejan said on February 24, 2009 2:31 PM:

nice project .. I have something similar for my school project .. and I need a litlle help with programing aplication in visual basic ...

if anyone can help me .. pls add me on msn:

dejantorcidas@live.com

thx ... ;))

# Basile Sah said on March 9, 2009 4:18 AM:

Good Job Ashish i used your project as a guide to my own. It helped me control a 3000 oz.in stepper for an industrial application. cheers

# Didi said on March 13, 2009 2:36 AM:

hello! can u give us the complete vb code for contolling 5-wired stepper motor via parallel port?

we need this tomorrow

for our project....

ASAP!!!

thank u!

yanah_388@yahoo.com

freaky_fella00@yahoo.com

# Coding4Fun said on March 13, 2009 5:40 PM:

@Didi, there is VB.Net code in the solution.

# Coding4Fun said on March 13, 2009 7:04 PM:

@Dejan there is a VB.Net solution in the source code download

# Dagim said on April 10, 2009 4:39 AM:

Hellow every one this is Dagim from Ethiopia I am try to doing little project on computer controlled based steppermoter would you guys give me some help?

Thank you

girmatchew2@yahoo.com

# Jamsheed said on April 10, 2009 2:09 PM:

I am doing a project which requires a program to run 3 stepper motor (My motor driving IC requires onlu 2 data outputs per motor) at diffrent times. I was thinking of keeping 3 buttons on the main form and calling the MainForm_MouseWheel method from that...But then I found that it will run all the 3 motors simulataneously which is unnecessary. Can you suggest me any ideas (I am expecting  simple codes as I am a beginner in VB). This blog helps us a lot...Thanks

My e-mail ID is mjamsheed@gmail.com

# anoop singh said on April 14, 2009 6:36 PM:

hi ashish, this is anoop i liked your article. i want to connected the stepper motor using serial communication port to the computer. please help me out. u can contact me on: anoop54451987@yahoo.com, anoop5445@gmail.com

# marcelo said on April 19, 2009 6:52 PM:

your artcle is so useful, but now I need help reading the pararallel port please send an example for doing this. I couldn't find much information about it....Thank you!!

My e-mail is cehio_lo@hotmail.com

# M.Nouman said on April 23, 2009 4:12 PM:

hello!! yar can u tell me that the power which we are giving to the ic can be given through the parrallel port?if yes then how?i m using 5volt and 1.1A motor.plz reply me i have only some days to submit the project

# GouthamN said on May 3, 2009 2:42 AM:

Hello, very nice job there Ashish. I am wondering how to give a different voltage and current to the stepper motors since I have a 20V 1.5A stepper motor and interfacing the same power will fry the uln2003a ics. How can I give a separate power supply for the motor

Thank you in advance.

# Elyas said on May 4, 2009 10:00 AM:

Amazing Article, i just wanted to know what is the maximum number of ULN 2003 that can be hooked up to a single parallel port. I think it is 2 but some people have schematics with 3.

thank you

# Mark M said on June 30, 2009 3:56 AM:

Saw this article a few days ago and decided to build this. Just got it working. It was fun. I look forward to more of this.

# uzairue stanley said on July 9, 2009 4:21 AM:

i want a note on interfacing computer with an automatic rewinding device.

# mardle said on July 28, 2009 1:34 PM:

hello!!  ahm... your blog is a great help to us.. we are doing our special proj.. we are trying to control a 3 unipolar stepper motor in VB.. but the problem is we are having problem in the programming.. it will be pleasure to us.. please do.. you can send a reply to mu email.. kenhearth@yahoo.com.. good day

# Coding4Fun said on July 28, 2009 2:36 PM:

@mardle, sorry, sounds like homework and we try not to really do the homework.  Gets us in trouble with teachers and we like teachers :-)

# mardle said on July 30, 2009 9:40 AM:

we understand.. thank you for your reply.. yeah its a homework type.. but we are not saying that you do all thing.. we are just asking if you could help us.. in problem programming, we are new in VB and we don't have our own computer to practice.. hope you could help us in coding.. but if you really like teachers then we don't have any choice.. self study.. :) thnx good day!!

# John said on August 3, 2009 8:41 PM:

This is very informative and thanks for posting this.

# Coding4Fun said on August 6, 2009 1:38 PM:

@mardle, check out the beginner developer learning center http://msdn.microsoft.com/en-us/beginner/default.aspx.

Ashish does tell you how to address multiple printer ports in his article.  I'd use something like a USB to LPT port adapter to get more printer ports here.

# dawit said on August 18, 2009 4:37 AM:

i found your project very interesting for me because i am doing my final project in the same area.i am clear how you were writing the code in c# but you have not specified what packages of c# you used.

would you mind if you do it for me?

please tell me the answer in this email

                        dvdbrine72@gmail.com

# mardle said on August 21, 2009 1:16 AM:

he thanks for this info.. atleast you help us..!! thanks alot.. if you change your mind. it will be great!! hahah LOL... until now we cant start on programming on it!!! :(

# niraj said on August 25, 2009 1:16 AM:

thank man. it help me in my project.

# Coding4Fun said on August 25, 2009 3:23 PM:

@dawit, this should work in visual studio 2003, 2005 or 2008 since example uses internal API calls.  I believe this project however uses Visual Studio 2008, which you can get the free Express version from www.microsoft.com/express/

# ayush said on October 1, 2009 3:51 AM:

these days PCs rarely come with parallel ports, so if i want to implement the computer controlled stepper motor, i wud first need a usb to parallel port cable, which i can get.

but how to know the addresses of my computer's usb ports so that i can access them in VB code?

# Coding4Fun said on October 1, 2009 1:28 PM:

@ayush use the device manager

# Stewie said on November 13, 2009 1:48 PM:

can you just post a download of an .exe program so that all we have to do is download and install to be able to control a stepper motor with the mousr scroll wheel. it would be alot easier than downloading C# or VB . if you could do that i would apreciate it greatly.  i do not understand P/Invoke  at all. if you could explain it for me that would help alot.

my email is stewie0056@yahoo.com

# Coding4Fun said on November 13, 2009 4:52 PM:

@Stewie no matter what you'll have to do some hardware building here.  To run this all you need to do is install Visual Studio Express C# or VB.  Then download the solution, open up either the VB or C# project file (vbproj or csproj) depending on what VS you installed and hit F5.

You don't have to do understand how the code works to run it.

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required

Search

This Blog

Syndication

Page view tracker