Backlash only applied on 1st move?

Moderators: TomKerekes, dynomotion

Post Reply
men8ifr
Posts: 19
Joined: Tue Mar 26, 2019 2:30 pm

Backlash only applied on 1st move?

Post by men8ifr » Wed Nov 22, 2023 4:34 pm

My Z axis needs some adjustments but that involves stripping the mill. I measured backlash at 0.25mm which I think is too high.

As a temporary workaround I tried applying backlash to the Z axis and then ran the following code to help debug what is happening.

g1 z0.4 F150
G4 P1
g1 z0
G4 P1
g1 z0.4 F150
G4 P1
g1 z0
G4 P1......

and repeats many times to observe via dial indicator what movement I actually get.

I put in 2750 steps and 1000 rate into backlash. This seemed to overshoot the target on the first move but then subsequent moves it made no difference , it cannot be applied otherwise this large movement would be quite obvious.

I would expect the additional movement request to be applied every up ..or down movement but does not seem to be the case. Mode was linear that is the only option I have.

C Code below for axis set-up Z is CH0

include "KMotionDef.h"

main()
{
ch0->InputMode=NO_INPUT_MODE;
ch0->OutputMode=STEP_DIR_MODE;
ch0->Vel=2000;
ch0->Accel=10000;
ch0->Jerk=400000;
ch0->P=1;
ch0->I=0;
ch0->D=0;
ch0->FFAccel=0;
ch0->FFVel=0;
ch0->MaxI=200;
ch0->MaxErr=1e+06;
ch0->MaxOutput=200;
ch0->DeadBandGain=1;
ch0->DeadBandRange=0;
ch0->InputChan0=0;
ch0->InputChan1=0;
ch0->OutputChan0=0;
ch0->OutputChan1=1;
ch0->MasterAxis=-1;
ch0->LimitSwitchOptions=0x100;
ch0->LimitSwitchNegBit=0;
ch0->LimitSwitchPosBit=0;
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_LINEAR;
ch0->BacklashAmount=2750;
ch0->BacklashRate=1000;
ch0->invDistPerCycle=1;
ch0->Lead=0;
ch0->MaxFollowingError=1000000000;
ch0->StepperAmplitude=20;

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=1;
ch0->iir[2].B1=0;
ch0->iir[2].B2=0;
ch0->iir[2].A1=0;
ch0->iir[2].A2=0;

ch1->InputMode=NO_INPUT_MODE;
ch1->OutputMode=STEP_DIR_MODE;
ch1->Vel=2000;
ch1->Accel=10000;
ch1->Jerk=400000;
ch1->P=0;
ch1->I=0.01;
ch1->D=0;
ch1->FFAccel=0;
ch1->FFVel=0;
ch1->MaxI=200;
ch1->MaxErr=1e+06;
ch1->MaxOutput=200;
ch1->DeadBandGain=1;
ch1->DeadBandRange=0;
ch1->InputChan0=0;
ch1->InputChan1=0;
ch1->OutputChan0=1;
ch1->OutputChan1=0;
ch1->MasterAxis=-1;
ch1->LimitSwitchOptions=0x100;
ch1->LimitSwitchNegBit=0;
ch1->LimitSwitchPosBit=0;
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=1000000000;
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=0.000769;
ch1->iir[2].B1=0.001538;
ch1->iir[2].B2=0.000769;
ch1->iir[2].A1=1.92076;
ch1->iir[2].A2=-0.923833;

ch2->InputMode=NO_INPUT_MODE;
ch2->OutputMode=STEP_DIR_MODE;
ch2->Vel=2000;
ch2->Accel=10000;
ch2->Jerk=400000;
ch2->P=0;
ch2->I=0.01;
ch2->D=0;
ch2->FFAccel=0;
ch2->FFVel=0;
ch2->MaxI=200;
ch2->MaxErr=1e+06;
ch2->MaxOutput=200;
ch2->DeadBandGain=1;
ch2->DeadBandRange=0;
ch2->InputChan0=0;
ch2->InputChan1=0;
ch2->OutputChan0=2;
ch2->OutputChan1=0;
ch2->MasterAxis=-1;
ch2->LimitSwitchOptions=0x100;
ch2->LimitSwitchNegBit=0;
ch2->LimitSwitchPosBit=0;
ch2->SoftLimitPos=1e+30;
ch2->SoftLimitNeg=-1e+30;
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=1000000000;
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=1;
ch2->iir[2].B1=0;
ch2->iir[2].B2=0;
ch2->iir[2].A1=0;
ch2->iir[2].A2=0;

EnableAxis(0); // enable the Axis
EnableAxis(1); // enable the Axis
EnableAxis(2); // enable the Axis
EnableAxis(3); // enable the Axis
EnableAxis(4); // enable the Axis
EnableAxis(5); // enable the Axis
EnableAxis(6); // enable the Axis
EnableAxis(7); // enable the Axis

}
My Set-up
PM30 Milling Machine - 3 axis
Kflop
Leadshine copy closed loop 'hybrid' stepper drivers similar to HBS86
Nema 34 6A 8.5Nm motors with encoder (encoder connects to stepper driver)
Fusion 360 Software

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

Re: Backlash only applied on 1st move?

Post by TomKerekes » Wed Nov 22, 2023 5:04 pm

Hi,

Trying to correct backlash in software rarely works well. Especially that large on an axis with gravity.

What is the Z axis resolution in steps/inch?

Is the GCode in Inches or mm?

The idea with backlash correction is that when the axis reverses the motor quickly takes out the slack. With 2750 steps of backlash being taken out at a rate of 1000 steps/sec it would take 2.75 seconds to remove the backlash. The move would likely be over by then.

Why are you enabling axes not being used?

How have you defined the Coordinate System?

Please post code using the code tag </> to make it more readable.
Regards,

Tom Kerekes
Dynomotion, Inc.

men8ifr
Posts: 19
Joined: Tue Mar 26, 2019 2:30 pm

Re: Backlash only applied on 1st move?

Post by men8ifr » Wed Nov 22, 2023 6:13 pm

Please post code using the code tag </> to make it more readable.

I hit code on in the reply and paste the code between tags?
Last edited by men8ifr on Wed Nov 22, 2023 6:42 pm, edited 1 time in total.
My Set-up
PM30 Milling Machine - 3 axis
Kflop
Leadshine copy closed loop 'hybrid' stepper drivers similar to HBS86
Nema 34 6A 8.5Nm motors with encoder (encoder connects to stepper driver)
Fusion 360 Software

men8ifr
Posts: 19
Joined: Tue Mar 26, 2019 2:30 pm

Re: Backlash only applied on 1st move?

Post by men8ifr » Wed Nov 22, 2023 6:41 pm

Trying to correct backlash in software rarely works well. Especially that large on an axis with gravity.

>>>Yes this is a temporary measure but I also guess even with a perfectly set-up machine there will be some backlash that could be cleaned up with software.

What is the Z axis resolution in steps/inch?

11005

Is the GCode in Inches or mm?

mm

The idea with backlash correction is that when the axis reverses the motor quickly takes out the slack. With 2750 steps of backlash being taken out at a rate of 1000 steps/sec it would take 2.75 seconds to remove the backlash. The move would likely be over by then.

Ah OK - It is not clear 'Rate' is Steps / sec (or I didn't read it - I did read the section just on rate )

Why are you enabling axes not being used?

Fusion defaults to outputting spindle activation so the only way I have to get it to work for now is to enable all axis - will that cause issues?

How have you defined the Coordinate System?

It's the defaults - I was answering this when I realize I've put the backlash on Ch0 = X. I've put it on CH2 (z) and it works like a charm - except the steps were way too big. My calculation how many steps I needed (0.25mm x 11005 steps/mm = 2750 steps) was wrong as steps must be steps/inch. It actually needs 100 steps and now moves z perfectly with my code 0 to 0.4mm is spot on with my dial indicator.
My Set-up
PM30 Milling Machine - 3 axis
Kflop
Leadshine copy closed loop 'hybrid' stepper drivers similar to HBS86
Nema 34 6A 8.5Nm motors with encoder (encoder connects to stepper driver)
Fusion 360 Software

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

Re: Backlash only applied on 1st move?

Post by TomKerekes » Wed Nov 22, 2023 7:03 pm

Great news.
Fusion defaults to outputting spindle activation so the only way I have to get it to work for now is to enable all axis - will that cause issues?
Yes it could. I don't think it is an issue with Fusion or the Spindle. I think it is that the default Coordinate System defines axis 3 as the A Axis. So XYZA must be enabled. Remove the A Axis from the Coordinate System with:

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

Then only enable the axes you are configuring.

HTH
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply