Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: pe2rvv on June 26, 2010, 03:50:28 AM

Title: Closed loop system, encoder connected to mach3
Post by: pe2rvv on June 26, 2010, 03:50:28 AM
Hi Guys.

I'm toying with an idea for quite some time now.. i'm sure that im not the first but i really like to know what to expect..

I'd like to know if its possible  to make for exemple a milling machine with steppermotors and connect some encoders to the shafts of the steppers. Then if I connect the encoders to mach3 will mach be able to adjust any loss of steps? or does mach only show the coordinates in a DRO and leaves the loss of steps as they are?

Up til now I havent found someone who could tell me how mach3 reacts to encoders and resolves faults like loss of steps..

Regards

Robin
Title: Re: Closed loop system, encoder connected to mach3
Post by: stirling on June 26, 2010, 04:17:20 AM
Hi Robin

Mach doesn't close the loop. In a servo system for example - the loop is closed at the driver. That said, just give me a minute - I'm going to get on my soapbox.

Correctly specified and correctly driven stepper motors DO NOT loose steps and even if they did you can't correct something that's already happened.

Cheers

Ian
Title: Re: Closed loop system, encoder connected to mach3
Post by: pe2rvv on June 26, 2010, 04:38:59 AM
Hi Ian

Thanks for the reply...

I understand how the servo closed loop systems work... And also know that  a good stepper system doesnt loose steps..
What I wanted to know whas in the event that it would happen, or that one of the steppers would stall for an instant  for what reason at all... that mach could  correct this by moving to the right position according to the feedback of the encoders..

SO if I understand correctly.. I CAN connect encoders to the shafts..  of each axis and connect it to mach... mach will show the coordinates in the DRO but in the event of a slight stall or loss of a step   mach does not correct it and continues from the "wrong"spot.. Or the other way around... that mach just puts out a pulse stream at a certain frequency untill the encoder says he reached the spot  and then stops..

Thats to bad.. hahah Just wanted to know if it whas possible  to have a cheap stepper system with the benifits of an encoder just like a servo system... and mach would have a realtime knowledge of where the axis are and correct any faults..

Thanks

Robin

Title: Re: Closed loop system, encoder connected to mach3
Post by: derekbpcnc on June 26, 2010, 06:31:14 AM
I think the Granite drives can be configured to use stepper motors with encoder "assist"

ATB
Derek

Hi Ian

Thanks for the reply...

I understand how the servo closed loop systems work... And also know that  a good stepper system doesnt loose steps..
What I wanted to know whas in the event that it would happen, or that one of the steppers would stall for an instant  for what reason at all... that mach could  correct this by moving to the right position according to the feedback of the encoders..

SO if I understand correctly.. I CAN connect encoders to the shafts..  of each axis and connect it to mach... mach will show the coordinates in the DRO but in the event of a slight stall or loss of a step   mach does not correct it and continues from the "wrong"spot.. Or the other way around... that mach just puts out a pulse stream at a certain frequency untill the encoder says he reached the spot  and then stops..

Thats to bad.. hahah Just wanted to know if it whas possible  to have a cheap stepper system with the benifits of an encoder just like a servo system... and mach would have a realtime knowledge of where the axis are and correct any faults..

Thanks

Robin


Title: Re: Closed loop system, encoder connected to mach3
Post by: stirling on June 26, 2010, 07:51:04 AM
Mach doesn't know or care whether you have a servo or a stepper system. It just sends out step and dir signals and trusts that whatever's attached does what it's meant to. The only difference is that with a servo drive you can connect the servo drive's fault output to Mach so that Mach get's to know about it. What does Mach do? It stops sending signals. Of course you can put encoders or whatever you like on a stepper. But you would have to get that "whatever" to detect a missing step and let mach know and Mach would do exactly the same thing - just stop sending signals. AFAIK there are no systems for steppers that will "re-position" after a lost step and to be honest if there was IMHO it would be pointless. In fact it would be as pointless as a servo system that tried to re-position after it had exceeded it's allowable following error. If you REALLY want the warm feeling of knowing that your system has lost position and that Mach will stop, then personally I'd go servos. Each motor brings there own advantages to the party but If it looks like a duck and quacks like a duck then it probably is a duck - no point in trying to pretend it's anything else.

Cheers

Ian
Title: Re: Closed loop system, encoder connected to mach3
Post by: pe2rvv on June 26, 2010, 08:21:59 AM
Hahah...

Ok message undersood... I get the idea..

Today I heard from someone else that EMC2 does have this function... and that its the only cnc controller that does that because its working on linux and not windows..
(dont know if it really works, havent seen it)
So i've heard a lot of stories, and just wanted to know what was the real deal...
The only thing I dont understand is... Why do Professional controls like Heidenhain, fanuc, siemens etc something similar like that?
Yes the do have servo's with encoders  connected to the drives but the frequently also have a measuring system like a liniair encoder (glass ruler) to give feedback to the controls . Thats a real closed loop..

Thats how i came up with the idea..and thought what is the reason why mach doesnt do that?

Anyway..thanks for the reply.... now for the decision.. stay with steppers or go servo  ;D
Title: Re: Closed loop system, encoder connected to mach3
Post by: RICH on June 26, 2010, 08:43:01 AM
Quote
stay with steppers or go servo
A decision only you can make. I have never gone to servos because i have 5 drives for steppers and a bunch of stepper motors.
But, i will get a servo and at least one drive ( one of these days ) for running the spindle on the lathe constantly.
This way there will not be changing torque and have linear speed over the rpm range.

FWIW and depends on the good junk you may already have,
RICH
Title: Re: Closed loop system, encoder connected to mach3
Post by: pe2rvv on June 26, 2010, 08:50:52 AM
Hahah indeed..

WHel this is the reason I'm asking

I'm rebuilding  a morbidelli U-15...
The old servo's and drives were unuseable... so i bought 20Nm stepper motors and 230V AC stepperdrives...

http://www.youtube.com/watch?v=CD5Dq8_9UDk

Sometimes I have tiny quarks with mach... and thats the reason i'd like some feedback to mach..

Servo's that size are very expensive and the project would loose its purpose to make a fairly cheap industrial machine...

Anyway, if you'd like to see some pics just register in the dutch cnc forum   www.cnczone.nl

and look in this topic:  http://www.cnczone.nl/viewtopic.php?f=6&t=2256

Thanks for the help
Title: Re: Closed loop system, encoder connected to mach3
Post by: stirling on June 26, 2010, 09:52:03 AM
Today I heard from someone else that EMC2 does have this function...
We have to be careful here and be clear exactly WHAT function we're talking about.

If you're saying that EMC can take encoder POSITIONAL feedback and correct a motor that's lost position then I'd say two things - "are you sure?" and "why?"

Let's take servos as an example as they allways have a feedback loop. It could be stated that servos are ALLWAYS in the wrong position and allways TRYING to get to the commanded position. The error between where they are and where they should be - the following error - has a maximum which is set to what is deemed acceptable. If this maximum is exceeded there's nothing ANY controller can do - it's too late - it's happened - the fat lady has sung!. If you're going to let ANY controller correct OUTSIDE the allowable following error - why not just increase what you regard as the acceptable maximum following error?

and that its the only cnc controller that does that because its working on linux and not windows..
May the great engineer in the sky save us from the Linux high priesthood. Linux is a great OS but  I wouldn't be surprised if one of the faithful claimed it could achieve world peace before dinner. EMC runs under a modified kernel just as Mach does. A vanilla Linux could not run EMC for exactly the same reason as a vanilla Windows couldn't run Mach. Neither of them are realtime systems and that's the challenge, to get them both to mimic one as best they can. The advantage the Linux guys had was they had access to the kernel source code. Somehow I don't think Bill and Art are that close!

The only thing I dont understand is... Why do Professional controls like Heidenhain, fanuc, siemens etc something similar like that?
Yes the do have servo's with encoders  connected to the drives but the frequently also have a measuring system like a liniair encoder (glass ruler) to give feedback to the controls . Thats a real closed loop..
Well someone who knows more about glass scales will hopefully step in. But I don't think that's what glass scales do. I thought their purpose was for accuracy. BUT AGAIN - If a drive can keep the servo within the following error limit - and they do - because if they didn't they'd be as much use as a chocolate fireguard - how can you improve on this?

All good fun...

Cheers

Ian
Title: Re: Closed loop system, encoder connected to mach3
Post by: BR549 on June 26, 2010, 09:57:19 AM
IAN, what IF we set up a brain to monitor the DRO/encoder like has allready been done. BUT instead of tripping a stop we write a macro to do a controlled stop, record current line of the program. RefHome the  axis then return to Currentline minus say 10 lines then" run from here" to restart???

Might be a poormans closed loop ERROR recovery system ???

We already have a brain to do cruise controll to monitor spindle speed and regulate Feedrate based on RPM drop.


EMC does run in a realtime kernal so all its I/O is realtime. Mach runs in a Buffered system, once the buffer runs there is little to no interaction to the pulse stream.

Heck even the old DOS could run realtime. I think that the old dos made a good controller inside of the mem limits.

AND there IS a Windows RTK but it is very expensive from MS

I don't think EMC does realtime corrections it just closes the stepper loop LIKE it does with a servo.  It doesn't really matter where you close the loop as far as position controll.
Title: Re: Closed loop system, encoder connected to mach3
Post by: pe2rvv on June 26, 2010, 10:25:57 AM
I dont know EMC for myself... Its just another one of the stories I heard..

And indeed. the thing that emc is "realtime thats also the thing i've heard... SO i think for that reason its not possible in mach3.. because windows is too slow..

Anyway the idea whas... the stepper system is an open loop with no feedback at all.. My idea was.. if there is something watching over the movements and could do "something"about eventual errors that would be better than nothing...
Title: Re: Closed loop system, encoder connected to mach3
Post by: Hood on June 26, 2010, 11:41:07 AM
There is a board sold by Ron Rogers that can monitor encoders and throw an error to stop Mach and then I believe update the DROs with the correct position. Its not closed loop as it will not correct until after an e-stop and whether it would save your work will depend on the following error you set and how fast you are cutting.

Theoretically you could do this in a Brain or a macropump but I have my doubts whether this would be fast enough to save the work as the update is only 10Hz and in reality is could be nearer 5Hz as the error could be seen just after one scan so will not be picked up until the next.

As said though it would all depend on how fast you cut and how much of an error is too much, could be fine for plasma or router but doubt it would be good enough for a metal cutting machine where tolerances are usually much tighter.

Just my thoughts on the subject.
Hood
Title: Re: Closed loop system, encoder connected to mach3
Post by: Jeff_Birt on June 26, 2010, 12:07:44 PM
There are a few different points to consider here.

1) If a stepper system looses position you are doing something wrong.
2) There are closed loop stepper systems available, but what does that mean?

#1) A stepper will always go where you command - unless you overload it, (or have an issue with the quality of pulse stream driving it.) A servo on the same system 'may' have enough power to bully through what would stall a stepper but you still have a problem where the potential stall occurred. If you ask either system to feed faster than it is able you will have a problem. Having a closed loop stepper does not make the stepper any more powerful, or capable of anything that it could not do when driven open loop.

#2) What does a closed loop stepper system get you? Well, since a stepper motor is a constant power device if you are near a stall condition you will not have any reserve power to try and accelerate to catch up. That leaves only two options: just report an error occurred, or ask the pulse generating device (i.e. Mach, EMC2) to hold up whilst the machine tries to catch up. (This second option is what controller manufacturers like to tout as 'closed loop back to the controller'.) For Mach the first option, reporting an error and stopping is viable. There is at least one BOB available that does this, and the Taig DSLS system does this as well. The second option, asking the controller to hold up, is not a viable option with the parallel port driver, an external motion control board could do this as generally they just grab the next n moves from Mach's buffer and process them, since they are in control of the motion they can hold up processing moves.


Still, if you are stalling a stepper system then you have a problem with what you are asking it to do. The value of a supervisory system depends on what type of system you are building.
Title: Re: Closed loop system, encoder connected to mach3
Post by: stirling on June 26, 2010, 12:41:21 PM
Let's see if we can't bust another myth for fun. realtime means real time.

The two types of realtime system that I know of are: Soft and hard. We're dealing here with soft.

To be called a soft realtime system two conditions have to be met.
1) The jitter must be kept within acceptable limits - but there will allways BE jitter. Remind you of anything?
2) The system must provide ready access for applications to be given higher priority than system functions if required.

No. 2 is really where RT linux passes and standard Windoze doesn't. AFAIK Art worked long and hard to get round that one - but get round it he did.

Another one.

Stepper motors can lose the occasional step.

Personally I've never seen it happen. I've seen steppers stall - period - but never have I seen one miss the occasional step. Not saying it absolutely CAN'T happen because never say never but here's why I find it difficult to understand how it can happen.

So our stepper is cruising along at whatever rpm and for some reason misses a step. The next pulse comes along and what? Well it's not going to move the stepper because the driver is in the wrong phase. Our stepper is still stalled. The next pulse comes along. No - still out of phase - our stepper stays where it is. In fact with a full step drive the stepper will miss 4 steps minimum because of incorrect phase and will allways lose steps in multiples of 4. (In a microstep system it will miss 4*microstep steps before the driver issues the correct phase signals). Anyway back to our full-step system - the 4th pulse comes along - good - correct phase, the motor moves a step from stationary. The 5th pulse comes along. Ooops - way to soon. The controller is sending out pulses at the speed the motor would have been going if it hadn't stalled, but it has only done one step from stationary - don't we need an acceleration ramp? The 6th, 7th, etc. steps are all too close together - stall....

The ONLY exception I can see to this is if the stepper motor is moving so slow in the first place that it doesn't NEED an acceleration ramp to get it going again. But wait - if it's going at that speed it's way up near the highest part of it's torque curve - so how come it missed a step in the first place? A system that misses steps at low speed is just plain not up to the job.

My ramblings for the day

Cheers

Ian

Title: Re: Closed loop system, encoder connected to mach3
Post by: RICH on June 26, 2010, 02:14:55 PM
Quote
I've seen steppers stall - period - but never have I seen one miss the occasional step

The missed step is a tough one. My experience in all this time on missed steps can be counted on one hand and i really can't clarify a simple single missed step as all is not as it seems. In the few times that a stepper "skipped" the outcome was that axis movement was such that the axis went off with a mind of it's owne, like just cutting some random path thru the metal, or you could hear the skip ( but maybe extremely short - say just a few steps / fraction of a second) and it kept the pathing of the code but was off somewhat in location. Very , very infrequent / unusual if your motor tuning &  application is proper for what you are going to do.

We tried finding magical lost steps using custom high end equipment which would count and compare steps out of the PP to the actual steps provided to a stepper along with measured distance. The counting accuracy was in parts per million and although the equipment said  there were a few in the comparison we never heard or experienced a problem in the stepper motor movement. In one case it identified that the lost steps were due to belt tension ie; the steppers were turning appropriately as pulsed....movment was lost in the timimg belt which made it appear like lost steps.  SO looking for a needle in the hay stack that may not even exist is difficult.

So i agree with ya, Ian.  Steppers are very accurate and reliable when used properly, and they either work or don't, and there is a world of difference between stalled/skipped/ lost step.

BTW, two different steppers, all things equal, can require different steps per unit ( lost steps ....not really, variation in constructed quality)
unusual, but true.

BUSTING THE MYTHS........ ???

RICH 

Title: Re: Closed loop system, encoder connected to mach3
Post by: skunkworks on July 15, 2010, 10:14:36 AM
I thought I would come in here and explain a few things.  (emc person)

Emc can count encoders in realtime.  (whether it is software (ie - printer port)  or hardware (ie mesa/pico systems hardware or such) - emc sees it the same)  On a decent computer I would expect the software counting to approach 30khz or more.  (hardware will be into the mhz)

Now - there are at least 2 ways that you could setup a closed loop stepper system within emc.

1.  trip a following error.  The commanded position in emc will be compared to the feedback position from the encoders.   If the following error is greater than the set point - the machine stops. (this is checked in the servo thread (by default the servo thread is 1khz)

2. Setup a pid loop.  this works similar to above.  If the following error is greater than the set point the machine stops.  Also - if the machine loses a few steps - this will be corrected for by the pid loop.  (it sort of sets the steppers up as servos - the step generator within emc (or hardware) is set to velocity mode instead of position.)

There is an issue with the above setup.  Steppers are not servos.  Servos - if you lag behind the pid loop will tell the servos to catch up.  If you do that with steppers - they will stall.  So - if you start to get a lag because you are pushing the steppers outside of their envelope - they will stall as the pid loops pushes them harder.

The good news is - emc still knows where the machine is.  (feedback from the encoder)  Turn it back on and go. :)

there has been talk of maybe trying adaptive feed.  where as the following error increases - the feedrate is decreased.  (I don't think anyone has tried that yet)

I really don't think it is a good solution.  IMHO - might as well go servos then.  (if you are putting in that much effort)

sam
Title: Re: Closed loop system, encoder connected to mach3
Post by: manmeran on July 15, 2010, 05:58:53 PM
Quote
what IF we set up a brain to monitor the DRO/encoder like has allready been done. BUT instead of tripping a stop we write a macro to do a controlled stop, record current line of the program. RefHome the  axis then return to Currentline minus say 10 lines then" run from here" to restart??
i think for mach is best way.

Amir
Title: Re: Closed loop system, encoder connected to mach3
Post by: aluplastvz on May 05, 2014, 05:11:31 PM
to look like brain that would compare encoder and line g coda

greeting
Title: Re: Closed loop system, encoder connected to mach3
Post by: magicniner on May 08, 2014, 03:47:34 AM
I dont know EMC for myself... Its just another one of the stories I heard..

Sticking to what you either know, or from experience have a good reason to believe, is an excellent strategy when standing on a soap-box ;-)

And indeed. the thing that emc is "realtime thats also the thing i've heard... SO i think for that reason its not possible in mach3.. because windows is too slow..

My House Rabbits are "realtime" ;-) what are you saying?

Anyway the idea whas... the stepper system is an open loop with no feedback at all.. My idea was.. if there is something watching over the movements and could do "something"about eventual errors that would be better than nothing...

Stepper systems are designed to be open loop, having steps becomes unnecessary once you close the loop - Think Servos - If you are getting missed steps you have a faulty system or setup which will be far easier to fix by correcting the faults than by bodging on something unnecessary for a good working system,

 - Nick
Title: Re: Closed loop system, encoder connected to mach3
Post by: Høj on October 21, 2014, 06:57:47 PM
Ian.....
Glas scale are for precision and nothing else... If you having 2 measuring systems on a machine it is usual to prevent the user to make bad parts. What is happening, the machine is comparing the 2 measuring system and if they aren't following within a given window the machine stops. all in all the NC looks for backlash in the machine.

If you buy a Siemens PCU 50, ER module, LT module, Controller and NC module, then you have spend a lot of money and we haven't been talking about licens for the CNC it is extremely expensive.
We have some hobbing machines and in October I bought a license for a PCU 50 Solusionline. The only thing the license it is gave me access to the parameter for the B spindle effect so we can prevent damaged the hob. the price for the license was 3000 $

My pointte is, and don't get me wrong but with all respect for MACH3, it's a super cool program but it is for hobby and light industry.

If you loose some steps you can make the machine to shut down, that is what expencive machines do.  You can't undo lost steps and you can't undo a car crash, it is just the way it is....

I totally agree with Ian it is spot on....

- Allan
Title: Re: Closed loop system, encoder connected to mach3
Post by: Davek0974 on October 24, 2014, 09:53:10 AM

So our stepper is cruising along at whatever rpm and for some reason misses a step. The next pulse comes along and what? Well it's not going to move the stepper because the driver is in the wrong phase. Our stepper is still stalled. The next pulse comes along. No - still out of phase - our stepper stays where it is. In fact with a full step drive the stepper will miss 4 steps minimum because of incorrect phase and will allways lose steps in multiples of 4. (In a microstep system it will miss 4*microstep steps before the driver issues the correct phase signals). Anyway back to our full-step system - the 4th pulse comes along - good - correct phase, the motor moves a step from stationary. The 5th pulse comes along. Ooops - way to soon. The controller is sending out pulses at the speed the motor would have been going if it hadn't stalled, but it has only done one step from stationary - don't we need an acceleration ramp? The 6th, 7th, etc. steps are all too close together - stall....


That paragraph answered many questions, never thought about it like that.

So, when you energise a stepper system from cold, is it instantly in the correct phase to move properly?

I need to read up on steppers ;)
Title: Re: Closed loop system, encoder connected to mach3
Post by: JohnHaine on October 26, 2014, 03:13:07 PM
So, when you energise a stepper system from cold, is it instantly in the correct phase to move properly?
I need to read up on steppers ;)

No!  That's why if you close down Mach and "save fixture", and try to start again from cold, the stepper may move a little when re-energised and be in a slightly different plave from where they were when closed down.  When I turn the drivers off or on there is a thump from the drives as they move slightly to align with wherever the drive phases are.

But yes, it can now move properly from wherever it now is but that wasn't quite where you left it. 
Title: Re: Closed loop system, encoder connected to mach3
Post by: Davek0974 on October 27, 2014, 03:12:27 AM
Excellent, thanks. I get that thump too when starting up.
Title: Re: Closed loop system, encoder connected to mach3
Post by: poppabear on October 27, 2014, 08:35:36 AM
Ian, here is my $0.02 that you did not ask for...  :)

    I wrote a plugin for a vendor, that would take in encoder values, and do an "Adaptive"
feed rate adjustment, i.e. slow the feed by 10% if the encoders where within a following (corrective) error band, it also had a Max error that would be an estop, then it had an "Acceptable" following error band in which it did not correct. While in the corrective band, it would slow the machine, then after it got through the "Hard" part, it would then ramp back up in 10% increments back to its original speed. 
    This worked in theory, and in bench top testing.... BUT..........  did NOT work in real world application on my test mills.  And that was due to the slow speed of the update loop in Mach3.
when machining a part that had a "Hard" spot in its material (or DOC was greater in that area),
the steps that where lost in the engine(s) loop would build up quickly, and already be past the MAX error when the plugin got around in the 1/10th loop. That was using the Para Port.
On the other machine, with an external motion card, the problem re-presented itself in a slightly different manner, in where the "buffered" moves would build up error, and again, you would be behind the MAX.  Under certain conditions, like cutting "soft" material, the system did work, in where the slow down was not that much through the softer material, in that LIMITED case it would do adaptive feed........
        But, again, having said the above...  I only run servos on my machines, so, having read your in-depth explanation on steppers and how they react to following errors..... I suspect the results would have been even worse.  The Plugin in its way would stop the machine and "catch up" the servos... but.... the part was completely non-acceptable, once you have lost those steps especially on a simple or compound curve...  you can easily see the "opps" area.
        The adaptive approach may, I repeat MAY work in wood since the tolerances are a lot looser, but, really only on straight lines.......curves or intricate designs I think you would see the error in the cut where the Axis lagged to much.
        From my point of view, for following error adaptive correction to work correctly, or at least useable, the Hardware (motion card or device), would have to be designed with that in mind in advance. The speed needed to catch this, and do something about it would be at the hardware level, and basically it would just notify the software of what it did about it when it got around to servicing the board...

        Note: I am NOT saying that it can not be done, I have not had the guts to try it at the Brain/Macro-pump level, since in my mind plugins should be more stable or at least reliable.  But, I have not tried it, nor will I since testing is expensive with broken tools, or crashed axis...

        My suspicion would be, that some enterprising user could take an Arduino, to read the encoders, and do the following error math/decisions and notify Mach about it, or control mach depending on what it decided to do about the current error condition(s). This could interface through a Plugin or some kind of hybrid Brains/Pump thing.... Good luck to the brave sole that tries it, and GOOD JOB if you get it to work good!!

Scott
Title: Re: Closed loop system, encoder connected to mach3
Post by: stirling on October 27, 2014, 12:59:51 PM
We do all realize the thrux of this thread is 4 and 1/2 years old? - Not sure why it was resurrected or whether I can summon the effort to read who said what all over again TBH  ;)
Title: Re: Closed loop system, encoder connected to mach3
Post by: poppabear on October 27, 2014, 02:21:50 PM
opps, didnt pay attention to the age............
Title: Re: Closed loop system, encoder connected to mach3
Post by: stirling on October 28, 2014, 07:31:10 AM
LOL - no worries Scott - seems that thread resurrection is happening a lot lately  ;D

Ian
Title: Re: Closed loop system, encoder connected to mach3
Post by: DMBGO on April 09, 2015, 07:05:21 PM
Well Easter has just been and gone, so there is a bit of it around :)