📜 ⬆️ ⬇️

CNC milling machine with stand-alone controller on STM32

Since I have assembled a CNC machine for a long time and have been regularly using it for hobby purposes for a long time, I hope my experience will be useful, as well as the source codes of the controller.

I tried to write only those moments that personally seemed important to me.

The link to the source of the controller and the configured Eclipse + gcc shell, etc., are in the same place as the movie:
')


History of creation


Regularly confronted with the need to make this or that small “trick” of a complex shape, I initially thought about a 3D printer. And even started to do it. But I read the forums and assessed the speed of the 3D printer, the quality and accuracy of the result, the rejection rate and the structural properties of thermoplastic, I realized that this is nothing more than a toy.

The order for components from China came in a month. And after 2 weeks the machine worked with control from LinuxCNC. I collected from any garbage that was on hand, because I wanted to quickly (profile + studs). I was going to remake it later, but, as it turned out, the machine turned out quite hard, and the nuts on the studs did not have to be tightened even once. So the design remained unchanged.

Initial operation of the machine showed that:
  1. Using a china noname 220V as a spindle is not a good idea. Overheats and works terribly loud. The side play of the cutter (bearings?) Is felt by the hands.
  2. Bormashinka Proxon works quietly. Luft is not noticeable. But overheats and turns off after 5 minutes.
  3. A time-taken computer with a LPT bidirectional port is not convenient. Taken for a while (finding a PCI-LPT turned out to be a problem). Takes place. And generally speaking..

After the initial operation, I ordered a water-cooled spindle and decided to make a controller for autonomous operation on the cheapest version of the STM32F103, sold in a set with a 320x240 LCD screen.
Why people still stubbornly torture 8-bit ATMega for relatively complex tasks, and even through Arduino is a mystery to me. Probably love difficulties.

Controller development


The program was created after a thoughtful review of the LinuxCNC source code and gbrl. However, they did not take the source code for the calculation of the trajectory. I wanted to try to write a calculation module without using float. Exclusively on 32-bit arithmetic.
The result suits me for all modes of operation and the firmware did not touch for a long time.
The maximum speed, selected experimentally: X: 2000mm / min Y: 1600 Z: 700 (1600 step / mm. Mode 1/8).
But not limited to controller resources. Just above the already nasty sound of skipping steps, even straight sections through the air. A budget Chinese shag control board on the TB6560 is not the best option.
In fact, the speed of the tree (beech, 5 mm depth, d = 1 mm cutter, 0.15 mm pitch) is not greater than 1200 mm. The probability of breakage of a mill increases.

The result is a controller with the following functionality:

The controller will connect to the control board shagovikov through the same connector LPT. Those. it acts as a control computer with LinuxCNC / Mach3 and is interchangeable with it.

After creative experiments on cutting his own hand-drawn reliefs on a tree, and experiments with adjustments of accelerations in the program, I also wanted to use encoders on the axes. Just on e-bay I found relatively cheap optically ecocoders (1/512), the division step of which for my ball screws was 5/512 = 0.0098mm.
By the way, the use of high-resolution optical encoders, without a hardware scheme for working with them (it is in STM32) is meaningless. Neither interruption processing, nor, all the more, program polling will ever cope with the “bounce” (I say this for ATMega fans).

First of all, I wanted for the following tasks:
  1. Manual positioning on the table with high accuracy.
  2. Control skipping steps with the control of the deviation of the trajectory from the calculated.


However, he found another use for them, albeit in a rather narrow problem.

Using encoders to correct the trajectory of a machine with stepper motors




I noticed that when cutting relief, when setting acceleration on Z more than a certain value, the Z axis starts to creep down slowly but surely. But, the relief cutting time at this acceleration is 20% less. At the end of the relief carving of 17x20 cm with a step of 0.1mm, the cutter can go down 1-2 mm from the calculated path.
An analysis of the situation in dynamics by encoders showed that when lifting the cutter, 1-2 steps are sometimes lost.
A simple algorithm for the correction of steps using an encoder gives a deviation of no more than 0.03 mm and reduces the processing time by 20%. And even 0.1 mm protrusion on the tree is difficult to notice.

Design




The ideal option for hobby purposes considered the desktop version with a field slightly larger than A4. And I still have enough of it.

Movable table


It still remains a mystery to me why everyone chooses a gantry design for desktop machines. Its only advantage is the ability to process a very long board in parts, or if you have to regularly process a material whose weight is greater than the weight of the portal.

For all the time of operation, there was never a need to cut the relief on a 3-meter board into parts or make an engraving on a stone slab.

The movable table has the following advantages for desktop machines:

  1. The design is simpler and, in general, the design is more rigid.
  2. All offal (power supplies, boards, etc.) are hung on the fixed portal and the machine is smaller and more convenient for carrying.
  3. The weight of the table and a piece of typical material for processing is significantly lower than the mass of the portal and spindle.
  4. The problem with the spindle cables and water cooling hoses almost disappears.


Spindle


I would like to note that this machine is not for power processing. CNC machine for power processing is the easiest to do on the basis of a conventional milling machine.

In my opinion, a metal power processing machine and a machine with a high-revving spindle for wood / plastics processing are completely different types of equipment.

Create at home a universal machine at least does not make sense.

The choice of spindle for a machine with this type of ball screw and guides with linear bearings is unambiguous. This is a highly revving spindle.

For a typical high-revving spindle (20,000 rpm), milling non-ferrous metals (even steel is out of the question) is the extreme mode for the spindle. Well, except that it is very necessary and then eat at 0.3 mm per pass with watering the coolant.
A spindle for a machine would recommend water-cooled. During his work, only “singing” of stepper motors and gurgling of the aquarium pump in the cooling circuit can be heard with it.

What can be done on such a machine



First of all, the case problem left me. In any form, the body is milled from “Plexiglas” and glued together with a solvent in ideally smooth cuts.

Steklotekstolit refused universal material. The accuracy of the machine allows you to cut a seat under the bearing, in which it will go cold, as it should be with light pressure, and then no longer pull out. PCB gears are perfectly cut with an honest involute profile.

Wood processing (reliefs, etc.) - a wide scope for the realization of their creative impulses or, at least, for the realization of other impulses (ready-made models).

That's just not tried jewelry. There is no place to calcine / melt / pour flasks. Although the bar of jewelry wax is waiting in the wings.

Source: https://habr.com/ru/post/250677/


All Articles