Difference between revisions of "PIC Stepper Motor Tester"

From OpenCircuits
Jump to navigation Jump to search
 
(64 intermediate revisions by 3 users not shown)
Line 2: Line 2:
  
  
 +
There are multiple versions of this project for general infomation see:  [[Stepper Motor Demonstration and Tester]]
 +
Note: we now have a version for the Arduino: [[Stepper Motor Tester for the Arduino]]
  
Summary: A PIC16F877A project that operates a stepper motor under the control of a PC running a terminal program.
+
*Name: PIC Stepper Motor Demonstration and Test Project
 +
*Status: still developing ( on back burner ), but is working.  Planning a version for the Arduino.
 +
*Technology: PIC microcontroller with code in BoostC
 +
*Author: russ_hensel ( where you can find an email address to reach me )
 +
*Summary: A PIC16F877A project that operates a stepper motor under the control of a PC running a terminal program.
  
Author: Russ Hensel, struve13@verizon.net email me any comments questions
+
Last revision July 4 2008 – Draft, near completion except for Java control program. The C code works, but there are lots of some in other parts of the project.
Last revision March 1 2007 – Draft, near completion except for Java control program. The C code works, but there are lots of errors in other parts of the project – they should be fixed soon, check back or email me
+
Archive zip file ( SerialStepperTest.zip ) includes: this doc, eagle schematic, program listing. Posted in download section.
Archive zip file ( SerialStepperTest.zip ) includes: this doc, eagle schematic, program listing.
 
  
 
This project has several potential uses:
 
This project has several potential uses:
Line 17: Line 22:
 
*Demonstrating the operation of a stepper motor.
 
*Demonstrating the operation of a stepper motor.
  
Platform: PIC16F877A using BoostC connected via rs232 to a PC running a terminal program, or as an alternative running a Java program developed especially to control the PIC ( still under development ). The PIC chip is supplemented with a MAX232 chip and a ULN2003 driver.
+
Platform: PIC16F877A using BoostC connected via rs232 to a PC running a terminal program. The PIC chip is supplemented with a MAX232 chip and a ULN2003 driver.
  
 
The project is able to drive a stepper motor in a number of ways ( controlled by the RS232 connection ):
 
The project is able to drive a stepper motor in a number of ways ( controlled by the RS232 connection ):
Line 25: Line 30:
 
* Set the time delay between the steps
 
* Set the time delay between the steps
 
* Drive the wires to the stepper in any of the 6 possible connections ( permutations), this allows the user to determine which wire is which.
 
* Drive the wires to the stepper in any of the 6 possible connections ( permutations), this allows the user to determine which wire is which.
* Demonstrate possible stepper motions with a few sets of special routines.
 
  
 
In general the stepper is driven by issuing several commands to set it up and then a final command to take a series of steps using this setup.
 
In general the stepper is driven by issuing several commands to set it up and then a final command to take a series of steps using this setup.
Line 71: Line 75:
 
== Hardware ==
 
== Hardware ==
  
I have used a PIC 16F877A for the project, but pretty much any PIC with a uart and another 4 free I/O lines should do. To increase the drive to the motor I used a ULN2803 which is simply an array of Darlington transistors and diodes to be used as a low side switch for each motor winding. There are other similar chips around or discrete devices can be used. I run the pic, on 5 volts, and a larger voltages for the stepper, up to the limit of the driver. ( the UNL2803 is good for 50 v at .5 amp as a switch ) and the rating of the stepper motor. If you have a high power motor you may want a driver with more guts, Just put in some substitute. Coil drive is on or off there is no PWM involved here. Note that the hardware has substantial uncommitted resources. You could easily drive another motor for example. Also some of you may want to put some pull up or down resistors on some of the uncommitted resources.  
+
I have used a PIC 16F877A for the project, but pretty much any PIC with a uart and another 4 free I/O lines should do. To increase the drive to the motor I used a ULN2803 which is simply an array of Darlington transistors and diodes to be used as a low side switch for each motor winding. There are other similar chips around or discrete devices can be used. I run the pic, on 5 volts, and a larger voltages for the stepper, up to the limit of the driver. ( the UNL2803 is good for 50 v at .5 amp as a switch ) and the rating of the stepper motor. If you have a high power motor you may want a driver with more guts, Just put in some substitute. Coil drive is on or off there is no PWM involved here. Note that the hardware has substantial uncommitted resources. You could easily drive another motor for example. Also some of you may want to put some pull up or down resistors on some of the uncommitted resources. Instead of this board you could use the circuit from the [[PIC based Stepper Motor Dancing Analog Clock]], the main difference is that that circuit does not use the MAX232 chip, it relies on an off board level shifter ( makes it easy to shift the level shifter from project to project while saving some money and board space )
Schematic ( also eagle file is in zip archive see above ):
 
  
 +
