Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: Kemlin on June 28, 2018, 08:41:49 AM

Title: Mach III motor tuning with servos and G320X
Post by: Kemlin on June 28, 2018, 08:41:49 AM
Bear with me as I don't have the technical knowledge that a lot of you do.  I converted a ticker tape NC machine to M3 and have it running G-code programs however it will fault out at random instances and I am not sure why.  I am thinking I need to do some more tuning either in the M3 motor tuning page or with the PID adjustments on the drives but am not sure.  Does anyone here have a recommendation on where I should look for motor specs and how I can apply them to motor tuning in M3?  Also is there a way to be in the motor tuning page and activate the jog feature or am I always going to have to save, close the page and then go back in to make additional adjustments?  This machine has some jumbo sized servos on it and I am wondering if I am limited by the Geckos to their speed, right now I have my velocity set at 80 inch and acceleration will go no higher than 5 inch and I think the acceleration is low.  I can get more velocity out of it but the velocity when pushed higher will get me and external E-stop request.  My machine is a belt drive setup from the servo to the screw and to this point I have been unable to get my O-scope to read any signals out of the drives so the PID tuning has all been done by ear which makes me think that may also be a problem as I am not sure if the gain setting is correct however the machine will run smoothly it just randomly faults out (roughly 4000 lines of code).  Any help is greatly appreciated.
Title: Re: Mach III motor tuning with servos and G320X
Post by: joeaverage on June 28, 2018, 03:19:51 PM
Hi,
you say that the machine Estops at random? What is it that makes you think that the servos are doing that?. I don't mean to say they aren't because
its common to have a servo fault trigger an Estop but you could have noise affecting one of your Estop signals and describe why its random.

Why don't you disconnect the G320 fault signal from Mach and try it again. If the servo is the real cause of your random faults then the Estops should
disappear. If they don't it points to a problem OTHER than your servo.

Do you have a current shunt or clip-on current probe for your scope? If you do insert the shunt into the servo circuit and measure the peak current. If its
near the maximum of the G320 then the driver is maxing out and probably faulting 'over current' before the servo is any where close to rated output.

If the measured peak current is less than the G320 max then the 'following error window' is too narrow, so the drive faults out 'following error' before it has
developed its maximum current. In the first instance open the 'following error' window as wide as you can and then start tuning. It sounds to me like your
Proportional gain is way too low. Easiest to set Prortional first and as high as you can with zero Inegral or Differential. Once you've established the
upper limit of P (as measured by peak current) back off a little and add some I, about 10%, then D for stability. Overall the best solutions tend to be high P
gains with enough  I for steady state following error performance and enough D for adequate phase margin.

Craig.
Title: Re: Mach III motor tuning with servos and G320X
Post by: Kemlin on June 28, 2018, 03:58:26 PM
So I think I tried your advise correctly.  I went to ports and pins and un-enabled the pin 10 Estop circuit and ran the same program as before.  It faulted as before as well and in the error log it simply says external Estop requested.  When I have tried to do the PID tuning before I find it to be extremely sensitive to adjustments and am just really happy it does what it does however my brain tells me it is either in the PID tuning or in M3 motor tuning.  I thought it was unusual that the acceleration needed to be so low to get some measurement of stability so not sure where to go from here for a direction.  What is a good way for me to tell when I have the maximum amount of proportional gain with the other 2 cranked all the way down?  It seems to me the drive will fault when it is set that way.  Also is there a way to jog when in the same window as motor tuning?
  Thanks for the advise thus far.
Title: Re: Mach III motor tuning with servos and G320X
Post by: joeaverage on June 28, 2018, 04:57:24 PM
Hi,
if you disabled the Estop how is it that Mach faulted?

You need to disconnect the servo fault line, not the Estop. Do this first and establish whether its a servo
fault or some other reason for the Estop.

