Re: starting my C program, any guidance would be appreciated.
Re: starting my C program, any guidance would be appreciated.
I am having a hard time getting code for my MPG to compile. I keep getting a MPGServiceSmoothHardwareEncFilteredRev3 undeclared error on the last line of this code, and Google won't answer me. If I remove the last line it compiles.
Code:
#include "KMotionDef.h"
#include "MPGServiceSmoothHardwareEncFilteredRev3.c"
#include "MySpindleDefs.h"
// Note Low Gains, Limited Max Limits, No Limit Options, No Soft Limits,
// Large allowed Following Error, No Feed Forward, No Filters, etc
void main()
{
ClearBit(SPINDLEDOWN_BIT);
ClearBit(SPINDLEUP_BIT);
ch0->InputMode=ENCODER_MODE;
ch0->OutputMode=DAC_SERVO_MODE;
ch0->Vel=40000;
ch0->Accel=40000;
ch0->Jerk=1e+06;
ch0->P=19;
ch0->I=0.0001;
ch0->D=5;
ch0->FFAccel=0.001;
ch0->FFVel=0.0009;
ch0->MaxI=9000;
ch0->MaxErr=100000;
ch0->MaxOutput=2000;
ch0->DeadBandGain=1;
ch0->DeadBandRange=2;
ch0->InputChan0=0;
ch0->InputChan1=1;
ch0->OutputChan0=0;
ch0->OutputChan1=1;
ch0->MasterAxis=0;
ch0->LimitSwitchOptions=0x11f;
ch0->LimitSwitchNegBit=136;
ch0->LimitSwitchPosBit=137;
ch0->SoftLimitPos=1e+09;
ch0->SoftLimitNeg=-1e+08;
ch0->InputGain0=1;
ch0->InputGain1=1;
ch0->InputOffset0=0;
ch0->InputOffset1=0;
ch0->OutputGain=1;
ch0->OutputOffset=0;
ch0->SlaveGain=0;
ch0->BacklashMode=BACKLASH_LINEAR;
ch0->BacklashAmount=1;
ch0->BacklashRate=2;
ch0->invDistPerCycle=0;
ch0->Lead=15;
ch0->MaxFollowingError=100000;
ch0->StepperAmplitude=250;
ch0->iir[0].B0=3.44761;
ch0->iir[0].B1=-6.74051;
ch0->iir[0].B2=3.29464;
ch0->iir[0].A1=1.91668;
ch0->iir[0].A2=-0.918416;
ch0->iir[1].B0=0.123861;
ch0->iir[1].B1=0.123861;
ch0->iir[1].B2=0;
ch0->iir[1].A1=0.752278;
ch0->iir[1].A2=0;
ch0->iir[2].B0=0.0166075;
ch0->iir[2].B1=0.033215;
ch0->iir[2].B2=0.0166075;
ch0->iir[2].A1=1.6066;
ch0->iir[2].A2=-0.673034;
ch1->InputMode=ENCODER_MODE;
ch1->OutputMode=DAC_SERVO_MODE;
ch1->Vel=400000;
ch1->Accel=1e+06;
ch1->Jerk=200000;
ch1->P=29;
ch1->I=0.0001;
ch1->D=5;
ch1->FFAccel=0.002;
ch1->FFVel=0.0006;
ch1->MaxI=5000;
ch1->MaxErr=100000;
ch1->MaxOutput=2000;
ch1->DeadBandGain=0;
ch1->DeadBandRange=1;
ch1->InputChan0=1;
ch1->InputChan1=1;
ch1->OutputChan0=1;
ch1->OutputChan1=1;
ch1->MasterAxis=-1;
ch1->LimitSwitchOptions=0x110;
ch1->LimitSwitchNegBit=140;
ch1->LimitSwitchPosBit=141;
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=0;
ch1->BacklashMode=BACKLASH_LINEAR;
ch1->BacklashAmount=0;
ch1->BacklashRate=0;
ch1->invDistPerCycle=0;
ch1->Lead=10;
ch1->MaxFollowingError=100000;
ch1->StepperAmplitude=250;
ch1->iir[0].B0=3.91172;
ch1->iir[0].B1=-7.64788;
ch1->iir[0].B2=3.73813;
ch1->iir[0].A1=1.91123;
ch1->iir[0].A2=-0.913201;
ch1->iir[1].B0=0.101606;
ch1->iir[1].B1=0.101606;
ch1->iir[1].B2=0;
ch1->iir[1].A1=0.796788;
ch1->iir[1].A2=0;
ch1->iir[2].B0=0.0110084;
ch1->iir[2].B1=0.0220167;
ch1->iir[2].B2=0.0110084;
ch1->iir[2].A1=1.68459;
ch1->iir[2].A2=-0.728624;
ch2->InputMode=ENCODER_MODE;
ch2->OutputMode=DAC_SERVO_MODE;
ch2->Vel=60000;
ch2->Accel=100000;
ch2->Jerk=200000;
ch2->P=26;
ch2->I=0.0001;
ch2->D=8;
ch2->FFAccel=0.0009;
ch2->FFVel=0.001;
ch2->MaxI=5000;
ch2->MaxErr=10000;
ch2->MaxOutput=2000;
ch2->DeadBandGain=0;
ch2->DeadBandRange=1;
ch2->InputChan0=2;
ch2->InputChan1=1;
ch2->OutputChan0=2;
ch2->OutputChan1=1;
ch2->MasterAxis=-1;
ch2->LimitSwitchOptions=0x11f;
ch2->LimitSwitchNegBit=139;
ch2->LimitSwitchPosBit=138;
ch2->SoftLimitPos=1e+30;
ch2->SoftLimitNeg=-1e+30;
ch2->InputGain0=-1;
ch2->InputGain1=1;
ch2->InputOffset0=0;
ch2->InputOffset1=0;
ch2->OutputGain=1;
ch2->OutputOffset=0;
ch2->SlaveGain=1;
ch2->BacklashMode=BACKLASH_LINEAR;
ch2->BacklashAmount=0.15;
ch2->BacklashRate=0;
ch2->invDistPerCycle=0;
ch2->Lead=12;
ch2->MaxFollowingError=100000;
ch2->StepperAmplitude=250;
ch2->iir[0].B0=0.0900489;
ch2->iir[0].B1=0.0900489;
ch2->iir[0].B2=0;
ch2->iir[0].A1=0.819902;
ch2->iir[0].A2=0;
ch2->iir[1].B0=0.0303998;
ch2->iir[1].B1=0.0607997;
ch2->iir[1].B2=0.0303998;
ch2->iir[1].A1=1.45093;
ch2->iir[1].A2=-0.572529;
ch2->iir[2].B0=8.05937;
ch2->iir[2].B1=-15.204;
ch2->iir[2].B2=7.17064;
ch2->iir[2].A1=1.6778;
ch2->iir[2].A2=-0.703757;
ch7->InputMode=ENCODER_MODE;
ch7->OutputMode=DAC_SERVO_MODE;
ch7->Vel=0.5;
ch7->Accel=1;
ch7->Jerk=5;
ch7->P=0;
ch7->I=0;
ch7->D=0;
ch7->FFAccel=0;
ch7->FFVel=2047;
ch7->MaxI=2047;
ch7->MaxErr=1e+10;
ch7->MaxOutput=2047;
ch7->DeadBandGain=1;
ch7->DeadBandRange=0;
ch7->InputChan0=7;
ch7->InputChan1=1;
ch7->OutputChan0=7;
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=10000000000;
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;
EnableAxis(0);
EnableAxis(1);
EnableAxis(2);
DefineCoordSystem(2,1,0,-1); // define XYZU axes
for(;;)
{
MPGServiceSmoothHardwareEncFilteredRev3.c();
}
}
Re: starting my C program, any guidance would be appreciated.
I think you put the filename instead of the function name. C doesn't call files. But it can call functions that are defined in a file. Open the file and see exactly what the name of the function in that file that you want to call and use that name. It won't likely have a .c in it.
1 Attachment(s)
Re: starting my C program, any guidance would be appreciated.
Quote:
Originally Posted by
TomKerekes
I think you put the filename instead of the function name. C doesn't call files. But it can call functions that are defined in a file. Open the file and see exactly what the name of the function in that file that you want to call and use that name. It won't likely have a .c in it.
I'm not sure what you mean, #include "KMotionDef.h", and #include "MySpindleDefs.h" at the top of the program are files that the Init. program calls? #include "MPGServiceSmoothHardwareEncFilteredRev3.c" is the code which may make my MPG work, haven't been able to get it working yet. If I remove the .c at the end it gives me an undefined symbol error on the MPGServiceSmoothHardwareEncFilteredRev3(); line.
here is a screen shot with the file open, maybe you can point me in right direction.
Re: starting my C program, any guidance would be appreciated.
I just attempted to add the file at the end of my Init. program instead of linking it, it's becoming too much of a headache, but when I copy the file and add it to the end, I get identifier expected on the last line at the }. I really am not getting this.
Code:
#include "KMotionDef.h"
#include "MySpindleDefs.h"
// Note Low Gains, Limited Max Limits, No Limit Options, No Soft Limits,
// Large allowed Following Error, No Feed Forward, No Filters, etc
void main()
{
ClearBit(SPINDLEDOWN_BIT);
ClearBit(SPINDLEUP_BIT);
ch0->InputMode=ENCODER_MODE;
ch0->OutputMode=DAC_SERVO_MODE;
ch0->Vel=40000;
ch0->Accel=40000;
ch0->Jerk=1e+06;
ch0->P=19;
ch0->I=0.0001;
ch0->D=5;
ch0->FFAccel=0.001;
ch0->FFVel=0.0009;
ch0->MaxI=9000;
ch0->MaxErr=100000;
ch0->MaxOutput=2000;
ch0->DeadBandGain=1;
ch0->DeadBandRange=2;
ch0->InputChan0=0;
ch0->InputChan1=1;
ch0->OutputChan0=0;
ch0->OutputChan1=1;
ch0->MasterAxis=0;
ch0->LimitSwitchOptions=0x11f;
ch0->LimitSwitchNegBit=136;
ch0->LimitSwitchPosBit=137;
ch0->SoftLimitPos=1e+09;
ch0->SoftLimitNeg=-1e+08;
ch0->InputGain0=1;
ch0->InputGain1=1;
ch0->InputOffset0=0;
ch0->InputOffset1=0;
ch0->OutputGain=1;
ch0->OutputOffset=0;
ch0->SlaveGain=0;
ch0->BacklashMode=BACKLASH_LINEAR;
ch0->BacklashAmount=1;
ch0->BacklashRate=2;
ch0->invDistPerCycle=0;
ch0->Lead=15;
ch0->MaxFollowingError=100000;
ch0->StepperAmplitude=250;
ch0->iir[0].B0=3.44761;
ch0->iir[0].B1=-6.74051;
ch0->iir[0].B2=3.29464;
ch0->iir[0].A1=1.91668;
ch0->iir[0].A2=-0.918416;
ch0->iir[1].B0=0.123861;
ch0->iir[1].B1=0.123861;
ch0->iir[1].B2=0;
ch0->iir[1].A1=0.752278;
ch0->iir[1].A2=0;
ch0->iir[2].B0=0.0166075;
ch0->iir[2].B1=0.033215;
ch0->iir[2].B2=0.0166075;
ch0->iir[2].A1=1.6066;
ch0->iir[2].A2=-0.673034;
ch1->InputMode=ENCODER_MODE;
ch1->OutputMode=DAC_SERVO_MODE;
ch1->Vel=400000;
ch1->Accel=1e+06;
ch1->Jerk=200000;
ch1->P=29;
ch1->I=0.0001;
ch1->D=5;
ch1->FFAccel=0.002;
ch1->FFVel=0.0006;
ch1->MaxI=5000;
ch1->MaxErr=100000;
ch1->MaxOutput=2000;
ch1->DeadBandGain=0;
ch1->DeadBandRange=1;
ch1->InputChan0=1;
ch1->InputChan1=1;
ch1->OutputChan0=1;
ch1->OutputChan1=1;
ch1->MasterAxis=-1;
ch1->LimitSwitchOptions=0x110;
ch1->LimitSwitchNegBit=140;
ch1->LimitSwitchPosBit=141;
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=0;
ch1->BacklashMode=BACKLASH_LINEAR;
ch1->BacklashAmount=0;
ch1->BacklashRate=0;
ch1->invDistPerCycle=0;
ch1->Lead=10;
ch1->MaxFollowingError=100000;
ch1->StepperAmplitude=250;
ch1->iir[0].B0=3.91172;
ch1->iir[0].B1=-7.64788;
ch1->iir[0].B2=3.73813;
ch1->iir[0].A1=1.91123;
ch1->iir[0].A2=-0.913201;
ch1->iir[1].B0=0.101606;
ch1->iir[1].B1=0.101606;
ch1->iir[1].B2=0;
ch1->iir[1].A1=0.796788;
ch1->iir[1].A2=0;
ch1->iir[2].B0=0.0110084;
ch1->iir[2].B1=0.0220167;
ch1->iir[2].B2=0.0110084;
ch1->iir[2].A1=1.68459;
ch1->iir[2].A2=-0.728624;
ch2->InputMode=ENCODER_MODE;
ch2->OutputMode=DAC_SERVO_MODE;
ch2->Vel=60000;
ch2->Accel=100000;
ch2->Jerk=200000;
ch2->P=26;
ch2->I=0.0001;
ch2->D=8;
ch2->FFAccel=0.0009;
ch2->FFVel=0.001;
ch2->MaxI=5000;
ch2->MaxErr=10000;
ch2->MaxOutput=2000;
ch2->DeadBandGain=0;
ch2->DeadBandRange=1;
ch2->InputChan0=2;
ch2->InputChan1=1;
ch2->OutputChan0=2;
ch2->OutputChan1=1;
ch2->MasterAxis=-1;
ch2->LimitSwitchOptions=0x11f;
ch2->LimitSwitchNegBit=139;
ch2->LimitSwitchPosBit=138;
ch2->SoftLimitPos=1e+30;
ch2->SoftLimitNeg=-1e+30;
ch2->InputGain0=-1;
ch2->InputGain1=1;
ch2->InputOffset0=0;
ch2->InputOffset1=0;
ch2->OutputGain=1;
ch2->OutputOffset=0;
ch2->SlaveGain=1;
ch2->BacklashMode=BACKLASH_LINEAR;
ch2->BacklashAmount=0.15;
ch2->BacklashRate=0;
ch2->invDistPerCycle=0;
ch2->Lead=12;
ch2->MaxFollowingError=100000;
ch2->StepperAmplitude=250;
ch2->iir[0].B0=0.0900489;
ch2->iir[0].B1=0.0900489;
ch2->iir[0].B2=0;
ch2->iir[0].A1=0.819902;
ch2->iir[0].A2=0;
ch2->iir[1].B0=0.0303998;
ch2->iir[1].B1=0.0607997;
ch2->iir[1].B2=0.0303998;
ch2->iir[1].A1=1.45093;
ch2->iir[1].A2=-0.572529;
ch2->iir[2].B0=8.05937;
ch2->iir[2].B1=-15.204;
ch2->iir[2].B2=7.17064;
ch2->iir[2].A1=1.6778;
ch2->iir[2].A2=-0.703757;
ch7->InputMode=ENCODER_MODE;
ch7->OutputMode=DAC_SERVO_MODE;
ch7->Vel=0.5;
ch7->Accel=1;
ch7->Jerk=5;
ch7->P=0;
ch7->I=0;
ch7->D=0;
ch7->FFAccel=0;
ch7->FFVel=2047;
ch7->MaxI=2047;
ch7->MaxErr=1e+10;
ch7->MaxOutput=2047;
ch7->DeadBandGain=1;
ch7->DeadBandRange=0;
ch7->InputChan0=7;
ch7->InputChan1=1;
ch7->OutputChan0=7;
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=10000000000;
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;
EnableAxis(0);
EnableAxis(1);
EnableAxis(2);
DefineCoordSystem(2,1,0,-1); // define XYZU axes
for(;;)
{
#define MPG_INPUT_AXIS 2 // Axis used to read hardware encoder (not necessarily the encoder channel)
#define A 19 // define to which IO bits the AB signals are connected
#define B 20
#define TAU 0.01 // smoothness factor (Low Pass Time constant seconds for MoveExp)
#define TAU1 0.015 // smoothness factor (Low Pass Time constant seconds for pre filter 1)
#define TAU2 0.015 // smoothness factor (Low Pass Time constant seconds for pre filter 2)
#define FINAL_TIME 1.0 // Set final dest after this amount of time with no change
#define FACTOR1 16
#define FACTOR10 17
#define FACTOR100 18
#define SELECTX 21
#define SELECTY 22
#define SELECTZ 23
#define SELECTA 24
#define ENABLE_MPG 25 // Switch/Button used to enable MPG Motion
main();
{
static int Pos, FirstTime = TRUE;
static int InMotion = FALSE, Axis, LastAxis = -1;
static double LastChangeTime = 0, Target, Factor = 0;
static double Target1, Target2, K1, K2, K1M, K2M;
int Change1, NewPos;
if (FirstTime)
{
Pos = chan[MPG_INPUT_AXIS].Position;
K1 = exp(-2 * TIMEBASE / TAU1); // filter coefficients
K2 = exp(-2 * TIMEBASE / TAU2);
K1M = 1.0 - K1;
K2M = 1.0 - K2;
FirstTime = FALSE;
}
NewPos = chan[MPG_INPUT_AXIS].Position;
Change1 = NewPos - Pos;
Pos = NewPos;
if (!ReadBit(ENABLE_MPG) || JOB_ACTIVE) // if not button pressed or Job Active ignore the encoder.
Change1 = 0;
if (ReadBit(FACTOR1)) // is X1 selected?
Factor = 4;
else if (ReadBit(FACTOR10)) // is X10 selected?
Factor = 20;
else if (ReadBit(FACTOR100)) // is X100 selected?
Factor = 40;
else
Factor = 0.0;
if (ReadBit(SELECTX)) // is x selected?
Axis = 0;
else if (ReadBit(SELECTY)) // is y selected?
Axis = 1;
else if (ReadBit(SELECTZ)) // is z selected?
Axis = 2;
else if (ReadBit(SELECTA)) // is A selected?
Axis = 3;
// Feedhold fully stopped ??
if (CS0_StoppingState == 4 && InMotion)
{
Change1 = 0; // ignore any MPG change
Jog(LastAxis, 0);
InMotion = FALSE;
}
// check if the Axis just changed or we have been
// converging to the target for a long time
if (Axis != LastAxis || (InMotion && Time_sec() > LastChangeTime + FINAL_TIME))
{
if (InMotion)
Move(LastAxis, Target1); //finalize any motion
LastAxis = Axis;
InMotion = FALSE;
}
if (Change1) // did we move?
{
if (!InMotion)
Target = Target1 = Target2 = chan[Axis].Dest;
Target1 += Change1 * Factor;
LastChangeTime = Time_sec();
InMotion = TRUE;
}
if (InMotion) // If moving
{
if (Target1 > chan[LastAxis].SoftLimitPos)
Target1 = chan[LastAxis].SoftLimitPos;
if (Target1 < chan[LastAxis].SoftLimitNeg)
Target1 = chan[LastAxis].SoftLimitNeg;
Target2 = Target2 * K1 + Target1 * K1M;
Target = Target * K2 + Target2 * K2M;
MoveExp(Axis, Target, TAU);
}
}
Re: starting my C program, any guidance would be appreciated.
You might think of a C Function definition as a list of instructions that has been given a name. Imagine a list of 10 steps to inflate a tire called "InflateATire". Now from a different list one of the instructions might be to go do list InflateATire. Functions can be useful when similar things need to be performed multiple times. For example servicing all 4 tires of a car. Instead of duplicating the10 instructions 4 times for 40 instructions by copying and pasting, 4 instructions (in a different list) can be to perform the list. But even if a list of instructions is only needed once it can still make sense to make a separate list and give it a name for purposes of organization and clarity.
Putting the list (function) in a separate file makes it easy to include that list in any program that might need it. Its also possible to put multiple functions in a file so its easy to include a bunch of functions. The names of any functions in a file and the name of the file itself are normally different.
If you decide to not use a function and just paste in the instructions instead then you would not define a function or include a call to the function. Its an either or situation.
In C there is a special function called main where the program begins executing instructions. Any C Program must have exactly one main function. It also doesn't make sense to call the main function to be executed as the program automatically does this when it starts.
I think the example you started with had a function called ServiceMPG but it was changed to main.
There is a ton of info on the Internet. Such as this. Also our wiki.
HTH
Re: starting my C program, any guidance would be appreciated.
I am having trouble getting g code to work. When I attempt to run a program the g code will stop. I know the code is the good so what else could be the problem.
Re: starting my C program, any guidance would be appreciated.
What is the GCode? What do you mean by "stop"? What is the state of the machine? Any messages on the KMotion Console? Is it consistent?
1 Attachment(s)
Re: starting my C program, any guidance would be appreciated.
Quote:
Originally Posted by
TomKerekes
What is the GCode? What do you mean by "stop"? What is the state of the machine? Any messages on the KMotion Console? Is it consistent?
%
O0015
(T1 D=0.5 CR=0. - ZMIN=-0.556 - FLAT END MILL)
(T2 D=0.25 CR=0.125 - ZMIN=-0.1119 - BALL END MILL)
(T3 D=0.25 CR=0. - ZMIN=-0.5886 - FLAT END MILL)
(T4 D=0.375 CR=0. TAPER=118DEG - ZMIN=-0.526 - DRILL)
N1 G90 G94 G17 G49 G40 G80
N2 G20
(DRILL1)
N6 T4 M06
N7 S458 M03
N8 G54
N9 M08
N10 G00 X0.5 Y-0.59 (stops here every time)
N11 G43 Z0.6 H04
N12 G00 Z0.2
Re: starting my C program, any guidance would be appreciated.
Make sure none of your Tool Setup Screen | Trajectory Planner | Axis Parameters | Cnts/inch (or deg) are set to 0
1 Attachment(s)
Re: starting my C program, any guidance would be appreciated.
Quote:
Originally Posted by
TomKerekes
Make sure none of your Tool Setup Screen | Trajectory Planner | Axis Parameters | Cnts/inch (or deg) are set to 0
That was it, I had 2 which were 0, I changed those to 1 an now I get Invalid buffer times.
Re: starting my C program, any guidance would be appreciated.
Your screenshot shows something else.
How many Axes do you have?
Post your Initialization C Program.
Post your Tool Setup Screens.
1 Attachment(s)
Re: starting my C program, any guidance would be appreciated.
Quote:
Originally Posted by
TomKerekes
Your screenshot shows something else.
How many Axes do you have?
I posted the wrong screenshot, here's the one. 3 axis.
5 Attachment(s)
Re: starting my C program, any guidance would be appreciated.
My init program.
Code:
:#include "KMotionDef.h"
// Note Low Gains, Limited Max Limits, No Limit Options, No Soft Limits,
// Large allowed Following Error, No Feed Forward, No Filters, etc
void main()
{
// enable AMPS
ClearBit(158);
ClearBit(159);
ch0->InputMode=ENCODER_MODE;
ch0->OutputMode=DAC_SERVO_MODE;
ch0->Vel=180000;
ch0->Accel=200000;
ch0->Jerk=100000;
ch0->P=2;
ch0->I=0;
ch0->D=110;
ch0->FFAccel=0.003;
ch0->FFVel=0.005;
ch0->MaxI=2000;
ch0->MaxErr=1000;
ch0->MaxOutput=2047;
ch0->DeadBandGain=1;
ch0->DeadBandRange=2;
ch0->InputChan0=0;
ch0->InputChan1=1;
ch0->OutputChan0=0;
ch0->OutputChan1=1;
ch0->MasterAxis=-1;
ch0->LimitSwitchOptions=0x11f;
ch0->LimitSwitchNegBit=136;
ch0->LimitSwitchPosBit=137;
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=0;
ch0->BacklashMode=BACKLASH_OFF;
ch0->BacklashAmount=1;
ch0->BacklashRate=4;
ch0->invDistPerCycle=0;
ch0->Lead=0;
ch0->MaxFollowingError=1000;
ch0->StepperAmplitude=250;
ch0->iir[0].B0=0.570375;
ch0->iir[0].B1=-1.07753;
ch0->iir[0].B2=0.508907;
ch0->iir[0].A1=1.91629;
ch0->iir[0].A2=-0.918042;
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=ENCODER_MODE;
ch1->OutputMode=DAC_SERVO_MODE;
ch1->Vel=140000;
ch1->Accel=140000;
ch1->Jerk=150000;
ch1->P=10;
ch1->I=0.0001;
ch1->D=25;
ch1->FFAccel=0.002;
ch1->FFVel=0.002;
ch1->MaxI=2000;
ch1->MaxErr=200;
ch1->MaxOutput=2047;
ch1->DeadBandGain=0;
ch1->DeadBandRange=1;
ch1->InputChan0=1;
ch1->InputChan1=1;
ch1->OutputChan0=1;
ch1->OutputChan1=1;
ch1->MasterAxis=-1;
ch1->LimitSwitchOptions=0x11c;
ch1->LimitSwitchNegBit=138;
ch1->LimitSwitchPosBit=137;
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=0;
ch1->BacklashMode=BACKLASH_LINEAR;
ch1->BacklashAmount=1;
ch1->BacklashRate=2;
ch1->invDistPerCycle=0;
ch1->Lead=0;
ch1->MaxFollowingError=200;
ch1->StepperAmplitude=250;
ch1->iir[0].B0=15.6378;
ch1->iir[0].B1=-30.2157;
ch1->iir[0].B2=14.5958;
ch1->iir[0].A1=1.73196;
ch1->iir[0].A2=-0.749922;
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=DAC_SERVO_MODE;
ch2->Vel=120000;
ch2->Accel=120000;
ch2->Jerk=120000;
ch2->P=5.4;
ch2->I=0.0001;
ch2->D=115;
ch2->FFAccel=0.0001;
ch2->FFVel=0.001;
ch2->MaxI=3000;
ch2->MaxErr=1000;
ch2->MaxOutput=2047;
ch2->DeadBandGain=2;
ch2->DeadBandRange=3;
ch2->InputChan0=2;
ch2->InputChan1=1;
ch2->OutputChan0=2;
ch2->OutputChan1=1;
ch2->MasterAxis=-1;
ch2->LimitSwitchOptions=0x12f;
ch2->LimitSwitchNegBit=137;
ch2->LimitSwitchPosBit=137;
ch2->SoftLimitPos=1e+30;
ch2->SoftLimitNeg=-1e+30;
ch2->InputGain0=-1;
ch2->InputGain1=1;
ch2->InputOffset0=0;
ch2->InputOffset1=0;
ch2->OutputGain=-1;
ch2->OutputOffset=0;
ch2->SlaveGain=1;
ch2->BacklashMode=BACKLASH_LINEAR;
ch2->BacklashAmount=0;
ch2->BacklashRate=0;
ch2->invDistPerCycle=0;
ch2->Lead=8;
ch2->MaxFollowingError=1000;
ch2->StepperAmplitude=250;
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=0.066019;
ch2->iir[1].B1=0.066019;
ch2->iir[1].B2=0;
ch2->iir[1].A1=0.867962;
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;
ch7->InputMode=ENCODER_MODE;
ch7->OutputMode=DAC_SERVO_MODE;
ch7->Vel=0.5;
ch7->Accel=1;
ch7->Jerk=5;
ch7->P=0;
ch7->I=0;
ch7->D=0;
ch7->FFAccel=0;
ch7->FFVel=2047;
ch7->MaxI=2047;
ch7->MaxErr=1e+10;
ch7->MaxOutput=2047;
ch7->DeadBandGain=1;
ch7->DeadBandRange=0;
ch7->InputChan0=7;
ch7->InputChan1=1;
ch7->OutputChan0=7;
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=10000000000;
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;
EnableAxis(0);
EnableAxis(1);
EnableAxis(2);
EnableAxis(7);
DefineCoordSystem(2,1,0,7); // define XYZU axes
}