CNC Stepper ConTroller

A. PREFACE



        This topic purpose to support the CNC controller, but the technique is universal. So it is relevant to any other stepper motor controller to run on any other machine, or to use it in robotic field. Stepper motor usually 2-phase or 4-phase and have the coil configured as bipolar or unipolar type. This type is universal and have many way to drive it. But I got the 5-phase stepper, not usual and hard to find controller to drive it.
        Controlled using a stepper motor is an open loop controlled system, it means the result can not be precisely handle any error caused by disturbance or something else. The distance is equal to the number of step pulse given to stepper motor. If the load is too heavy then the controlled distance become disorder, and it must have to refer again to reference point.

EasyDriver Stepper Motor Driver 

B. EXPERIMENT

        Not like the universal bipolar or unipolar 2 phase stepper motor. Bipolar and unipolar stepper motor has many chip controllers and can be build from discrete part. But to run a 5-phase stepper motor, it takes more than that. My stepper motor have spec like this :
  • Vexta, 5-phase Stepping Motor, 6-cable, 
  • Type : A2487-9215 or A3380-9215,
  • 0.75A, 4 Ohm, 0.72Deg/Step, 
  • FH7-1413, 
  • Under license of Berger Lahr, 
  • Vexta, Oriental Motor Co. Ltd., 
  • Made in Japan.
I hacking the stepper motor and found the connection is star connection with one cable is the center tap.
        At first, I search the net to find how to run the stepper, I found Prof. Douglas W. Jones tutorial, show algorithm how to run the star type stepper motor for 5-phase coils. This program contains a good example to run the stepper. See also the http://www.stepperworld.com/, it contain tutorial how to run stepper motor, the technique to control it. Then I make some modification to run it from lpt parallel port. Here is the test program if you want to see it. The circuit attach to the lpt parallel port directly for data pin 2~6 connect related to coil 1~5 driver of stepper motor, using bipolar transistor. I put the rating voltage for 5V because the stepper motor rating only for 3V max. Check by tester to the motor voltage only about 1.3V and the current only about 0.4A, but it runs. Here is the circuit layout :
5-Phase Stepper Motor Controller Test Circuit Diagram (19.144 Bytes)
It doesn't have big torque yet, not a problem. I try to test the speed, it's only about 25 rpm (12.500 steps/minute) or only about 208 step/sec. This is of course very slow to run the threadrod, because I used about 20 tpi pitch. It just travel about 1 inch more per minute. It takes to slow. Up to this speed the motor start to buzzing and the moving not continuously. I try to read some chip controller data book. I found that if the frequency rise, the torque will become low, for high frequency the fluxtuation of magnetic field in the coil not get the maximum, because the voltage not get to maximum also. To rise this frequency, I must put the higher voltage to the motor, so the rise and fall time of the changing magnetic fluxtuation can be made more vertical slope. This information also discuss at internet CNC forum and other FAQ's. But I think that I must try this motor anyhow. So I surf the net .....
        Here are a few relevant infos, due to this project. First, Scott Stephens CNC PCB drill. He made his card using PIC microcontroller, but for bipolar type stepper motor. Good resource. Second, JAL, a pascal style PIC micro chip compiler, but still a primitive design, not like commercial product yet. Most important things that this is a free (based on GNU licence) design by Wouter Olaf van Ooijen. Many explanation about PIC micro types, designs, and kits, etc. Most a very good resource. Expecially for me, I am not to good in C programming, because it is too hard to follow the rules, also added by the complexity of the compiler rules itself, give me a dizzy. This JAL style more like Pascal style, it is more easy to follow.  

C. SCHEMATIC

        Here are the schematic for this PIC micro project. I need 3 inputs to control (this refer to the schematic block diagram for CNC made by Kelly, KCAM), ie: step, direction, and enable inputs.
  • Step input is an active low signal, 
  • Direction is CW for positive signal and CCW for negative signal,
  • Enable is active low signal, if low it will keep, if high then motor is free wheel. This function is also for power saving option,
