Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: X7JAY7X on September 09, 2010, 03:45:22 PM

Title: Closed loop control using encoders?
Post by: X7JAY7X on September 09, 2010, 03:45:22 PM
I have read quite a bit and from what I understand Mach 3 uses encoders to update its DRO's.  But these encoder DRO's are seperate from the internal DRO's mach3 calculates from sending motor step pulses.  If Mach3 sees there is an error between the encoder DRO and the internal step pulse DRO it will feedhold and allow you to use the encoder DRO to update the step pulse DRO.  Is this correct?

Is there a way for Mach3 to use the encoder DRO only for positioning so it would be true closed loop control?
Title: Re: Closed loop control using encoders?
Post by: Hood on September 09, 2010, 04:02:33 PM
No and No

There is a board you can buy which does the first thing, well sort of, it wont pause and update then carry on. What it will do is fault Mach and then update DROs to encoder position. But is this useful? probably not as you have lost position by the amount of following error you have set up, this has probably ruined your work anyway if you are using a metal cutting machine with fairly tight tolerances, on a router the tolerances in your work are normally less so it may help.
Having said that you need to think why you are losing position and it all comes down to one thing if it is a regular occurrence, that thing is the motors are not big enough for the task you are asking them to do.

Now your second part, Mach is a buffered system so software closed loop is not possible.

Hood
Title: Re: Closed loop control using encoders?
Post by: Promech on September 10, 2010, 12:41:04 AM
Question: If one uses servos (not steppers) then in theory no steps should be ever lost. Is this statement correct?
Title: Re: Closed loop control using encoders?
Post by: Hood on September 10, 2010, 02:11:27 AM
If you use Servos then the loop is closed between the drives and motors.
Hood
Title: Re: Closed loop control using encoders?
Post by: stirling on September 10, 2010, 04:40:10 AM
Question: If one uses servos (not steppers) then in theory no steps should be ever lost. Is this statement correct?
Well the crux is the "in theory" bit.
Put it this way. Are servos able to produce infinite power? No. Are steppers? No.
If the servo or stepper is correctly matched to the job required of it then NIETHER will ever "in theory" miss a step. But the contrary is also true - and yes - I mean for servos too.

Ian
Title: Re: Closed loop control using encoders?
Post by: siggma on December 02, 2013, 11:17:49 PM
I know this is an old thread, if I get no response I'll start a new one.

I too have an issue with occasionally loosing steps. I'm thinking of adding encoders to my NEMA 23 motors but then comes the issue is what to do with the additional information. Because of the way Mach renders the Gcode to machine moves, closed loop operation is out of the question without an external device to manage the error. But, my preliminary testing indicates that Mach3, being a buffered system, probably pre-compiles the input gcode file producing a second file of actual machine moves that are then used to drive the motors. This second copy includes the effect of tool offsets, work offsets, rotations, scaling etc, and is generated whenever you load a Gcode file or press the "Regen Toolpath" button. Since I use Mach as a 3 axis router a small amount of error while cutting is acceptable. My X and Y axes have about 0.002" resolution which will make little difference cutting most of the things I cut. My idea is to alter the current work offsets by the error amount then "regen toolpath" to update the DRO and continue. I've discovered that its possible to successfully regenerate the toolpath during a feed hold. Once you cycle start again the DRO position makes an apparently G1 type move to the next position and begins running again. If the error is small, say less than 5 actual steps in X or Y or even as many as 20 in the Z, the effect will be almost unnoticeable.

Does anybody have any idea where I might find more information about writing code to accomplish such a task?
VbScript? Plugin?
Title: Re: Closed loop control using encoders?
Post by: HimyKabibble on December 02, 2013, 11:39:42 PM
Why not simply FIX your machine?  A properly designed, properly operated stepper system will NOT lose steps.  Encoders are totally unnecessary, and are nothing more than a band-aid to hide the real problem.  Lost steps are ALWAYS a direct result of attempting to operate the motors beyond their capability.  Either slow down to stay within the machines capability, or improve your stepper system (bigger motors and/or better drives and/or higher voltage) to make it perform the way you want.

Regards,
Ray L.
Title: Re: Closed loop control using encoders?
Post by: siggma on December 03, 2013, 11:52:45 AM
Why not simply FIX your machine?  A properly designed, properly operated stepper system will NOT lose steps.  Encoders are totally unnecessary, and are nothing more than a band-aid to hide the real problem.  Lost steps are ALWAYS a direct result of attempting to operate the motors beyond their capability.  Either slow down to stay within the machines capability, or improve your stepper system (bigger motors and/or better drives and/or higher voltage) to make it perform the way you want.

Regards,
Ray L.

