Hybrid View
-
13-01-2017 #1
-
12-02-2017 #2
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.
It looks complex, but I'll break it down.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; }
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-
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.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;
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.
-
The Following 3 Users Say Thank You to m_c For This Useful Post:
-
12-02-2017 #3
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
-
12-02-2017 #4
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.
-
12-02-2017 #5
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-9fDLAn2sAvoiding the rubbish customer service from AluminiumWarehouse since July '13.
-
12-02-2017 #6
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
-
14-02-2017 #7
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.
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.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.
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.
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.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 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.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Denford Triac - Help
By mikeadams1985 in forum Denford MillsReplies: 1Last Post: 12-01-2017, 10:06 AM -
FOR SALE: Denford Triac CNC PC
By ricey3 in forum Items For SaleReplies: 6Last Post: 10-01-2017, 01:39 PM -
Denford Triac VMC
By fidia in forum Milling Machines, Builds & ConversionsReplies: 6Last Post: 19-08-2016, 08:18 AM -
Help Denford triac p.c.
By mikeulike in forum Denford MillsReplies: 3Last Post: 02-06-2015, 03:59 PM -
WANTED: Denford Triac
By edwardsjc in forum Items WantedReplies: 13Last Post: 20-08-2012, 08:17 AM




Reply With Quote

Bookmarks