You need to measure the current in the servo...you don't know at this point whether the
drive is maxed out or whether its just poorly tuned. Note a multimeter wont cut it, you need a good measurement
of peak current before you can start making decisions.

Craig
Title: Re: Mach III motor tuning with servos and G320X
Post by: Kemlin on June 28, 2018, 05:48:51 PM
I'm not trying to be difficult just trying to get the instructions correct so my apologize in advance here and thanks again for the guidance.  So far as hard wiring from the servo is concerned if that is what you are after I don't have a direct fault line from there as it is simple as A+ B+ 5V+ and a negative that are fed from the encoder with the same and routed through the G320X (hopefully that makes sense as it's been over a year since I wired the machine).  What exactly am I looking for for a servo fault line?  I have 2 O-scopes I can use one is mine and it's a fluke 97 so I should be able to graph from that on the output of the gecko right?
Title: Re: Mach III motor tuning with servos and G320X
Post by: joeaverage on June 28, 2018, 06:08:01 PM
Hi,

Quote
I don't have a direct fault line from there as it is simple as A+ B+ 5V+ and a negative that are fed from the encoder
That is from the encoder to the G320, you are interested in the lines between the G320 and your BoB/Mach.
I don't have the G320 manual in front of me but usually there is step, direction and enable lines
FROM your BoB/Mach to the G320 and one line FROM the G320 back TO your BoB/Mach to signal
a servo fault.

You may not have a servo fault signal setup but if thats the case then it cant be a servo fault thats making
Mach Estop, more likely noise on a limit switch say.

There are three common conditions that the G320 would recognise as a fault and signal it so:
1) Overcurrent, if you attempt to accelerate quickly, more than the G320 can handle or you progammed,
2) Overvoltage, usually happens if you try to de-accelerate to fast, the servo acts as a generator and will push
    voltage back into the drive, at a high enough level the drive will fault or worse blow,
3) Following error, if the servo lags behind its commanded position beyond a limit that you set it will determine
     that the accuracy of the machining job is at risk and fault.

Your Fluke scope should be isolated and so you could put a current shunt in the servo circuit to measure current.

Craig
Title: Re: Mach III motor tuning with servos and G320X
Post by: Kemlin on June 28, 2018, 07:30:04 PM
Not that it will help much but I went back to setup the fluke and realized I need to get my amp clamp in the same building, so testing for that right now is out but I will get it done.  I did wire the reset wire direct (+5V to the err/res) and ran the same program without issue.  I went over the wiring on the BOB and the 320X to see how I had that setup as it's been a while since that was originally done and found the following:
From the BOB I have 3 wires that interact with the 320 which are step direction and common
I have + and - coming from the power supply to the 320
I have encoder + - A & B from the encoder
I have the armature + and - going from the 320 to the servo

I will get what I need to test for amperage and see what is going on there.  With the ERR/RES pin hotwired as it were with this last run, does that help diagnose anything or just put me at an over voltage/amperage risk?
Title: Re: Mach III motor tuning with servos and G320X
Post by: joeaverage on June 28, 2018, 08:43:10 PM
Hi,
no, that suggests to me that it is indeed the servo drive that is signaling Mach to shut down.
It means that the drive is detecting one of the errors I mentioned.

When tuning you want to have all the fault warnings turned way up so the drive doesn't fault while you are tuning.
Once you have it dialled in you set the limits.

I will read the manual, but if memory serves there are two settings you can make.
One is the following error, you want it as wide as possible or even 'off' if you can. The other is overcurrent.
You want to set it to the maximum the drive can handle. Remember that current is proportional to torque
which in turn is proportional to acceleration. You want maximum acceleration when tuning, you may want to turn it down
later but you want it maxed when tuning.

Craig
Title: Re: Mach III motor tuning with servos and G320X
Post by: joeaverage on June 28, 2018, 11:49:06 PM
Hi,
I have quickly read the manual and you can increase the current limit to 20A by turning the pot fully
CCW. Unlike the manual I suggest opening the error window to as wide as possible, that is the DIP
switches 4 and 5 should be off.

