Code: Select all

```
#include "KMotionDef.h"
main()
{
KStepPresent=TRUE; //which tells KFLOP that KSTEP is connected
FPGA(KAN_TRIG_REG)=4; //Mux PWM0 to JP7 Pin5 IO 44 for KSTEP
FPGA(STEP_PULSE_LENGTH_ADD) = 63 + 0x80; //which sets polarity and pulse length to 4us
ch2->InputMode=NO_INPUT_MODE;
ch2->OutputMode=STEP_DIR_MODE;
ch2->Vel=60000;
ch2->Accel=600000;
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=10;
ch2->OutputChan1=0;
ch2->MasterAxis=-1;
ch2->LimitSwitchOptions=0x100;
ch2->LimitSwitchNegBit=0;
ch2->LimitSwitchPosBit=0;
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=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=0.000769;
ch2->iir[2].B1=0.001538;
ch2->iir[2].B2=0.000769;
ch2->iir[2].A1=1.92076;
ch2->iir[2].A2=-0.923833;
EnableAxisDest(2, 0);
ch7->InputMode=NO_INPUT_MODE;
ch7->OutputMode=STEP_DIR_MODE;
ch7->Vel=40000;
ch7->Accel=400000;
ch7->Jerk=4e+06;
ch7->P=0;
ch7->I=0.1;
ch7->D=0;
ch7->FFAccel=0;
ch7->FFVel=0;
ch7->MaxI=200;
ch7->MaxErr=1e+06;
ch7->MaxOutput=200;
ch7->DeadBandGain=1;
ch7->DeadBandRange=0;
ch7->InputChan0=0;
ch7->InputChan1=1;
ch7->OutputChan0=15;
ch7->OutputChan1=1;
ch7->MasterAxis=-1;
ch7->LimitSwitchOptions=0x100;
ch7->LimitSwitchNegBit=0;
ch7->LimitSwitchPosBit=0;
ch7->SoftLimitPos=1e+09;
ch7->SoftLimitNeg=-1e+09;
ch7->InputGain0=1;
ch7->InputGain1=1;
ch7->InputOffset0=0;
ch7->InputOffset1=0;
ch7->OutputGain=1;
ch7->OutputOffset=0;
ch7->SlaveGain=1;
ch7->BacklashMode=BACKLASH_OFF;
ch7->BacklashAmount=0;
ch7->BacklashRate=0;
ch7->invDistPerCycle=1;
ch7->Lead=0;
ch7->MaxFollowingError=10000000;
ch7->StepperAmplitude=250;
ch7->iir[0].B0=1;
ch7->iir[0].B1=0;
ch7->iir[0].B2=0;
ch7->iir[0].A1=0;
ch7->iir[0].A2=0;
ch7->iir[1].B0=1;
ch7->iir[1].B1=0;
ch7->iir[1].B2=0;
ch7->iir[1].A1=0;
ch7->iir[1].A2=0;
ch7->iir[2].B0=1;
ch7->iir[2].B1=0;
ch7->iir[2].B2=0;
ch7->iir[2].A1=0;
ch7->iir[2].A2=0;
EnableAxisDest(7, 0);
DefineCoordSystem(2, 7, -1, -1);
SetBitDirection(45, 1);
SetBit(45);
SetBitDirection(18, 0);
while(1)
{
while(ReadBit(18))
{
Jog(2, 300);
Jog(7, 10000);
}
Jog(2, 0);
Jog(7, 0);
}
}
```