. .

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    m_c's Avatar
    Lives in East Lothian, United Kingdom. Last Activity: 1 Day Ago Forum Superstar, has done so much to help others, they deserve a medal. Has a total post count of 2,969. Received thanks 368 times, giving thanks to others 9 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:


  3. #2
    Clive S's Avatar
    Lives in Marple Stockport, United Kingdom. Last Activity: 13 Hours Ago Forum Superstar, has done so much to help others, they deserve a medal. Has a total post count of 3,345. Received thanks 618 times, giving thanks to others 87 times. Made a monetary donation to the upkeep of the community. Is a beta tester for Machinists Network features.
    Things like this would be nice to copy out to a tutorial section for future reference as stickies
    ..Clive
    The more you know, The better you know, How little you know

  4. #3
    Not sure if this a good advert for Kflop or not.? Certainly not for the beginner.! But well written.
    Last edited by JAZZCNC; 12-02-2017 at 11:27 AM.

  5. #4
    m_c's Avatar
    Lives in East Lothian, United Kingdom. Last Activity: 1 Day Ago Forum Superstar, has done so much to help others, they deserve a medal. Has a total post count of 2,969. Received thanks 368 times, giving thanks to others 9 times.
    Quote Originally Posted by JAZZCNC View Post
    Not sure if this a good advert for Kflop or not.? Certainly not for the beginner.! But well written.
    It's certainly not a simple bit of kit, however I have seen a few complete beginners manage to get some quite complex systems up and running, with not that much help. It's one of those things, that if you want to learn how to get it working, you will, and you could say the same about most controllers if you've got no experience.

    Saying that, this is one part of setting up that would really benefit from a video showing the actual process, as once you know the process, it's not that hard.
    There are a few Dynomotion videos showing specific parts, or for specific boards. The KStep Introduction video, from 3:55 onwards shows the software process - https://www.youtube.com/watch?v=pW-9fDLAn2s
    Avoiding the rubbish customer service from AluminiumWarehouse since July '13.

  6. #5
    Well, I use Kflop and I was a complete beginner, my only coding experience was with Arduino which operates on a kind of simplified version of C.

    I first found it daunting. But I will say this, you don't really need to know the C language to make it work, you just need to apply a bit of common sense and spend time reading forum posts and reading the instructions. I requires real determination and patience and I fear that a lot of people will give up, which is a shame because it's a fantastic controller card.It's by no means a plug and play card.

    My breakthrough was when a friend sent me a basic set up file for the three motors. Very basic, but enough to get the motors going. In fact, Kmotion already includes a simple configuration file that can be used. But it is a convoluted program, you have to go from one window to the other and then back again. For instance, if the axes are disabled due to an e-stop, you can't switch them back on from within the CNC program, you have to open another program to enable the axes back again. They should amalgamate the two main programs (KMotion and KMotionCNC) into one.

    But, like a lot of applications, suddenly it all starts to click and make sense, and it is not difficult to add some lines of code to the basic init file as you build up the system.

    There are quirks, for example, you don't upload to the drive, you download. To reverse motor direction you set up your Gain to -1....then most of the program settings are calculated in inches, although you can work in metric when it matters.

    It is a very powerful and very stable controller, but it could do with some simplification for the novice, without losing the ability of tweaking and adding once you gain the experience. I think most Kflop users have needed some help at the beginning either from the very helpful owner or from other kind users.

    As for Dean's comment, he is spot on, you need to put yourself on the side of the novice to understand that even the very detailed information in M_C's post is just too daunting and a lot of people will say, the hell with it, I want a controller that works first time without all that coding palaver!

    Edward

  7. #6
    m_c's Avatar
    Lives in East Lothian, United Kingdom. Last Activity: 1 Day Ago Forum Superstar, has done so much to help others, they deserve a medal. Has a total post count of 2,969. Received thanks 368 times, giving thanks to others 9 times.
    Quote Originally Posted by Edward View Post
    Well, I use Kflop and I was a complete beginner, my only coding experience was with Arduino which operates on a kind of simplified version of C.
    Arduino uses C++ (C plus plus), which is a higher level version of C. The other major version of C is C# (C sharp), which is a higher level yet.
    However they all use fairly similar coding techniques/layouts, so experience of any is a benefit.

    My breakthrough was when a friend sent me a basic set up file for the three motors. Very basic, but enough to get the motors going. In fact, Kmotion already includes a simple configuration file that can be used. But it is a convoluted program, you have to go from one window to the other and then back again. For instance, if the axes are disabled due to an e-stop, you can't switch them back on from within the CNC program, you have to open another program to enable the axes back again. They should amalgamate the two main programs (KMotion and KMotionCNC) into one.
    KMotion is solely for configuration. KFlops are not solely designed for CNC use, and KMotion contains the functionality to configure and program KFlops to run standalone, or via software.
    KMotionCNC is just a PC program to use the KFlop as a more conventional CNC controller. The full source code is provided, so if you really want, you can edit the source and recompile it.

    Dynomotion provide a pretty comprehensive library for creating your own software, along with example programs for all the possible software interfacing methods (A quick scan of the directory shows Virtual Basic, C, C#, LabView and Python). The only things that are not publically provided, are the base programming for the KFlop, and the source code for the firmware and the various DLLs/dotNet framework which provide the software interface.

    The key to setup, is to get a basic init.c file created as quickly as possible, then add to it as you get things configured. Taking your example about re-enabling things after an EStop, you could create a very simple init.c that simply turns outputs back on. I didn't have that problem on this machine, as during setup the EM806 drives default to enabled, but it would be a simple case to add a SetBit(xx) command to your init.c to activate the output for your drive enable.
    I'll expand more on the general C program framework I use for my machines when I get time, as all I've posted so far is the bare minimum to get machine movement. Things have expanded quite a bit since that basic file, as E Stop monitoring code and tool changer code has been added. I'll also discuss how I use the multiple program threads.

    There are quirks, for example, you don't upload to the drive, you download. To reverse motor direction you set up your Gain to -1....then most of the program settings are calculated in inches, although you can work in metric when it matters.
    The whole download/upload thing is actually quite common in the programming world, but there is no hard and fast way to know. My day job is dealing with vehicle diagnostics, and it can be a nightmare. Ford programming software you download software updates, and upload configuration data to ECUs. GM/Vauxhall you upload software to ECUs and store configuration data. Mercedes you download updates to ECUs, and then set parameters.
    The best way to think of it is the KFlop is the server, so you're uploading to it, and downloading from it when dealing with motor parameters. Off course, then you download C programs when you want to run them..

    The whole imperial thing is my biggest gripe with KMotionCNC. It's natively written around inches, so if you are going to be changing between metric and imperial, you have to allow for the fact that the tool table is unitless.
    Avoiding the rubbish customer service from AluminiumWarehouse since July '13.

  8. #7
    m_c's Avatar
    Lives in East Lothian, United Kingdom. Last Activity: 1 Day Ago Forum Superstar, has done so much to help others, they deserve a medal. Has a total post count of 2,969. Received thanks 368 times, giving thanks to others 9 times.
    So getting back to the mechanics, the spindle was stripped, and rebuilt with new bearings and fresh grease. I only took one photo of it, which is this one, showing the spindle removed, but the lower bearing, and lower bearing retainer still on the spindle.



    The process goes something along the lines of-
    Remove drawbar cylinder.
    Unbolt top support bearing and housing, and extract using bolts into the threaded holes provided for the purpose.
    Remove spindle motor and drive belt (you have to unbolt the motor to get the belt of)
    Remove notched adjustment nut, along with locking tab ring.
    Unbolt the lower spindle bearing retaining/seal plate.
    Knock/press the spindle down out of the head assembly.
    Pull the lower bearing of the spindle.
    And reassemble in reverse.

    After reassembly, you need to preload the bearings. The method used by Denford was to adjust by feel.
    Now as I deal with things like this occasionally, I've got a reasonable idea of how a preloaded bearing should feel, but I'll give some tips for those who've never done it before.
    Once you have the spindle assembled, with the adjustment nut on, nip the nut up. Then using a hammer and punch on the top face of the nut, give it a tap at various points around the nut. Nip the nut up again.
    Now using a block of wood on the face of the spindle, give it a couple taps upward, before seeing if you can get anymore movement on the nut.
    Repeat a couple times until you're happy things are settled, with no more movement on the nut.
    What this does, is help ensure everything is seated correctly. Given the interference fit of parts, it's very possible that you could preload the bearings, but without something seated correctly. What that would mean, is that you rebuild everything, and then after a period of time (it could be after a few minutes, or even a few months), the whatever it is will settle in, your preload disappears and you end up with a load of spindle run out, where it's flapping around in the bearings.
    At this point I gave the spindle a good few spins to help work the fresh grease out from the bearing tracks.

    Now taking a DTI mounted on the head (so any movement in slides doesn't affect the reading) and set against the side of the spindle, using a best guess effort as too how much pressure the spindle is likely to see, I grab the top of the spindle and pull/push it in the direction of the DTI needle.
    I then adjust up the lock nut until I'm getting minimal movement. I spin the spindle a few times, give things another tap with the hammer/punch/block of wood, and recheck. Once no more adjustment is needed, I spin the spindle by hand. I then adjust up the nut until I feel a very slight bit of springiness just as the spindle starts to move. Once again, I give everything a tap, and recheck. Once I'm happy, I bend a locking tab into a notch.

    The real proof in whether you've got it right, is in the running.
    Once you get the motor back on, you should run the spindle at a lowish speed (I opted for about 500rpm) for 10-15 minutes to let the grease work it's way out from the bearing tracks, while also monitoring the spindle temperature.
    If you run the bearings too fast too soon, they can slide on the grease, which results in premature wear and even causing flat spots on the bearings, which will lead to vibrations and poor cutter finishes.
    If everything sounds OK, gradually ramp the speed up, allowing maybe 5 minutes at every step (I went up in 500rpm steps), while monitoring the temperature. If you've got the preload within acceptable limits, after an hours running the spindle/housing should of warmed up, but you should still be able to keep your hand on it. If at any point you can't keep your hand on it, you've got too much preload, so stop it and slacken the adjustment nut of a notch. If on the hand it barely warms up, you've not got enough preload, which means you're most likely going to get a rubbish finish on parts as the spindle/cutter deflects while cutting.
    Avoiding the rubbish customer service from AluminiumWarehouse since July '13.

  9. The Following 2 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
  •