Now you need to offer a set of MDi moves which challenge the servo.
for instance:

G0 x50
X0
X50
X0
X50
X0
X50
X0

This will move the X axis back and forth 50mm. If you observe the servo current as you increase
the P and D gain with I=0 (increasing D before P, per instruction) until the max current is just short of 20A.
This will be about the max acceleration your axis can achieve with this drive.
Back both D and P by about 20% and feed in a little I.

Now you can set the error window, too narraow results in very accurate motion but inclined to fault
whereas a larger window is less inclined to fault but follows less accurately.

Craig


Title: Re: Mach III motor tuning with servos and G320X
Post by: Kemlin on June 29, 2018, 11:59:31 AM
I turned the error count up to the highest setting and went through all of the different gain settings but ran into awful oscillation when trying to tune.  I went back to the settings as the amount of amps used stayed approximately the same however the actual speed of the table had increased.  Still at a loss but I am going to keep toiling with it to try to figure out why.  I am going to try to get my O-scope hooked up to see if I can get a waveform pattern out of the drive and figure it out from there.  Thanks for all of the help and if there are other pointers you can give me please do so.
Title: Re: Mach III motor tuning with servos and G320X
Post by: joeaverage on June 29, 2018, 05:24:12 PM
Hi,
the bottom line is to get the fastest and most powerful response from your servo you will need maximum current. Current is proportional
to torque which is proportional to acceleration. Thus you need to set the drive to deliver maximum current it can without fault.

The second thing you need to do to screw up the maximum Proportional gain you can within the limits of stability. You can't avoid this, it is absolutely
basic to any feedback control system, the higher the feedback gain the better. In order for you to do this you will need to turn the following error window
as wide as possible or even 'off' if you could.

In Machs motor tuning page specify an effectively infinite speed and acceleration, this will mean that the speed and acceleration that you see at the servo are the
most the servo can produce with this drive. You do not want the command to the servo limited in such a manner that you can't find the servos natural limits.
So in Machs tuning page put some ridiculously high numbers for max speed and acceleration. Then try tuning.

Next mistake you are making is that the current going into the drive from the power supply IS NOT THE SAME  as the servo current. The output of the drive is PWM,
that is to say the supply voltage switched on and off in proportion to the deemed required output voltage. Thus the output is in effect the output of a buck regulator,
it output voltage will always be somewhat less than the supply voltage but its output current can be GREATER than the supply current. How is this so?

Lets put some numbers  in to illustrate the idea.
Vsupply=100V
Vout(commanded)=10V
Thus the duty cycle for a 10V output is 10%.
The charge balance equation is:
100 X I(input)=10 X I(output)
I(output)/I(input) = 100/10
                          =10
So the driver is in effect behaving like a transformer, its input voltage is being transformed downwards and so its output current is being transformed upwards.
It makes no sense then to measure the supply input current because the output current could  differ markedly.

Craig
Title: Re: Mach III motor tuning with servos and G320X
Post by: joeaverage on June 29, 2018, 05:57:12 PM
Hi,
hopefully the attached pic may help.

In operation we want the error between the commanded position and the actual (encoder) position to be as small as we can, ie
small following error. The error (small) is amplified by the three gain blocks, P, I and D. In order that the current be maximized to the servo for maximum
acceleration and speed then the combined gains must be as big as we can make them because the input to the blocks is so small.

The G320 manual tells us to tune you turn the I down to zero, and then turn up a little D, then some P until it starts getting a bit unstable. Then dial in some
more D and then a little more P. You keep repeating it until you get the GREATEST amount of P gain you can AND still be stable.

This is the trick to tuning...you are trying to maximize the Proportional gain and use the minimum amount of Differential gain to keep it stable
AND then add a little I gain to get acceptable steady state error following.

Craig