Skip to content

Hardware Setup

Shai Seger edited this page Jun 19, 2020 · 16 revisions

Introduction

In order for a Gcode App to send commands to a CNC machine, some sort of hardware driver is needed in order to convert the GCode language into electric pulses that drives the CNC motors. There are two levels for this hardware. The interpreter that translates text GCode to electric pulses, and the power semiconductors that actually drive the motors. Most Chinese hobby CNC machines comes with the power drivers and relies on PCs with parallel ports to do the GCode interpretation. Software like LinuxCNC do exactly that. Since most PCs and certainly laptops no longer have parallel ports, other ways must be used to do this work.
This can now be done using cheap, small micro-controller boards (much like Arduino) The BluePill was selected for its relative high performance (32bit arm based), its built in USB connection, and its very low price. An adapter PCB was also designed so the controller can be plugged directly to the CNC's parallel port input.
Although this was design to be used on a generic Chinese CNC3040, It can be used on any CNC with parallel port input.
For other DIY CNC machines, the controller board can be connected directly using wires.

Here are the pin connections

Pin Diagram

Hardware adapter assembly

Ordering the PCB

  1. Download the latest release from here and unzip to an empty folder.
  2. Inside the folder you will find the pcb production file: gerbers_cnc3040_2Layer.zip
  3. Upload the file to SeeedStudion leave all parameters as default and make the order. You will get 10 pcbs for a ridiculously low price. Share the extra PCBs with friends!
  • Another option (might be a better choice for US residents) is to order it directly from OSHPark, no need to upload anything...

Order all the parts

you will need the following:

  1. BluePill Controller board. Very important note: Many of these boards ordered in china comes with non original ST chips. They will work with firmware as is, but if you want to make changes to the firmware and debug it, the STMCubeIDE will not let you. This link used to send me genuine chips, but the last batch was not. If you want to play with the firmware, make sure you find a genuine seller.
  2. DB25 right angle female connector - Only one needed
  3. 1/8w 47R resistors - Quantity depending on your CNC configuration. 17 max.
  4. STLink Programmer - needed for flashing the controller

Parts

Assembling

  1. Solder the pin header to the controller board. Solder pin header Make sure the pins are perpendicular to the board or it will not fit the PCB. A good way to do it is to solder only one of the pins, then hold the board in the air and straighten the pins while heating the soldered pin with the soldering iron. pins soldered When the pins are straight enough, turn the board back and complete soldering all other pins.

  2. Solder the controller to the PCB. Insert the controller board to the PCB taking care to insert it the right way. See the image for correct orientation, and also make sure the PCB is not upside down: Orientation

  3. Trim excess pins: Trim pins

  4. Insert the DB25 connector: Insert connector Turn the PCB arround and solder the connector, making sure it is all the way in. Again, better solder 1 pin, make sure the connector is fully in, adjust if needed, then solder all other pins. solder connector

Soldering the switchboard

This is where the adapter is customized to your CNC. From your CNC documentation find the function table of each pin on the parallel port input connector. for example:

X Step -> pin 2
X Direction -> pin 3
Y Step -> pin 4
.
.
etc...

On the back of the PCB there are the switchboard pads in 2 columns - the function, and the input pins. Switchboard pads

You now need to attach 47 Ohm resistors from each function pad to the corresponding parallel pin pad. For example, lets say the limit pins in your CNC function table are:

X Limit -> Pin 9
Y Limit -> Pin 11
Z Limit -> Pin 12

You will need to solder the resistors as follows: switchboard resistors

Do the same for all the functions your CNC supports. Pins without functions leave empty. If some of the resistors cross over other resistors, use insulation to prevent shorts. you can solder the resistors on both sides of the PCB, this can help reducing clutter. If pins and function pads are in the same line, you can use 0603 smd resistors to connect them directly.

Final result:
Final product

Assembly is finished, continue to firmware flashing.