Wiring and configuration SERVO DRIVES

Moderators: TomKerekes, dynomotion

User avatar
TomKerekes
Posts: 2529
Joined: Mon Dec 04, 2017 1:49 am

Re: Wiring and configuration SERVO DRIVES

Post by TomKerekes » Wed Nov 18, 2020 5:42 pm

Hi Gabriel,
Also, I could higher the P gain because there is a P gain I the drive. With older control it was 316, I lowered to 216 and got 1 P, now it's on 116 and I can go to +/-2.5 P, should I lower (like 10) the P in the drive and raise in kanalog?
Probably better to leave the gain high in the Drive. But whatever gives the best results in that the errors are smaller.
Regards,

Tom Kerekes
Dynomotion, Inc.

GabrielR922
Posts: 79
Joined: Thu Aug 13, 2020 10:07 pm

Re: Wiring and configuration SERVO DRIVES

Post by GabrielR922 » Sun Nov 22, 2020 2:00 pm

Hi Tom.

Had more time and read all with a lot of attetion. Could get better results but still having some problems.

Look at this results.

The X axis have some bumps in pos error in the graph
The Y axis make a bump when enabled, you can see in the graph. (no bump starting jogging or starting g code)

The configs for both drivers, X and Y are the same, the same for the wiring.
I Have A+/- and B+/- wired. 0V isn't wired, if wired to ground the servos won't work.

Also, sometimes the machine give a little bump when running g code, i found that it's more common when its doing an arc and then enters in a straigth line. For example, an arc where starts with Y and goes to X, then to a straight line with X, when the Y axis is near to the end of the arc, it bumps to get position. Looks like it miscalculate the deacceleration.
Running some G code, when the axis interpolate X and Y, the system goes unstable or noisy. Lowering or raising the speed don't solve the problem, just change the intensity of it. I can film it and upload to youtube if you need.


Thanks Tom. Your board is awesome, in the next months a friend of mine will be buying more boards. He is a automation technician and is starting to retrofit CNC's.

#include "KMotionDef.h"

// Default Initial Configuration for 3 Axis Analog DAC Servo with encoder feedback
//
// Note Low Gains, Limited Max Limits, No Limit Options, No Soft Limits,
// Large allowed Following Error, No Feed Forward, No Filters, etc

