Author Topic: How does CNC _actually_ work?  (Read 6301 times)

Offline AdeV

  • Madmodder Committee
  • Hero Member
  • *****
  • Posts: 2434
  • Country: gb
How does CNC _actually_ work?
« on: April 14, 2017, 12:02:52 PM »
OK, that might seem like an odd (and pretty wide) question.... so let me boil it down by way of a couple of examples...

Let's say I wanted to machine a straight line between the position my cutter is at now, and another position which is 10 inches away at an angle of 14.8 degrees (some nice random numbers there...)

I'm assuming that the controller figures out that for every N steps in the X-direction, there must be 1 step in the Y-direction. But how does it then apply this to the controller? Does it literally move N steps in the X-axis, then 1 step in the Y, repeat until we arrive at our destination? If N is not a whole number, presumably it keeps track of the remainder & occasionally moves 1 step in the Y axis at N-1 steps, or N+1, or whatever.

OK, so next question... This time we need to move in an arc. I can't remember exactly what my machine requires to machine an arc (in polar coords), but let's say it takes the distance around the arc, and the radius - and the start point, which is the current cutter position. I'm assuming(!) that the controller, in this case, "chops" the arc into hundreds or thousands of little straight lines, then applies the same logic as above (N X-steps, 1 Y-step, or 1-X step, N Y-steps, whatever), would that be correct?

So... my final question... but first, a bit of setup...

Imagine an upside-down "V" shaped pair of identical length arms. Linked together a bit like a pantograph, but in the vertical axis. As the angle between arm "A" and the bed changes from zero (flat) and 90 degrees (dead upright), the angle between arm "A" and arm "B" changes from 180 degrees to zero degrees. i.e. the joint between the arms is always at the exact mid-point of the distance between the arms.

With me so far? Then I shall continue...

Imagine arm "A" is mounted at the centre of a rotary table. It can be rotated between 0 and 180 degrees, where 0 points due south, and 180 points due north.

If the arms were 1 meter long, therefore, at maximum extension the far end of arm "B" would describe a semicircle some 2 meters in radius. Depending on how close in one could get, this gives us a reasonable working rectangle of 1.5 x 2.5 meters, with a little reserve left in the tank.

Anyway, assuming you've got this far.... does anyone have any idea of what the maths would be to convert that straight line, or (worse) the arc, into the 2x angles needed to drive such a contraption?



Postscript: This is the sort of thing that happens when you've got all day to yourself, and no workshop to play in... I've been following Andrew Mawson's CNC plasma adventures with much tool envy... but, with the best will in the world, I just don't have room for a flat-bed CNC plasma cutter, even a home made one. Well, unless I can hang it on the wall maybe...  So. my hyperactive mind thinks: Robot arms... if you made it compact enough, in theory it would take up very little space when "parked", and could be more or less bolted to a regular bench when in use. Yes, you still need the space when it's actually being operated; but that can usually be arranged. For storage, it all folds up and out of the way...  With this in mind, I figured if it were accurate to the nearest 1mm, that's probably close enough for plasma work; in fact, in the "distance" angle, a resolution of 0.01 degrees allows precision no worse than 0.3mm per step at the full 2m stretch. I haven't figured the rotation accuracy yet, but I'm assuming it'd be similar. This would be fairly easy to achieve using a 10:1 driver & 36-position rotary encoder. And beyond that... I haven't thought any further yet. Thought I ought to get some knowledge about how CNC systems actually work first. Hence, the question :)
Cheers!
Ade.
--
Location: Wallasey, Merseyside. A long way from anywhere.
Occasionally: Zhengzhou, China. An even longer way from anywhere...

Online awemawson

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8966
  • Country: gb
  • East Sussex, UK
Re: How does CNC _actually_ work?
« Reply #1 on: April 14, 2017, 01:30:19 PM »
Ade,

Cutting straight to the end of your post - GRAVITY is your issue with a vertical table - the bits need to fall away from the cut without snagging on your expensive plasma torch and breaking it. I went through this thought process when I actually HAD a professional welding hardened robotic arm, but discounted it due to Newtons Apple.

I have seen a design for a tilting table - used horizontal and folds like a Z-Bed into the upright position to take less storage space, but I suspect it wouldn't be very rigid  :scratch: You need a table that is pretty stiff and firm to cut reasonable detail.
Andrew Mawson
East Sussex

Offline philf

  • Hero Member
  • *****
  • Posts: 1108
  • Country: gb
Re: How does CNC _actually_ work?
« Reply #2 on: April 14, 2017, 02:37:37 PM »
Ade,

I assume that you're describing something like:



Any point within a 2m rad circle will have (or I think they will have) coordinates as follows:

X = 2 * A * COS(V) * COS(R)
Y = 2 * A * COS(V) * SIN(R)

You wouldn't get away with just specifying the two end points of your straight line and expecting the end of arm B to describe a straight line.

Phil.
« Last Edit: July 13, 2017, 12:55:23 PM by philf »
Phil Fern
Location: Marple, Cheshire

Offline mc

  • Full Member
  • ***
  • Posts: 108
Re: How does CNC _actually_ work?
« Reply #3 on: April 14, 2017, 03:19:31 PM »
It all depends on the controller.

Something like Mach 3 which doesn't have any kind of built in non-linear kinematics, you would need some method to generate the required G-code to generate the required motion, whereas something like a KFlop you can program to handle the non-linear kinematics internally, and simply provide it with your usual Cartesian coordinates (XYZ) for the movement.
I think LinuxCNC and Mach 4 are also able to handle non-linear kinematics, but you'd have to check.

To given an example of the KFlop doing it, here's a video of Dynomotion's Geppetto 6-axis demonstration robot-

If you run full screen, you'll see the g-code being run only contains XYZ moves. The moves get transferred to the KFlop, which then handles all the kinematic calculations before moving the required motors/axes to achieve the movement. I think the hardest part of these kind of setups is making sure the required kinematic calculations are correct, but philf has already provided the basics.

This video may be a bit more suitable for what you're thinking, but it only shows the movement, not the code being run -

Offline PK

  • Sr. Member
  • ****
  • Posts: 369
  • Country: au
Re: How does CNC _actually_ work?
« Reply #4 on: April 14, 2017, 05:42:53 PM »
Quote
Something like Mach 3 which doesn't have any kind of built in non-linear kinematics,
I've used mach3 to control a mates scara arm with a grab on the end. You can key in formula that compute output positions for real axii (usually the rotary ones) based on X and Y.
Might have a pic somewhere....

Offline mc

  • Full Member
  • ***
  • Posts: 108
Re: How does CNC _actually_ work?
« Reply #5 on: April 14, 2017, 05:53:30 PM »
Quote
Something like Mach 3 which doesn't have any kind of built in non-linear kinematics,
I've used mach3 to control a mates scara arm with a grab on the end. You can key in formula that compute output positions for real axii (usually the rotary ones) based on X and Y.
Might have a pic somewhere....

I thought Mach 3 had limitations on what it could do?
It could be I'm mixing it up with some other feature (geometric corrections?), as it's not something I've ever paid much attention to.

Regardless, what the OP wants to do is achievable.

Offline PK

  • Sr. Member
  • ****
  • Posts: 369
  • Country: au
Re: How does CNC _actually_ work?
« Reply #6 on: April 14, 2017, 06:16:14 PM »
I thought Mach 3 had limitations on what it could do?
I admit it was some time ago, so I just went out to the shed and checked.

Function Cfgs->Formulas, whilst notionally for screw pitch error correction and bed leveling, allows you to implement arbitrary kinematics..

LinuxCNC can do it too. We can (but don't) program this in an XYZAB space.


Quote
Regardless, what the OP wants to do is achievable.
Agreed.
« Last Edit: April 15, 2017, 02:02:16 AM by PK »

Offline RodW

  • Full Member
  • ***
  • Posts: 120
  • Country: au
    • Vehicle Modifications Network
Re: How does CNC _actually_ work?
« Reply #7 on: April 14, 2017, 06:44:56 PM »
You should read this LinuxCNC page on kinematics.
http://linuxcnc.org/docs/html/motion/kinematics.html

There are some simulators in the default Linuxcnc installation  for various robot arms etc that allow you to command a 3d drrawing of the machine on screen but i have not played with them.
As far as gravity and a vertical plasma table  all you need to do is to tab your parts which  is supported in sheetcam.
RodW
Brisbane, Australia

Offline AdeV

  • Madmodder Committee
  • Hero Member
  • *****
  • Posts: 2434
  • Country: gb
Re: How does CNC _actually_ work?
« Reply #8 on: April 14, 2017, 11:22:54 PM »
Many thanks for all the replies! Seems others were waaay ahead of me - I had no idea that there were controllers out there with reprogrammable kinematics. Cool! Now all I need to do is work out the formulae.... that should take me most of a day at least :D

Andrew - yes, gravity... I've been bitten by it more than once! As Rod says, leave tabs to keep the piece in place & free it with an angle grinder is one option. Problem is, even with a vertical table, it's going to take a fair amount of room; fume extraction is difficult, there's a very real danger of setting fire to the building (OK, you'd put a backplate behind it to stop the sparks...), and I'm still not sure I've actually got room for it.

