Hi Mr Tom,
please correct the c program that I made.
and how to post the correct code on the forum, so that it can be read and understood?
i want to increment axes, when i click init. first I want to try with a short distance (100). with the output DAC2 = 5 volts.
upon hitting the target, bit 152 is off, and DAC2 = 0.
CODE:
#include "KMotionDef.h"
main()
{
//Axis 0
ch0->InputMode=ENCODER_MODE;
ch0->OutputMode=DAC_SERVO_MODE;
ch0->Vel=700;
ch0->Accel=3500;
ch0->Jerk=350000;
ch0->P=2;
ch0->I=0.01;
ch0->D=10;
ch0->FFAccel=0;
ch0->FFVel=0;
ch0->MaxI=200;
ch0->MaxErr=1024;
ch0->MaxOutput=1024;
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+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=100000;
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;
// Axis 1
ch1->InputMode=ENCODER_MODE;
ch1->OutputMode=DAC_SERVO_MODE;
ch1->Vel=700;
ch1->Accel=3500;
ch1->Jerk=350000;
ch1->P=2;
ch1->I=0.01;
ch1->D=10;
ch1->FFAccel=0;
ch1->FFVel=0;
ch1->MaxI=200;
ch1->MaxErr=1024;
ch1->MaxOutput=1024;
ch1->DeadBandGain=1;
ch1->DeadBandRange=0;
ch1->InputChan0=1;
ch1->InputChan1=1;
ch1->OutputChan0=1;
ch1->OutputChan1=1;
ch1->MasterAxis=-1;
ch1->LimitSwitchOptions=0x100;
ch1->LimitSwitchNegBit=0;
ch1->LimitSwitchPosBit=0;
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=100000;
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;
Zero(0); //nol posisi encoder dan posisi yang diperintahkan saat ini
Zero(1);
EnableAxis(0); //aktifkan sumbu dan tetapkan tujuan
EnableAxis(1);
DefineCoordSystem(0,1,-1,-1); // tentukan nomor sumbu chan untuk digunakan sebagai x, y, z, a
if ( EnableAxisDest(0,0) || EnableAxisDest(1,0) )
{
SetBit(152); // to activate the pressure.
DAC(2,1024); // 1024 is 5 volt
}
if ( EnableAxisDest(0,100) || EnableAxisDest(1,100) ) //
{
ClearBit(152); // to non activate the pressure.
DAC(2,0); // 0 is 0 volt
}
}