Master/Slave not working correctly, all other axis OK

Moderators: TomKerekes, dynomotion

Post Reply
jerryn
Posts: 6
Joined: Tue Mar 21, 2023 4:02 pm

Master/Slave not working correctly, all other axis OK

Post by jerryn » Tue Mar 21, 2023 11:00 pm

Using KFlop, KStep, and KConnect. First start up. Axis CH2 and CH3 work with no issues, sensors work and homing is achieved. Problem is with CH0 and CH1. CH0 is master and CH1 is slaved to CH0. Step Response for CH0 and CH1 motors work fine. Sensors have all been verified and show status in KConnect. CH0 and CH1 are not playing together....

When homing in KMotion CNC, both CH0 and CH1 motors spin. Sensor for Negative sensor CH0 does not stop CH0 motor. CH1 Negative sensor does not stop when activated, however, after activating and then releasing, CH0 motor will stop (not before or during CH1 sensor activation). CH1 motor continues to spin and no sensor stops it.

I do not see what I did wrong. It is like one or more registers are messed up.

// Define X Master Axis
ch0->InputMode=ENCODER_MODE;
ch0->OutputMode=STEP_DIR_MODE;
ch0->Vel=40000;
ch0->Accel=400000;
ch0->Jerk=4e+06;
ch0->P=0;
ch0->I=0.01;
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=8;
ch0->OutputChan1=0;
ch0->MasterAxis=-1;
ch0->LimitSwitchOptions=0x113;
ch0->LimitSwitchNegBit=1024;
ch0->LimitSwitchPosBit=1025;
ch0->SoftLimitPos=1e+09;
ch0->SoftLimitNeg=-1e+09;
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=0;
ch0->BacklashRate=0;
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=0.000768788;
ch0->iir[2].B1=0.00153758;
ch0->iir[2].B2=0.000768788;
ch0->iir[2].A1=1.92076;
ch0->iir[2].A2=-0.923833;

EnableAxisDest(0,ch0->Dest);
// End X Master Axis

//Define X Slave Axis
ch1->InputMode=ENCODER_MODE;
ch1->OutputMode=STEP_DIR_MODE;
ch1->Vel=40000;
ch1->Accel=400000;
ch1->Jerk=4e+06;
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=1;
ch1->InputChan1=0;
ch1->OutputChan0=9;
ch1->OutputChan1=0;
ch1->MasterAxis=0;
ch1->LimitSwitchOptions=0x103;
ch1->LimitSwitchNegBit=1026;
ch1->LimitSwitchPosBit=1027;
ch1->SoftLimitPos=1e+09;
ch1->SoftLimitNeg=-1e+09;
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.92081;
ch1->iir[2].A2=-0.923885;

EnableAxisDest(1,ch1->Dest);
// End X Slave Axis

DefineCoordSystem(0,2,3,-1); // Channel numbers for X,Y,Z

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

Re: Master/Slave not working correctly, all other axis OK

Post by TomKerekes » Wed Mar 22, 2023 12:26 am

Hi Jerry,

What code are you using for homing? What messages appear on the Console?

But normally Master/Slave axes are homed independently and simultaneously with limits disabled so the orthogonality can be adjusted. See the HomeSlaved.c example.
Regards,

Tom Kerekes
Dynomotion, Inc.

jerryn
Posts: 6
Joined: Tue Mar 21, 2023 4:02 pm

Re: Master/Slave not working correctly, all other axis OK

Post by jerryn » Wed Mar 22, 2023 10:04 pm

Tom,
Thanks so much for your timely advice. What a simple mistake I made, I forgot to change bits in the home program. Thanks for your time!

Post Reply