Hi Chris,
Try:
DefineCoordSystem6(0,-1,1,2,3,-1); // define XYZABC
Regards
Hey Fellas,
So I've build a proprietary cnc, with a X, Z, A, and B axis and I'm trying to have Mach3 id my axes correctly. Right now it's just seeing xyza, but I'm hoping I can get my CAD sofware to write it the actual axes on the machine. Of course, I'm driving with the KFLOP, I've uploaded my copy/paste c program and configed it to open in Mach3, but my .C has 0,1,2, and 3 as my axes.
How should I define these axis as XZAB? DefineCord (0,-1,1,2,3) ....?
Thanks,
Chris
Similar Threads:
Hi Chris,
Try:
DefineCoordSystem6(0,-1,1,2,3,-1); // define XYZABC
Regards
Regards
TK http://dynomotion.com
Tom,
Thanks for that, I was able to upload the C program into the Kflop.
So I have 4 axes, XZAB, step/Dir to KFLOP, at J7, in pins A 15,16 B 17,18 X 19,20 Z 21,22.
I have pointed Mach3 to this C program, but I don't know what "pins" to direct the axis to in the Port and Pins configuration screen. I change them but there is no change in the axis. Jog X move axis A.
Again I'm not a C programmer, So even with the Kflop Utility to create these axis parameters I don't know what the code is doing. I need someone to help me configure my axis and limit switches to where they will communicate with Mach3, so I can finally get this machine moving!
I just don't have the time and energy to learn C. I'm willing to compensate anyone who can guide me through this process.
I copied and pasted channels 0 1 2 and 3 into the original C program from Dynamotion "3axisStepDir.C" and modified the program the best I could.
Help. Me. Please.
GlintTree 4axis CNC.C
#include "KMotionDef.h"
// Defines axis 0, 1, 2 as simple step dir TTL outputs for KSTEP
// enables them
// sets them as an xyz coordinate system for GCode
int main()
{
double T0, LastX=0, LastY=0, LastZ=0, LastA=0, LastB=0, Tau;
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
ch0->InputMode=NO_INPUT_MODE;
ch0->OutputMode=STEP_DIR_MODE;
ch0->Vel=40000;
ch0->Accel=400000;
ch0->Jerk=4e+006;
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=0;
ch0->OutputChan1=0;
ch0->MasterAxis=0;
ch0->LimitSwitchOptions=0x12f;
ch0->LimitSwitchNegBit=11;
ch0->LimitSwitchPosBit=12;
ch0->SoftLimitPos=1e+030;
ch0->SoftLimitNeg=-1e+030;
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.92081;
ch0->iir[2].A2=-0.923885;
EnableAxisDest(0,0);
ch1->InputMode=NO_INPUT_MODE;
ch1->OutputMode=STEP_DIR_MODE;
ch1->Vel=40000;
ch1->Accel=400000;
ch1->Jerk=4e+006;
ch1->P=0;
ch1->I=0.01;
ch1->D=0;
ch1->FFAccel=0;
ch1->FFVel=0;
ch1->MaxI=200;
ch1->MaxErr=1e+006;
ch1->MaxOutput=200;
ch1->DeadBandGain=1;
ch1->DeadBandRange=0;
ch1->InputChan0=1;
ch1->InputChan1=0;
ch1->OutputChan0=1;
ch1->OutputChan1=0;
ch1->MasterAxis=-1;
ch1->LimitSwitchOptions=0x12f;
ch1->LimitSwitchNegBit=13;
ch1->LimitSwitchPosBit=14;
ch1->SoftLimitPos=1e+009;
ch1->SoftLimitNeg=-1e+009;
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=1000000000;
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=0.000769;
ch1->iir[2].B1=0.001538;
ch1->iir[2].B2=0.000769;
ch1->iir[2].A1=1.92081;
ch1->iir[2].A2=-0.923885;
EnableAxisDest(1,0);
ch2->InputMode=NO_INPUT_MODE;
ch2->OutputMode=STEP_DIR_MODE;
ch2->Vel=40000;
ch2->Accel=400000;
ch2->Jerk=4e+006;
ch2->P=0;
ch2->I=0.01;
ch2->D=0;
ch2->FFAccel=0;
ch2->FFVel=0;
ch2->MaxI=200;
ch2->MaxErr=1e+006;
ch2->MaxOutput=200;
ch2->DeadBandGain=1;
ch2->DeadBandRange=0;
ch2->InputChan0=2;
ch2->InputChan1=0;
ch2->OutputChan0=2;
ch2->OutputChan1=0;
ch2->MasterAxis=-1;
ch2->LimitSwitchOptions=0x100;
ch2->LimitSwitchNegBit=0;
ch2->LimitSwitchPosBit=0;
ch2->SoftLimitPos=1e+009;
ch2->SoftLimitNeg=-1e+009;
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.92081;
ch2->iir[2].A2=-0.923885;
EnableAxisDest(2,0);
ch3->InputMode=ENCODER_MODE;
ch3->OutputMode=STEP_DIR_MODE;
ch3->Vel=40000;
ch3->Accel=4000;
ch3->Jerk=4e+006;
ch3->P=0;
ch3->I=0.01;
ch3->D=0;
ch3->FFAccel=0;
ch3->FFVel=0;
ch3->MaxI=200;
ch3->MaxErr=1e+006;
ch3->MaxOutput=200;
ch3->DeadBandGain=1;
ch3->DeadBandRange=0;
ch3->InputChan0=3;
ch3->InputChan1=0;
ch3->OutputChan0=3;
ch3->OutputChan1=0;
ch3->MasterAxis=-1;
ch3->LimitSwitchOptions=0x100;
ch3->LimitSwitchNegBit=0;
ch3->LimitSwitchPosBit=0;
ch3->SoftLimitPos=1e+009;
ch3->SoftLimitNeg=-1e+009;
ch3->InputGain0=1;
ch3->InputGain1=1;
ch3->InputOffset0=0;
ch3->InputOffset1=0;
ch3->OutputGain=1;
ch3->OutputOffset=0;
ch3->SlaveGain=1;
ch3->BacklashMode=BACKLASH_OFF;
ch3->BacklashAmount=0;
ch3->BacklashRate=0;
ch3->invDistPerCycle=1;
ch3->Lead=0;
ch3->MaxFollowingError=1000000000;
ch3->StepperAmplitude=20;
ch3->iir[0].B0=1;
ch3->iir[0].B1=0;
ch3->iir[0].B2=0;
ch3->iir[0].A1=0;
ch3->iir[0].A2=0;
ch3->iir[1].B0=1;
ch3->iir[1].B1=0;
ch3->iir[1].B2=0;
ch3->iir[1].A1=0;
ch3->iir[1].A2=0;
ch3->iir[2].B0=0.000769;
ch3->iir[2].B1=0.001538;
ch3->iir[2].B2=0.000769;
ch3->iir[2].A1=1.92081;
ch3->iir[2].A2=-0.923885;
EnableAxisDest(3,0);
DefineCoordSystem6(0,-1,1,2,3,-1);
SetBitDirection(45,1); // set Enable Signal as Output
SetBit(45); // Enable the amplifiers
// Add a small amount of Coordinated Motion Path smoothing if desired
// Tau = 0.001; // seconds for Low Pass Filter Time Constant
// KLP = exp(-TIMEBASE/Tau);
KLP=0; // force to 0 to disable
// printf("Tau=%f KLP=%f\n",Tau,KLP);
for (; // loop forever
{
WaitNextTimeSlice();
// Service Amplifier disable after no activity for a while
if (ch0->Dest != LastX || ch1->Dest != LastY || ch2->Dest != LastZ)
{
// we moved - enable KStep Amplifers
SetBit(45);
T0 = Time_sec(); // record the time and position of last motion
LastX=ch0->Dest;
LastY=ch1->Dest;
LastZ=ch2->Dest;
}
else
{
if (Time_sec() > T0 + 10.0) ClearBit(45);
}
}
return 0;
}
The ports/pins configuration for axis has no effect with the KFlop.
You need to configure what step/dir pins are used in your initialisation file, with the OutputChan0 value. The possible values can be found at Step and Direction Setup
So using your X with pins 19/20, which are step/dir generator 2 (I'm sure you already know, but the KFlop connector page lists the numbering - KFLOP Connectors), for the X output channel, which I see is channel 0 (set via the DefineCoordSystem6() setting), you need ch0->OutputChan0=2 for OpenCollector mode, or ch0->OutputChan0=10 for LVTTL mode.
This is probably one of the most confusing bits of setting up a KFlop for first time users. Each axis channel (ie. ch0), can use any output channel, and then that axis channel can be configured to any physical axis (I.e. X,Y,Z,A,B,C,U,V,W).
So I'm using open collector mode, but I'm not clear on how you associated j7 19/20 with generator 2.
Sent from my SM-G900V using Tapatalk
If you look at the pin out tables on the KFlop connector page, it's listed in the Description column.
So for pins 19/20-
19 IO12 Gen Purpose LVTTL I/O (5V Tolerant) or Axis 0 + Limit (or Step 2 output)
20 IO13 Gen Purpose LVTTL I/O (5V Tolerant) or Axis 0 - Limit (or Dir 2 output)
It's one area Dynomotion could maybe do with clarifying things to ensure a bit more continuity between pages, as they're listed as step/dir generators on the Step and Direction setup page.
Hi toolbag33,
You have KFLOP Axis #0 configured to use Step/Dir Gen #0 which is wired to your A axis. Therefore KFLOP Axis #0 is the A Axis.
You have KFLOP Axis #1 configured to use Step/Dir Gen #1 which is wired to your B axis. Therefore KFLOP Axis #1 is the B Axis.
You have KFLOP Axis #2 configured to use Step/Dir Gen #2 which is wired to your X axis. Therefore KFLOP Axis #2 is the X Axis.
You have KFLOP Axis #3 configured to use Step/Dir Gen #3 which is wired to your Z axis. Therefore KFLOP Axis #3 is the Z Axis.
Probably not the way most Users would wire and configure things. But that's ok.
Your coordinate system would then be defined as:
DefineCoordSystem6(2,-1,3,0,1,-1); // define KFLOP axes for XYZABC
Regards
Regards
TK http://dynomotion.com
MC,
You were correct. I changed the output channels to corresponding axis and Mach3 responded.
Any idea why my axis only move in 1 direction? Must have been something I might have deleted in the .c program.
Any thoughts?
Much Thanks.
Sent from my SM-G900V using Tapatalk
Hi toolbag33,
Is the Direction signal connected to your Drives?
Are your Drives in CW/CCW mode?
Regards
Regards
TK http://dynomotion.com
No Open Collector, they work independent of Kflop / mach3. I think it's something in the .C program...
Open Collector is the electrical operation mode. Open Collector is best though of as working like a basic switch. It's either open circuit, or connected to GND.
It's counterpart is LVTTL, which actively drives the relevant pin to near 3.3V for high, or drives to GND for low.
Step/Dir, CW/CCW, and Quadrature are the different types of signal sequencing available.
If you look at the Step and Direction setup page - Step and Direction Setup
about a third of the way down the page, there is a diagram that shows how the output modes work.
What drives are you using?
Yes, I'm using Step/Dir.
What drives are you using?
If they're set to take CW/CCW, then what you're seeing would be normal if you fed them Step/Dir signals, however it could be a connection issue if they are meant to take Step/Dir.
Knowing what drives you are using, will help us guide you to the problem.
Just found your other thread, and it's the ClearPath SD drives/motors.
Have you got a multimeter?
With everything connected and powered up (be careful not to short anything out when probing!)
First up, double check you have 5V at the clearpath + terminals - should be pins 2,3&4, according to the diagram in your post at http://www.cnczone.com/forums/dynomo...ml#post2025792
Next pick an axis, jog it one direction. Measure the voltage at the Dir pin/wire at the drive/motor. Then jog the opposite direction, and re-measure the voltage. The voltage should change from around 5V, to near 0V. If it doesn't change, measure again as near as you can get to the KFlop.
So all Axis move both directions when commanded by Kflop console. It's something in the C file between Kflop and MACH3.
Thanks, for you help All.
You might post your Mach3 XML file and Initialization C file for us to check (add .txt extension to upload to cnczone)
Regards
Regards
TK http://dynomotion.com
Tom,
So some progress with the axes,
I have my limit switches on pins 0-7, but they seem to be floating in my Digital I/O screen, and I'm not seeing any C commands setting them at inputs, except in the axes definitions.... Should there be separate commands even though the set axes parameters for the limit switches?
#include "KMotionDef.h"
// Defines axis 0, 1, 2 as simple step dir outputs
// enables them
// sets them as an xyz coordinate system for GCode
int main()
{
ch0->InputMode=ENCODER_MODE;
ch0->OutputMode=STEP_DIR_MODE;
ch0->Vel=40000;
ch0->Accel=400000;
ch0->Jerk=4e+006;
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=0;
ch0->OutputChan1=0;
ch0->MasterAxis=-1;
ch0->LimitSwitchOptions=0x100;
ch0->LimitSwitchNegBit=0;
ch0->LimitSwitchPosBit=0;
ch0->SoftLimitPos=1e+009;
ch0->SoftLimitNeg=-1e+009;
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.000768788;
ch0->iir[2].B1=0.00153758;
ch0->iir[2].B2=0.000768788;
ch0->iir[2].A1=1.92076;
ch0->iir[2].A2=-0.923833;
EnableAxisDest(0,0);
ch1->InputMode=ENCODER_MODE;
ch1->OutputMode=STEP_DIR_MODE;
ch1->Vel=40000;
ch1->Accel=400000;
ch1->Jerk=4e+006;
ch1->P=0;
ch1->I=0.01;
ch1->D=0;
ch1->FFAccel=0;
ch1->FFVel=0;
ch1->MaxI=200;
ch1->MaxErr=1e+006;
ch1->MaxOutput=200;
ch1->DeadBandGain=1;
ch1->DeadBandRange=0;
ch1->InputChan0=1;
ch1->InputChan1=0;
ch1->OutputChan0=1;
ch1->OutputChan1=0;
ch1->MasterAxis=-1;
ch1->LimitSwitchOptions=0x100;
ch1->LimitSwitchNegBit=0;
ch1->LimitSwitchPosBit=0;
ch1->SoftLimitPos=1e+009;
ch1->SoftLimitNeg=-1e+009;
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=1000000000;
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=0.000769;
ch1->iir[2].B1=0.001538;
ch1->iir[2].B2=0.000769;
ch1->iir[2].A1=1.92081;
ch1->iir[2].A2=-0.923885;
EnableAxisDest(1,0);
ch2->InputMode=ENCODER_MODE;
ch2->OutputMode=STEP_DIR_MODE;
ch2->Vel=40000;
ch2->Accel=400000;
ch2->Jerk=4e+006;
ch2->P=0;
ch2->I=0.01;
ch2->D=0;
ch2->FFAccel=0;
ch2->FFVel=0;
ch2->MaxI=200;
ch2->MaxErr=1e+006;
ch2->MaxOutput=200;
ch2->DeadBandGain=1;
ch2->DeadBandRange=0;
ch2->InputChan0=2;
ch2->InputChan1=0;
ch2->OutputChan0=2;
ch2->OutputChan1=0;
ch2->MasterAxis=-1;
ch2->LimitSwitchOptions=0x100;
ch2->LimitSwitchNegBit=0;
ch2->LimitSwitchPosBit=0;
ch2->SoftLimitPos=1e+009;
ch2->SoftLimitNeg=-1e+009;
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.92081;
ch2->iir[2].A2=-0.923885;
EnableAxisDest(2,0);
ch3->InputMode=ENCODER_MODE;
ch3->OutputMode=STEP_DIR_MODE;
ch3->Vel=40000;
ch3->Accel=400000;
ch3->Jerk=4e+006;
ch3->P=0;
ch3->I=0.01;
ch3->D=0;
ch3->FFAccel=0;
ch3->FFVel=0;
ch3->MaxI=200;
ch3->MaxErr=1e+006;
ch3->MaxOutput=200;
ch3->DeadBandGain=1;
ch3->DeadBandRange=0;
ch3->InputChan0=3;
ch3->InputChan1=0;
ch3->OutputChan0=3;
ch3->OutputChan1=0;
ch3->MasterAxis=-1;
ch3->LimitSwitchOptions=0x100;
ch3->LimitSwitchNegBit=0;
ch3->LimitSwitchPosBit=0;
ch3->SoftLimitPos=1e+009;
ch3->SoftLimitNeg=-1e+009;
ch3->InputGain0=1;
ch3->InputGain1=1;
ch3->InputOffset0=0;
ch3->InputOffset1=0;
ch3->OutputGain=1;
ch3->OutputOffset=0;
ch3->SlaveGain=1;
ch3->BacklashMode=BACKLASH_OFF;
ch3->BacklashAmount=0;
ch3->BacklashRate=0;
ch3->invDistPerCycle=1;
ch3->Lead=0;
ch3->MaxFollowingError=1000000000;
ch3->StepperAmplitude=20;
ch3->iir[0].B0=1;
ch3->iir[0].B1=0;
ch3->iir[0].B2=0;
ch3->iir[0].A1=0;
ch3->iir[0].A2=0;
ch3->iir[1].B0=1;
ch3->iir[1].B1=0;
ch3->iir[1].B2=0;
ch3->iir[1].A1=0;
ch3->iir[1].A2=0;
ch3->iir[2].B0=0.000769;
ch3->iir[2].B1=0.001538;
ch3->iir[2].B2=0.000769;
ch3->iir[2].A1=1.92081;
ch3->iir[2].A2=-0.923885;
EnableAxisDest(3,0);
DefineCS(0,-1,1,2,3,-1);
return 0;
}
Hi toolbag33,
I don't understand what you are asking.
First get your limits properly interfaced to some inputs and check out hat they are working using the digital IO Screen.
Regards
Regards
TK http://dynomotion.com