The logic driver:
Over the last few weeks I was developing the logic driver for the CNC machine, with logic driver I mean that circuit that converts the step and direction inputs coming from the parallel port of the PC to a predefined 4 bit pattern that drives the power driver, and that consecutively drives the steppers.
The pattern that I'm referring to is the following:
![]() |
Drive mode: Bipolar Full stepping two phases on |
The circuit has been developed as a FSM (finited states machine), I've started designing it by writing down the ASM diagram, then I've extrapolated the circuit's truth table from the diagram, next from the truth table I've extracted the logic formulas and finally from the formulas I've drawn the actual circuit, here it is:
![]() |
On the left a 2 bit up/down counter, on the right 2 XOR gates and a NOT gate |
As you can see the circuit is very simple to implement, on the 4 output (on the right) will be attached the 4 wires of the power driver, that consists simply of an L298N dual full H bridge chip plus some flyback diodes and other miscellaneus parts, as you can see in the following image:
I've bought 3 of those power driver board on ebay for 3€ (3.3$) each from china.
The original idea was to build the power driver too with mosfets, but that approach is way more expensive than buy the already built driver.
Here the image of a dual full H bridge implemented using mosfets and flyback diodes:![]() |
Theese two circuits are used to drive one single stepper, one for each phase of the stepper |
To build the logic driver I'm using the HCF4029BE 4 bits up/down counter, the CD4070BE quad 2 inputs XOR gates and a 2N3904 transistor used as a NOT gate.
I chosen theese parts because they're quite cheap and easy to find online.
Let's talk a little bit about resetting the counter, I've came up with a neat idea (then I discovered that this method is used in almost all modern microcontrollers), it consists of auto resetting the chip for some milliseconds after the power is turned on, this is accomplished with a RC delay line and an op. amp. used in the inverted Schmitt trigger non symmetrical configuration, here an example:
![]() |
The output J1 is connected to the reset pin of the counter (the HCF4029BE reset pin is active high) |
Here an image of one logic driver mounted on the breadboard:
The breakout board:
The logic driver is only one of the parts that mades up the CNC breakout board, in fact the breakout board is made up by the parallel port, the logic driver, the power driver, the auto reset circuit, the e-stop (with its own de-bounce circuit), the coolant controller, the spindle controller and so on.
I want to keep the design of my CNC simple, so the unnecessary functions are left off, such as the PWM spindle speed control, the home and limit switches, etc...
Here an image of the breakout board schematic:
![]() |
As you can see the auto reset circuit can be also used as a switch de-bounce circuit |
You can find the EAGLE schematics for this breakout board in the download section of the blog.