Author Topic: Stepper Motors And Circuits  (Read 13469 times)

Jon

  • Jr. Member
  • **
  • Posts: 93
    • View Profile
    • YouTube
Stepper Motors And Circuits
« on: September 27, 2009, 03:14:13 PM »
Stepper motors can be used for CNC and many other uses, like heliostats and robotics.  A stepper motor has been described as being something like both a regular motor and a solenoid.  Stepper motors are found in a larger class of mechanical movements called "actuators".  There's so many websites and discussions around for stepper motors.  I recently found this introduction to them, with what is supposed to be a simple circuit to run/control them.  There's also some nice links related to the project on that site.  I have more followup postings below which also includes some basic ideas/circuits on connecting and using the computers parallel port to control the stepper motor (there is also some discussion elsewhere on this site related to this).  Take a glancing overview of all the material, and then do an indepth review at your own pace if you want to learn some more about stepper motors.  I don't think material is overly difficult in any way.

http://www.taomc.com/bits2bots/stepmotor.htm

http://en.wikipedia.org/wiki/Stepper_motor
https://csel.cs.colorado.edu/~bauerk/legorobots/motors.html

If that chip is hard to find, as mentioned in the first link, there is a newer related or replacement IC mentioned when I searched for it.  This new one will allow much more current, although it uses external components to do so.  I see there is also a nice premade board available for $25 bux to run a stepper motor with a parallel port interface.  It looks ready to use; has the power transistors on it:

http://www.stepgenie.com/

That board just given appears to be for only controlling 1, 4-wire stepper motor which is good for some projects.   For other projects like a 3-axis machine,  you can  get a relatively inexpensive board capable of driving three stepper motors (this link was mentioned by travis77), and is for controlling 5, 6 and 8 wire stepper motors.:  

http://www.hobbycnc.com/products/hobbycnc-ez-driver-board-kit/

External gearing to the stepper motor can be used to alter both torque and speed of the available power for further use.
« Last Edit: October 21, 2009, 03:46:32 AM by Jon »


Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Stepper Motors And Circuits
« Reply #1 on: September 30, 2009, 12:23:51 PM »
Nice links, Thanks!

There really is a lot you can do with stepper motors. I just bought 12 of them off of Ebay myself for use with my heliostats.

I'm still waiting for them to arrive, but, once they do, I want to build some more heliostats. I guess I could build up to six of them if I wanted to. Of course, I would need to get a few more mirrors first.


Jon

  • Jr. Member
  • **
  • Posts: 93
    • View Profile
    • YouTube
Re: Stepper Motors And Circuits
« Reply #2 on: October 01, 2009, 05:30:15 PM »
Thanks, I'll probably stick to experimenting with one stepper motor for now, when I can get the parts.  Maby see what can be done
with one motor.  I'm thinking of a stand to turn something like a camera left or right might be good to start with.

Jon

  • Jr. Member
  • **
  • Posts: 93
    • View Profile
    • YouTube