void main()
{
InitAux();
AddKonnect(0,&VirtualBits,VirtualBitsEx);
AddKonnect(1,VirtualBitsEx+1,VirtualBitsEx+2);
AddKonnect(2,VirtualBitsEx+3,VirtualBitsEx+4);


ch0->InputMode=ENCODER_MODE;
ch0->OutputMode=DAC_SERVO_MODE;
ch0->Vel=200000;
ch0->Accel=1e+06;
ch0->Jerk=2e+06;
ch0->P=0.55;
ch0->I=0.006;
ch0->D=1.9;
ch0->FFAccel=0;
ch0->FFVel=0.00462;
ch0->MaxI=20;
ch0->MaxErr=50;
ch0->MaxOutput=1024;
ch0->DeadBandGain=0;
ch0->DeadBandRange=0;
ch0->InputChan0=0;
ch0->InputChan1=1;
ch0->OutputChan0=0;
ch0->OutputChan1=1;
ch0->MasterAxis=-1;
ch0->LimitSwitchOptions=0x10f;
ch0->LimitSwitchNegBit=136;
ch0->LimitSwitchPosBit=136;
ch0->SoftLimitPos=1e+30;
ch0->SoftLimitNeg=-1e+30;
ch0->InputGain0=1;
ch0->InputGain1=1;
ch0->InputOffset0=0;
ch0->InputOffset1=0;
ch0->OutputGain=-1;
ch0->OutputOffset=0;
ch0->SlaveGain=1;
ch0->BacklashMode=BACKLASH_OFF;
ch0->BacklashAmount=10;
ch0->BacklashRate=1;
ch0->invDistPerCycle=1;
ch0->Lead=0;
ch0->MaxFollowingError=100;
ch0->StepperAmplitude=250;

ch0->iir[0].B0=1;
ch0->iir[0].B1=0;
ch0->iir[0].B2=0;
ch0->iir[0].A1=0;
ch0->iir[0].A2=0;

ch0->iir[1].B0=1;
ch0->iir[1].B1=0;
ch0->iir[1].B2=0;
ch0->iir[1].A1=0;
ch0->iir[1].A2=0;

ch0->iir[2].B0=0.0170064;
ch0->iir[2].B1=0.0340128;
ch0->iir[2].B2=0.0170064;
ch0->iir[2].A1=1.64519;
ch0->iir[2].A2=-0.713217;

ch1->InputMode=ENCODER_MODE;
ch1->OutputMode=DAC_SERVO_MODE;
ch1->Vel=150000;
ch1->Accel=1.5e+06;
ch1->Jerk=5e+06;
ch1->P=0.8;
ch1->I=0.01;
ch1->D=0.8;
ch1->FFAccel=0;
ch1->FFVel=0.0044;
ch1->MaxI=50;
ch1->MaxErr=200;
ch1->MaxOutput=1024;
ch1->DeadBandGain=0;
ch1->DeadBandRange=0;
ch1->InputChan0=1;
ch1->InputChan1=0;
ch1->OutputChan0=1;
ch1->OutputChan1=1;
ch1->MasterAxis=-1;
ch1->LimitSwitchOptions=0x10f;
ch1->LimitSwitchNegBit=136;
ch1->LimitSwitchPosBit=136;
ch1->SoftLimitPos=1e+30;
ch1->SoftLimitNeg=-1e+30;
ch1->InputGain0=1;
ch1->InputGain1=1;
ch1->InputOffset0=0;
ch1->InputOffset1=0;
ch1->OutputGain=-1;
ch1->OutputOffset=0;
ch1->SlaveGain=1;
ch1->BacklashMode=BACKLASH_OFF;
ch1->BacklashAmount=0;
ch1->BacklashRate=0;
ch1->invDistPerCycle=1;
ch1->Lead=0;
ch1->MaxFollowingError=60;
ch1->StepperAmplitude=20;

ch1->iir[0].B0=1;
ch1->iir[0].B1=0;
ch1->iir[0].B2=0;
ch1->iir[0].A1=0;
ch1->iir[0].A2=0;

ch1->iir[1].B0=1;
ch1->iir[1].B1=0;
ch1->iir[1].B2=0;
ch1->iir[1].A1=0;
ch1->iir[1].A2=0;

ch1->iir[2].B0=1;
ch1->iir[2].B1=0;
ch1->iir[2].B2=0;
ch1->iir[2].A1=0;
ch1->iir[2].A2=0;

ch2->InputMode=ENCODER_MODE;
ch2->OutputMode=DAC_SERVO_MODE;
ch2->Vel=50000;
ch2->Accel=300000;
ch2->Jerk=350000;
ch2->P=0.8;
ch2->I=7e-06;
ch2->D=5;
ch2->FFAccel=0;
ch2->FFVel=0.005;
ch2->MaxI=200;
ch2->MaxErr=500;
ch2->MaxOutput=1024;
ch2->DeadBandGain=0;
ch2->DeadBandRange=0;
ch2->InputChan0=2;
ch2->InputChan1=0;
ch2->OutputChan0=2;
ch2->OutputChan1=0;
ch2->MasterAxis=-1;
ch2->LimitSwitchOptions=0x10f;
ch2->LimitSwitchNegBit=136;
ch2->LimitSwitchPosBit=136;
ch2->SoftLimitPos=1e+09;
ch2->SoftLimitNeg=-1e+09;
ch2->InputGain0=-1;
ch2->InputGain1=1;
ch2->InputOffset0=0;
ch2->InputOffset1=0;
ch2->OutputGain=1;
ch2->OutputOffset=0;
ch2->SlaveGain=1;
ch2->BacklashMode=BACKLASH_OFF;
ch2->BacklashAmount=0;
ch2->BacklashRate=0;
ch2->invDistPerCycle=1;
ch2->Lead=0;
ch2->MaxFollowingError=300000000;
ch2->StepperAmplitude=20;

ch2->iir[0].B0=1;
ch2->iir[0].B1=0;
ch2->iir[0].B2=0;
ch2->iir[0].A1=0;
ch2->iir[0].A2=0;

ch2->iir[1].B0=1;
ch2->iir[1].B1=0;
ch2->iir[1].B2=0;
ch2->iir[1].A1=0;
ch2->iir[1].A2=0;

ch2->iir[2].B0=0.00641907;
ch2->iir[2].B1=0.0128381;
ch2->iir[2].B2=0.00641907;
ch2->iir[2].A1=1.76294;
ch2->iir[2].A2=-0.788615;


EnableAxis(0);
EnableAxis(1);
EnableAxis(2);

DefineCoordSystem(0,1,2,-1);



}
Attachments
NEWQ.rar
(722.1 KiB) Downloaded 39 times
EixoYerro.PNG
EixoXerro.PNG

