problems with 4-5th axis configuration

Moderators: TomKerekes, dynomotion

Post Reply
gonzalo
Posts: 13
Joined: Wed Feb 27, 2019 4:03 pm

problems with 4-5th axis configuration

Post by gonzalo » Fri Dec 27, 2019 9:19 am

Dear Tom,

I am making a new setup with the following:

1 KFLOP
1 KSTEP: for direct use axis 0, 1,2,3 to steppers, for the moment only moving 0
Axis 4 and Axis 5 using JP5 GPI/O pins 1-2 (Pulse/dir) for external driver 1 and 2-3 for external driver 2
1 Kconnect.

My problem is when I try to set up the configuration for axis 4th and 5th I do not get any Pulses from the JP5 connector. Another strange thing is that when I moves axis 4 it moves the axis 0..... Please can you check my code and tell me the error I am making?

Many thanks!!!!


Code:

#include "KMotionDef.h"

////////////////////////////////////////////////////////
////////////FUNCTIONS DEFINITIONS///////////////////////
///////////////////////////////////////////////////////

int Set_Bit_Status(int bit)
{
persist.UserData[100] = (1 << bit) | persist.UserData[100];
}

int Clear_Bit_Status(int bit)
{
persist.UserData[100] = persist.UserData[100]& (~(1 << bit));
}

void Axis_Setting(void)
{ //Axis X en eje 4. Paso 5mm. Subdiviones de 40
ch4->InputMode=NO_INPUT_MODE;
ch4->OutputMode=STEP_DIR_MODE;
ch4->Vel=5;
ch4->Accel=50;
ch4->Jerk=4e+006;
ch4->P=0;
ch4->I=0.01;
ch4->D=0;
ch4->FFAccel=0;
ch4->FFVel=0;
ch4->MaxI=200;
ch4->MaxErr=1e+006;
ch4->MaxOutput=200;
ch4->DeadBandGain=1;
ch4->DeadBandRange=0;
ch4->InputChan0=0;
ch4->InputChan1=0;
ch4->OutputChan0=8;
ch4->OutputChan1=0;
ch4->MasterAxis=-1;
ch4->LimitSwitchOptions=0x0;
ch4->SoftLimitPos=100;
ch4->SoftLimitNeg=-100;
ch4->InputGain0=1;
ch4->InputGain1=1;
ch4->InputOffset0=0;
ch4->InputOffset1=0;
ch4->OutputGain=1600;// OutputGain = 360º/1.8º/step= 200 steps/rev (without microsep). With KSTEP= 200*40= 8000 steps/rev / 5 mm/rev = 1600
ch4->OutputOffset=0;
ch4->SlaveGain=1;
ch4->BacklashMode=BACKLASH_OFF;
ch4->BacklashAmount=0;
ch4->BacklashRate=0;
ch4->invDistPerCycle=1;
ch4->Lead=0;
ch4->MaxFollowingError=1000000000;
ch4->StepperAmplitude=20;

ch4->iir[0].B0=1;
ch4->iir[0].B1=0;
ch4->iir[0].B2=0;
ch4->iir[0].A1=0;
ch4->iir[0].A2=0;

ch4->iir[1].B0=1;
ch4->iir[1].B1=0;
ch4->iir[1].B2=0;
ch4->iir[1].A1=0;
ch4->iir[1].A2=0;

ch4->iir[2].B0=0.000769;
ch4->iir[2].B1=0.001538;
ch4->iir[2].B2=0.000769;
ch4->iir[2].A1=1.92076;
ch4->iir[2].A2=-0.923833;
EnableAxisDest(4,0);

//Axis Z en eje 5. Paso 5mm. Subdiviones de 40
ch5->InputMode=NO_INPUT_MODE;
ch5->OutputMode=STEP_DIR_MODE;
ch5->Vel=5;
ch5->Accel=100;
ch5->Jerk=4e+003;
ch5->P=0;
ch5->I=0.01;
ch5->D=0;
ch5->FFAccel=0;
ch5->FFVel=0;
ch5->MaxI=200;
ch5->MaxErr=1e+006;
ch5->MaxOutput=200;
ch5->DeadBandGain=1;
ch5->DeadBandRange=0;
ch5->InputChan0=0;
ch5->InputChan1=0;
ch5->OutputChan0=9;
ch5->OutputChan1=0;
ch5->MasterAxis=-1;
ch5->LimitSwitchOptions=0x0;
ch5->SoftLimitPos=100;
ch5->SoftLimitNeg=-100;
ch5->InputGain0=1;
ch5->InputGain1=1;
ch5->InputOffset0=0;
ch5->InputOffset1=0;
ch5->OutputGain=1600;// OutputGain = 360º/1.8º/step= 200 steps/rev (without microsep). With KSTEP= 200*40= 8000 steps/rev / 5 mm/rev = 1600
ch5->OutputOffset=0;
ch5->SlaveGain=1;
ch5->BacklashMode=BACKLASH_OFF;
ch5->BacklashAmount=0;
ch5->BacklashRate=0;
ch5->invDistPerCycle=1;
ch5->Lead=0;
ch5->MaxFollowingError=1000000000;
ch5->StepperAmplitude=20;

ch5->iir[0].B0=1;
ch5->iir[0].B1=0;
ch5->iir[0].B2=0;
ch5->iir[0].A1=0;
ch5->iir[0].A2=0;

ch5->iir[1].B0=1;
ch5->iir[1].B1=0;
ch5->iir[1].B2=0;
ch5->iir[1].A1=0;
ch5->iir[1].A2=0;

ch5->iir[2].B0=1;
ch5->iir[2].B1=0;
ch5->iir[2].B2=0;
ch5->iir[2].A1=0;
ch5->iir[2].A2=0;
EnableAxisDest(5,0);

//AXIS Y (STANDA) va al KSTEP 0
ch0->InputMode=NO_INPUT_MODE;
ch0->OutputMode=STEP_DIR_MODE;
ch0->Vel=5;
ch0->Accel=100;
ch0->Jerk=4e+003;
ch0->P=0;
ch0->I=0.01;
ch0->D=0;
ch0->FFAccel=0;
ch0->FFVel=0;
ch0->MaxI=200;
ch0->MaxErr=1e+006;
ch0->MaxOutput=200;
ch0->DeadBandGain=1;
ch0->DeadBandRange=0;
ch0->InputChan0=0;
ch0->InputChan1=0;
ch0->OutputChan0=10;
ch0->OutputChan1=0;
ch0->MasterAxis=-1;
ch0->LimitSwitchOptions=0x0;
ch0->SoftLimitPos=100;
ch0->SoftLimitNeg=-100;
ch0->InputGain0=1;
ch0->InputGain1=1;
ch0->InputOffset0=0;
ch0->InputOffset1=0;
ch0->OutputGain=-6400; //OutputGain = 360º/1.8º/step= 200 steps/rev (without microsep). With KSTEP= 200*16= 3200 steps/rev / 0.5 mm/rev = 6400
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=1;
ch0->iir[2].B1=0;
ch0->iir[2].B2=0;
ch0->iir[2].A1=0;
ch0->iir[2].A2=0;
EnableAxisDest(0,0);

void DefineCoordSystem(4,5,0,-1);
}

void Home_X(void)
{
ch4->Dest=99;
Jog(4,-10); // start moving (EL JOG NO PARECE HACER NI CASO AL VALOR DEL SENTIDO DEL OutputGain, por ello lo he teanido que poner en + el JOG, curioso!!)
while (ReadBit(1032)) ; // wait for switch (input #16) to change

Jog(4,1); // start moving
while (!ReadBit(1032)) ;
Zero(4); // Set current position to 0
MoveAtVel(4,100,10);
while (!CheckDone(4)); //esperamos a que terminen el movimiento
Zero(4); // Set current position to 0
ch4->LimitSwitchOptions=0x0;//0x103;
ch4->SoftLimitPos=100;
ch4->SoftLimitNeg=-100;
persist.UserData[9]=0;
persist.UserData[12]=0;
}
void Home_Y(void)
{
ch0->Dest=19;
Jog(0,-1); // start moving (EL JOG NO PARECE HACER NI CASO AL VALOR DEL SENTIDO DEL OutputGain, por ello lo he teanido que poner en + el JOG, curioso!!)
while (!ReadBit(1030)) ; // wait for switch (input #16) to change

Jog(0,0.2); // start moving
while (ReadBit(1030)) ;
Zero(0);
MoveAtVel(0,1,2);
while (!CheckDone(0)); //esperamos a que terminen el movimiento
Zero(0); // Set current position to 0
ch0->LimitSwitchOptions=0x0;//0x103;0x103; //activo el watch limit
ch0->SoftLimitPos=20; //pongo los limetes de software activados
ch0->SoftLimitNeg=-0.05; //pongo los limites de software activados
persist.UserData[10]=0;
persist.UserData[13]=0;
}
void Home_Z(void)
{
ch5->Dest=32;
Jog(5,-4); // start moving (EL JOG NO PARECE HACER NI CASO AL VALOR DEL SENTIDO DEL OutputGain, por ello lo he teanido que poner en + el JOG, curioso!!)
while (ReadBit(1031)) ; // wait for switch (input #16) to change

Jog(5,1); // start moving
while (!ReadBit(1031)) ;
Zero(5);
MoveAtVel(5,1,5);
while (!CheckDone(5)); //esperamos a que terminen el movimiento // Set current position to 0
Zero(5);
ch5->LimitSwitchOptions=0x0;//0x103;0x103; //activo el watch limit
ch5->SoftLimitPos=33; //pongo los limetes de software activados
ch5->SoftLimitNeg=0; //pongo los limites de software activados
persist.UserData[11]=0;
persist.UserData[14]=0;
}


/////////////////////////////////////////
/////////////////////////////////////////
/////////////MAIN///////////////
/////////////////////////////////////////
int main()
{
double T0, LastX=0, LastY=0, LastZ=0, Tau;

//ACTIVACIÓN Kconnect.
InitAux();
AddKonnect(0,&VirtualBits,VirtualBitsEx);
/////////////////////////////////////////

KStepPresent=TRUE; // enable KSTEP input multiplexing
FPGA(KAN_TRIG_REG)=4; // Mux PWM0 to JP7 Pin5 IO 44 for KSTEP

FPGA(STEP_PULSE_LENGTH_ADD) = 63 + 0x80; // set polarity and pulse length to 4us

Axis_Setting();

SetBitDirection(45,1); // set Enable Signal as Output
SetBit(45); // Enable the amplifiers

KLP=0; // force to 0 to disable

//Home_X();
//Home_Y();
//Home_Z();
persist.UserData[40]=1;

}

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

Re: problems with 4-5th axis configuration

Post by TomKerekes » Fri Dec 27, 2019 5:13 pm

Hi gonzalo,

KFLOP JP5 has Step/Direction outputs 4-7 so you should configure the KFLOP Output Channel to be 4-7 (or 11-15 for TTL Mode). Any KFLOP axis can control any Output. You might read this and this.

Also this should be a function call not a definition so change this:
void DefineCoordSystem(4,5,0,-1);
to this:
DefineCoordSystem(4,5,0,-1);
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply