====C Programs provide a powerful and flexible capability to perform almost any sequence of operations within KFLOP. In most cases after you have tested and tuned all your hardware using the KMotion.exe setup program all the settings and initialization steps required for your system can be placed into an Initialization C Program so that your system can be fully initialized simply by executing the Initialization program. Using a C Program offers full flexibility to initialize your system however and in whatever order you wish. In most common cases an existing example can be used with simple modification of values specific to your system. The KMotion.exe Setup program has some [http://www.dynomotion.com/Help/ConfigurationScreen/ConfigurationScreen.htm#Utilities automatic capability] to translate the Axes Screen Values that were determined by you during configuration and testing into C Code. The Initialization C Program will normally perform operations of the following type: * Enable/define any Option boards present (ie. KStepPresent=TRUE; // enable KSTEP input multiplexing)* The setting of Axes parameters (ie. ch0->Accel=200000; )* Enable Axes (ie.EnableAxisDest(0,0); )* Define the Coordinated Motion Axes (ie. DefineCoordSystem(0,1,2,-1); // define axes for XYZ* Forever Loop to service any continuous requirements such as MPG, External Buttons, EStop, etc ====Simplest C Program====It is important to understand that any KFLOP C Program consists of a minimum number of parts as shown below. The first part is an #include statement which includes a definition file that defines all the functionality available in KFLOP. The KMotionDef.h file is included with every installation to define all the functions, variables, structures, and defines available in that Version. It is located in the DSP_KFLOP subdirectory of the installation. Open it with the KMotion.exe C Programs Screen to see what's available. The next part is the "main" function. This is where execution of the program will actually begin. The last part is the code that is to be executed and belongs to the main function. Curly brackets { } define the beginning and end of the function. This example contains only one print statement to be executed. Note how the code within the curly brackets is indented (using a tab or spaces) to show that it belongs to the main function block. This indentation is not required but helps readers see the program structure. Instructions must end with a semicolon ';'. Double forward slashes allow comments to be added at the end of an instruction. #include "KMotionDef.h"<br />main()<br />{<br /> printf("Hello World!\n"); // send message to console<br />} ==<br />Wiring Diagrams==
[[Media:Kanalog_Connections.pdf|Basic Kanalog DAC and Encoder Connections 3 Axis]]