=== Schematic ===
  
== Command Interface ==
+
[[Image:Sstest.png | Schematic]]
  
All commands ( except stop should be terminated with a carriage return ) Note that the command interface is not very smart, giving parameters that are out of range my blow the whole program up. If so reboot the PIC. Do not send a new command ( except stop ) until earlier commands have been completed ( actually you can get ahead some if you are careful )
 
  
  
 +
Parts  -- this is not up to date, working on it
  
Request motor position
+
{| class="wikitable"
w
+
|-valign="top"
Step taken since power on.
+
|Part
Signed int.
+
|Details
Report on all parameters
 
r
 
Reports on internal state of the PIC driver.
 
Go for a number of steps
 
( max. about 30,000 )
 
gnnnn
 
Move nnnn steps. Responds with a !<cr> when done
 
Time delay between steps in ms ( max 255 )
 
t
 
Reports delay set.
 
Micro second delay in addition to to the ms delay.
 
u
 
Reports delay set. Ok to use values as high as 5000 us.
 
Set the permutation of the motor wires.
 
( n 0 to 5 )
 
pn
 
  
Set the permutation, find the value that works for your motor.
+
|-valign="top"
Report permutation set
+
|Power supply
Spin the motor in an interesting way
+
|Not shown, you need two dc voltages, one for the PIC at 5 volts, and another with the right voltage for the motors. There is a suitable power supply in the [[PIC based Stepper Motor Dancing Analog Clock]]
x1
+
<!-------------------------------->
Motor spins
 
!<cr> when done.
 
Vibrate the motor first a lot then less and less to stop
 
x2
 
!<cr> when done.
 
Stop
 
s
 
Should almost immediately stop long running commands like Go or x1 or x2
 
!<cr> when done.
 
  
 
+
|-valign="top"
{| class="wikitable"
+
|PIC16F877A
|-valign="top"
+
|My favorate 16 series part, relatively lots of memory and pins.  Bigger than you need, but only about 8 bucks.  Try with an 18 series part, should not be hard and will leave you more up to date.  Let me know.
! Command
+
<!--------------------------------
! Code
+
|-valign="top"
! Notes, PIC Response
+
|MODE_1...MODE_6 = Rotory Switch connections
<!------------------------------->
+
|I used an old Radio Shack 12 position switch only 6 of them are used here.  You could use seperate pushbuttons, the advantage is that the position of the rotory switch indicates which mode you are in, else you may want an led for each one, perhaps using another bunch of ports.
|-valign="top"
+
<!--------------------------------
|Report version
+
|-valign="top"
|v
+
|
|Version of the PIC software as:
+
|
v2.3 or similar
+
<!-------------------------------->
<!------------------------------->
+
|-valign="top"
|-valign="top"
+
|Pull Up/Down Resistors
|Set direction
+
|10k more or less
|d+
+
<!-------------------------------->
d-
+
|-valign="top"
|+ for forward, - for back
+
|CQ1, CQ2 = capicators for the crystal
Direction set.
+
|about 20 pf seems to work, see the PIC16F877A manual
<!------------------------------->
+
<!--------------------------------
|-valign="top"
+
|-valign="top"
 +
|xx
 +
|
 +
<!--------------------------------
 +
|-valign="top"
 +
|xx
 +
|
 +
<!-------------------------------->
 +
|-valign="top"
 +
|Q = crystal
 +
|4 meg Hz is what I used.  May be quite a bit faster than needed, I have not looked into this.  The 4 meg crystal seems to work ok on a proto board.  Note that some of the code is dependent on this frequency, but could be fairly easily changed.
 +
<!--------------------------------
 +
|-valign="top"
 +
|RA4, RA5 = Pull up resistors
 +
|10K more or less
 +
<!--------------------------------
 +
|-valign="top"
 +
|RB1 ... RB6 = Pull up resistors
 +
|10K more or less
 +
<!--------------------------------
 +
|-valign="top"
 +
|RRA2, RRA3  = Pull up resistors
 +
|10K more or less
 +
<!-------------------------------->
 +
|-valign="top"
 +
|C_BP  = By Pass Cap.
 +
|Not on schematic, good idea to add one. A .01 to .1 mfd mica or other by pass cap, good at high frequency seems good.
 +
<!--------------------------------
 +
|-valign="top"
 +
|RRA1 = Pull Up resistor
 +
|10K more or less
 +
<!--------------------------------
 +
|-valign="top"
 +
|
 +
|
 +
<!-------------------------------->
 +
|-valign="top"
 +
|DRIVER  = Low side switch for motor coils.
 +
|Driver chip for stepper.  ULN2803.  Good for up to .5 amp 35 volts I think.  Could use discrete transistors ( possibly darlingtons ) if you want higher current. Also see note on stepper power.
 +
<!-------------------------------->
 +
|-valign="top"
 +
|RMC  = Pull up resistor for master clear ( pull down with push button switch to reset ).
 +
|10k more or less
 +
<!-------------------------------->
 +
|-valign="top"
 +
|PUSH_BUTTON_SWITCH  = Reset
 +
|Push to reset the processor.  Mine was from salvage.
 +
<!-------------------------------->
 +
|-valign="top"
 +
|STEPPER_POWER
 +
|This voltage needs to be adjusted for the voltage of you stepper motor.  Lower voltage motors, like 5 volt motors, often require more current than the driver chip can supply.  You may need to change this to an array of power transistors for high currents.  Make sure that 5 volts is enough to turn them on and perhaps add a current limiting resistor to the base drive.  MOSFETS can be good, but not all switch on at 5 volt drive.
 +
<!--------------------------------
 +
|-valign="top"
 +
|  =
 +
|
 +
<!--------------------------------
 +
|-valign="top"
 +
|  =
 +
|
 +
<!--------------------------------
 +
|-valign="top"
 +
|  =
 +
|
 +
<!--------------------------------
 +
|-valign="top"
 +
|  =
 
|
 
|
 +
<!--------------------------------
 +
|-valign="top"
 
|
 
|
 
|
 
|
<!------------------------------->
+
<!-------------------------------->
|-valign="top"
+
|-valign="top"
 +
|VPLUS_VDD = Positive power
 +
|To the 5 volt power.  Note stepper power is normally a different supply and often a higher voltage.
 +
<!-------------------------------->
 +
|-valign="top"
 +
|G1  = Ground connection
 +
|Not show, add one to connect the power supply.
 +
<!--------------------------------
 +
|-valign="top"
 +
|SW_UP, SW_DOWN =
 
|
 
|
 +
<!--------------------------------
 +
|-valign="top"
 +
|  =
 
|
 
|
 +
<!-------------------------------->
 +
|-valign="top"
 +
|MOUNT_1...4
 +
|Mounting holes
 +
<!--------------------------------
 +
|-valign="top"
 +
|  =
 
|
 
|
<!------------------------------->
+
<!-------------------------------->
  
 +
|}
  
|}
+
== Command Interface ==
  
 +
