SETTING UP KFLOP, KANALOG FOR NEW CNC ROUTER RETROFIT

Moderators: TomKerekes, dynomotion

Post Reply
NOELNOG
Posts: 146
Joined: Wed Nov 10, 2021 3:54 pm

SETTING UP KFLOP, KANALOG FOR NEW CNC ROUTER RETROFIT

Post by NOELNOG » Thu Jan 06, 2022 12:09 am

first time using kflop and kanalog, this is going to bring back to life a 1994 Morbidelli cnc router with an obsolet computer. for now lot of work coming up.
https://www.youtube.com/watch?v=Q1pTdpt53ek

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

Re: SETTING UP KFLOP, KANALOG FOR NEW CNC ROUTER RETROFIT

Post by TomKerekes » Thu Jan 06, 2022 1:05 am

Its alive :)

Good luck!
Regards,

Tom Kerekes
Dynomotion, Inc.

NOELNOG
Posts: 146
Joined: Wed Nov 10, 2021 3:54 pm

Re: SETTING UP KFLOP, KANALOG FOR NEW CNC ROUTER RETROFIT

Post by NOELNOG » Fri Jan 07, 2022 5:24 pm

I have a question about the opto inputs on kanalog JP15 terminals. can i use this terminals for connecting my limit, home, estop switches? i know the bits 12 to 15 are designed for limits on kflop digital I/O window, or i have to use the JP12 terminals for home,limits,estop? i tried connecting a limit sw. to inputs 0 on JP15 negative to ground and positive to 5v+ with the switch Normally closed, i can see the check mark in kanalog I/O window turning on and off as a activate the switch, but it doesn't stop the running program, i am confusing with this, do i have to modify some of the c programs?

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

Re: SETTING UP KFLOP, KANALOG FOR NEW CNC ROUTER RETROFIT

Post by TomKerekes » Fri Jan 07, 2022 6:18 pm

Any input can be configured as a limit. Those on KFLOP are only suggestions. See here.

Homing is handled by a C Program which can use any input. See here.

EStop can also be any input(s). It can be monitored in a C Program forever loop and then perform any necessary actions.

HTH
Regards,

Tom Kerekes
Dynomotion, Inc.

NOELNOG
Posts: 146
Joined: Wed Nov 10, 2021 3:54 pm

Re: SETTING UP KFLOP, KANALOG FOR NEW CNC ROUTER RETROFIT

Post by NOELNOG » Sat Jan 08, 2022 8:00 pm

Hi Tom

i have the switch detected and working in the bit 1172, the LED and the check mark turns on and off when push the switch, now i am dealing with the c programs to make that switch to work as a Estop, i opened the ExternalButtons.c file, and i added #define ESTOPBIT 1172, i also noted that in the section //handle ESTOP in the line if (result ==0) i change to 1, it reverse the polarity of the swich N.O or N.C, that's ok until this point, the question is, when i run my G code in KmotionCNC, i press the switch to simulate an emergency stop, and it do not respond, now if i execute in C the program ExternalButtons.c with the save,compile arrows button then the Gcode first get in feed hold, and now if i use the phisical switch it does stop the program like it suppost to do, but my question is, how to make the switch call the Estop directly when the program is running, like an emergency, maybe i need to add some instruction in the InitKstep3axis.c file? that's what i am using to enable the software.

thanks

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

Re: SETTING UP KFLOP, KANALOG FOR NEW CNC ROUTER RETROFIT

Post by TomKerekes » Sat Jan 08, 2022 8:24 pm

Correct. Add the ExternalButtons loop to the end of your INIT C Program so as soon as the system is initialized it executes the code forever.

See also here.
Regards,

Tom Kerekes
Dynomotion, Inc.

NOELNOG
Posts: 146
Joined: Wed Nov 10, 2021 3:54 pm

Re: SETTING UP KFLOP, KANALOG FOR NEW CNC ROUTER RETROFIT

Post by NOELNOG » Sun Jan 09, 2022 12:30 am

I added the externalbutton loop at the end of the init program, but when i try to initialize the software it doesn't do anything, if i remove the externalbutton loop from the init file then it works, while it runnig i paste back the loop and compile it then it works ok, the switch activates feedhold, the problem is when reset the program with the stop button or start the software, i know i am doing something wrong, i pasted below how the init file looks like.

thanks




#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()
{

InitAux();
AddKonnect(0,&VirtualBits,VirtualBitsEx);
AddKonnect(1,VirtualBitsEx+1,VirtualBitsEx+2);
AddKonnect(2,VirtualBitsEx+3,VirtualBitsEx+4);

double T0, LastX=0, LastY=0, LastZ=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=200000;
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=8;
ch0->OutputChan1=0;
ch0->MasterAxis=-1;
ch0->LimitSwitchOptions=0x0;
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.92076;
ch0->iir[2].A2=-0.923833;
EnableAxisDest(0,0);

ch1->InputMode=NO_INPUT_MODE;
ch1->OutputMode=STEP_DIR_MODE;
ch1->Vel=40000;
ch1->Accel=200000;
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=0;
ch1->InputChan1=0;
ch1->OutputChan0=9;
ch1->OutputChan1=0;
ch1->MasterAxis=-1;
ch1->LimitSwitchOptions=0x0;
ch1->SoftLimitPos=1e+030;
ch1->SoftLimitNeg=-1e+030;
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.92076;
ch1->iir[2].A2=-0.923833;
EnableAxisDest(1,0);

ch2->InputMode=NO_INPUT_MODE;
ch2->OutputMode=STEP_DIR_MODE;
ch2->Vel=40000;
ch2->Accel=200000;
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=0;
ch2->InputChan1=0;
ch2->OutputChan0=10;
ch2->OutputChan1=0;
ch2->MasterAxis=-1;
ch2->LimitSwitchOptions=0x0;
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=1;
ch2->iir[2].B1=0;
ch2->iir[2].B2=0;
ch2->iir[2].A1=0;
ch2->iir[2].A2=0;
EnableAxisDest(2,0);

DefineCoordSystem(0,1,2,-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;
}

// FeefHold sequence
#include "KMotionDef.h"

int main()
{

for (;;) // loop forever
{
WaitNextTimeSlice();

if (ReadBit(1172)) // Watch an external input switch
{
StopCoordinatedMotion(); //feedhold
}
}
return 0;
}
Attachments
init file.txt
(5.22 KiB) Downloaded 55 times

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

Re: SETTING UP KFLOP, KANALOG FOR NEW CNC ROUTER RETROFIT

Post by TomKerekes » Sun Jan 09, 2022 4:45 pm

Hi NOELNOG,

You pasted the entire program at the end. Instead only paste the "for" loop. A C program starts at the main() function. You can only have one main function in a program.
Regards,

Tom Kerekes
Dynomotion, Inc.

NOELNOG
Posts: 146
Joined: Wed Nov 10, 2021 3:54 pm

Re: SETTING UP KFLOP, KANALOG FOR NEW CNC ROUTER RETROFIT

Post by NOELNOG » Mon Jan 10, 2022 4:19 pm

Thanks Tom, it's running ok now.

how can i add messages in the program to pop up in the screen when determined switch is active?

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

Re: SETTING UP KFLOP, KANALOG FOR NEW CNC ROUTER RETROFIT

Post by TomKerekes » Mon Jan 10, 2022 5:21 pm

See the MessageBox examples
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply