STM32 Based Desktop CNC – Version 2018

I have been playing with simple moving tables equipped with stepper motors since years.

Last year (2017) I decided to develop a “useful version” of the desktop CNC as a support tool for my hobby electronics. Once I started to have the first prototypes, it became a main hobby item itself  with its never ending more and more improved versions.

I did not develop a Mach3 compatible interface, instead, I tried to develop a smarter device that directly accepts Gcode commands and executes them.  We need to send it Gcode commands line by line. To do that, I developed a “streamer” and HMI of CNC that runs on a PC.

Making a Mach3 compatible version has been a consideration, but I postponed that idea. This compatibility is not a priority for my personal interests .  I want to have full control on the controller HW/FW and HMI interface, to do whatever I like. Down side is, my SW does not have publicity and support as Mach3 compliant applications do that you can find all around.

For example, I can easily create a class  to draw/cut any thing using my HMI (Python based). I can instruct it to drill a series of holes to a certain depth, or cut a rectangular block etc. My HMI already has several preprogrammed buttons to do such things.

Library functions on the HMI on the PC Screen

For those who prefer to take the Mach3 route, there are a lot of free tools such as Linux CNC etc. In that case a purchased Mach3 compatible motor driver would do the controller/driver job, which can be found with many alternatives in the market.

Development has been progressive process with “trial and error” style. This work has been a hobby thing at the end, so mainly enjoying myself by doing a better version on each step.

CNC parts fron previous versions
Parts from previous versions.

MAIN SPECIFICATIONS

  • Motors : 3 x NEMA23 5V 2A stepper Motors
  • Working area (XYZ) : 150x150x100mm
  • Step Size : 0.020 mm
  • Positioning accuracy : % 0.5
  • Positional repeatability over the range : +-0.1mm (with proper load/speed considerations to avoid skipping of steps.)
  • Steps per mm : 50
  • Travel speed : 10mm/sec (600mm/min)
  • Typical cutting speed  : 5mm/sec (300mm/min)
  • Displays: One LCD with 4 lines of 20 chars for text, one 320×480 TFT Graphics display for displaying keyboard soft keys and drawing of the processed file.
  • User Interface : One 4×4 keypad for direct entries to CNC and using it standalone without a PC. Plus a HMI on PC for steaming gerber codes from files, manual motion control and parameter settings and library functions for mostly used shapes.
  • Codes accepted : Gerber G-Codes and Excellon drilling codes. For detailed listing of accepted codes please see the relevant paragraph.
  • Power supply : 220VAC/50Hz
  • Structural material : Aluminium profiles and Fiber Reinforced Phenolic Resin boards.

PERFORMANCE EXAMPLES

Displaying Graphics on TFT
Displaying a Gcode file on TFT Screen (red lines display tool movement in air.)

Above example is a Gcode drawing file, that I found on internet, consist of ~6500 lines of text. It takes 2:30 minutes to stream and draw on TFT, without cutting it on CNC.

PCB as Displayed on TFT while engraving and drilling..

This is a PCB engraving example. PCB has dimensions of 70x80mm. Its Gcode file has 350 lines and takes 4:32 minutes to engrave on CNC. Excellon (.xln) drilling file consist of ~80 steps and takes another 4:00 minutes to execute.

PCB Made by CNC Engraving

And this is the PCB that has been made using my CNC.

MECHANICAL STRUCTURE and PARTS

Mechanical stability and precision of the sliding tables had been the most challenging tasks. I made my first version using the furniture drawer rails – surprisingly performed not so bad ! Then I tried 8mm hardened steel linear motion rods with linear ball bearings. But they were not providing satisfactory support for the table and spindle motor.

3 main components. Nema23 Step Motor, threaded rod and linear motion rail. 8mm linear motion rail as seen on the photo did not perform well.

These 8mm rods, even 10mm diameter rail rods were flexing under the load. Finally, after several trials, I decided to use 12mm hardened steel rods with a full length support rail underside.

Linear motion rails with full length support underside that prevent flexing.

I had to try several linear ball bearing carriages to find the one that slides smoothly. Although there are many from different manufacturers with same specs, some of them have very bad quality due to the low quality balls and weird plastic separators. I had to throw some of the packages I bought on internet into the trash, due to the clogged balls. They were not sliding smoothly, even being locked on the rails. So, pay attention to buy them from a shop after trying them at the spot. (Bring a sample of your rail rod with you).

