Hello Guest it is October 19, 2019, 01:43:38 AM

Author Topic: Closed loop control using encoders?  (Read 5449 times)

0 Members and 1 Guest are viewing this topic.

Closed loop control using encoders?
« 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?
« Last Edit: September 09, 2010, 03:49:26 PM by X7JAY7X »

Offline Hood

*
  •  25,855 25,855
  • Carnoustie, Scotland
    • View Profile
Re: Closed loop control using encoders?
« Reply #1 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
Re: Closed loop control using encoders?
« Reply #2 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?

Offline Hood

*
  •  25,855 25,855
  • Carnoustie, Scotland
    • View Profile
Re: Closed loop control using encoders?
« Reply #3 on: September 10, 2010, 02:11:27 AM »
If you use Servos then the loop is closed between the drives and motors.
Hood
« Last Edit: September 10, 2010, 02:14:11 AM by Hood »

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: Closed loop control using encoders?
« Reply #4 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
« Last Edit: September 10, 2010, 09:53:43 AM by stirling »
Re: Closed loop control using encoders?
« Reply #5 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?
Re: Closed loop control using encoders?
« Reply #6 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.
Regards,
Ray L.
Re: Closed loop control using encoders?
« Reply #7 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


Offline RICH

*
  • *
  •  7,367 7,367
    • View Profile
Re: Closed loop control using encoders?
« Reply #8 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
Re: Closed loop control using encoders?
« Reply #9 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