# fast motor control for a cnc machine brainstorming session

#### scott165

Joined Oct 13, 2017
5
Hello all

I just wish to brainstorm with some of you and many of you may have some experience and recommendations.

Over my engineering career i have done many projects that involve precision motion control.
However, one problem continues to lurk. I have yet to tackle a project that required multiple motor coordination that is nearly real time. For example a CNC machine.

Now anyone can google and see that DIY cnc machines are the norm project now. so i ask the following.

How are people achievement dang near real time multi motor control? IF someone asks me this question my mind runs to the most complex solution i know of. Real time target machines using matlab models or perhaps an FPGA based solution.

I have done lots of old projects with RS232 communication based motors and some PLC motor control but non o those options are fast enough for a cnc machine.

So these DIY yourself kits are what..........?

The only guess i have is micro controller based.
IS the micro controller able to execute fast enough to issue 3 lines of commands . e.g move the x motor to this postion the y motor to this positon and the Z motor to this position fast enough that there is not a total loss in resolution of a movement?

Take for example, you want to cut a 2D circle on a a cnc machine
The Micro Controller executes a line that says
Move the X axis motor to this point. As it moves to the second line to execute the Y axis already the X has already moved. And around and around we go.

If you could zoom in with a microscope you would see not a perfect circular cut but a stairway cut pattern in your circle.

So my question is, are cheap micro controllers just fast enough these days to where the "stairway" i speak of above is so small that it does not effect the machine?

I often wonder how people are building $1000 cnc machines because my real time target machine i would use for one cost$5k just for the computer lol so...... obviously its something else

Who here has the answer to my question?

Thanks for the ideas

Joined Jul 18, 2013
26,277
I believe you are referring to circular interpolation, in the most basic of systems such as Mach3 etc, the PC is the trajectory planner and hands off the motion control to individual intelligent drives, stepper or servo, in the case of servo, the loop is closed back to the drive and Mach has no FB/track of the actual motion path.
And yes, a circular path is made up of small individual steps, and in order to keep thing working smooth, advanced systems use something called feed forward buffer that usually involves a storage buffer for the individual moves.
With these systems, features like electronic gearing and electronic CAM moves are not possible.
The next step up is a central motion processor such as used by Kmotion and the ones I love, Galil Motion cards, this is where the encoders are fed back to the central processor and the drives can be simple trans-conductance amplifiers with no micro logic.
The Galil, BTW, accept up to 8 encoders at a rate of 12Mhz! Also electronic gearing is possible.
These are close to any of the major Industrial systems.
Max.

#### scott165

Joined Oct 13, 2017
5
[QUOTE="
Max.[/QUOTE]

More like gave me an entire new bunch of questions to ask lol

#### scott165

Joined Oct 13, 2017
5
Another step up from Mach, is the Linux based CNC controller program.
http://linuxcnc.org/docs/html/getting-started/getting-linuxcnc.html
Max.
Which makes me then ask even more questions. I have fooled around with the linux kernel before. Its not exactly what i call fast.
Now the last time i did, it was RS232, so what com protocol are they using to do it on a linux machine.

everytime i fool with old stuff like RS232 the problem is always over loading the input buffer. And unless you are using multi threading techniques you can not read the buffer and send process data at the same time.
It has been a thorn in my side for many years

Joined Jul 18, 2013
26,277
I have not used the Linux S/W, so cannot really comment, but it seems to have quite a following and AFAIK a PC slot can be used in order to use one of the motion cards they recommend.
On the Kmotion, the PC is used as a front end HMI and the motion is done externally by Micro on a USB board, where the encoders are returned to, so electronic gearing should be possible..
Max.

#### scott165

Joined Oct 13, 2017
5
So the direct answer to my question is, CNC machines are really being driven today by fast multiple micro controllers. We sure as heck are not going to execute this in C++ and push it out of a serial port

#### scott165

Joined Oct 13, 2017
5
I have not used the Linux S/W, so cannot really comment, but it seems to have quite a following and AFAIK a PC slot can be used in order to use one of the motion cards they recommend.
On the Kmotion, the PC is used as a front end HMI and the motion is done externally by Micro on a USB board, where the encoders are returned to, so electronic gearing should be possible..
Max.
So i was just looking at this mach 3 business. IT appears its just software.
Where are people getting the motors and drivers?

Joined Jul 18, 2013
26,277
So i was just looking at this mach 3 business. IT appears its just software.
Where are people getting the motors and drivers?
As per the first line of my first post, Mach is just a trajectory planner and uses the P.P. to output to external drives, spindle etc, using step/dir for the motion drives and PWM for the spindle.
There is all kind of sources on the internet for drives, I have always preferred using non-inteligent drives with ±10vdc analog input rather than step/dir. using either a Galil or the Kmotion Kanalog card allows their use
The vast majority of DIY'ers use step/dir.
For more general info there is also the CNCzone which is a very large DIY CNC forum.
Max.

.

#### strantor

Joined Oct 3, 2010
6,335
Which makes me then ask even more questions. I have fooled around with the linux kernel before. Its not exactly what i call fast.
Now the last time i did, it was RS232, so what com protocol are they using to do it on a linux machine.

everytime i fool with old stuff like RS232 the problem is always over loading the input buffer. And unless you are using multi threading techniques you can not read the buffer and send process data at the same time.
It has been a thorn in my side for many years
So the direct answer to my question is, CNC machines are really being driven today by fast multiple micro controllers. We sure as heck are not going to execute this in C++ and push it out of a serial port
LinuxCNC does not (typically) push anything through a serial port. My CNC uses Mesa cards that plug into the PCI slot of the PC. there is no serial bottleneck.