I see my "robot arm" (TBH that's being generous to it) being something that stands unobtrusively out of the way when not being used, then gets dragged into the middle of the room, attached to a bench & used once in a while. I'll still need some kind of bed to hold the metal while it's being cut; but this doesn't need to be anything like as fancy as yours. I'm thinking a lightweight ali box with a few curved slats to hold the sheet being cut, and some way of clamping it down (magnets?) whilst its being cut.

Maybe I've been watching too many of those "Make it Extreme" videos...  :lol:
Cheers!
Ade.
--
Location: Wallasey, Merseyside. A long way from anywhere.
Occasionally: Zhengzhou, China. An even longer way from anywhere...

Online awemawson

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8966
  • Country: gb
  • East Sussex, UK
Re: How does CNC _actually_ work?
« Reply #9 on: April 15, 2017, 03:29:15 AM »
Beware of magnetic hold downs, they deflect the plasma jet so it doesn't cut where you want it to.

A while back someone developed a device with two axis's that clamped to the plate of steel being cut, and was CNC controlling the movement of an oxy-acetylene torch. Basically just two beams mutually at right angles with an appropriate carriage.OK it had relatively small operating envelope, but handy on site never the less. I seem to remember that they were hugely expensive.  No reason it couldn't carry a plasma torch.
« Last Edit: April 15, 2017, 08:21:43 AM by awemawson »
Andrew Mawson
East Sussex

Offline russ57

  • Sr. Member
  • ****
  • Posts: 278
Re: How does CNC _actually_ work?
« Reply #10 on: April 15, 2017, 08:18:00 AM »
AvE (YouTube) recently described something a bit like you are talking about, but still horizontal. Packs away, as it doesn't have a table.


-russ


Offline PekkaNF

  • Hero Member
  • *****
  • Posts: 2523
  • Country: fi
Re: How does CNC _actually_ work?
« Reply #11 on: April 15, 2017, 01:31:44 PM »
just thinking here aloud on alphanumerals....polar cordinates are ok with bearings....but gears and position sensors are harder than you think prior taking pen and paper and then industrial robot sounds really good.

I don't know about plasma much, then ones I heard have water table.

But if you solve the "table" and bolt down the plate both cut and off-cut - why not? After all direction of the gravity does not change.

Slight angle might help. Is there anything to learn from vertical panel saw?
http://www.productiq.com/DesktopModules/ProductIQ/Shared/ProductImage.aspx?Large=1&ProductId=75637

http://www.dbkeighley.co.uk/images/koolkut_kk12.jpg


Pekka

Offline vtsteam

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6466
  • Country: us
  • Republic of Vermont
Re: How does CNC _actually_ work?
« Reply #12 on: May 04, 2018, 10:31:48 PM »
OK, that might seem like an odd (and pretty wide) question.... so let me boil it down by way of a couple of examples...

Let's say I wanted to machine a straight line between the position my cutter is at now, and another position which is 10 inches away at an angle of 14.8 degrees (some nice random numbers there...)

I'm assuming that the controller figures out that for every N steps in the X-direction, there must be 1 step in the Y-direction. But how does it then apply this to the controller? Does it literally move N steps in the X-axis, then 1 step in the Y, repeat until we arrive at our destination? If N is not a whole number, presumably it keeps track of the remainder & occasionally moves 1 step in the Y axis at N-1 steps, or N+1, or whatever.  snip.....

Yes, it does -- sorry to be answering such an old post, but I just happened to read it, and I also think nobody answered this first part of the question.

The way it is handled is by what's called a DDA algorithm. You can find complex mathematical explanations online, but the process you mention is for practical purposes what happens. A motion increment is determined -- equal to one unit of movement for X (for instance, it might be in eighth steps for a stepper motor). You then calculate the amount of Y increase that one unit of X  movement would generate according to the formula for your particular function (for instance if its a straight line you'd use y=mx+ b). Likewise If a circle, you'd use a circle formula, or if some other function, you use that.