All commands ( except stop should be terminated with a carriage return ) Note that the command interface is not very smart, giving parameters that are out of range my blow the whole program up. If so reboot the PIC. Do not send a new command ( except stop ) until earlier commands have been completed ( actually you can get ahead some if you are careful ).  In earlier versions the commands had to be in lower case, I think current versions take either upper or lower case - check it out.
  
Notes on terminal program set up.
+
see: [[Stepper Motor Demonstration and Tester]] which covers both the PIC and Arduino Version.
  
*Baud rate should be 19.2K 8N1
+
== Microcontroller Program Design ==
*Most terminal programs can be set to treat a carriage return as a carriage return line feed. Do it.
 
Some terminal programs will not transmit in lower case ( all our commands are lower case ) unless specially set to do so. Set it to allow lower case.
 
== Program Design ==
 
 
I no longer have the patience for assembly language. I have moved on to C in particularly BoostC, see link below. I like this compiler it has both a free version with some restrictions and a very reasonably priced full version. Writing in C should make the program fairly easy to read. Most of the design should be evident by reading the program, however a few notes here may help.
 
I no longer have the patience for assembly language. I have moved on to C in particularly BoostC, see link below. I like this compiler it has both a free version with some restrictions and a very reasonably priced full version. Writing in C should make the program fairly easy to read. Most of the design should be evident by reading the program, however a few notes here may help.
 +
see: [[Stepper Motor Demonstration and Tester]] for comments that apply to both the PIC and Arduino versions of the project.
  
The idea is to put each activation sequence in a table and then step through that table and activate the corresponding ports and thus stepper coils. The four wires can be activated in a total of 6 different ways, one table corresponds to each permutation. The particular table to use is set using the permutation command ( p ).  
+
==== Compiling ====
 +
The zip file contains the entire source bootst project.  Unzip into a directory and open in source boost. Set the target to 16F877A and change the linker options ( Settings -> options -> linker  <none> Settings -> options -> compiler  <none>  ) There are 2 #defines, one for 20 meg crystal and one for a 4 meg crystal. After compiling my compiler reports something like:
  
The series of wires to energize is specified in the arrays StepperStepsN where N is the number of the wire permutation. Each step just increments its way through the array wrapping around the the beginning and the end.
+
Memory Usage Report
  
Commands are received via an interrupt driven routine, the main loop checks each time around to see if a complete command has been received. Because commands are only interpreted in the main loop all commands are ignored until the program returns to the main loop. The exception to this is the stop command which will terminate a g or x command and return to the main loop quickly. RS232 transmission is not driven by an interrupt and so during transmission from the pic no stepping takes place.  
+
*RAM available:368 bytes, used:139 bytes (37.8%), free:229 bytes (62.2%),
 +
*Heap size:229 bytes, Heap max single alloc:95 bytes
 +
*ROM available:8192 words, used:2118 words (25.9%), free:6074 words (74.1%)
  
Currently drive to the motor is half step drive. This gives twice as many steps per revolution as is labeled on the motor. I plan later to let you select half step, full step or wave drive. See the links below for more information.
+
I think you could contract the program a bit to get under the 2K free compiler limit.
  
Java Control Program
+
== Java Control Program ==
 +
This was once an idea, but I have dropped it for lack of interest ( both mine and others ).  Some thoughts that I had in the past:
  
Rather than use a terminal emulation program you can use a Java Program that I have written. This makes it easier to issue commands and has a much lower chance of making a mistake. The interface looks like this:
+
Rather than use a terminal emulation program you can use a Java Program. This makes it easier to issue commands and has a much lower chance of making a mistake. The interface looks like this: ( actually almost written, email me if you have a special interest ).
  
 
This basically issues the same commands as you can issue with the terminal. There are a couple of enhancements
 
This basically issues the same commands as you can issue with the terminal. There are a couple of enhancements
  
 
<All> sends all the parameters then the go command, thus you can run the whole setup by typing in the parameters and pressing <All>.
 
<All> sends all the parameters then the go command, thus you can run the whole setup by typing in the parameters and pressing <All>.
Setting up the java control program.
 
Will have to wait until program is done.
 
How fast can your stepper go?
 
Run it faster and faster ( shorter time delay ) until it fails. You may want to turn it 400 turns to clockwise fast, then 400 counter clockwise slow. If it does not end up where it started then it skipped a step or more. If you know how many steps per rev then you need not reverse it just ask it to go a round number of revolutions.
 
How many steps per revolution for your motor?
 
Guess, try to make it turn 10 revolutions fairly slowly or at least slowly enough so that it is not skipping steps.. If you number is right it will end up at the same angle it started. If not try a new guess.
 
Demo the motor with Special Commands
 
To be written.........
 
To determine which wire is which on a Stepper
 
Unipolar motors typically have 6 wires that come in 2 pairs. Typically the “center tap” of each winding is connected to V+ and the individual windings are grounded ( as with the Darlington array described in hardware ) to switch them on. The tester does not determine which of the wires are the center taps, but that is easy to do with an ohm meter. Each center tap will have the same resistance to far end of either of the coils connected to it. There will be twice the resistance between the ends of the coils. Sometimes the two center taps will be connected together so the motor has only 5 wires. Sometimes the center taps will be the only two wires that are the same color. Once the center taps have been determined connect them to V+ ( whatever voltage is appropriate for the motor ) and the other wires in any order to the 4 ports. Name the wires A, B, C, D ( or use the wire colors if available, adjusting the chart below for the colors ) and connect to the drivers on bit 0, 1, 2, 3. ( in the software given I have actually used bits 4, 5, 6, 7 )
 
 
Make sure the PIC came up all right and the serial connection is working – use the Version command ( v ) and see if the response is reasonable, if not try another couple of times, if it sill does not work reboot the pic. If it still does not work check over the communications parameters on your terminal program. And so on.
 
  
Set the motor to run forward, with say 50 ms delay per step. Choose permutation 0. Now try 100 steps ( g100 ) If the motor does not run try another permutation.
+
== Which Wire is Which? ==
  
If the motor is good you should find 2 configurations that work, one forward, one back. ( In some cases I have found more than 2, I do not quite understand this, look for the smoothest running – russ test some more with more motors ) The jerky motion of the shaft can be deceiving, I add a pointer to the shaft, one that will not slip. This chart then tells you the “standard” identification of the wires:
+
[[Stepper Motor Demonstration and Tester]] which covers both the PIC and Arduino Version.
  
 +
== Other Things to Try With the Tester ==
  
{| class="wikitable"
+
[[Stepper Motor Demonstration and Tester]] which covers both the PIC and Arduino Version.
|-valign="top"
 
! Topic
 
! Topic Link
 
! Comment
 
<!------------------------------->
 
<!------------------------------->
 
|-valign="top"
 
|
 
|
 
<!------------------------------->
 
|-valign="top"
 
|
 
|
 
<!------------------------------->
 
|-valign="top"
 
|
 
|
 
<!-------------------------------
 
|-valign="top"
 
|
 
*Links
 
*Arduino
 
|[http:]
 
|comment
 
<!-------------------------------
 
|-valign="top"
 
|
 
*Links
 
*Arduino
 
|[http:]
 
|comment
 
<!-------------------------------
 
-->
 
|}
 
  
 +
== Additions/Changes ==
  
 +
[[Stepper Motor Demonstration and Tester]] which covers both the PIC and Arduino Version.
  
Discussion
+
== Possibly useful links ==
  
Which wire is which depends in part what you consider a standard coil activation sequence. From my reading I believe that this corresponds to the table Zero_StepperSteps in the code. Your standard may differ, if so you can modify the code. The code uses a so-called “half step” drive. You can contact me [[russ_hensel]] if you are having trouble figuring this out. Google will link you to a huge amount of information on steppers.
+
[[Stepper Motor Demonstration and Tester]] which covers both the PIC and Arduino Version.
  
Possibly useful links:
+
== Download ==
Info on steppers:
 
Stepper motors
 
http://www.allaboutcircuits.com/vol_2/chpt_13/5.html
 
  
More info on steppers:
+
[http://home.comcast.net/~russ_hensel/OC/StepperTest_v1.zip Version 1 zip file: StepperTest_v1.zip]  If you want the most up to date version, email me to see if there have been some unposted revisions. [[russ_hensel]]
Basic Stepping Motor Control Circuits
 
http://www.cs.uiowa.edu/~jones/step/circuits.html
 
  
A terminal program this may work for you:
+
== Comment, Questions, Contributions? ==
Welcome to our Free Download/New Products Page!
 
http://www.rs485.com/psoftware.html
 
  
BoostC – I think the free version is enough to compile the program:
+
Email me [[russ_hensel]], or use the talk page for this topic.  All feedback is welcome.
SourceBoost Technologies
 
http://www.sourceboost.com/
 
  
Some may considered this project for just determining which stepper wire is which overly complicated: there are some simpler methods ( for example: http://www.doc.ic.ac.uk/~ih/doc/stepper/others/ ). However for one reason or another this has not always worked for me, this test is definitive and fun.
+
[[category:projects]][[Category:Test Equipment]][[category:Serial Communications]][[category:Microcontroller]][[category:PIC]][[category:BoostC]]

Latest revision as of 15:19, 30 December 2010

PIC Stepper Motor Demonstration and Test Project[edit]

There are multiple versions of this project for general infomation see: Stepper Motor Demonstration and Tester Note: we now have a version for the Arduino: Stepper Motor Tester for the Arduino

  • Name: PIC Stepper Motor Demonstration and Test Project
  • Status: still developing ( on back burner ), but is working. Planning a version for the Arduino.
  • Technology: PIC microcontroller with code in BoostC
  • Author: russ_hensel ( where you can find an email address to reach me )
  • Summary: A PIC16F877A project that operates a stepper motor under the control of a PC running a terminal program.

Last revision July 4 2008 – Draft, near completion except for Java control program. The C code works, but there are lots of some in other parts of the project. Archive zip file ( SerialStepperTest.zip ) includes: this doc, eagle schematic, program listing. Posted in download section.

This project has several potential uses:

  • Example code for stepper motor control and for RS232 communications ( interrupt driven on the receive end ) on the PIC16F877A.
  • Determining which drive wire is which on a unipolar stepper motor. This is the type of motor that I have most commonly found surplus or in salvage equipment
  • Determing angle per step or steps per revolution of a stepper motor.
  • Determing maximum speed of stepper motor.
  • Demonstrating the operation of a stepper motor.

Platform: PIC16F877A using BoostC connected via rs232 to a PC running a terminal program. The PIC chip is supplemented with a MAX232 chip and a ULN2003 driver.

The project is able to drive a stepper motor in a number of ways ( controlled by the RS232 connection ):

  • Set the number of steps
  • Set the direction of the steps
  • Set the time delay between the steps
  • Drive the wires to the stepper in any of the 6 possible connections ( permutations), this allows the user to determine which wire is which.

In general the stepper is driven by issuing several commands to set it up and then a final command to take a series of steps using this setup.

Example:

Command Meaning
v<cr> Get the version make sure the command interface is running, usually takes 2 tries to initialize, this is a bug which I have not fixed yet.
t10<cr> Set the step delay to 10 ms
p1<cr> Select permutation 1
d+<cr> Set direction forward
g400<cr> Go for 400 steps – full turn on many motors


Hardware[edit]

I have used a PIC 16F877A for the project, but pretty much any PIC with a uart and another 4 free I/O lines should do. To increase the drive to the motor I used a ULN2803 which is simply an array of Darlington transistors and diodes to be used as a low side switch for each motor winding. There are other similar chips around or discrete devices can be used. I run the pic, on 5 volts, and a larger voltages for the stepper, up to the limit of the driver. ( the UNL2803 is good for 50 v at .5 amp as a switch ) and the rating of the stepper motor. If you have a high power motor you may want a driver with more guts, Just put in some substitute. Coil drive is on or off there is no PWM involved here. Note that the hardware has substantial uncommitted resources. You could easily drive another motor for example. Also some of you may want to put some pull up or down resistors on some of the uncommitted resources. Instead of this board you could use the circuit from the PIC based Stepper Motor Dancing Analog Clock, the main difference is that that circuit does not use the MAX232 chip, it relies on an off board level shifter ( makes it easy to shift the level shifter from project to project while saving some money and board space )

Schematic[edit]

Schematic


Parts -- this is not up to date, working on it

Part Details
Power supply Not shown, you need two dc voltages, one for the PIC at 5 volts, and another with the right voltage for the motors. There is a suitable power supply in the PIC based Stepper Motor Dancing Analog Clock
PIC16F877A My favorate 16 series part, relatively lots of memory and pins. Bigger than you need, but only about 8 bucks. Try with an 18 series part, should not be hard and will leave you more up to date. Let me know.
Pull Up/Down Resistors 10k more or less
CQ1, CQ2 = capicators for the crystal about 20 pf seems to work, see the PIC16F877A manual
Q = crystal 4 meg Hz is what I used. May be quite a bit faster than needed, I have not looked into this. The 4 meg crystal seems to work ok on a proto board. Note that some of the code is dependent on this frequency, but could be fairly easily changed.
C_BP = By Pass Cap. Not on schematic, good idea to add one. A .01 to .1 mfd mica or other by pass cap, good at high frequency seems good.
DRIVER = Low side switch for motor coils. Driver chip for stepper. ULN2803. Good for up to .5 amp 35 volts I think. Could use discrete transistors ( possibly darlingtons ) if you want higher current. Also see note on stepper power.
RMC = Pull up resistor for master clear ( pull down with push button switch to reset ). 10k more or less
PUSH_BUTTON_SWITCH = Reset Push to reset the processor. Mine was from salvage.
STEPPER_POWER This voltage needs to be adjusted for the voltage of you stepper motor. Lower voltage motors, like 5 volt motors, often require more current than the driver chip can supply. You may need to change this to an array of power transistors for high currents. Make sure that 5 volts is enough to turn them on and perhaps add a current limiting resistor to the base drive. MOSFETS can be good, but not all switch on at 5 volt drive.
VPLUS_VDD = Positive power To the 5 volt power. Note stepper power is normally a different supply and often a higher voltage.
G1 = Ground connection Not show, add one to connect the power supply.
MOUNT_1...4 Mounting holes

Command Interface[edit]

All commands ( except stop should be terminated with a carriage return ) Note that the command interface is not very smart, giving parameters that are out of range my blow the whole program up. If so reboot the PIC. Do not send a new command ( except stop ) until earlier commands have been completed ( actually you can get ahead some if you are careful ). In earlier versions the commands had to be in lower case, I think current versions take either upper or lower case - check it out.

see: Stepper Motor Demonstration and Tester which covers both the PIC and Arduino Version.

Microcontroller Program Design[edit]

I no longer have the patience for assembly language. I have moved on to C in particularly BoostC, see link below. I like this compiler it has both a free version with some restrictions and a very reasonably priced full version. Writing in C should make the program fairly easy to read. Most of the design should be evident by reading the program, however a few notes here may help. see: Stepper Motor Demonstration and Tester for comments that apply to both the PIC and Arduino versions of the project.

Compiling[edit]

The zip file contains the entire source bootst project. Unzip into a directory and open in source boost. Set the target to 16F877A and change the linker options ( Settings -> options -> linker <none> Settings -> options -> compiler <none> ) There are 2 #defines, one for 20 meg crystal and one for a 4 meg crystal. After compiling my compiler reports something like:

Memory Usage Report

  • RAM available:368 bytes, used:139 bytes (37.8%), free:229 bytes (62.2%),
  • Heap size:229 bytes, Heap max single alloc:95 bytes
  • ROM available:8192 words, used:2118 words (25.9%), free:6074 words (74.1%)

I think you could contract the program a bit to get under the 2K free compiler limit.

Java Control Program[edit]

This was once an idea, but I have dropped it for lack of interest ( both mine and others ). Some thoughts that I had in the past:

Rather than use a terminal emulation program you can use a Java Program. This makes it easier to issue commands and has a much lower chance of making a mistake. The interface looks like this: ( actually almost written, email me if you have a special interest ).

This basically issues the same commands as you can issue with the terminal. There are a couple of enhancements

<All> sends all the parameters then the go command, thus you can run the whole setup by typing in the parameters and pressing <All>.

Which Wire is Which?[edit]

Stepper Motor Demonstration and Tester which covers both the PIC and Arduino Version.

Other Things to Try With the Tester[edit]

Stepper Motor Demonstration and Tester which covers both the PIC and Arduino Version.

Additions/Changes[edit]

Stepper Motor Demonstration and Tester which covers both the PIC and Arduino Version.

Possibly useful links[edit]

Stepper Motor Demonstration and Tester which covers both the PIC and Arduino Version.

Download[edit]

Version 1 zip file: StepperTest_v1.zip If you want the most up to date version, email me to see if there have been some unposted revisions. russ_hensel

Comment, Questions, Contributions?[edit]

Email me russ_hensel, or use the talk page for this topic. All feedback is welcome.