User avatar
TomKerekes
Posts: 2529
Joined: Mon Dec 04, 2017 1:49 am

Re: Wiring and configuration SERVO DRIVES

Post by TomKerekes » Sun Nov 22, 2020 4:53 pm

Hi Gabriel,
The X axis have some bumps in pos error in the graph
I'm not sure what you mean. It looks similar to Y and pretty much as expected. I believe you said your resolution was 16000 counts per inch? If that is the case these errors would be ~0.00075 inches.

With the Integratpr limited to only 50 DAC counts it means the V FF is doing most of the work to generate ~500 DAC counts of output. That might be ok but if conditions change like friction or cutting forces then the Integrator wouldn't be able to make sufficient corrections.

Note your max Velocity and Acceleration for Y are set at 150000 and 1.5e6 but you are only testing ~120000 and 0.8e6. Acceleration of 1.5e6 is 1.5e6/16000 = 94in/sec2 (0.244G) is quite aggressive.

The Y axis make a bump when enabled, you can see in the graph.
That probably isn't an issue that is caused by servo drift and somewhat a quirk related to the Step Response Screen. It disables the axis, sets the parameters, then re-enables the axis at the destination where it was commanded before disabling. If the axis drifted it will "snap" back to where it was. This allows repeated Step Response plots starting from the exact same position. Normally the axis will be enabled to the current Position where it is and there will be no "snap".

I Have A+/- and B+/- wired. 0V isn't wired, if wired to ground the servos won't work.
This doesn't sound right. There is no GND connection to the encoders? What exactly happens if the ground is connected?

Also, sometimes the machine give a little bump when running g code, i found that it's more common when its doing an arc and then enters in a straigth line. For example, an arc where starts with Y and goes to X, then to a straight line with X, when the Y axis is near to the end of the arc, it bumps to get position. Looks like it miscalculate the deacceleration.
Possibly your accelerations are set too high. GCode Accelerations are set in the KMotionCNC | Tool Setup | Trajectory Planner. Please post all your settings. What is the feedrate? Radius?

running some G code, when the axis interpolate X and Y, the system goes unstable or noisy. Lowering or raising the speed don't solve the problem, just change the intensity of it. I can film it and upload to youtube if you need.
Sounds like your tuning might be marginally stable. Check the margins on your gains. You should also check at your max velocities and accelerations. You might read this.
Regards,

Tom Kerekes
Dynomotion, Inc.

GabrielR922
Posts: 79
Joined: Thu Aug 13, 2020 10:07 pm

Re: Wiring and configuration SERVO DRIVES

Post by GabrielR922 » Sun Nov 22, 2020 10:58 pm

Hello Tom!
With the Integratpr limited to only 50 DAC counts it means the V FF is doing most of the work to generate ~500 DAC counts of output. That might be ok but if conditions change like friction or cutting forces then the Integrator wouldn't be able to make sufficient corrections.
I will raise the integrator limit and test again.
Note your max Velocity and Acceleration for Y are set at 150000 and 1.5e6 but you are only testing ~120000 and 0.8e6. Acceleration of 1.5e6 is 1.5e6/16000 = 94in/sec2 (0.244G) is quite aggressive.
The acceleration with jog or G0 is pretty fast, but it doesn't become unstable or make any noise. (probably i will lower the acc)
I Have A+/- and B+/- wired. 0V isn't wired, if wired to ground the servos won't work.
This doesn't sound right. There is no GND connection to the encoders? What exactly happens if the ground is connected?