And as you say, if there is a decimal part (remainder), you test the result using the old rounding method we learned in school -- if it is .5 or more, you add one additional unit step to the Y movement, and if it is less, you don't.

Hope that's understandable.

I first learned about the DDA algorithm when I built an LNW-80 computer in the late 70's and wanted to write a program to draw wire frame 3D boat hulls on screen. The algorithm is very fast with integer math -- particularly in assembly language, and it was a success on the old Z-80 proc I had.
« Last Edit: May 05, 2018, 10:31:47 AM by vtsteam »
I love it when a Plan B comes together!
Steve
https://www.youtube.com/watch?v=4sDubB0-REg

Offline sparky961

  • Hero Member
  • *****
  • Posts: 844
  • Country: ca
Re: How does CNC _actually_ work?
« Reply #13 on: May 05, 2018, 06:08:36 PM »
On the first CNC machine I built, or rather the first iteration of my CNC 3-in-1 conversion saga, I used Bresenham's algorithm. There are versions for lines and arcs. The concept was very easy to grasp. This was for a stepper systwm. I'd do it differently today with servos.

Offline CrazyModder

  • Jr. Member
  • **
  • Posts: 86
  • Country: de
Re: How does CNC _actually_ work?
« Reply #14 on: May 29, 2018, 03:55:20 PM »
Indeed these are the same kinds of algorithms (Bresenham...) which draw lines, circles or splines on your computer monitor. They have been around for a very long time, since the advent of the first graphical computer displays. Their beauty is that they work very simply with no floating point arithmetic, i.e. only integer arithmetic. While today, computing performance would not be an issue for a CNC controller, this especially means that the algorithms internally use "steps" anyways (we call them pixel on the monitor...). So they conform naturally to the steps of the CNC motors/servos. Also, those algorithms move "along" the line they are drawing, and not jumping around in weird fashion.

https://en.wikipedia.org/wiki/Bresenham's_line_algorithm shows the line algorithm. At first glance it seems pretty complicated, but if you do it per hand once you find that it is incredibly simple... just some additions and subtractions; the only multiplication is "times two", which is incredible easy for a computer to do, for obvious reasons.

https://en.wikipedia.org/wiki/Midpoint_circle_algorithm for the circle algorithm (though it would need to be adapted for CNC as this draws the 8 octants simultaneously.

Same would apply for arcs/segments, splines, or other complex shapes - the same algorithms which draw that stuff on the screen would likely also used by the CNC controllers.

Offline WeldingRod

  • Sr. Member
  • ****
  • Posts: 400
Re: How does CNC _actually_ work?
« Reply #15 on: June 07, 2018, 07:26:30 PM »
The Maslow cnc is very low floor space, and you might be able to plasma cut with it.  Partial sheets would be the real problem; it literally slides on the material surface.

Sent from my SAMSUNG-SM-G891A using Tapatalk


Offline PekkaNF

  • Hero Member
  • *****
  • Posts: 2523
  • Country: fi
Re: How does CNC _actually_ work?
« Reply #16 on: June 22, 2018, 05:45:18 AM »
I really don't like all the features Maslow cnc:
* Accuracy/relolution varies wildly depending on where the router is located, "top" of the plate resolution is low on vertical direction. 
* To avoid excessive waste you have to get pretty creative.

Offline hanermo

  • Full Member
  • ***
  • Posts: 103
Re: How does CNC _actually_ work?
« Reply #17 on: June 26, 2018, 02:50:35 PM »
In all mechanical engineering everything depends on everything else.
Often in weird and wonderful ways if one wants a very good of something.

Be it accuracy, angle, level, flatness, size, rigidity, whatever.

Nothing is strong, flat straight rigid repeatable or accurate.
You just need to measure accurately enough.

The first highly repeatable and high resolution device I know of was the ruling engine done around 1960 by 2 crazy geniuses.
Took them about 16-20 years of work iirc.