Axis set up
Posted: Tue Mar 05, 2024 5:22 am
Hi,
I'm currently working on a 5-axis and one spindle CNC project and have done testing each axis individually and now moving on to simultaneous axis control.
I am facing two technical issues:
1. Soft Limits Issue: Hardware limits correctly stop movement at boundaries and allow reverse direction movement. However, software-defined limits lock all movements once reached, even though the axis stays enabled, rendering jog and move commands ineffective.
2. Origin: I have sensors at each origin and I am not quite sure about the syntax to be used to set it up.
For you reference, this is the complete code I'm using to set-up all five axis:
I'm currently working on a 5-axis and one spindle CNC project and have done testing each axis individually and now moving on to simultaneous axis control.
I am facing two technical issues:
1. Soft Limits Issue: Hardware limits correctly stop movement at boundaries and allow reverse direction movement. However, software-defined limits lock all movements once reached, even though the axis stays enabled, rendering jog and move commands ineffective.
2. Origin: I have sensors at each origin and I am not quite sure about the syntax to be used to set it up.
For you reference, this is the complete code I'm using to set-up all five axis:
Code: Select all
#include "KMotionDef.h"
//code for all axis motor set-up
int main()
{
InitAux();
AddKonnect_Aux0(0, &VirtualBits, VirtualBitsEx);
double T0, LastX=0, LastY=0, LastZ=0, LastA=0, Tau;
FPGA(STEP_PULSE_LENGTH_ADD) = 63 + 0x80; // set polarity and pulse length to 4us
//ch0=x
ch0->InputMode=NO_INPUT_MODE;
ch0->OutputMode=STEP_DIR_MODE;
ch0->Vel=40000;
ch0->Accel=200000;
ch0->Jerk=4e+006;
ch0->P=0;
ch0->I=0.01;
ch0->D=0;
ch0->FFAccel=0; //feed foward acceleration
ch0->FFVel=0; //feed foward velocity
ch0->MaxI=200;
ch0->MaxErr=1e+006;
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=0x110;
ch0->LimitSwitchNegBit = 1025;
ch0->LimitSwitchPosBit = 1024;
ch0->SoftLimitPos = 56000; //TBT
ch0->SoftLimitNeg = -56000; //TBT
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.000769;
ch0->iir[2].B1=0.001538;
ch0->iir[2].B2=0.000769;
ch0->iir[2].A1=1.92076;
ch0->iir[2].A2=-0.923833;
EnableAxisDest(0,0);
//similarly for the other 4 axis and spindle
//ENA pins, ClearBit()=low, SetBit()=high
void SetBitDirection(56, 1); // Set pin 56 as an output, xyzy'z' ENA
ClearBit(56); // Set pin 56 low ="turn off" the enable pin=motor start
void SetBitDirection(55, 1); // Set pin 55 as an output, polishing tool ENA
ClearBit(55); // Set pin 55 low ="turn off" the enable pin=motor start
//Brake pins
void SetBitDirection(52, 1); //Set pin 52 as an output, z brake
SetBit(52); //"turn on" 52=high
void SetBitDiretion(53, 1); //Set pin 53 as an output, polishing tool brake
SetBit(53); //"turn on" 53=high
//definecoordinate
DefineCoordSystem6(0,1,4,-1,3,2); // define axis chan numbers to use as x,y,z,a,b,c (set -1 to disable)
return 0;
}
Thank you :)