I originally posted this on DesignSpark to give something back for the great, free PCB design app they have provided, figured it's more likely to be useful here, in the CNC community.
Incidently, I have also designed/built a similar circuit using the Allegro A397X chips, written my own Arduino library for a G-Code interpreter and designed my own app for parsing/transmitting the G-Code to the Arduino (with real-time display of the CNC output) - If you're *really* kind, I *might* post these at a later date
I am building myself a CNC machine based on a programmable Arduino UNO to act as the G-Code interface between the PC and the CNC. I needed to drive the stepper motors and found plenty of ready-made boards I could buy to do the job.
My first problem was the usual budget constraints - I have been building the CNC for several months, buying parts each month to spread the cost but I couldn't really justify to "she who must be obeyed" that the expense of 3 motor drivers was a necessity. So building the circuits myself was the only way I could break down the cost and come in cheaper than the ready-made boards I had seen.
The second problem was that my Arduino pins are nearly all in use just controlling the stepper motors and other parts that I've planned/designed into the CNC (such as an optional/exchangeable 3D print head, controlling the main PSU on/off etc). I didn't really have the pins I needed to detect if the CNC had reached its limits (X, Y and Z).
So I designed this circuit to allow the stepper motors themselves to stop if they reached their limits. At the time I was also considering sacrificing the ENABLE pins of the Arduino/Steppers too, so the circuit enables the stepper motors by default.
I ordered the PCBs from the US Dorkbot PCB manufacture service at a cost of $5 per square inch, for that you get 3 copies of your PCB - perfect for me as I had 3 motors to drive.
I had already built a prototype using stripboard and it seemed to work fine but was a little on the large size (about twice as big as the PCBs I had designed) so I was eager to see if my PCB version would work as well as the prototype.
I built and tested the first board - it worked perfectly. The L298 chip reached about 60 degrees C without any heatsinking, well within the design tolerance, and the rest of the board stayed nice and cool.
Since it worked so well, I decided I would share the circuit for others to build the boards for their own use.
The board provides several inputs/outputs and options:
2 power inputs:
5V for the circuitry and 5-36V for driving the steppers themselves, although I just used the same 5V supply for both inputs on mine which worked fine for me as my stepper motors were only rated at 3V.
Allows you to enable/disable the stepper motor.
Clockwise or counter-clockwise stepping of your motor
Steps the motor once, toggle this line for repeated stepping of the motor in the given direction.
Limit Clockwise: (optional)
Stops the motor from turning clockwise, useful for when a limit switch has been reached. Pulling the limit pin low forces the motor to stop responding to any further step requests in the clockwise direction. The circuit does provide a 0V pin next to the limit pin to just connect a switch.
Limit Counter-Clockwise: (optional)
Same as above for the reverse direction
Allows full or half-step modes to be used by simply changing a jumper position
Uses a jumper to select between using the inhibit or output methods for control limiting.
A jumper selects between internal and external Sync options. In External mode it provides a pin for connecting the external sync. I just use the internal clock since the timing of my motor steps isn't that critical and it's all controlled by the Arduino anyway.
4 pins to connect your stepper motor. Remember, this circuit is designed for bipolar steppers only. You need to read the spec on your motors to determine the correct wiring of your motor fly leads.
A trimmer resistor for altering the output current driving the stepper motors. Note: this trimmer works in reverse to what you might expect, clockwise rotation actually LOWERS the output current.
If you have problems with your motor appearing jittery when no step/dir signal is applied, you plobably need to tweak the current limit trimmer. If the stepper seems to respond to step/dir but doesn't appear to step in the same direction for each successive step request, you probably have the stepper motor wired wrong.
This circuit is provided as-is, with no warranty or fit-for purpose statement. This circuit works fine for me but use it at your own risk.