Need Help! KFLOP with Mach3 and c-programming


Results 1 to 16 of 16

Thread: KFLOP with Mach3 and c-programming

  1. #1
    Member
    Join Date
    Jun 2012
    Location
    US
    Posts
    74
    Downloads
    4
    Uploads
    0

    Post KFLOP with Mach3 and c-programming

    Hello all,

    I am returning to this forum whenever I couldn't find right thinking myself.

    My situation is this.

    Build a new CNC gantry router using 6 servo packs
    servo pack 1 = axis X
    servo pack 2 = axis Y1
    servo pack 3 = axis Y2, slaved to Y1
    servo pack 4 = axis Z
    servo pack 5 = axis A
    servo pack 6 = belt driven milling spindle, swap to water-cooled VFD spindle(inverter driven) when needed

    So far, my progress is that I have finished fabricating all necessary mechanical joints, bushing, bearing support and control box having KFLOP, 6 servo packs, all kinds of terminals, VFD inverter, noise filter, circuit breaker, blah blah.

    I tried to configure software setting to verify everything is functionally working and I could see with my oscilloscope that pulse trains were successfully generated without problem for all axis, spindle pwm failed, trying to sort out this atm - I mean from KFLOP.
    My remaining task is to hookup other peripherals and let them acknowledged by mach3/kflop so that they watch those input pins all the time.
    I have been reading so many things in dynomotion webpage but many parts are still vague to me.
    Webpages are very descriptive for pros, but it is not kind to a new comer like me, just my thinking.

    Peripherals currently involved in this task are:

    1. Limit switches used for homing but also act as limit switches all the time, 1 for each axis and soft-limit will be active. I seperated 3 limit switches and they will be put into 3 different IO pins of KFLOP. Why seperated? Well... There were just bunch of IOs that I could use...

    2. probe that will always be monitored by kflop all the time whether the pin is active or not

    3. E-stop switch that will also be monitored all the time.

    Looks very simple.... but not to me....
    I know there are various sample c-codes bundled with the software.
    My problem is that they are all seperated, spreaded and there are too many codes with similar names..

    Below image, I assume, is what I can make use of.

    KFLOP with Mach3 and c-programming-cnczone-jpg

    Attachment 326958

    KFLOP seems to have total 7 user memory slots that can run simultaneously when initialized.

    Number 1 has no thread indication but I assume this will be the fixed thread No.1 because this is the most important core process, axis control.

    No. 2 has spindle speed which can be allocated to thread 2 - or whatever available.

    No. 3 is for homing process, thread 3 in this case. Whole code is unbelievably long for a homing sequence but it does seem like it is a homing. However, it does not look like it look at 3 limit switches all the time after homing sequence.

    No. 4 is for communication between mach3 and KMotion and I think it looks one of vital process that can not be skipped or omitted. Thread 4 here.

    4 threads are occupied up to now and I have 3 threads empty as available for other use.

    Okay, here comes my curiosity and request for wisemen's opinion.

    - Should I put each process of <watch limit pin>, <watch probe pin> and <watch estop pin> routines into thread 5 & thread 6 & thread 7 for example?
    - Or can I put these monitoring processes as one package at the bottom of initialize.c(let's call this whatever..) code and leave empty threads free?
    - To let several threads active at Launch, what action exactly is required? Power-up KFLOP board? Launch KMOTION.exe and Mach3? Or launch Mach3 alone?
    - When c-code is launched, do I still have to configure MACH3's input/output as enabled for spindle PWM, limit, ptobe, estop, etc? If yes, do I have to match port/pin in Mach3 config to KFLOP IO?

    I know these questions are basic things, still all vague to me.

    I have not yet looked inside rigid tapping code so I haven't grab an idea how they work or what I would need to do this yet, probably later.
    Except that, I think all functions I really need will be settled by solving this puzzle.

    My understanding is for { } loop is necessary to monitor any input.
    What I do not exactly know is whether I can put several for{ } loop in one c-program, i.e. initialize.c here or a seperate c-code having all these routines. <Several> means monitoring limit#1, limit#2, limit#3, probe , estop all the time.

    Can anybody tell me an ideal way to accomplish what I want to do please?

    regards
    Kevin

    Similar Threads:


  2. #2
    Member
    Join Date
    Jun 2012
    Location
    US
    Posts
    74
    Downloads
    4
    Uploads
    0

    Default Re: KFLOP with Mach3 and c-programming

    Hello again,

    This is going very complex to hook things up properly.

    KFLOP with Mach3 and c-programming-cnczone_question-jpg

    Well, I am stuck here.
    Can anyone suggests me how to wire this in a good manner please?
    As there is already a pull-down 150R on each pin, I am uncertain what to do next.
    PWM output for spindle, step/dir output for drivers are all ready.
    This circuit will be used for all limit switches, estop and probe.
    Please throw some light on my rotten brain.

    Kevin



  3. #3
    Member Need TECH Help!'s Avatar
    Join Date
    Dec 2007
    Location
    United States
    Posts
    578
    Downloads
    0
    Uploads
    0

    Default Re: KFLOP with Mach3 and c-programming

    Hello Kevin,
    Have you made a list of the pin out connections yet? It helps to get things in order and understanding for you and others trying to help. I just use a blank spreadsheet. Attached is one from my current project, still in progress.Also attached is my main INIT C program.

    Are you wiring directly to KFLOP headers or is there a Breakout board or? This will help to know how you are set up.

    A note on limit switch monitoring by c program.... On the ConfigFlash screen of Kmotion you select how the limit switch for that axis works. Then when you use the C copy to Clipboard and paste the code into your main INIT c program, the code to watch limit switches is in there.a snipet of my X axis config, limit switch section....
    Code:
            ch0->OutputChan1=0;
    	ch0->MasterAxis=-1;
    	ch0->LimitSwitchOptions=0x113;// This line determines how your limit switch acts and if it is watched/monitored.
    	ch0->LimitSwitchNegBit=138;
    	ch0->LimitSwitchPosBit=137;
    	ch0->SoftLimitPos=1e+009;
    	ch0->SoftLimitNeg=-1e+009;
    	ch0->InputGain0=1;
    	ch0->InputGain1=1;
    You need to test things and C code one at a time in the Kmotion software, before even starting to set up Mach3 or Kmotion CNC. Just a recommendation, i would use KmotionCNC rather than Mach3, machine will run much smoother by eliminating the "middle man" Mach3.

    Troy

    Attached Files Attached Files
    www.tsjobshop.com, www.homecncstuff.elementfx.com


  4. #4
    Member Need TECH Help!'s Avatar
    Join Date
    Dec 2007
    Location
    United States
    Posts
    578
    Downloads
    0
    Uploads
    0

    Default Re: KFLOP with Mach3 and c-programming

    Forgot, iam working on a document/tutorial of basic config of an X,Y,Z axis milling machine(my current project). Its attached, be carefull and be aware this is a very rough draft and it is from a novice point of view like me. but might shed some light on things.
    Troy

    Attached Thumbnails Attached Thumbnails KFLOP with Mach3 and c-programming-basic-3axis-kflopkanalog-setup-pdf  
    www.tsjobshop.com, www.homecncstuff.elementfx.com


  5. #5
    Member
    Join Date
    Jun 2012
    Location
    US
    Posts
    74
    Downloads
    4
    Uploads
    0

    Default

    Hello Troy,

    thanks for your kind and warm advice.
    Yes, I made a full spreadsheet for IOs and they match channel concept.
    And yes again, focus is to fabricate my own BoB to contain all stuffs I want to have. I already fried one board and got another from Dyno, quite disastrous but I hope the reward afterwards may compensate current pain in my a$$....

    There are things I still don't get but they will be eventually sorted out as long as hardware connections are correct.

    Currently my PC is busy doing some PCB autorouting so I will be back later

    regards
    Kevin



  6. #6
    Member
    Join Date
    Jun 2012
    Location
    US
    Posts
    74
    Downloads
    4
    Uploads
    0

    Default

    Oh and by the way, are you satisfied with Kmotion in terms of features,
    like touch plate, digitizing probe, offset setting, corner finding a block, etc. Loading and running g-code is something any software can do... Easy setup of stock and finding origin is what I pursue.

    regards
    Kevin



  7. #7
    Member Need TECH Help!'s Avatar
    Join Date
    Dec 2007
    Location
    United States
    Posts
    578
    Downloads
    0
    Uploads
    0

    Default Re: KFLOP with Mach3 and c-programming

    Cant say for myself how well KmotionCNC works with probes, i know others have done it, i myself still do it old fashioned way with indicators, tooling balls, edgefinders , etc. Setting tools and offsets is just as easy as any other software/hardware controls ive used. KmotionCNC has a much better trajectory planner than Mach3. That was the deciding factor for me to change from Mach3.

    Troy

    www.tsjobshop.com, www.homecncstuff.elementfx.com


  8. #8
    Member
    Join Date
    Jun 2012
    Location
    US
    Posts
    74
    Downloads
    4
    Uploads
    0

    Default Re: KFLOP with Mach3 and c-programming

    Hi Troy,

    Thanks for your attention.
    I absolutely agree with your point and I don't doubt that.
    But as a plug-in, Mach3 only provides its functional buttons and skins, not trajectory planer. All computings are done in KFLOP hardware, that's my understanding.
    So yes, the skins and buttons and macros... that's what I don't want to give up by using KFLOP.

    Well. hardware is done, beautifully working, not frying KFLOP PCB.

    KFLOP with Mach3 and c-programming-img_4650-jpg

    2 probes, 3-home switches, 6 axis step/dir with encoder input, 1 analog 0~10V output for VFD spindle, hardware e-stop switch, servo-error reset switch, and servo ON/OFF switch for possible maintenance.
    Well, looked simple but took me a great time to accomplish cause I am a complete newbie in circuit design.
    All quardrature outputs verified, probes and limit inputs were checked and looks good.

    This is the screenset I am using. Its original author is Hoss and I got it from CNCZONE sometime ago.
    Very useful, very handy.

    KFLOP with Mach3 and c-programming-mach3_probe_screen-jpg

    Now, I am stuck with software thingies, probably the last huddle to me.

    Here is what I have done so far

    - 6 axis setup done, they make pulse train, good
    - probe inputs wired and configured, working good. I am using IO27 & IO28 for each, one of them inverted and then monitored all the time as long as KFLOP is powered ON.

    Here is what I have to solve some mysteries.

    1. Limit(or home) switches : I can see DIGITAL IO changing when I activate this induction type NPN switch. It is wired correctly. I just don't know how to correctly sequence them.
    I wished I could attach a file but I don't see where the menu is at... (how did you attach files?)
    As soon as sequence begins(hit ref all button), all DROs go zero at the same time, and then starts to move Z axis.
    Where is the code to make every DRO to set zero???
    I don't want to make them Zero at the beginning. They will be automatically set to zero after they hit the switches.

    2. Mach3's RESET button also resets DROs. This one is also strange. Why should it try to reset DRO? And where is the corresponding lines of codes?
    As long as there isn't any evident reason, I don't want to reset DROs(machine coordinates) as long as machine is powered ON.

    3. Mach3 has the setting to slow down jogging speed near limit zone and the range is up to configuration. I do not see this 'slow down zone' option anywhere.
    Am I simply missing something or do I have to write a program of my own to slow-down jogging speed near end zone like Mach3 does?

    4. IO relation between Mach3 and KMotion
    This is somewhat confusing to me.
    Mach3 Plugin + KMotion
    I saw this page and mostly acknowledged except limit(or home) inputs.
    - Do I have to leave port/pin in mach3 input as zero or should I put IO_BIT number there?
    - Mach3 has a configuration page about homing, and I can set ranges for soft-limit. These ranges for x/y/z directly appears on tool-path screen as a visible box.
    What should I do to make this box still usable when KFLOP(or KMOTION) takes over soft-limit functionality? Do I have to manually input matching numbers?
    Please tell me the already studied method of doing this.

    I believe this limit-issues are the only puzzles left to me.

    Thanks for reading so long questions.

    regards,
    Kevin

    ================================================== =====================
    Homing 3 axis : Axis0 = X, Axis1 = Y, Axis2 = slaved to Axis1, Axis3 = Z
    IO30 = x home, 31=y home, 32=z home.
    ================================================== =======================
    #include "KMotionDef.h"

    // Homing program for a 3 axis System
    // Limit switches are disabled and used as a home switch
    // then they are re-enabled

    main()
    {
    //ClearBit(47);

    int SaveXLimits,SaveYLimits,SaveZLimits; //place to save limit switch settings

    DisableAxis(0); // Disable all axes
    DisableAxis(1);
    DisableAxis(3);

    // Set the axis parameters here
    // after everything is configured in the KMotion Screens
    // disable the limits (first save how they were set)
    SaveXLimits = ch0->LimitSwitchOptions;
    SaveYLimits = ch1->LimitSwitchOptions;
    SaveZLimits = ch3->LimitSwitchOptions;

    //SaveZLimits = ch2->LimitSwitchOptions;
    ch0->LimitSwitchOptions = 0;
    ch1->LimitSwitchOptions = 0;
    ch3->LimitSwitchOptions = 0;

    // enable all 3 axes and begin servoing where we are

    EnableAxis(0);
    EnableAxis(1);
    EnableAxis(3);


    // Home Z up first - jog until it sees the limit
    ch3->SoftLimitPos=0;
    ch3->SoftLimitNeg=-327680;
    Jog(3,-1000); // jog slowly negative
    while (ReadBit(32)) ; // loop until IO bit goes High
    Jog(3,0); // stop
    while (!CheckDone(3)) ; // loop until motion completes
    DisableAxis(3); // disable the axis
    Zero(3); // Zero the position
    EnableAxis(3); // re-enable the ServoTick
    MoveRel(3,-16384); // move some amount inside the limits
    while (!CheckDone(3)) ; // loop until motion completes
    ch3->LimitSwitchOptions = SaveZLimits; // restore limit settings
    ch3->SoftLimitPos=0;
    ch3->SoftLimitNeg=-327680;

    // Home X next - jog until it sees the limit
    ch0->SoftLimitPos=246700;
    ch0->SoftLimitNeg=0;
    Jog(0,-4096); // jog slowly negative
    while (ReadBit(32)) ; // loop until IO bit goes High
    Jog(0,0); // stop
    while (!CheckDone(0)) ; // loop until motion completes
    DisableAxis(0); // disable the axis
    Zero(0); // Zero the position
    EnableAxis(0); // re-enable the ServoTick
    MoveRel(0,4096.0); // move some amount inside the limits
    while (!CheckDone(0)) ; // loop until motion completes
    ch0->LimitSwitchOptions = SaveXLimits; // restore limit settings
    ch0->SoftLimitPos=246700;
    ch0->SoftLimitNeg=0;


    // Home Y next - jog until it sees the limit
    ch1->SoftLimitPos=409600;
    ch1->SoftLimitNeg=0;
    Jog(1,-4096); // jog slowly negative
    while (ReadBit(32)) ; // loop until IO bit goes High
    Jog(1,0); // stop
    while (!CheckDone(1)) ; // loop until motion completes
    DisableAxis(1); // disable the axis
    Zero(1); // Zero the position
    EnableAxis(1); // re-enable the ServoTick
    MoveRel(1,4096.0); // move some amount inside the limits
    while (!CheckDone(1)) ; // loop until motion completes
    ch1->LimitSwitchOptions = SaveYLimits; // restore limit settings
    ch1->SoftLimitPos=409600;
    ch1->SoftLimitNeg=0;
    SetBit(47);
    }


    ================================================== ===========================
    Initialize program/encoder inputs temporarily disabled for test purpose, no motor is wired yet
    ================================================== ============

    #include "KMotionDef.h"

    // Defines axis 0, 1, 3,4 as step dir TTL outputs
    // enables them
    // sets them as an xyz coordinate system for GCode

    int main()
    {
    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) = 32 + 0x80; // set polarity and pulse length to 2us

    SetBitDirection(26,1); // Set Bit 26 as an Output, PWM
    SetBitDirection(44,1); // Set Bit 44 as an Output, Spindle ON (CW)
    SetBitDirection(45,1); // Set Bit 45 as an Output, Spindle CCW


    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=56;
    ch0->OutputChan1=0;
    ch0->MasterAxis=-1;
    ch0->LimitSwitchOptions=0x11a;
    ch0->LimitSwitchNegBit=0;
    ch0->LimitSwitchPosBit=32;
    ch0->SoftLimitPos=245760;
    ch0->SoftLimitNeg=0;
    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=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=57;
    ch1->OutputChan1=0;
    ch1->MasterAxis=-1;
    ch1->LimitSwitchOptions=0x11a;
    ch1->LimitSwitchNegBit=0;
    ch1->LimitSwitchPosBit=32;
    ch1->SoftLimitPos=409600;
    ch1->SoftLimitNeg=0;
    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=58;
    ch2->OutputChan1=0;
    ch2->MasterAxis=1;
    ch2->LimitSwitchOptions=0x110;
    ch2->LimitSwitchNegBit=0;
    ch2->LimitSwitchPosBit=32;
    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=NO_INPUT_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=59;
    ch3->OutputChan1=0;
    ch3->MasterAxis=-1;
    ch3->LimitSwitchOptions=0x11a;
    ch3->LimitSwitchNegBit=0;
    ch3->LimitSwitchPosBit=0;
    ch3->SoftLimitPos=0;
    ch3->SoftLimitNeg=-327680;
    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);


    ch4->InputMode=NO_INPUT_MODE;
    ch4->OutputMode=STEP_DIR_MODE;
    ch4->Vel=40000;
    ch4->Accel=400000;
    ch4->Jerk=4e+006;
    ch4->P=0.2;
    ch4->I=0;
    ch4->D=0;
    ch4->FFAccel=0;
    ch4->FFVel=0;
    ch4->MaxI=200;
    ch4->MaxErr=200;
    ch4->MaxOutput=200;
    ch4->DeadBandGain=1;
    ch4->DeadBandRange=0;
    ch4->InputChan0=4;
    ch4->InputChan1=1;
    ch4->OutputChan0=60;
    ch4->OutputChan1=1;
    ch4->MasterAxis=-1;
    ch4->LimitSwitchOptions=0x100;
    ch4->LimitSwitchNegBit=0;
    ch4->LimitSwitchPosBit=0;
    ch4->SoftLimitPos=1e+009;
    ch4->SoftLimitNeg=-1e+009;
    ch4->InputGain0=1;
    ch4->InputGain1=1;
    ch4->InputOffset0=0;
    ch4->InputOffset1=0;
    ch4->OutputGain=1;
    ch4->OutputOffset=0;
    ch4->SlaveGain=1;
    ch4->BacklashMode=BACKLASH_OFF;
    ch4->BacklashAmount=0;
    ch4->BacklashRate=0;
    ch4->invDistPerCycle=1;
    ch4->Lead=0;
    ch4->MaxFollowingError=10000000;
    ch4->StepperAmplitude=250;

    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=1;
    ch4->iir[2].B1=0;
    ch4->iir[2].B2=0;
    ch4->iir[2].A1=0;
    ch4->iir[2].A2=0;
    EnableAxisDest(4,0);

    ch5->InputMode=NO_INPUT_MODE;
    ch5->OutputMode=STEP_DIR_MODE;
    ch5->Vel=40000;
    ch5->Accel=400000;
    ch5->Jerk=4e+006;
    ch5->P=0.2;
    ch5->I=0;
    ch5->D=0;
    ch5->FFAccel=0;
    ch5->FFVel=0;
    ch5->MaxI=200;
    ch5->MaxErr=200;
    ch5->MaxOutput=200;
    ch5->DeadBandGain=1;
    ch5->DeadBandRange=0;
    ch5->InputChan0=5;
    ch5->InputChan1=1;
    ch5->OutputChan0=61;
    ch5->OutputChan1=1;
    ch5->MasterAxis=-1;
    ch5->LimitSwitchOptions=0x110;
    ch5->LimitSwitchNegBit=0;
    ch5->LimitSwitchPosBit=0;
    ch5->SoftLimitPos=1e+009;
    ch5->SoftLimitNeg=-1e+009;
    ch5->InputGain0=1;
    ch5->InputGain1=1;
    ch5->InputOffset0=0;
    ch5->InputOffset1=0;
    ch5->OutputGain=1;
    ch5->OutputOffset=0;
    ch5->SlaveGain=1;
    ch5->BacklashMode=BACKLASH_OFF;
    ch5->BacklashAmount=0;
    ch5->BacklashRate=0;
    ch5->invDistPerCycle=1;
    ch5->Lead=0;
    ch5->MaxFollowingError=10000000;
    ch5->StepperAmplitude=250;

    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;

    DefineCoordSystem(0,1,3,4);



    //Watches for EStop Input and disables Axes when detected

    for (; //loop forever
    {
    WaitNextTimeSlice();
    // if ESTOP present disable any enabled Axis ??
    #define ESTOP_BIT 29
    if (!ReadBit(ESTOP_BIT))
    {
    if (ch0->Enable) DisableAxis(0); // axis still enabled? - Disable it
    if (ch1->Enable) DisableAxis(1); // axis still enabled? - Disable it
    if (ch2->Enable) DisableAxis(2); // axis still enabled? - Disable it
    if (ch3->Enable) DisableAxis(3); // axis still enabled? - Disable it
    if (ch4->Enable) DisableAxis(4); // axis still enabled? - Disable it
    if (ch5->Enable) DisableAxis(5); // axis still enabled? - Disable it
    }
    //Watches for probe inputs and set IO_BIT(48) according to probe Status
    if (ReadBit(27) || !ReadBit(28))
    SetBit(48);
    else
    ClearBit(48);

    }



    //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;
    //}



    }

    Last edited by Lozzy; 07-26-2016 at 10:04 AM.


  9. #9
    Member
    Join Date
    Jun 2012
    Location
    US
    Posts
    74
    Downloads
    4
    Uploads
    0

    Default Re: KFLOP with Mach3 and c-programming

    Okay, I just found one thing.

    EnableAxis(0) automatically zero axis0, i didn't know that.
    It seems like there is no option NOT to reset axis position.
    I disabled these enable/disable axis lines and things are getting much better, I just doubt why it was necessary.
    I think homing sequence has no trouble for now.
    Mach3's reset button triggered this routines too... and they are disabled either.
    So... next is... how to match Mach3's dimension box with KMotion's soft-limit range... and how to slow down axis near soft limits...

    regards,
    Kevin



  10. #10
    Member
    Join Date
    Jun 2012
    Location
    US
    Posts
    74
    Downloads
    4
    Uploads
    0

    Default Re: KFLOP with Mach3 and c-programming

    Okay again,

    I found SoftLimits3AxesV2.c in c-program folder and its corresponding yahoo forum.
    Dang, so many things to try to find.
    I'd like to find a way NOT to disable axis when it hit the limit.
    Instead, it goes only to the opposite direction never disabling the axis.
    Or maybe I can live with reset button as long as it doesn't reset DROs if I fail to find how to NOT disable the axis......

    regards,
    Kevin



  11. #11
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4045
    Downloads
    0
    Uploads
    0

    Default Re: KFLOP with Mach3 and c-programming

    Hi Lozzy,

    But as a plug-in, Mach3 only provides its functional buttons and skins, not trajectory planer. All computings are done in KFLOP hardware, that's my understanding.
    Actually incorrect. With Mach3 it is the GCode Interpreter and the Trajectory Planner. The Plugin must just perform the motion it is commanded to perform.

    I wished I could attach a file but I don't see where the menu is at... (how did you attach files?)
    see the "Go Advanced" and "Manage Uploads Buttons"

    Do I have to leave port/pin in mach3 input as zero or should I put IO_BIT number there?
    Normally leave them as zero. KFLOP handles all real-time operations like Step/Dir pulses, limits, homing...

    What should I do to make this box still usable when KFLOP(or KMOTION) takes over soft-limit functionality? Do I have to manually input matching numbers?
    Please tell me the already studied method of doing this.
    After Homing set KFLOP Soft Limits in Counts or Steps. See Soft Limit Settings here:

    Configuration Screen

    EnableAxis(0) automatically zero axis0, i didn't know that.
    It seems like there is no option NOT to reset axis position.
    For Open loop systems (like yours?) EnableAxis resets the commanded destination to zero. To keep the commanded Destination set to the Last Destination use:

    EnableAxisDest(0,ch0->Dest);

    for axis 0

    HTH
    Regards

    Regards
    TK http://dynomotion.com


  12. #12
    Member
    Join Date
    Jun 2012
    Location
    US
    Posts
    74
    Downloads
    4
    Uploads
    0

    Default Re: KFLOP with Mach3 and c-programming

    Hi Tom,

    Quote Originally Posted by TomKerekes View Post
    Actually incorrect. With Mach3 it is the GCode Interpreter and the Trajectory Planner. The Plugin must just perform the motion it is commanded to perform.
    Wow... this is definitely a shocking news to me... I totally misunderstood it and I lost my speech...
    I know KMotion doesn't provide G31. What option would be there to use G31/probing utilities and KFLOP motion planers all together?

    see the "Go Advanced" and "Manage Uploads Buttons"
    Thanks, I didn't try this before.. much more comfortable now

    Normally leave them as zero. KFLOP handles all real-time operations like Step/Dir pulses, limits, homing...
    Got it and configured upon your instruction.

    After Homing set KFLOP Soft Limits in Counts or Steps. See Soft Limit Settings here:
    Alrighty, I calculated range I need and its corresponding step counts and put them both in Kmotion and Mach3.
    Now I see that white-dot box matching KMOTION ranges.


    For Open loop systems (like yours?) EnableAxis resets the commanded destination to zero. To keep the commanded Destination set to the Last Destination use: EnableAxisDest(0,ch0->Dest)
    KFLOP and BoB is sitting on my desk, currently in test&verification situation so no motor(encoder)is connected at the moment.
    It will eventually be connected to 6 servo packs - 6 encoders are awaiting. I didn't wire it yet.
    For current environment, yes it is an open-loop test and EnableAxis(ch) reset DROs, especially machine coordinates and this bothers me.
    Are you implying it will not happen in closed-loop system after encoder feedback is configured?
    And EnableAxisDest(0,ch0->Dest) can restore previous DRO value?
    Will you please let me know correct systax to try this command in console screen?

    regards,
    Kevin



  13. #13
    Member
    Join Date
    Jun 2012
    Location
    US
    Posts
    74
    Downloads
    4
    Uploads
    0

    Default Re: KFLOP with Mach3 and c-programming

    BTW Tom,

    I don't have access to your YAHOO forum.
    Can you give me one please?
    I am interested in the files and information there.
    I can PM you my email.

    regards,
    Kevin



  14. #14
    Member
    Join Date
    Jun 2012
    Location
    US
    Posts
    74
    Downloads
    4
    Uploads
    0

    Default Re: KFLOP with Mach3 and c-programming

    I found this information just ago,
    daily new discoveries !!



    This man didn't rely on Mach3 to probe.

    I know it is only me who didn't know it yet.
    Nevertheless, it is good to know I don't have to use Mach3 only for probing stocks.
    And the better thing is that this gentleman has posted his full c-codes here;

    http://joeschmoe.com/jerbroZCircles.c

    I guess he should be one of CNCZONE members

    I am now looking into this, trying to split the codes into each function and to allocate each of them (I mean probe down, probe north, south, east and west) into user buttons in KMotionCNC.
    It seems like it is the only way to utilize KMotion motion planer + probing functions at the same time.
    Oh it just hit my brain that I can sync Mach3/KmotionCNC and use Mach3 to probe, then load G-Code into KMotionCNC and run it from there.
    Would it still raise any performance issue?

    regards,
    Kevin



  15. #15
    Member
    Join Date
    Jun 2012
    Location
    US
    Posts
    74
    Downloads
    4
    Uploads
    0

    Default Re: KFLOP with Mach3 and c-programming

    Hi,

    I think I got a major progress with coding.
    I have attached two files, homing and initializing.
    Now INIT button doesn't reset all DROs. It just re-initialize the board without touching DRO numbers.
    Homing is working good too.
    Monitoring e_stop bit, probe_bit and watching soft-limit are all put into one FOR loop in initializing program, looping forever, and it also looks working fine.

    I have one question though.
    As you can see, my axis2 is slaved to axis1.
    Under this setup, is it necessary to disable/enable axis2 seperately?

    In the main body of this init program, you see all axis are present and I doubt if it is really necessary.
    If you say NO, I would delete all commands related to axis2.

    I am currently working on probing routines, it takes time to figure out which commands give certain value to axis DRO.
    What command(or syntax) should be used to set, i.e, Z DRO to the plate thickness when probe touches it?

    regards,
    Kevin


    main()
    {
    for (; //loop forever
    {
    WaitNextTimeSlice();
    // if ESTOP present disable any enabled Axis ??

    if (!ReadBit(ESTOP_BIT))
    {
    if (ch0->Enable) DisableAxis(0); // axis still enabled? - Disable it
    if (ch1->Enable) DisableAxis(1); // axis still enabled? - Disable it
    if (ch2->Enable) DisableAxis(2); // axis still enabled? - Disable it
    if (ch3->Enable) DisableAxis(3); // axis still enabled? - Disable it
    if (ch4->Enable) DisableAxis(4); // axis still enabled? - Disable it
    if (ch5->Enable) DisableAxis(5); // axis still enabled? - Disable it
    }
    //Watches for probe inputs and set IO_BIT(48) according to probe Status

    if (ReadBit(27) || !ReadBit(28)) SetBit(48);
    else ClearBit(48);

    //Watches for Soft Limits, slow down and stop axis
    if (InLimit()) // check for any limit
    {
    DisableAxis(0);
    DisableAxis(1);
    DisableAxis(2);
    DisableAxis(3);
    DisableAxis(4);
    DisableAxis(5);

    //Delay_sec(0.5);

    EnableAxisDest(0,ch0->Dest);
    EnableAxisDest(1,ch1->Dest);
    EnableAxisDest(2,ch2->Dest);
    EnableAxisDest(3,ch3->Dest);
    EnableAxisDest(4,ch4->Dest);
    EnableAxisDest(5,ch5->Dest);
    }
    }
    }


    Attached Files Attached Files


  16. #16
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4045
    Downloads
    0
    Uploads
    0

    Default Re: KFLOP with Mach3 and c-programming

    Hi Kevin,

    I don't have access to your YAHOO forum.
    Can you give me one please?
    You should have access. You need to create a Yahoo account.

    I am now looking into this, trying to split the codes into each function and to allocate each of them (I mean probe down, probe north, south, east and west) into user buttons in KMotionCNC.
    It seems like it is the only way to utilize KMotion motion planer + probing functions at the same time.
    Oh it just hit my brain that I can sync Mach3/KmotionCNC and use Mach3 to probe, then load G-Code into KMotionCNC and run it from there.
    Would it still raise any performance issue?
    Running GCode using KMotionCNC would use our GCode Interpreter and Trajectory Planner and give better performance. But probing in Mach3 would probably set offsets in Mach3 and not have the desired effect in KMotionCNC
    As you can see, my axis2 is slaved to axis1.
    Under this setup, is it necessary to disable/enable axis2 seperately?
    You should enable/disable all axes that you are using independently regardless of whether they are slaved or not.

    In the main body of this init program, you see all axis are present and I doubt if it is really necessary.
    If you say NO, I would delete all commands related to axis2.
    You must configure all the axes you are using

    I am currently working on probing routines, it takes time to figure out which commands give certain value to axis DRO.
    What command(or syntax) should be used to set, i.e, Z DRO to the plate thickness when probe touches it?
    See the SetFixtureZ.c example

    HTH
    Regards

    Regards
    TK http://dynomotion.com


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

KFLOP with Mach3 and c-programming

KFLOP with Mach3 and c-programming