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

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

Logged

Cheers!Ade.--Location: Wallasey, Merseyside. A long way from anywhere.Or: Zhengzhou, China. An even longer way from anywhere...Skype: adev73

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 You need a table that is pretty stiff and firm to cut reasonable detail.

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 -

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....

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.

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.

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

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...

Logged

Cheers!Ade.--Location: Wallasey, Merseyside. A long way from anywhere.Or: Zhengzhou, China. An even longer way from anywhere...Skype: adev73

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.

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.

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.

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.