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.