The axis won't move.
Here is the drive/servo scheme.

Also, Kanalog is on earth ground. I read that it can cause noise but was afraid to remove it. Should I ground the 5v power supply and remove ground from kanalog? then ground the encoder?

Possibly your accelerations are set too high. GCode Accelerations are set in the KMotionCNC | Tool Setup | Trajectory Planner. Please post all your settings. What is the feedrate? Radius?
At the moment i'm not at the machine, but I can remeber i'm using max speed of 10 and acceleration os 4. is that too much ? Can i found a formula to calculate the acceleration that i'm using in step response to trajectory planer ?

running some G code, when the axis interpolate X and Y, the system goes unstable or noisy. Lowering or raising the speed don't solve the problem, just change the intensity of it. I can film it and upload to youtube if you need.
Sounds like your tuning might be marginally stable. Check the margins on your gains. You should also check at your max velocities and accelerations. You might read this.
[/quote]

Maybe lowering a little bit P and D will help on this ? I will make some tests.
servopc.PNG
Here is the wiring from the old CNC.
I have the cable/connector 1CN

Also, everything is grounded, drives and everything in the machine.
Should I ground the cable shield and not the 0V from the encoder? The shield is grounded in the drive.

Attached are drive specs.
Attachments
servo2.PNG
servo1.PNG

GabrielR922
Posts: 79
Joined: Thu Aug 13, 2020 10:07 pm

Re: Wiring and configuration SERVO DRIVES

Post by GabrielR922 » Sun Nov 22, 2020 11:36 pm

Hello again Tom.
Saw this now.

Fix bug first introduced in V4.35c. The issue is triggered by multiple GCode segments in exactly the same direction and
where one of those is microscopic in length and is filtered out. In this case the updated change in direction is computed
incorrectly which results in a zero direction change being "rounded" and causes a divide by zero.

Maybe the error i'm reporting is this ? will update tomorrow and try again.

Thanks.

GabrielR922
Posts: 79
Joined: Thu Aug 13, 2020 10:07 pm

Re: Wiring and configuration SERVO DRIVES

Post by GabrielR922 » Mon Nov 23, 2020 2:33 pm

Hi Tom.

The bump issue seems to be solved.

About the XY interpolation it looks the same. tried to change a million parameters and can't get it right.

The axis seems to be "bouncing" while doing the interpolation. Like overcorrecting.

Thanks Tom.

User avatar
TomKerekes
Posts: 2529
Joined: Mon Dec 04, 2017 1:49 am

Re: Wiring and configuration SERVO DRIVES

Post by TomKerekes » Mon Nov 23, 2020 3:12 pm

Hi Gabriel,
What exactly happens if the ground is connected?

The axis won't move.
Here is the drive/servo scheme.
Connect the ground (0V in the schematic) and figure out why the axis won't move.

Also, Kanalog is on earth ground. I read that it can cause noise but was afraid to remove it. Should I ground the 5v power supply and remove ground from kanalog? then ground the encoder?
Grounding is complex. Remove any earth grounds from KFLOP or Kanalog.

At the moment i'm not at the machine, but I can remeber i'm using max speed of 10 and acceleration os 4. is that too much ?
Acceleration of 4 inches/sec2 doesn't seem high. Please post all your settings.

Can i found a formula to calculate the acceleration that i'm using in step response to trajectory planer ?
To convert from counts to inches divide by your counts/inch. I think it is 16000?

Should I ground the cable shield and not the 0V from the encoder?
no

The shield is grounded in the drive.
The schematic doesn't show that. It is usually best to connect the shield to Kanalog GND on the Kanalog end only.

Fix bug first introduced in V4.35c. The issue is triggered by multiple GCode segments in exactly the same direction and
where one of those is microscopic in length and is filtered out. In this case the updated change in direction is computed
incorrectly which results in a zero direction change being "rounded" and causes a divide by zero.
No I don't think that is the problem.

About the XY interpolation it looks the same. tried to change a million parameters and can't get it right.

The axis seems to be "bouncing" while doing the interpolation. Like overcorrecting.
That sounds like a tuning problem. If after checking the tuning there still is a problem you can use a C Program to capture data while running GCode to see exactly what is happening. See the CaptureXYZPosDestToFile.c example.
Regards,

Tom Kerekes
Dynomotion, Inc.

GabrielR922
Posts: 79
Joined: Thu Aug 13, 2020 10:07 pm

Re: Wiring and configuration SERVO DRIVES

Post by GabrielR922 » Mon Nov 23, 2020 6:02 pm

Tom, i unwired the Kanalog ground and tried encoder 0V again. Whenever i wire it, the axis won't move, i jog it and it disable (max following error), neither won't move in step screen with a high following error (10000).

It seems the error is main in Y now, the X axis is very fine.

Tried to change every setting. testing one by one in step response. Achieved graphs of +10 -10 error counts, but while running gcode it start to "vibrate" or being unstable. I tried to lower the P gain in drive and raise in Kanalog, same results. (after ajust)

Its around 16000 pulses for X/Y.

About the Limits, i read that it's good to leave they in a low value. but for the settings below, what would be a resonable value ?
For Max limits for example?
is it best to use a I max of 10 or 100.

tested: I=0.01 / I=0.0001
D= 1 / D= 16
P= 1 / P= 3

All theses values i tested not just putting the value, but putting the value and configuring the others to give a low error count.

problema.PNG
I wish Brazilian real wasn't 0.20U$$, so I could contract you for fine tuning.
But it becomes impracticable for brazil.
Anyway, thanks for your attention and help with me, it's getting a bit long.

my kmotinoCNC configs:
Attachments
kcnc.PNG

User avatar
TomKerekes
Posts: 2529
Joined: Mon Dec 04, 2017 1:49 am

Re: Wiring and configuration SERVO DRIVES

Post by TomKerekes » Mon Nov 23, 2020 6:32 pm

Oi Gabriel,
i unwired the Kanalog ground and tried encoder 0V again. Whenever i wire it, the axis won't move, i jog it and it disable (max following error), neither won't move in step screen with a high following error (10000).
You need to figure out why it doesn't move. When something doesn't work at all it is normally easy to find the reason by checking what things are working an what isn't. On your Step Response Screen it appears you didn't try to make a move.


About the Limits, i read that it's good to leave they in a low value. but for the settings below, what would be a resonable value ?
For Max limits for example?
is it best to use a I max of 10 or 100.
One approach is to look at how much Output is needed to make the fastest move and set it to a bit more than that value.

tested: I=0.01 / I=0.0001
D= 1 / D= 16
P= 1 / P= 3

All theses values i tested not just putting the value, but putting the value and configuring the others to give a low error count.
Yes that is the basic idea. Your earlier plots were quite good, but with different values.


I would focus on getting 0V connected to the Drives before doing anything else.


I wish Brazilian real wasn't 0.20U$$, so I could contract you for fine tuning.
But it becomes impracticable for brazil.
Anyway, thanks for your attention and help with me, it's getting a bit long.
Sim, eu sei que a situação no brasil é ruim. Minha esposa é carioca. E nós temos amigos lá. E investimentos. Fique seguro.

Saudações
Regards,

Tom Kerekes
Dynomotion, Inc.

GabrielR922
Posts: 79
Joined: Thu Aug 13, 2020 10:07 pm

Re: Wiring and configuration SERVO DRIVES

Post by GabrielR922 » Mon Nov 23, 2020 8:25 pm

Hi Tom.

Sorry for the first plot, it was supposed to have info.

Here goes the plot with Ground connect.
grounded.PNG
The DAC maximaze at 10v and the drive won't respond.

I can see the motor moving very slow.

I'm using the grounds of JP6. Show i use JP11 ground?
Sim, eu sei que a situação no brasil é ruim. Minha esposa é carioca. E nós temos amigos lá. E investimentos. Fique seguro.

Saudações
That's interesting to know. If you ever come to Rio grande do sul - Brasil, please let me know, i can give you some recomendation on good turistic points to visit.

Thanks Tom!

Post Reply