KSTEP Basics TutorialIntroductionKSTEP is an add-on stepper driver for KFLOP and it is perhaps the easiest way available to start controlling stepper motors.This guide will help you with the most basic KSTEP setup so that by the end of these instructions you will be able to control stepper motors using the KMotion setup/configuration screens, C-Code and G-Code. This guide is not comprehensive, however, and you should spend time reading the help pages for more in-depth information:
KSTEP Tutorial Table of Contents:
What you need:
1. Software SetupStart by ensuring you have the latest KMotion software installed on your computer. Download and install the latest KMotion software from This Software Download Page. Ensure the software installs and starts normally. If the software does not install properly, search the Yahoo or CNC Zone forums for help on common installation issues such as temporarily disabling antivirus software installation preventions, or enabling Windows unsigned software installations.Note: Every screen in KMotion has a 'Help' button that will bring up a Help page that is focused on that particular screen. 2. Hardware Setup2A. Providing +5V Board PowerIn a static-free environment, remove your KFLOP and KSTEP from the packaging and connect the two as shown here. The first step to powering up KFLOP is to determine how to provide the +5V used to power the boards. Both KFLOP and KSTEP require +5V for operation and there are a number of ways to provide it.Note: Once +5V is supplied to the boards, it is available at every +5V terminal. Therefore do not supply +5V by more than one way or you will damage the boards and potentially your power supplies. The only exception to this is if KFLOP and KSTEP are isolated by removing jumpers on KSTEP JP34 and JP35. With this isolation, +5V must be supplied to both KFLOP and KSTEP as described below. With jumpers installed on KSTEP's JP34 and JP35, the +5V and GND signals will be shared between both boards and only needs to be supplied in one way. The possibilties are:
Once the board power delivery method is determined, the boards are ready to power up. Provide +5V via your chosen method to power up the boards. On power up, KFLOP LEDs will illuminate as will the "+5V" LED on KSTEP indicating that both boards are receiving a +5V signal. Once motor supply power is fed into KSTEP as described below, the "MOT PWR" motor supply LED on KSTEP will illuminate. 2B. Check the firmware version and update if necessaryNext, ensure the software version on KFLOP is up-to-date. In the KMotion software, open the Console screen and type the command "Version" into one of the command lines (if one of the command lines already contains the command there is no need to type it). Press the "Send" button next to the command to send the Version Command to KFLOP to display the version of onboard firmware. If the firmware version does not match the version of KMotion you downloaded and are running (Help>About KMotion...), open the Config screen and press the "New Version" button. The pop-up window will automatically locate the necessary file for the sofware update, click "Open" and confirm the next pop-up. Allow a few seconds for the software to finish updating and after it is finished, cycle power to KFLOP.2C. Motor Power Supply Setup - Voltage ClampingVoltage spikes due to Regenerative Braking and other sources can potentially raise the supply voltage up to a level that can damage electronics including KSTEP or the power supply. Voltage Spikes may also cause a power supply to trip a fault and shut down. KSTEP's Voltage clamp can be used to avoid these problems.Motor power supply may be supplied through KSTEP's J1 terminal block OR KSTEP's JR1 Molex connector, but not both at the same time; and it is crucial that voltage clamps on KSTEP are set according to the motor power supply voltage level. KSTEP can handle motor power supplies from 12V to 48V and voltage clamp settings are designed to be 1V higher than common power supply voltages. It is critical that you clamp voltage on KSTEP at a value HIGHER than the motor power supply See this image for voltage clamp jumper location: KSTEP Connector Pinouts Common power supply voltages are 12V, 24V, 36V, and 48v. KSTEP has a voltage clamping feature that can be set to 13V, 25V, 37V, or 49V volts. So whatever is the value of your motor power supply voltage, set the clamp to the next value higher than your motor power supply. Setting the voltage clamp to a value lower than the power supply will draw excessive current and is likely to cause damage to your KSTEP and/or the power supply Pin jumpers are provided with every KSTEP purchase. These are small plastic rectangular pieces with a metal coupling inside that connects two pins together when applied. You will use these to set the voltage clamp. Essentially, every jumper added to A, B, or C of the voltage clamping pins will reduce the voltage clamping by 12V. So, with no jumpers, voltage is clamped at 49V. With a jumper on A, voltage is clamped at 37V. With jumpers on A and B, voltage is clamped at 25V. With jumpers applied to A, B, and C, voltage is clamped at 13V (the lowest setting). Make sure voltage is clamped HIGHER than your power supply voltage or you will damage KSTEP.
2D. Motor Power Supply Setup - Connecting Motor Power to KSTEPThere are two ways to feed motor power into KSTEP, and they are incompatible with each other such that you must choose one or the other and not both or you will damage your power supplies and KSTEP.The first and perhaps easiest way to connect motor power is through the Molex connector at position JR1 on KSTEP. Many power supplies have this standard connector and it plugs easily into KSTEP to provide motor power. Caution: Note that if JR1 is plugged into a power supply this way, all VB connections on the board will have that voltage active on them. Also, it is likely that +5V signals are provided by a power supply with this connector and so you need to make sure no other 5V signals are being provided as described in the Board Power section of this tutorial before plugging power into the board in this way. The second way to supply motor power is through the screw terminals at position J1 on KSTEP. For applications requiring less than 10 Amps, simply screw in power supply leads into one of the respective VBB+ and GND terminals on J1. Do not supply power through JR1 if you supply power on J1 or you will damage KSTEP and your power supply. Note: for applications requiring more than 10 Amps, both of the VBB and GND connections on J1 should be used. Power Supply Voltage Selection is a fairly complex subject but as a rule-of-thumb the supply should be 10~15 times higher than the rated voltage of the steppers. Sometimes the voltage of the Stepper motor is not stated, in which case it can be determined by using Ohm's law ( V = I x R ) and the Current and Resistance specifications. For example, for a 3 Amp motor with a resistance of 0.6 ohms the motor would require 1.8V. A power supply of 18V to 27V might be used. 2E. Motor Current SettingsThe current supplied to your motors must be configured to provide the correct level and KSTEP provides a physical method of doing this through the installation of jumpers on current setting pins on KSTEP.Stepper motor current is generally specified on a per coil basis such as 670mA, or 0.67A, per coil. It is important to know what is the current per coil for your motors so you can set the correct current jumpers on KSTEP. The current setting pins are labeled on the board as "CUR MOTOR#" where # is the axis number from 0-3. KSTEP has a High, Medium, and Low current jumper for each motor coil (2 coils per axis). Set jumpers on the H (high), M (medium), and L (low) pins such that the value is the next level lower than your motor specifications. For example, if your motor has a per coil current rating of 670 mA, you will not set any jumpers for both coils - corresponding to a current setting of 0.63A. For a motor with a 3.5A current per coil specification you would set jumpers on H for both coils corresponding to a current setting of 3.13A. Use the table below to determine how to set your jumpers according to the motor current ratings.
2F. Wiring Motors to KSTEPStepper motors come in a variety of wiring configurations from 4 to 8 wires. KSTEP only needs 4 of these to drive a stepper since KSTEP does not require the center tap wires. KSTEP requires only the full bridge coils to drive the stepper and you can ignore center tap wires if your motor has them. For 8-wire steppers, you have a choice about how to wire them, in series or in parallel and would need to choose the power supply to fit the wiring method.There are many resources on the web that describes Stepper motor wiring so we will not address the specifics here, but essentially you need only to wire in the coils across the "+" and "-" of the motor power output of KSTEP. Warning: you can damage KSTEP if you wire the motors incorrectly make sure to measure the resistance between coils and that you have identified your coils properly before wiring into KSTEP. It is vitally important that each coil is wired into KSTEP properly. Motors can be wired into connectors J2 through J5 on KSTEP according to the following diagram:
3. Driving Your Steppers3A. Enabling OutputOnce you have the voltage clamping, current limits and power supply set and wired, you are ready to begin moving your motors.To do this, while the KSTEP LED D1 MOT PWR is illuminated, open KMotion.exe, select the Digital IO Screen, Set IO bit 45 as Output (enable the checkbox to the left of bit 45), Set IO 45 State to On (enable the checkbox to the right of bit 45). Verify that the KSTEP D3 ENABLE LED illuminates and that your motors hold position against a torque - in other words, you cannot move the motor shaft with your fingers. In this state, the motors will become warm and may become too hot to touch.
As a side note, this action can also be performed by entering the following commands in a C program or sending the commands using the Console screen:
3B. Setting Axis/Channel Parameters and Running an Initialization C Program (Init)The goal in this section is to set the parameters that will ultimately go into the Init program. To do this, you will use two screens in KMotion: "Config & Flash" and "Step Response." If you plan to use an encoder for Closed-Loop Stepper Control, you would also use the "IIR Filters" screen as well, but it is not used for open-loop stepper control as described in this tutorial. You can view an explanation of how parameters are passed to/from KFLOP, loaded, saved and copied to C Programs here: http://dynomotion.com/Help/FlashHelp/Parameters/index.html.
Once the parameters are set, you can save them to a file, export them to a C program or download them to KFLOP. To do this:
Here are the parameters for a single axis:
ch0->InputMode=NO_INPUT_MODE;
ch0->OutputMode=STEP_DIR_MODE;
ch0->Vel=115000;
ch0->Accel=50000;
ch0->Jerk=100000;
ch0->P=0;
ch0->I=0.01;
ch0->D=0;
ch0->FFAccel=0;
ch0->FFVel=0;
ch0->MaxI=200;
ch0->MaxErr=1e+006;
ch0->MaxOutput=200;
ch0->DeadBandGain=1;
ch0->DeadBandRange=0;
ch0->InputChan0=0;
ch0->InputChan1=0;
ch0->OutputChan0=8;
ch0->OutputChan1=0;
ch0->MasterAxis=-1;
ch0->LimitSwitchOptions=0x100;
ch0->LimitSwitchNegBit=0;
ch0->LimitSwitchPosBit=0;
ch0->SoftLimitPos=1e+030;
ch0->SoftLimitNeg=-1e+030;
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=320;
ch0->BacklashRate=320;
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.000769;
ch0->iir[2].B1=0.001538;
ch0->iir[2].B2=0.000769;
ch0->iir[2].A1=1.92076;
ch0->iir[2].A2=-0.923833;
Notice that the "ch0->" indicates it is setting parameters for Axis #0. Each axis will have all of these parameters and these are what are exported to the C program or copied to the clipboard when those options are selected in the Configuration screen. Below is the example that shows 3 Axes being configured, enabled, and referenced into a coordinate system. This constitutes a full Init file to initialize a 3-axis system as discussed in the next section: #include "KMotionDef.h"
// Defines axis 0, 1, 2 as simple step dir outputs
// enables them
// sets them as an xyz coordinate system for GCode
int main()
{
ch0->InputMode=ENCODER_MODE;
ch0->OutputMode=STEP_DIR_MODE;
ch0->Vel=40000.000000;
ch0->Accel=400000.000000;
ch0->Jerk=4000000.000000;
ch0->P=0.000000;
ch0->I=0.010000;
ch0->D=0.000000;
ch0->FFAccel=0.000000;
ch0->FFVel=0.000000;
ch0->MaxI=200.000000;
ch0->MaxErr=1000000.000000;
ch0->MaxOutput=200.000000;
ch0->DeadBandGain=1.000000;
ch0->DeadBandRange=0.000000;
ch0->InputChan0=0;
ch0->InputChan1=0;
ch0->OutputChan0=0;
ch0->OutputChan1=0;
ch0->LimitSwitchOptions=0x0;
ch0->InputGain0=1.000000;
ch0->InputGain1=1.000000;
ch0->InputOffset0=0.000000;
ch0->InputOffset1=0.000000;
ch0->invDistPerCycle=1.000000;
ch0->Lead=0.000000;
ch0->MaxFollowingError=1000000000.000000;
ch0->StepperAmplitude=20.000000;
ch0->iir[0].B0=1.000000;
ch0->iir[0].B1=0.000000;
ch0->iir[0].B2=0.000000;
ch0->iir[0].A1=0.000000;
ch0->iir[0].A2=0.000000;
ch0->iir[1].B0=1.000000;
ch0->iir[1].B1=0.000000;
ch0->iir[1].B2=0.000000;
ch0->iir[1].A1=0.000000;
ch0->iir[1].A2=0.000000;
ch0->iir[2].B0=0.000769;
ch0->iir[2].B1=0.001538;
ch0->iir[2].B2=0.000769;
ch0->iir[2].A1=1.920810;
ch0->iir[2].A2=-0.923885;
EnableAxisDest(0,0);
ch1->InputMode=ENCODER_MODE;
ch1->OutputMode=STEP_DIR_MODE;
ch1->Vel=40000.000000;
ch1->Accel=400000.000000;
ch1->Jerk=4000000.000000;
ch1->P=0.000000;
ch1->I=0.010000;
ch1->D=0.000000;
ch1->FFAccel=0.000000;
ch1->FFVel=0.000000;
ch1->MaxI=200.000000;
ch1->MaxErr=1000000.000000;
ch1->MaxOutput=200.000000;
ch1->DeadBandGain=1.000000;
ch1->DeadBandRange=0.000000;
ch1->InputChan0=1;
ch1->InputChan1=0;
ch1->OutputChan0=1;
ch1->OutputChan1=0;
ch1->LimitSwitchOptions=0x0;
ch1->InputGain0=1.000000;
ch1->InputGain1=1.000000;
ch1->InputOffset0=0.000000;
ch1->InputOffset1=0.000000;
ch1->invDistPerCycle=1.000000;
ch1->Lead=0.000000;
ch1->MaxFollowingError=1000000000.000000;
ch1->StepperAmplitude=20.000000;
ch1->iir[0].B0=1.000000;
ch1->iir[0].B1=0.000000;
ch1->iir[0].B2=0.000000;
ch1->iir[0].A1=0.000000;
ch1->iir[0].A2=0.000000;
ch1->iir[1].B0=1.000000;
ch1->iir[1].B1=0.000000;
ch1->iir[1].B2=0.000000;
ch1->iir[1].A1=0.000000;
ch1->iir[1].A2=0.000000;
ch1->iir[2].B0=0.000769;
ch1->iir[2].B1=0.001538;
ch1->iir[2].B2=0.000769;
ch1->iir[2].A1=1.920810;
ch1->iir[2].A2=-0.923885;
EnableAxisDest(1,0);
ch2->InputMode=ENCODER_MODE;
ch2->OutputMode=STEP_DIR_MODE;
ch2->Vel=40000.000000;
ch2->Accel=400000.000000;
ch2->Jerk=4000000.000000;
ch2->P=0.000000;
ch2->I=0.010000;
ch2->D=0.000000;
ch2->FFAccel=0.000000;
ch2->FFVel=0.000000;
ch2->MaxI=200.000000;
ch2->MaxErr=1000000.000000;
ch2->MaxOutput=200.000000;
ch2->DeadBandGain=1.000000;
ch2->DeadBandRange=0.000000;
ch2->InputChan0=2;
ch2->InputChan1=0;
ch2->OutputChan0=2;
ch2->OutputChan1=0;
ch2->LimitSwitchOptions=0x0;
ch2->InputGain0=1.000000;
ch2->InputGain1=1.000000;
ch2->InputOffset0=0.000000;
ch2->InputOffset1=0.000000;
ch2->invDistPerCycle=1.000000;
ch2->Lead=0.000000;
ch2->MaxFollowingError=1000000000.000000;
ch2->StepperAmplitude=20.000000;
ch2->iir[0].B0=1.000000;
ch2->iir[0].B1=0.000000;
ch2->iir[0].B2=0.000000;
ch2->iir[0].A1=0.000000;
ch2->iir[0].A2=0.000000;
ch2->iir[1].B0=1.000000;
ch2->iir[1].B1=0.000000;
ch2->iir[1].B2=0.000000;
ch2->iir[1].A1=0.000000;
ch2->iir[1].A2=0.000000;
ch2->iir[2].B0=0.000769;
ch2->iir[2].B1=0.001538;
ch2->iir[2].B2=0.000769;
ch2->iir[2].A1=1.920810;
ch2->iir[2].A2=-0.923885;
EnableAxisDest(2,0);
DefineCoordSystem(0,1,2,-1);
return 0;
}
You can find more information on how to quickly import or export settings between the KMotion Screens and a C Program here. 3C. The Four Requirements for an Init C ProgramAt this point, you are ready to begin writing a C program to move your motors or simply use it as an Initilization file that allows KMotionCNC to control them. An initilization C program, which is also referred to simply as an Init file, will have four operations (all of which the InitKStep3Axis.c and InitKStep4Axis.c programs already have):
Since adding C code is more involved, that will be handled in a different tutorial, but here is an example of a simple infinite loop to move one motor that can be added into an init file:
Then you only need to Save, Compile, Download and Run the program to have KFLOP execute the program. You can do this in steps on the C Program screen or all in one button click with the Save-Compile-Download-Run button on the top. To stop the program, press the "Stop" button on the main KMotion menu. The next steps cover how to use KMotionCNC for basic movements. 3D. Use KMotionCNC to jog your motorsAfter running an Init file such as InitKStep3Axis.c for initialization, you are ready to move your motors by using KMotionCNC. Try moving the motors by first clicking on the jog buttons (buttons with green arrows at left). If everything is initialized properly the motors should move when the respective jog button is clicked. These jog buttons are mapped to the axes by the "DefineCoordSystem(0,1,2,-1);" command discussed above. In this example, the X-axis is mapped to Axis #0, Y-axis is mapped to Axis #1, Z-axis is mapped to Axis #2 and the A-axis is not used. If pressing the jog buttons move the motors, then you are ready to begin running G-Code. To do this, within KMotionCNC choose "Open" and choose a G-Code program from the GCode Programs folder. If everything has been initialized correctly, the motors will move when the Start button is pressed to start the G-Code.Note: An initialization C program such as the InitKStep3Axis.c must be run before operating with KMotionCNC will work. This initialization C program can be called with the 'Init' button in KMotionCNC once programmed to do so by setting the file location and Thread number for the INIT button within the 'Tool Setup' Screen on the 'User Buttons' tab in KMotionCNC:
The GUI of KMotionCNC can be configured based on how many axes you are using by changing the option for "Main Dialog Face" on the 'Tool/Setup Files' tab within the 'Tool Setup' screen. The screenshot below is for a 3-axis setup as you can tell from the display of only X, Y, and Z coordinates.
Note that the motors will not yet be moving accurately until the full parameters are set within KMotionCNC. To do this, you will set the Counts per inch (Cnts/inch) for each axis on the Trajectory Planner tab within the Tool Setup screen of KMotionCNC. You should also set the axis velocities and accelerations, and jog velocities and accelerations for your system on this tab.
You can measure the distance each axis moves for a given number of steps and then use this Cnts/inch value as a conversion factor so KMotionCNC knows how many steps to move for a given distance. For greater accuracy, you can create a Geocorrection File.
|