Thanks for the feedback. I agree that fixing the machine is the best option but ignoring a tool that I could use to help learn more about machine limits is just as stupid as adding a bigger spindle to a cheezy eBay machine in hopes it will cut faster. I have been continually tuning things as I go, learning what this machine can and cannot do but I have no clear way to determine what effect the changes produce without ruining work, which I can't really afford any more. I have a cncrouterparts 24x48 kit machine with R&P drives on X and Y and lead screw on Z. I've checked and re-checked rail bearings to make sure they are zero play but aren't binding, varied acceleration and max IPS values in motor tuning, changed pulse widths and even experimented with Sherline mode. What I've determined is that even with fairly high accel and max IPS values I don't loose position just jogging around or under light load, even when rastering, so it has to be router kickback and/or too high a feedrate for bit/material combination that is overloading the drive motors. I started my tuning by following chip load charts and quickly discovered that with larger bits (3/8">) I cannot even begin to approach the feed rates necessary to stay within recommended chip loads for larger bits so my concern now is to find a feed rate that cuts without bit burning. Especially on hard to cut materials like plywood. I toasted a brand-new router motor and a good 3/8" compression bit, and even got a small fire going while learning about heat build up. But, to do that I need a way to accurately determine exactly which moves are causing lost steps and I need to determine that limit before the work is ruined. Is accel set too fast, pulse width wrong for my controller, router RPM too low feed rate too high? Would an air blast to clean out deep cuts be helpful? All questions that the information an encoder can provide will help answer. If I do upgrade motors I'll probably get away from Mach3/Windows altogether and go to a Linux solution so I can install and use feedback steppers. But I don't really see that happening.

Finally, I agree that closed loop is not a way to overcome poor machine setup and/or tuning. But encoders can also be a very a useful tool to help one learn and explore machine limits without destroying work in the process. And that is what I'm after. The pseudo offset-update-regen process I noted would only work if there were only very occasional positional losses, if the machine were already tuned and running at its limits. For one thing the machine would continue to run till the buffer were empty so any correction would come as much as 8 seconds after the error was detected. If the machine jammed that process could actually cause machine damage, especially if it continually updated the offset and kept retrying to move. And, the first move after a regen would need to be only a very few steps to be useful, otherwise it would destroy the very work I'm trying to save. It could prevent continual positional drift in a long run though. But it definitely won't make the machine cut any faster.

I guess what I was asking is if there is a way to get inside the Mach process and set breakpoints or triggers on events etc. Most software like this has some kind of built-in API hooks so one can add subroutines to the main processing loop and trap different conditions or insert loops at various logical break points. Mach must have some kind of facility like that.

Tom


Title: Re: Closed loop control using encoders?
Post by: RICH on December 04, 2013, 05:37:23 AM
Tom,

Why not take a moment and run some tests on scrap stock to see what your machine can do with different tools and see what
feedrates you can use. In general you should have the velocity and accel values set that you have headroom which would allow for
things like a knot in the wood or whatever. You have what you have and running anything to it's limits without proper consideration
in the program to address the task at hand just shows lack of experience.

I echo what Ray replied if your machine dosen't satisfy your requirements.

RICH
Title: Re: Closed loop control using encoders?
Post by: siggma on December 04, 2013, 11:23:53 AM
Tom,

Why not take a moment and run some tests on scrap stock to see what your machine can do with different tools and see what
feedrates you can use.

I've done that and I have a general idea how hard I can run against various materials but just when I think I have it figured out a part comes up short. This machine has so little overhead it makes sense to me to use whatever tools I can to help me run it at it's best, especially when it can make the difference between a 4 hour run at plodding speeds with burning hot bits and a 1 hour run with reasonable chip loads.


Quote
In general you should have the velocity and accel values set that you have headroom which would allow for
things like a knot in the wood or whatever. You have what you have and running anything to it's limits without proper consideration
in the program to address the task at hand just shows lack of experience.

I echo what Ray replied if your machine dosen't satisfy your requirements.

RICH
Why are you and others so against encoders? It's not the tool that makes or breaks a well run machine, it's how the tool it used. Encoders are just another part of the tool. And, I still agree that machine tuning is the key. I'm not after a closed loop system, I'm just looking for a faster, more accurate way to learn what I can and cannot do with what I have. It's better to measure it directly than test and guess. It could take days and days of testing to make a chart of feed rates that may or may not be transferable from one material to another and testing does nothing to address bit wear or sharpness. Obviously I have a lack of experience or I wouldn't be having issues. But experience alone won't help me run this small hobby machine at its limits. I suspect you're using a much more capable machine than I am so it's easy to say "just tune it and forget encoders". If you have a NEMA 34 or larger motor you have literally 5 times the torque I do. 380 oz-in motors don't have much overhead when driving against a 1/2" bit mounted in a router plowing through hardwood plywood. Feed rate changes as little as a few IPS under those conditions make the difference between a toasted bit and a successfully cut part. A pinion gear encoder setup may make the difference between a part that's only a few thousandths out of spec and completely ruined work. The bottom line is that for the miniscule cost of a few encoders, two hours of time and a breakout board I can find out for sure exactly what moves are causing positional loss. Since I have R&P drives I've decided to install a pair of shaft encoders mounted on the X and Y axes driven directly by a secondary pinion gear. The setup will allow me to detect and address backlash as well as help prevent ruined work. It will alert me that I need to home the machine as part of a bit change if it's begun to creep. It will provide me with very useful information that I didn't have before, information that cannot be easily measured any other way.

Lastly, the original question was, does Mach have a facility to alter or augment it's overall program execution? The answer is "yes", it's called "Brains". That's all I really wanted to know but it doesn't hurt to share opinions.

Tom

Title: Re: Closed loop control using encoders?
Post by: ger21 on December 04, 2013, 11:46:40 AM

Why are you and others so against encoders?

Because your machine should be 100% reliable if set up correctly. Adding encoders won't make it any more reliable, they'll just give you the opportunity to stop it when things go wrong.

Quote
If you have a NEMA 34 or larger motor you have literally 5 times the torque I do. 380 oz-in motors don't have much overhead when driving against a 1/2" bit mounted in a router plowing through hardwood plywood. Feed rate changes as little as a few IPS under those conditions make the difference between a toasted bit and a successfully cut part.

The issue here is that you have a machine capable of a certain level of performance. You want it to perform like a machine with much higher capabilities. Encoders aren't going to do that. The "overhead" that you mention is up to you. The reality is that if the machine stalls or loses steps, then you should be running at least 15%-20% slower than you're trying to. That's how you get a reliable machine.

As far as burning bits. Try slowing down the rpm. As far as achieving recommended chip loads. You'll need at least a 5-7HP spindle to achieve those, as 3/8 spiral router bits are easily capable of cutting 3/4" deep in one pass at 800-1000ipm. With a normal router for a spindle, you'll stall it instantly at those feedrates. When you have an underpowered machine (which most of us have), you run at reduced depth of cut and lower rpms to keep the bits from burning, while getting the most you can from your machine and it's capabilities.




Title: Re: Closed loop control using encoders?
Post by: HimyKabibble on December 04, 2013, 12:18:35 PM
Brains will not help you do what you want to do.  Using encoders you can only detect gross position errors, unless you add custom hardware to monitor BOTH the encoders and the step pulses coming out of the parallel port, and determine for yourself whether you are really on-position or not in real-time.  This question comes up on a regular basis, and what you propose has NEVER succesfullly solved the problem.  In the end, everyone either gives up in frustration (after having spent a HUGE amount of time, money and effort in the attempt), or they finally break down and FIX the machine hardware.  If you have NEMA23 motors, you can buy higher torque motors for about $50 each.  More likely, the problem is your stepper drivers, and power supplies, which can be swapped for better ones for probably about $300 for all three axes.  SOLVING the problem will give you a machine that performs FAR better than one that simply detects the problems, and in the end you'll be reliably turning out MORE good parts MUCH sooner.  You got people here with many, many, many years of experience with CNC machines, and Mach3.  Ignore them at your peril.

Regards,
Ray L.
Title: Re: Closed loop control using encoders?
Post by: Bodini on December 04, 2013, 01:09:28 PM
I have closed loop (encoder feedback) on 3 of 3 machines and feel uncomfortable without it.  I use it as an alarm to tell me something is wrong with the machine.  When closed loop is telling me that things aren't right, I investigate and resolve the issue.  Encoder feedback runs through a plug-in and ESTOPs when the difference between commanded position and encoder position exceeds the tolerance.
Title: Re: Closed loop control using encoders?
Post by: RICH on December 04, 2013, 02:17:38 PM
Your machine is not capabale of doing what you want it to do. So quit pushing it, modify the way you work, or
upgrade it or even get something different. If you have backlash but want more accuracy or assurance of position
when  machining then get rid of the backlash. You don't need encoders to find the backlash. If the backlash varies
then you have additional problems which only axis component replacement can cure. You have what you have and
if dosen't work for you encoders will not be of any help.

I am not against encoders. I have a digital display unit on the mill for each axis, so similar to having encoder readout, but, provides
nothing of real value other than confirmation that i am at some point / home or whatever, BUT, the Mach DRO is more accurate
than the digital readout and just as reliable becuase i have confidence in my machine and the way it is run.
Do as you wish, I don't think you'll learn any faster.

I don't have big steppers on any of my machines. I replaced the old 34's with 23's. I do have the axis adjusted such that I get
 max torque out of them while still minimizing backlash and having reliablility. Bearing adjustment gave me almost 70 oz-in
improvement.

 For any given stepper what you are after is max power which is torque times speed and that occurs in rather narrow range.
Go over that max which is required for some machining task and you have an unreliable situation.

Just some opinions,  ;)
RICH