This kind of circular rails are good for medium precision works, where a sidewards slack of 0.2mm or so does not bother you. When you need higher stability, you must use more expensive rails and trucks as below.

SPINDLE MOTOR

One of the difficulties was the spindle motor. There are powerful alternatives, air cooled, water cooled models. But they are terribly expensive for me. Besides that, they are heavy, I must save the limited driving capabilities of my stepper motors. I first used a wood engraver from Dremel, which performed good for many light-weight tasks.

Dremel engraver used as spindle motor.
Wood engraving tool used as spindle motor, and home made clamping parts.

But I can not keep it fastened on the CNC all the time, since I need it for other works. Besides that, it is very noisy for the CNC works, some of them lasting tens of minutes. I finally invested in a 500W DC Powered spindle motor. It is very quiet. It is not very professional but quite satisfactory for working on plastics, wood and light work on aluminium.

Spindle motor as purchased, with ER11 Chuck, adjustable 100V DC Power supply and a mounting clamp.
spindle motor
Spindle Motor – mounted on CNC X/Z Table

Speed of this motor can be set to a value between 3000 to 12000 rpm, by adjusting its DC supply voltage. That means, in slower speeds, you have proportionally less torque, in a professional application where you need full cutting power at all speeds, this is not acceptable, so you have to go to real spindle motors with serious speed controls.  This one is less than 100 US Dollars. If you afford to pay the twice, you can buy a brushless motor with its driver with a speed controller that utilize hall effect sensor feedback.

For my applications; making PCB’s, cutting wood, plastics and plexiglass, it fits in perfectly .

It came with a chuck to hold cutting/drilling bits with 3mm diameter shafts. I want to be able to use cutting/drilling bits of various shaft diameters, so I bought a set of ER11 spring collets.

USER INTERFACE

This CNC can be used standalone, without a PC. In this case you can do basic linear movements and cutting operations using the key panel and two displays of controller. It has two displays, one 4×20 character text LCD display and the other is a 3.5″ TFT Graphic display.

Second and main alternative of use is by using a PC, connected via an USB cable. In this case you can do complicated tasks, and execute Gcode/xln files.

CNC CONTROLLER KEYPANEL AND DISPLAYS

Controller unit has a 4×4 button key panel. Usr can set basic parameters of the CNC, enter coordinates to go for each axis etc. Key panel is used as a soft key set. That means, keys are assigned to different functions according to the menu which is in effect. Under normal operation, that is, while working under PC control,  all keys except one control button are disabled. Control button, which is lowest right one is used to enter into keypanel(KP)  control mode.

In KP control mode TFT screen displays soft functions of the keys.

LCD Text display is for displaying coordinate information, entered numerical values and set values of parameters.

main menu
CNC Main menu

Main menu appears on TFT screen, when lower rightmost key is depressed.

Under main menu, top two rows of the KP is activated. You can select one of the 4 submenus, Clear the screen and return to PC Control mode. Graphic icons on buttons are self explanatory.

Submenus are :

  • File menu : Under this menu you can execute a Gerber file read from a SD card.
  • Manual jogging Menu : You can manually jog in X/Y/Z directions
  • Coordinate entry Menu: Movements by entering X,Y,Z coordinates
  • Parameter settings menu : You can set various parameters of the CNC

FILE MENU

This menu has been disabled in this version.

JOGGING MENU

In this version 9 buttons are activated, plus return key.

You can move in X,Y,Z directions and go to home (0,0,0) position. Movement steps can be adjusted using two (+ and -) buttons.

COORDINATE ENTRY MENU

You can enter X,Y,Z coordinates and press “ENTER” button to move to desired location manually.

Coordinates are entered without decimal points, and x100 mm’s. That means if wet to enter 12mm, you should enter 1200 and hit OK to set the coordinate value.

ADJUSTMENTS MENU

Here you san set following parameters:

  • Draw on TFT only : Does not move X,Y,Z motors, draws only on TFT
  • Machine only : Only moves X,Y,Z motors, no drawing on TFT
  •  Machine and TFT : Draws on TFT while cutting/drilling on CNC.
  • Zoom in: Effects TFT image only
  • Zoom Out : Effects TFT image only
  • Mirror : Cuts and draws a horizontal mirror image of the received drawing
  • Normal : Resets from mirror to normal mode

TO BE CONTINUED