Hi i finish to setup and make homing on my machine but got some issue whit soft limit switch
on Z-axi i got 250 encoder cont over shoot on soft limit ,that not critical just anoing
but on X axis the soft limit not work ! ,debug console tell me limit reach and go into feed hold ,but motor still move until physically spindle hit rotary table
any idea ? i try many may option for LimitSwitchOptions=0x whit similar result
Best regard Marc Alphatronique
that config i use
#include "KMotionDef.h"
// Configuration and Homing program for a 3 axis System
// Limit switches are disabled and used as a home switch
// then they are re-enabled
main()
{
int SaveXLimits,SaveYLimits,SaveZLimits; //place to save limit switch settings
DisableAxis(0); // Disable all axes
DisableAxis(1);
DisableAxis(2);
// Set the axis parameters here
// after everything is configured in the KMotion Screens
// use copy C Code to clipboard on the configuration screen
// then paste here. Repeat for each axis
WriteSnapAmp(SNAP0+SNAP_PEAK_CUR_LIMIT0,10);
WriteSnapAmp(SNAP0+SNAP_PEAK_CUR_LIMIT1,10);
ch0->InputMode=ENCODER_MODE;
ch0->OutputMode=DC_SERVO_MODE;
ch0->Vel=100000;
ch0->Accel=2e+06;
ch0->Jerk=900000;
ch0->P=30;
ch0->I=0;
ch0->D=10;
ch0->FFAccel=0;
ch0->FFVel=0;
ch0->MaxI=200;
ch0->MaxErr=500;
ch0->MaxOutput=200;
ch0->DeadBandGain=1;
ch0->DeadBandRange=0;
ch0->InputChan0=8;
ch0->InputChan1=0;
ch0->OutputChan0=8;
ch0->OutputChan1=0;
ch0->MasterAxis=-1;
ch0->LimitSwitchOptions=0x120;
ch0->LimitSwitchNegBit=0;
ch0->LimitSwitchPosBit=0;
ch0->SoftLimitPos=100;
ch0->SoftLimitNeg=-290000;
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=1000;
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=10000;
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=0;
ch1->InputChan1=0;
ch1->OutputChan0=5;
ch1->OutputChan1=0;
ch1->MasterAxis=-1;
ch1->LimitSwitchOptions=0x100;
ch1->LimitSwitchNegBit=0;
ch1->LimitSwitchPosBit=0;
ch1->SoftLimitPos=1e+06;
ch1->SoftLimitNeg=1e+06;
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=20;
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=STEP_DIR_MODE;
ch2->Vel=10000;
ch2->Accel=400000;
ch2->Jerk=4e+06;
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=4;
ch2->OutputChan1=0;
ch2->MasterAxis=-1;
ch2->LimitSwitchOptions=0x110;
ch2->LimitSwitchNegBit=0;
ch2->LimitSwitchPosBit=0;
ch2->SoftLimitPos=100;
ch2->SoftLimitNeg=-27000;
ch2->InputGain0=-2.5;
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=20;
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;
// disable the limits (first save how they were set)
SaveXLimits = ch0->LimitSwitchOptions;
SaveYLimits = ch1->LimitSwitchOptions;
SaveZLimits = ch2->LimitSwitchOptions;
// ch0->LimitSwitchOptions = 0;
// ch1->LimitSwitchOptions = 0;
// ch2->LimitSwitchOptions = 0;
// enable all 3 axes and begin servoing where we are
EnableAxis(0);
EnableAxis(1);
EnableAxis(2);
// Home Z up first - jog until it sees the limit
ch2->SoftLimitPos=270000;
ch2->SoftLimitNeg=-270000;
Jog(2,500); // jog slowly positive
while (!ReadBit(76)) ; // loop until IO bit goes high
Jog(2,0); // stop
while (!CheckDone(2)) ; // loop until motion completes
DisableAxis(2); // disable the axis
Zero(2); // Zero the position
ch2->SoftLimitPos=100;
ch2->SoftLimitNeg=-26000;
EnableAxis(2); // re-enable the ServoTick
Move(2,-1000.0); // move some amount inside the limits
while (!CheckDone(2)) ; // loop until motion completes
//ch2->LimitSwitchOptions = SaveZLimits; // restore limit settings
// Home X next - jog until it sees the limit
ch0->SoftLimitPos=290000;
ch0->SoftLimitNeg=-290000;
Jog(0,1000); // jog slowly negative
while (!ReadBit(77)) ; // loop until IO bit goes high
Jog(0,0); // stop
while (!CheckDone(0)) ; // loop until motion completes
DisableAxis(0); // disable the axis
Zero(0); // Zero the position
ch0->SoftLimitPos=100;
ch0->SoftLimitNeg=-290000;
EnableAxis(0); // re-enable the ServoTick
Move(0,-1000.0); // move some amount inside the limits
while (!CheckDone(0)) ; // loop until motion completes
//ch0->LimitSwitchOptions = SaveXLimits; // restore limit settings
// Home Y next - jog until it sees the limit
// Jog(1,-100); // jog slowly negative
// while (!ReadBit(9)) ; // loop until IO bit goes high
// Jog(1,0); // stop
// while (!CheckDone(1)) ; // loop until motion completes
// DisableAxis(1); // disable the axis
// Zero(1); // Zero the position
// EnableAxis(1); // re-enable the ServoTick
// Move(1,1000.0); // move some amount inside the limits
// while (!CheckDone(1)) ; // loop until motion completes
ch1->LimitSwitchOptions = SaveYLimits; // restore limit settings
// DefineCoordSystem(0,1,2,-1); //Define XYZ coordinated motion axes
}