. .

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #14
    m_c's Avatar
    Lives in East Lothian, United Kingdom. Last Activity: 19 Hours Ago Forum Superstar, has done so much to help others, they deserve a medal. Has a total post count of 2,957. Received thanks 366 times, giving thanks to others 8 times.
    So dragging this back on topic, I'll quickly cover the seemingly mysterious world of configuring a KFlop to do the basics.

    There is no denying the KFlop can appear very complex, but it's not that much more complex than using any other controller. The key thing is, whereas programs like Mach have configuration options spread over various screens which create/update your machine configuration file, you have to create the equivalent KFlop configuration file yourself. However, the included KMotion software has various screens/functions to help you create the needed parameters, and several example files are included.

    I'll start with the basic file I used to get basic motion.
    Code:
    #include "KMotionDef.h"
    
    main()
    {
    	
    	ch1->InputMode=NO_INPUT_MODE;
    	ch1->OutputMode=STEP_DIR_MODE;
    	ch1->Vel=40000;
    	ch1->Accel=400000;
    	ch1->Jerk=4e+06;
    	ch1->P=0;
    	ch1->I=0.01;
    	ch1->D=0;
    	ch1->FFAccel=0;
    	ch1->FFVel=0;
    	ch1->MaxI=200;
    	ch1->MaxErr=1e+06;
    	ch1->MaxOutput=200;
    	ch1->DeadBandGain=1;
    	ch1->DeadBandRange=0;
    	ch1->InputChan0=1;
    	ch1->InputChan1=0;
    	ch1->OutputChan0=13;
    	ch1->OutputChan1=0;
    	ch1->MasterAxis=-1;
    	ch1->LimitSwitchOptions=0x100;
    	ch1->LimitSwitchNegBit=0;
    	ch1->LimitSwitchPosBit=0;
    	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=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;
    	
    	ch2->InputMode=NO_INPUT_MODE;
    	ch2->OutputMode=STEP_DIR_MODE;
    	ch2->Vel=40000;
    	ch2->Accel=400000;
    	ch2->Jerk=4e+06;
    	ch2->P=0;
    	ch2->I=0.01;
    	ch2->D=0;
    	ch2->FFAccel=0;
    	ch2->FFVel=0;
    	ch2->MaxI=200;
    	ch2->MaxErr=1e+06;
    	ch2->MaxOutput=200;
    	ch2->DeadBandGain=1;
    	ch2->DeadBandRange=0;
    	ch2->InputChan0=2;
    	ch2->InputChan1=0;
    	ch2->OutputChan0=14;
    	ch2->OutputChan1=0;
    	ch2->MasterAxis=-1;
    	ch2->LimitSwitchOptions=0x100;
    	ch2->LimitSwitchNegBit=0;
    	ch2->LimitSwitchPosBit=0;
    	ch2->SoftLimitPos=1e+09;
    	ch2->SoftLimitNeg=-1e+09;
    	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;
    
    	EnableAxis(0);
    	EnableAxis(1);
    	EnableAxis(2);
    	
    	FPGA(STEP_PULSE_LENGTH_ADD)=63;  // set the pulse time to ~ 5.xus
    	DefineCoordSystem(0,1,2,-1);
    	
    	InitAux();
    
    	AddKonnect(0,&VirtualBitsEx,VirtualBitsEx+1);
    
        return 0;
    
    }
    It looks complex, but I'll break it down.
    You have three sets of channel configuration data (one for each axis in this case). These set all the possible parameters for each channel.
    To create this information, within the Config function in KMotion, you use the various dropdown boxes and boxes to select/enter the information. You can then download the information to the KFlop to test (this can be done on the fly), and then once you're happy, you can copy the information to the clipboard, and paste it into your init.c file (init.c is the generic name used to reference your initialisation file - the file can be called whatever you want, but for simplicity it's gets called this).
    Although not needed for this, if you were to use some form of closed loop, there is the Step Response screen for tuning servos and carrying out test moves, an IIR Filter screen for applying filters to closed loops, and a Bode Plot screen for generating test plots to see in detail how the closed loop is performing.

    For a basic step/dir system such as this, there are only 6 lines that need to be set, which I've highlighted in bold below-
    Code:
    	ch0->InputMode=NO_INPUT_MODE;  Sets open loop mode
    	ch0->OutputMode=STEP_DIR_MODE; Sets Step dir output
    	ch0->Vel=40000; Sets maximum velocity
    	ch0->Accel=400000; Sets Acceleration
    	ch0->Jerk=4e+06; Sets Max Jerk
    	ch0->P=0;
    	ch0->I=0.01;
    	ch0->D=0;
    	ch0->FFAccel=0;
    	ch0->FFVel=0;
    	ch0->MaxI=200;
    	ch0->MaxErr=1e+06;
    	ch0->MaxOutput=200;
    	ch0->DeadBandGain=1;
    	ch0->DeadBandRange=0;
    	ch0->InputChan0=0;
    	ch0->InputChan1=0;
    	ch0->OutputChan0=12; Configures output mode (Step/dir, Quadrature, open collector, or actively driven)
    	ch0->OutputChan1=0;
    	ch0->MasterAxis=-1;
    	ch0->LimitSwitchOptions=0x100;
    	ch0->LimitSwitchNegBit=0;
    	ch0->LimitSwitchPosBit=0;
    	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=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;
    The lines in bold, are the keys ones. There are other options, like the limit switch options, soft limit, and backlash settings that can be used in open loop mode, but nearly everything else is servo tuning specific.
    I'm guessing several people will be wondering what Jerk is. Well it's a limit on how quickly acceleration can be applied, and is defined in units per second per second per second. Using a basic non-jerk limited trajectory planner, you end up with a sharp start to acceleration, and a sharp stop to acceleration. On a graph plot showing that velocity, you end up with sharp corners during velocity changes. What Jerk does is round those corners, so you get smoother motion.

    After the channel configuration data, you need to enable each channel/axis, which is a simple job using EnableAxis(n).

    As I'm using Leadshine drives which have a relatively long pulse setup time requirement, the FPGA line stretches the standard KFlop step pulse length to meet this requirement.

    Then we finally assign each channel to the relevant axis, using the DefineCoordSystem() function. It's simply in the order of X(0), Y(1), Z(2), and as we have to declare four axes, we simply set the unused A to -1. This function allows you to set whatever channel you want to any axis, and you can even change it on the fly, by simply running another program which redefines the coordinate system I.e for if you wanted to do something like change the spindle (which is not controlled by the coordinate system) to a A axis (which needs to be part of the coordinate system).
    There are 6 and 8 axis versions of this function, so you can use any combination of X,Y,Z,A,B,C,U and/or V axes.

    The final couple lines of code tell the KFlop there is a Konnect expansion board attached, and what address range to use for the Konnect inputs and outputs.

    And that is a breakdown of a basic KFlop init.c file.
    Off course, it's been expanded on, which I will try and cover in later posts.
    Avoiding the rubbish customer service from AluminiumWarehouse since July '13.

  2. The Following 3 Users Say Thank You to m_c For This Useful Post:


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Denford Triac - Help
    By mikeadams1985 in forum Denford Mills
    Replies: 1
    Last Post: 12-01-2017, 10:06 AM
  2. FOR SALE: Denford Triac CNC PC
    By ricey3 in forum Items For Sale
    Replies: 6
    Last Post: 10-01-2017, 01:39 PM
  3. Denford Triac VMC
    By fidia in forum Milling Machines, Builds & Conversions
    Replies: 6
    Last Post: 19-08-2016, 08:18 AM
  4. Help Denford triac p.c.
    By mikeulike in forum Denford Mills
    Replies: 3
    Last Post: 02-06-2015, 03:59 PM
  5. WANTED: Denford Triac
    By edwardsjc in forum Items Wanted
    Replies: 13
    Last Post: 20-08-2012, 08:17 AM

Bookmarks

Posting Permissions

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