The output run from a commercial power supply. I got these power supply for CB batery charger. the output about 13.8V/1.5A. So I used a resistor to cover this over voltage, since the motors are for 3V/0.75A. I used the power transistor C1061 or H1061 type, since this type already try before at my relay board project. In fact that this type is for 15A max current. But note that, I don't need a heatsink to this transistor. The others output 5-leds for monitoring the stepping sequence. It may be omitted and the spare I/O can be used for another purpose, like current limiter or something else. It is up to your choice, because the PIC can be reprogrammed. For this design I use PIC16F84A type and I choose the I/O map like this :
  • I/O port A-0 = LED indicator phase-1 stepper
  • I/O port A-1 = LED indicator phase-2 stepper
  • I/O port A-2 = LED indicator phase-3 stepper
  • I/O port A-3 = LED indicator phase-4 stepper
  • I/O port A-4 = LED indicator phase-5 stepper
  • I/O port B-0 = Coil phase-1 stepper
  • I/O port B-1 = Coil phase-2 stepper
  • I/O port B-2 = Coil phase-3 stepper
  • I/O port B-3 = Coil phase-4 stepper
  • I/O port B-4 = Coil phase-5 stepper
  • I/O port B-5 = Input step pulse
  • I/O port B-6 = Input direction
  • I/O port B-7 = Input enable motor
Note that for I/O port A-4 pin, because this I/O is an open collector type I/O. It can not sink or source any self current. Another I/O are totem pole I/O. If you don't know that, when you experiment with it, as if this I/O was broken.

New FREESCALE SEMICONDUCTOR FREESCALE SEMICONDUCTOR Integrated 8-Ch Stepper Motor Controller

D. LAYOUT

        To wiring the component, I design a PCB layout to fit this purpose. Here is one of this design and tested as my prototype. It work good. I made 3 of it to run my CNC drilling machine (XYZ table).

E. PART LIST

        Here are the part list for this stepper controller :
   1. Resistors :
      R1 ~ R5 = 220 Ohm, 1/4W, 10% ..............5 pcs
      R6 ~ R10 = 1k, 1/4W, 10% ................. 5 pcs
      R11 ~ R15 = 12 Ohm, 10W, 10% .............5 pcs
      R16 ~ R19 = 4k7, 1/4W, 10% ............... 4 pcs
   2. Capasitors :
      C1 ~ C2 = 22 pF (for oscillator) ........... 2 pcs
      C3 = 100 nF (for IC decoupling, used as necessary)....1 pcs
   3. Semiconductors :
      IC1  = PIC16F84A (PIC microcontroller) ...........1 pcs
      Q1 ~ Q5 = C1061 or H1061 (NPN transistor) ........2 pcs
      D1 ~ D5 = 1N4007 (Silicon diode) .................5 pcs
      LED1 ~ LED5 = 3mm red ........................... 5 pcs
   4. Others :
      X1 = 4MHz (Crystal oscillator) ...................1 pcs
      Optional IC socket for 18-pins (use 20-pins) .... 1 pcs
      Optional terminal connector CON1, CON4 = 2 pin ...2 pcs
      Optional terminal connector CON2 = 4 pin .........1 pcs
      Optional terminal connector CON3 = 6 pin .........1 pcs

F. FIRMWARE

        PIC microcontroller IC needs to programmed with the specific programmer. Many commercial programmers can programmed this IC. But for this purpose ofcourse, I don't want to spend too much to these kind of programmer. So I used a selfmade PIC programmer. Many free design PIC programmer included with its software program on the net right now (search the net by types "PIC micro programmer). Some are free, some are shareware, many are comercial made. Some only for a specific type, some for a wide variety types. I choose a free one. I made the El-Cheapo PIC programmer, because I already have the PCB when I buy the book of Myke Predko (as a free bonus included with his book), also this is a simple one. It can programmed a few types of PIC micro from the small type to the large type. And the most important, it works. I already reprogrammed many-many times. But I change the original design to fit the last version (newer version, its V0.84 when I made this). This is  my PIC programmer looks like.
        For this stepper controller, I used JAL (free pascal compiler), but still limited development (all is free, include the source program base on GNU licence). More interesting to learn yet.
        For this 5-phase stepper controller sequence algorithm, I make the sequence like this :
  • If input disable then all output coil low (zero)
  • If input enable then keep the output with the last step
  • If input step low then check direction. If direction CW then increment step, else decrement step
  • Loop the process to the beginning
In my last experiment, I don't put delay between 2 pulses, so the timing keep up to the clock frequency. I hope that I could run the stepper motor as fast as possible. The speed about 70 RPM (600 steps/sec) could be make.
Here is the firmware for PIC-16F84A :
  1. 5-phase stepper controller final version (jal)
  2. 5-phase stepper controller final version (asm)
  3. 5-phase stepper controller final version (hex)
That's all ...!!!

G. APPLICATION

Running Small Motors with PIC Microcontrollers 

        To run the stepper board from PC, I need an interface to connect all the board and parts togethers. Here are the application to my CNC drilling machine, schematics for CNC LPT interface diagram and CNC block to block connection diagram. The PCB layout for this interface also already made like this. For this interface it takes a few component also. I used the relay board that I already design first when I fix my washing machine. Because I need only 2 relays for spindle motor and maybe for vacuum for next expand. Even the board reserved for 3 relays. Then the interface board can be build small enough. Here are the additional part list for this interface :
   1. Resistors :
      R1 ~ R12 = 4k7, 1/4W, 10% .......................12 pcs
      R13 ~ R15 = 1k, 1/4W, 10% ...................... 3 pcs
      R16 ~ R17 = 1k, 1/4W, 10% (for relay indikator led)  2 pcs
   2. Capasitors :
      C1 ~ C2 = 1000 uF/16V ..................... 2 pcs
   3. Semiconductors :
      IC1  = 7805 (Voltage Regulator) ........... 1 pcs
      Q1 ~ Q2 = C1061 or H1061 (NPN transistor) ... 2 pcs
      D1 ~ D2 = 1N4007 (Silicon diode) ............. 2 pcs
      LED1 ~ LED2 = 3mm red (for relay indicator) ...2 pcs
   4. Others :
      Optional power supply connector CON1, CON6, CON11 ...3 pcs
      Optional terminal connector CON2, CON4, CON5, CON7, CON9,
               CON10, CON12, CON14, CON15, CON19 = 2 pin ...10 pcs
      Optional terminal connector CON17 = 3 pin ........1 pcs
      Optional terminal connector CON3, CON8, CON13,
               CON18 = 4 pin .......................... 4 pcs
      LPT connector CON16 = DB25-F .....................1 pcs
      Optional terminal connector CON3 = 6 pin ......... 1 pcs

H. PROTOTYPE

        Here are the prototypes 5-phase stepper board, and cnc lpt interface also the relay board. For those of you which curious and enthusiasm or want to built also, here are the complete cnc controller package.

AUTONICS 5PFF9 Stepper Motor Controller, 2 Axis, 24VDC 

I. PENTA CONNECTION 5-PHASE STEPPER

        Some 5-phase stepper motor has star connection wiring, while the other is penta connection. For this kind of connection I already modified the firmware to control it but I didn't try it, please use it at your own risk. First of this firmware ask by a reader, Andy Evans, who has found the wiring schematic and the boolean truth table to run it. But he has difficulty to make the controller. The controller still use PIC16F84A type and some change to the I/O map are like this :
  • I/O port B-0 = Bridge Transistor SW1 drive
  • I/O port B-1 = Bridge Transistor SW2 drive
  • I/O port B-2 = Bridge Transistor SW3 drive
  • I/O port B-3 = Bridge Transistor SW4 drive
  • I/O port B-4 = Bridge Transistor SW5 drive
  • I/O port B-5 = Bridge Transistor SW6 drive
  • I/O port B-6 = Bridge Transistor SW7 drive
  • I/O port B-7 = Bridge Transistor SW8 drive
  • I/O port A-0 = Bridge Transistor SW9 drive
  • I/O port A-1 = Bridge Transistor SW10 drive
  • I/O port A-2 = Input step pulse
  • I/O port A-3 = Input direction
  • I/O port A-4 = Input enable motor
All of the I/O are used. To make it easy, I put all the port B I/O to drive the transistor, and some of  port A. While the control signal put at the rest of port A. You can change it as your purpose, but remember to change the firmware too. No need I/O for selected input for half or full step, because the sequence only for half step purpose, besides that the I/O already run out. Here is the complete firmware for this 'penta 5-phase stepper controller' by my concept and design. Have a good luck!
        Recently, I got somewhere from the net, 5-phase penta connection stepper and the sequence to run it (in full step). May be it's helpful to another person.

1 comment:

Followers