Re: Stepper Motors And Circuits
« Reply #3 on: October 02, 2009, 09:52:05 PM »
Those link(s) I mentioned usually use some type of IC chip.  In the maze of links that I have mentioned,  I managed to find what looks like a simple ("hard" or "direct" coded") method to run a stepper motor directly from the computer without an IC chip and uses power transistors.   It does provide a nice basic explanation of what goes on to get the stepper motor to turn, and a easy computer program to even utilize it.

As I can see, each signal from the computer, is essentially used to turn on a transistor which then allows current to flow through the stepper motors and allow it to turn (due to the magnetic field created by the current in one or more coils of the motor, physically attracting/moving the metal in the rotor part and the connecting external shaft of the motor).

http://neil.fraser.name/hardware/stepper/cpu.html


That circuit shown in the link above uses 4 of the 8 standard data lines.  Hence up to 2 steppor motors can be directly controlled with
this method (a third motor can be controlled using the control pins/lines).  I guess it is possible to use up to all 8 data lines in a similar circuit but it will limit the project to 1 stepper motor.  In the previous links with the IC chips, to run a stepper motor, only 2 lines of the 8 standard data lines are needed. One for "step" (ie. turn/rotate a single increment), and one for "direction" to turn (clockwise CW, or counter-clockwise CCW).  The IC chip will create the necessary binary signals inplace of the "hard coded" binary signals directly from the computer.  The IC also provides the right sequence of binary signals to step the motor CW or CCW without any extra programming by the user.  Up to 4 stepper motors can be controlled using this method.  Using these facts, I guess it is possible to use two common hand switches (ok, maby with a delay circuit to prevent extra steps) to control a stepper motor if the "IC method" is utilized, and a computer or other microprocessor is not even needed.


Does your parallel port work:  From CerebralMeltdown (here):  http://www.cerebralmeltdown.com/projects/suntrackprogram/parallelport/default.htm
« Last Edit: October 22, 2009, 05:04:19 PM by Jon »

Jon

  • Jr. Member
  • **
  • Posts: 93
    • View Profile
    • YouTube
Re: Stepper Motors And Circuits
« Reply #4 on: October 03, 2009, 08:31:31 PM »
On that last link, it might look confusing in that program where he has, for example:

70 .........  OUT PORT, 3:  REM 1100

It appears that the binary number is backwards.  3 would be better written as:   0011

This is his preference, unless someone can say otherwise,  since of what is more important
than the binary number is the actuall pin/lines used.  If you looked at the lines from one way it
would look as 1100 and if you looked at them from another direction it would appear as 0011.  
The other values are also shown as written backwards in the binary number form.

Basically, in the non-numerical representation:

1 means "on" since this 5V ("high voltage") signal on the data line will turn the transistor on.  
0 means just the opposite or "off", and basically represents a "low voltage", perhaps 0 volts.

Each bit (of a byte) in a memory chip are said to be either 1 or 0 also. A bit represents the most
compact form of information.  It can represent two states:  on (1), or off (0), and is easilly
implemented or can be applied with electronics (such as transistors - even one or two, or IC chips).  
When a bit in the paralel port is set with a computer program, it will turn the motor on since
physically/electronically, this will also put +5 volts (or some other high voltage) on that corresponding
data line.

Extra:

Logic chips or "logic gates" such as AND or OR chips - these basically compare
the binary values input , 0 and 1, and have a predetermined output value, of either 0 or 1,  that depends
on those input values - hence in a way the logic gate is somewhat like a decision maker or little
computer.  These "logic gates" are almost self explanatory, for example, take the OR gate - if either
input "A" Or input "B" is high, or any other input is high, the output will be high.  IC chips can often contain
things such as  logic gates, memory (RAM and/or ROM), timers, microprocessors, and even amplifiers
« Last Edit: October 06, 2009, 11:55:01 PM by Jon »


Jon

  • Jr. Member
  • **
  • Posts: 93
    • View Profile
    • YouTube
Re: Stepper Motors And Circuits
« Reply #5 on: October 06, 2009, 05:14:22 PM »
If you dont have any other program to send a byte out the port, here is a simple program
that sends a binary number value out the printer port.  It's called pport2.exe (about 2K)
I have the link in another posting here, infact, I might bring everything there over to here since
it's of a basic nature related to the port, and not entirely related to only solar things. I guess
it sort of found a place into that topic at the time.  The program below was not built for any
kind of speed, perhaps 10 to 20 times a second it can be ran.  When your running any CNC
or HELIOSTAT setup as shown on this website, you probably will never have to do any computer
programming since there are programs, some free, available for you already.

http://www.megaupload.com/?d=8XWEE1IX

Use format:    pport2  value              ; the highest value is for 8 bits or digit positions of a binary number being set or 255 decimal.
                                                     ; the value to use is the decimal equivalent of the binary value

Ex.   pport2   0                   ; output is:     00000000    : this is the representation of what is on the 8 data lines
Ex.   pport2   1                   ; output is:     00000001
Ex.   pport2   2                   ; output is:     00000010
Ex.   pport2   3                   ; output is:     00000011
Ex.   pport2   4                   ; output is:     00000100
Ex.   pport2   8                   ; output is:     00001000
Ex.   pport2  16                  ; output is:     00010000
Ex.   pport2  32                  ; output is:     00100000
Ex.   pport2  64                  ; output is:     01000000
Ex.   pport2  128                ; output is:     10000000
Ex.   pport2  129                ; output is:     10000001
Ex.   pport2  255                ; output is:     11111111


If you want some more understanding about binary numbers here is one link:  http://www.swansontec.com/binary.html
« Last Edit: October 18, 2009, 11:55:51 PM by Jon »

Jon

  • Jr. Member
  • **
  • Posts: 93
    • View Profile
    • YouTube
Re: Stepper Motors And Circuits
« Reply #6 on: October 07, 2009, 08:26:05 PM »
The post(s) below is only one example of what it took to access the 8 data lines of the (PC) computer's parallel port without buying any special project board, etc.  They were moved over to here from one of the solar topics since this stepper motor/parallel port stuff is of a basic nature not entirely related to solar things, and it might be more useful here.
« Last Edit: October 07, 2009, 09:05:50 PM by Jon »

Jon

  • Jr. Member
  • **
  • Posts: 93
    • View Profile
    • YouTube
Re: Stepper Motors And Circuits
« Reply #7 on: October 07, 2009, 08:34:22 PM »
I read that when you connect a printer up to the printer port, the port controller (or peripheral interface controller/driver stuff) is expecting some data input/communication from the printer also.  So, then you have to trick the port into thinking it is getting some input like an "acknowledge signal" from the printer.  There is a certain wireing of the pins that can do this, I read it once in a magazine, maby Popular Mechanics , and I may have saved it someplace.  Many years ago, I have made a box with a printer port connector, and I ran devices such as a turning on a Triac and Scr with the 5V output from the pins of the computer and then sent that signal to an OPTO-ISOLATOR chip (LOCATED IN THE SAME BOX AS THE SCR, TRIAC, RELAY, ETC) to prevent possible damage from 120V house voltage/current.  I also ran a 7 segment led, and could display a number on it, or change the number to display  the time (one digit after the other with a slight pause/delay).   If I can find the box I will look at the pins and try to film or draw what I see/did.  As for the programming the port, I think I used Basics "out" or "print" command (I dont remember the format/syntax), and for otherstuff I used C programming and all that is put in boxes and/or old disks, but I will try to look around and see what I have, or maby some old sample code.  Using the printer port is easy they say, but on new computers the port is not installed as much and USB (port) seems to be for everything but USB not too user friendly for homemade stuff, but I think there is some project boards available for USB stuff with like TTL (transistor) outputs so that other devices can be easilly controlled (on/off) or for data.  I havent made anything for USB though.
« Last Edit: October 07, 2009, 09:09:27 PM by Jon »

Jon

  • Jr. Member
  • **
  • Posts: 93
    • View Profile
    • YouTube
Re: Stepper Motors And Circuits
« Reply #8 on: October 07, 2009, 08:34:55 PM »
I made a drawing, I'll see if it can be placed here, I also made a short vid of the box I used.  The result below is that you can easilly control 8 data lines, and hence 8 devices on or off, when you send values to the printer port.

25 Pin , Printer Port,  "breakout box"   (note that this is only one example of the wireing possible/needed).


http://i27.tinypic.com/2ahikaf.jpg


I beleive each data line is equivalent to each bit of the byte (8 bits) sent out of the port.  So I think now, pin 2 corresponds to logical bit 0 (which is the first physical bit/pin/line),   pin 3 corresponds to logical bit 1,  pin 4 corresponds to logical bit 2, pin 5 corresponds to logical bit 3, and so on up to logical bit 7 (making a total of 8 bits).   If you want, you can think of logical as numerical, logical things or labels start at 0 (instead of 1) so that the numeric value of 0 can always be considered, in a programming sense logical also means "offset from" the start of the data, so an offset of 0 means the exact start of the data, and is usually its address (of that byte) in memory, etc.

If you wanted to put a high signal (or logical 1 as its sometimes called as opposed to a logical 0 or off as its sometimes called) on all the data lines/pins,  you would send a byte code of 255 which corresponds to all the bits of that byte set to 1 or "on".  To turn them all off you would send a byte code of 0 to the printer port.


To set a specific data line pin(s) you only need consider the "binary weight" of the corresponding bit and pin (or data line).  To set a pin(s) add their binary weights and output that value to the printer port.


Jon

  • Jr. Member
  • **
  • Posts: 93
    • View Profile
    • YouTube
Re: Stepper Motors And Circuits
« Reply #9 on: October 07, 2009, 08:36:59 PM »
> continued from last post:


Data lines:                           8          7          6          5          4           3            2          1  


Logical Pin:                          7          6          5          4          3           2           1            0


binary weights:                 2^7        2^6         2^5      2^4        2^3        2^2        2^1       2^0

decimal value                   128        64         32        16          8          4           2            1



Ex. To set pins (I mean the data lines actually, confusing?) 8, 4 and 1  to high (binary 1), and considering the other pins will be off (0).

       To do this, add the numerical representation of the set  bits of the byte, and this numerical
       representation is determined by the bits position (just like with the decimal system) within
        the byte number and is equivalent to the binary weight of those bit positions.:  128 + 8 + 1 =  137

      Send a value of 137 out of the computers printer port.

        
If you later wanted to turn on the 7th data pin/line, you could add on 64 to the value of 137,
for a new "main control" value of:  137 + 64  =  201, so send a value of 201 out the
printer port.


If you wanted to turn off, say data pin/line 8 now, you can simply subtract 128:
    201 -  128 =  73,   so send a value of 73 out of the printer port.


« Last Edit: October 07, 2009, 09:14:05 PM by Jon »

Jon

  • Jr. Member
  • **
  • Posts: 93
    • View Profile
    • YouTube
Re: Stepper Motors And Circuits
« Reply #10 on: October 07, 2009, 08:37:25 PM »
The 8 data lines are "data output" lines from the printer port.  I did not discuss any input lines on the computers printer port.  I think I read that some printer ports/cards might be incapable of receiving any incomming data.   I connect each data line to a 100 ohm resistor for current limiting safety, but the value of this resistor depends on what you are doing.  I then connected the other end of the resistor to the output terminals of the box, I used RCA female type connections (I bought 8 of them connected together on a plastic mounting surface) to make connecting wires (ie speaker wires, etc) easy with RCA male connections.  For testing, I used an led connected to the end of a male rca plug (you may have to adjust your resistor slightly higher, maby to 220 ohms) on a short length of speaker wire.  I believe I used 100 ohms so that I can run the signal into an opto-isolator, and then that signal to a triac or scr ("electronic relay or switch") to turn on high power devices.  Usually, a "high" on the computers printer port data lines is about 5V and a "low" or off signal is about 0V.

The 25 pin cable line from the computers printer port to the (homemade) "breakout box" is comparable to the length of a USB line, but the output from this homeade "breakout box" can be very long, as long as needed within reason. Standard USB lines tend to be for short distances only, unless you have a "breakout box" connected to the USB port,  and that's usually some IC chips or TTL (transistors) that can be used to send the data or small power to other devices.




When I run the pport2 program with the project box connected, the program will exit by itself.  When the program is then ran with the porject box not connected the program sort of "hangs", I guess it's waiting for an acknowledge signal basically.  You can "X" out of the program then.   Overall, it does indicate the signifigance of the correct wireing needed by the electronics and  port driver since the pport2 program does not have any error checking and should run smoothly.
« Last Edit: October 14, 2009, 07:45:55 PM by Jon »

Jon

  • Jr. Member
  • **
  • Posts: 93
    • View Profile
    • YouTube
Re: Stepper Motors And Circuits
« Reply #11 on: October 07, 2009, 08:37:50 PM »
Note, Do not place things like high power SCR or Triac within your "breakout box", instead connect your long signal lines to the distant external boxes with the low power signal/data lines like I have mentioned, I used speaker wires from the "breakout box".  These low power signals can be used to switch on other things such as transistors, SCR's, Triac's, and electro-mechanical relay's.  You dont want high voltage on the external (ie output) lines of the breakout box, for safety reasons...the line might get stepped on or shorted out if a pet bites the cable.  To do this you can use an "opto-isolator" chip (ie has an led and a light sensor inside a IC chip) in the box with the SCR, TRIAC, RELAY, or TRANSISTOR, ETC.  Just use these small signals of the breakout box on wire, like speaker-wires,  to control things farther away from the "breakout box" and computer.  There is a good cost benefit also for using cheap speaker wires than something like expensive 300 foot extension cords to control distant devices or someplace in your building (of course you might need to see your local building codes about certain wires that are permitted  .... like "low voltage communication wire" such as speaker or telephone wire).

« Last Edit: October 07, 2009, 09:20:02 PM by Jon »

Jon

  • Jr. Member
  • **
  • Posts: 93
    • View Profile
    • YouTube
Re: Stepper Motors And Circuits
« Reply #12 on: October 07, 2009, 08:38:21 PM »
Here is the video I made to show the design of the "breakout box":  

Parallel Port Breakout Box - Read side notes also.


Usually, to connect the project box to the computer you will need a 25 pin - printer parallel port cable, with
one end male (goes into the computer) and one end female (to connect to the project box).  But to be safe,
check your computer's printer port and project box port to see what you will need.


Here is a site with the DB25 male and female - 25 pin - parallelport connector, the price of it is fairly cheap,
and I'm not sure if that inclues any machine screws, but they are cheap at the local harware store:

Look at the DB25 D-Sub Connector Solder type Male here:
http://clickercable.com/catalog/index.php?cPath=26&osCsid=ryxzqldklo

« Last Edit: October 08, 2009, 09:55:57 PM by Jon »

Jon

  • Jr. Member
  • **
  • Posts: 93
    • View Profile
    • YouTube
Re: Stepper Motors And Circuits
« Reply #13 on: October 07, 2009, 08:40:04 PM »
Ok, this info. will be usfull for anyone looking around for any more ideas about the subject.  That box I made is about 15 years old, and the wireing schematic diagram is someplace in a "storage box", so I just drew it as I seen it in the project box.  I was looking on YouTube last night and I see theres some other useful stuff in some videos (search for like "interfacing parallel port", etc), particularly with the "control pins" which can be used for 4 extra data lines (or input lines , but this is only if the printer port/card is able to accept input).  These 4 extra lines can actually be used for something like "chip select" to select a particular (IC) chip (that has a chip select pin) you want to send the output byte to, so it can be very useful in controlling many more devices or doing things.

Here is a treasure trove of data about the printer port:  http://www.epanorama.net/circuits/parallel_output.html
Also:  http://www.lvr.com/parport.htm
This page looked interesting:  http://www.arunet.co.uk/tkboyd/ele1pp.htm
About the numbers:  http://www.taomc.com/bits2bots/pport1.htm

For XP - Modern WIndows:  http://logix4u.net/Legacy_Ports/Parallel_Port/A_tutorial_on_Parallel_port_Interfacing.html

http://www.absoluteastronomy.com/topics/Parallel_port

I think one simple program I wrote once used the Function keys F1 to F8 to toggle the data lines and connected devices on and off easy... thats asynchronous, which basically means "without any inherant timing, or unsynchronized".  If you want things done over and over you will need something that can perform a cycle, which takes time to complete, over and over, either physical hardware or software can do this.  Software would involve some kind of "loop" program that is run over and over and will not stop unless programmed to.  It is possible to turn devices on and off at certain times of the day also.

For testing purposes, all the data lines of the printer port can easilly be controlled with a very small program, and the command and its syntax/format is often something like:  

OUT    port_number     byte_value ;



This page talks about some problems, or new things you need to consider, since PC's went from a "DOS"
operating system to a "Windows" operating system:  http://discuss.joelonsoftware.com/default.asp?joel.3.12410.11
In particular, it discusses programming for the printer port.

I made a new small program to ouput a byte (0 to 255) on the printer port data lines.  We'll it "sort of" works for now.
I get some to light up ok (data lines corresponding to the 4 least signifigant bits, or decimal 1, 2, 4 and 8 ).  Some (2 leds on the numeric display) seem to be "stuck on".  When Windows starts, some
may also be set initally set on (signaling some installed printer?, maby, maby uninstall?) that you may need to
"clear".  I don't think there is a  short in the line, and the program looks simple enough (you never know though),
and the circuit worked fine in a DOS system.  So if anyone wants the .exe program,  (run from the command line or a
batch file, ex:  pport1 255  )  or the C source code, just let me know.  If anyone knows what might be going on you can
also let us know.  A good reason to save those old DOS or early Windows computers, and maby even give USB boxes a try.

« Last Edit: October 07, 2009, 09:22:45 PM by Jon »

Jon

  • Jr. Member
  • **
  • Posts: 93
    • View Profile
    • YouTube
Re: Stepper Motors And Circuits
« Reply #14 on: October 07, 2009, 08:40:46 PM »
Well, I tried, and now I see with modern computer like XP, a special "DLL" file/driver is needed that you just mentioned and I stumbled upon about a half-hour ago also (I think Gabriel mentioned it previously on this site here also), and I found some stuff about it here:  http://logix4u.net/Legacy_Ports/Parallel_Port/Inpout32.dll_for_Windows_98/2000/NT/XP.html   and there are links to some samples of using it there and where to get it, I didnt do anything with it though, yet, but it looks promising if I want to do anything with the printer port on a modern "Windows Computer".

On length of speaker wire/data line.  Ok as I recall, there is a limit to communication with a std. printer cable, maby 25 feet or something, but I'm not sure if it applies to speaker wire.  If it fails/problematic, then some (non-inverting hopfully) buffer chip (maby for 8 lines) or 8 transistors will be needed, one  for each data line to send the signal a great distance.  I didn't mention any sheilding from noise either.  It's all experimental at this point, hopefully without a puff of smoke and some zig-zags arcross my monitor and a blown power fuse.  


64 bit, maby this has something to do with Vista:  http://logix4u.net/Legacy_Ports/Parallel_Port/Inpoutx64.dll_for_WIN_XP_64_bit.html

Here is some stuff about that DLL from a programming forum or something:  http://cboard.cprogramming.com/cplusplus-programming/104139-question-accessing-parallel-port.html

I think the best thing to have for non programmers or simple programs is  to keep things simple is for someone to write a simple
program that sends a byte out the port (maby have another program for both read/write or a command line option).  The byte to be sent could be on the command line when that function/program is called, maby from a batch program or within another program.  All the user would need is that DLL to make that functional, of course it might not be the fastest thing around if you are calling
that  program many, many times a second, but for ordinary use, maby up to once a second or minute, it seems to be a good
solution.  Maby such a program exists?, already made for simple tasks, because many programmers seem to be having some trouble
getting that to work right, so premade seems to be a good solution, also it would at least alow non-programmers/lite-programmers/experimenters some quick testing  amd functionality without learning a full blown programming language.
« Last Edit: October 07, 2009, 09:28:07 PM by Jon »