Table of contents |

# Configuring Step and Direction Outputs

KFLOP supports connection to motor amplifiers that utilize step and direction (or quadrature or CW/CCW Pulses) inputs to control the motion. Step and direction motor amplifiers are typically used with stepper motors with or without micro-stepping capability. Each "step" causes the motor amplifier to advance the motor position one step in the direction specified by the "Direction" signal. Only two digital output signals are required for this interface. Fine micro-stepping resolution combined with high motor RPM can result in step rates in the megahertz. For example, a 200 step/rev stepping motor with 128:1 micro-stepping running at 3000 RPM requires:

3000 RPM / 60 Sec/Min * 200 steps/rev * 128 µsteps/full step = 1.28 MHz µsteps/sec

KFLOP has 8 axes of Step and Direction. Output pulses up to 2.5 MHz can be generated.

The 8 Axes of Step/Dir outputs are normally hard wired to IO bits 8 through 15 on JP7 and IO bits 36 through 43 on JP5. However the first 4 Step/Dir outputs can be multiplexed to connectors JP4 and JP6 if desired. This may be required if JP7 is used for some other purpose such as interfacing to the Kanalog I/O Expander. A global multiplexing bit is used to switch the outputs to the alternate connectors.

Note that the first 8 of 10 I/O pins of Aux #0 and Aux #1 have internal 150 Ohm pull down resistors. Therefore Pins JP4-13, JP4-14, JP6-13 and JP6-14 may not be used in Open Collector mode.

If an axis channel is selected as a Step and Direction axis, the corresponding 2 output pins will be automatically configured as outputs and they may not be used as general purpose IO.

For KFLOP see the table below:

| Mux = 0 | Mux = 1
--- | --- | ---
Signal | IO Bit | Pin | IO Bit | Pin
Step 0 | 8 | JP7 - 15 | 22 | JP4 - 13
Direction 0 | 9 | JP7 - 16 | 23 | JP4 - 14
Step 1 | 10 | JP7 - 17 | 24 | JP4 - 15
Direction 1 | 11 | JP7 - 18 | 25 | JP4 - 16
Step 2 | 12 | JP7 - 19 | 32 | JP6 - 13
Direction 2 | 13 | JP7 - 20 | 33 | JP6 - 14
Step 3 | 14 | JP7 - 21 | 34 | JP6 - 15
Direction 3 | 15 | JP7 - 22 | 35 | JP6 - 16

Signal | IO Bit | JP5 Pin
--- | --- | ---
Step 4 | 36 | JP5 - 1
Direction 4 | 37 | JP5 - 2
Step 5 | 38 | JP5 - 3
Direction 5 | 39 | JP5 - 4
Step 6 | 40 | JP5 - 5
Direction 6 | 41 | JP5 - 6
Step 7 | 42 | JP5 - 7
Direction 7 | 43 | JP5 - 8

To configure an axis as step and direction, on the Configuration Screen select output mode as "Step Dir" and select which of the 8 available Step and Direction generators should be used by setting the appropriate Output Channel 0 setting. See below.

Valid output channel settings 0-63 are allowed for KFLOP. Although only 8 Step and Direction generators are available for KFLOP by adding 8 and/or 16 and/or 48 to the channel number the mode of each Step/Dir Generator can be changed independently.
Adding 8 to the channel number uses the same generator to be used except the output pins are actively driven (high and low) as 3.3V LVTTL signals instead of only driven low as open collector outputs.
Adding 16 to the channel number switches the generator from Step/Dir to Quadrature output mode.
Adding 48 to the channel number switches the generator from Step/Dir to CW/CCW output mode.

If your amplifier has opto coupler inputs driven off +5V then open-collector mode is likely to work better. The diagram below shows how the open collector mode works driving the LED of an Opto Coupler with the anode connected to +5V.

However if the amplifier has standard logic inputs then LVTTL outputs should work better.

Quadrature outputs are required for some amplifiers. Quadrature outputs output two A B phases instead of Step/Dir signals. An advantage is that only one signal edge transition takes place for each "step" as opposed to a complete pulse and any Direction Setup Time and Minimum pulse time is avoided. Quadrature mode is selected by adding 16 to the Output Channel Number.

CW/CCW Mode is also available. In this mode instead of having a Direction signal there is a separate output for CW and CCW Pulses. This mode avoids any Direction Setup Time as well. CW/CCW mode is selected by adding 48 to the Output Channel Number.

The table below summarizes the Channel Number to specify to access the desired Generator and Mode:

Output Chan 0 Setting | Step & Dir Generator Selected | Output Drive Type
--- | --- | ---
0 | 0 | Open Collector - Step/Dir
1 | 1 | Open Collector - Step/Dir
2 | 2 | Open Collector - Step/Dir
3 | 3 | Open Collector - Step/Dir
4 | 4 | Open Collector - Step/Dir
5 | 5 | Open Collector - Step/Dir
6 | 6 | Open Collector - Step/Dir
7 | 7 | Open Collector - Step/Dir
8 | 0 | LVTTL - Step/Dir
9 | 1 | LVTTL - Step/Dir
10 | 2 | LVTTL - Step/Dir
11 | 3 | LVTTL - Step/Dir
12 | 4 | LVTTL - Step/Dir
13 | 5 | LVTTL - Step/Dir
14 | 6 | LVTTL - Step/Dir
15 | 7 | LVTTL - Step/Dir
16 | 0 | Open Collector - Quadrature
17 | 1 | Open Collector - Quadrature
18 | 2 | Open Collector - Quadrature
19 | 3 | Open Collector - Quadrature
20 | 4 | Open Collector - Quadrature
21 | 5 | Open Collector - Quadrature
22 | 6 | Open Collector - Quadrature
23 | 7 | Open Collector - Quadrature
24 | 0 | LVTTL - Quadrature
25 | 1 | LVTTL - Quadrature
26 | 2 | LVTTL - Quadrature
27 | 3 | LVTTL - Quadrature
28 | 4 | LVTTL - Quadrature
29 | 5 | LVTTL - Quadrature
30 | 6 | LVTTL - Quadrature
31 | 7 | LVTTL - Quadrature
32 | 0 | reserved
33 | 1 | reserved
34 | 2 | reserved
35 | 3 | reserved
36 | 4 | reserved
37 | 5 | reserved
38 | 6 | reserved
39 | 7 | reserved
40 | 0 | reserved
41 | 1 | reserved
42 | 2 | reserved
43 | 3 | reserved
44 | 4 | reserved
45 | 5 | reserved
46 | 6 | reserved
47 | 7 | reserved
48 | 0 | Open Collector - CW/CCW
49 | 1 | Open Collector - CW/CCW
50 | 2 | Open Collector - CW/CCW
51 | 3 | Open Collector - CW/CCW
52 | 4 | Open Collector - CW/CCW
53 | 5 | Open Collector - CW/CCW
54 | 6 | Open Collector - CW/CCW
55 | 7 | Open Collector - CW/CCW
56 | 0 | LVTTL - CW/CCW
57 | 1 | LVTTL - CW/CCW
58 | 2 | LVTTL - CW/CCW
59 | 3 | LVTTL - CW/CCW
60 | 4 | LVTTL - CW/CCW
61 | 5 | LVTTL - CW/CCW
62 | 6 | LVTTL - CW/CCW
63 | 7 | LVTTL - CW/CCW

Note when configuring the motion profile for a Step and Direction Axis the appropriate maximum Velocity, Acceleration, and Jerk should be set in units of micro-steps/sec, micro-steps/sec2, and micro-steps/sec3 respectively.

## Global Register sets Pulse Width, Polarity, Multiplexor

To change the Step/Dir Pulse width, Step Pulse Polarity, and connector multiplexor for channels 0-3 a programmable register in KFLOP's FPGA may be used.

KFLOP has the capability to program the Step pulse width as a 6-bit value. The default setting is 2us. The pulse length may be adjusted from 1 to 63 of 16.67 MHz clocks. Which corresponds to 60ns to 3.78us. Using a long pulse length limits the maximum frequency that can be generated. For example with the default pulse length of 2us the frequency should not exceed 1/(2 x 2us) = 250KHz.

KFLOP sets the Direction output 1.92us before generating a Step Pulse. With the maximum Step Pulse length of 3.78us the maximum Direction Setup time to the trailing edge of the Step Pulse is 5.7us.

Setting Bit-6 high of the register can be set high to multiplex Step/Dir generators 0-3 from JP7 to JP4 and JP6.

Setting Bit-7 high will invert the Step Output pulse so that it pulses High rather than Low. Some Amplifiers (Geckos) prefer this mode. If the drive "steps" on the falling edge of the pulse, then this option will provide more setup time for the Direction Signal.

A User C Program must be used to change the FPGA register. The following statement should be used:

    	FPGA(STEP_PULSE_LENGTH_ADD)=32;					// set the pulse time to ~ 2μs
    	FPGA(STEP_PULSE_LENGTH_ADD)=32 + 0x40;			// set the pulse time to ~ 2μs and multiplex to JP4 and JP6
    	FPGA(STEP_PULSE_LENGTH_ADD)=32 + 0x80;			// set the pulse time to ~ 2μs and pulse the Step High
    	FPGA(STEP_PULSE_LENGTH_ADD)=32 + 0x40 + 0x80 	// set the pulse time to ~ 2μs, mux to JP4 and JP6, and pulse the Step High

## Example Configuration for a IM804 Amplifier and Rapidsyn Stepper

## Layout - KMotion - Amplifier - Motor

Amplifier Connections - resistors set coil currents (1500 ohms = 3A) and idle standby current (270 ohms = 0.5A). DIP Switches set to ON-OFF-OFF-ON for 128:1 micro-stepping.

Rapidsyn stepper motor. Note coil winding's centertaps are not used.

Axis channel 0 configures as "Step Dir" mode and using Step and Direction generator 0.

Max Velocity 1.6 x 106 steps/sec (1.6e6 / 128 = 12,500 sps = 3750 RPM). Note this (and most) steppers lose most all of their useful torque above several thousand full steps per second. The high speed demonstrated here is intended to demonstrate KMotion's ability to generate high pulse rates.

Max Acceleration 6 x 106 steps/sec2.

Max Jerk 2 x 108 steps/sec3.

1 x 106 count Move performed and data captured over 3 seconds.

Pushing Move downloads all parameters, enables the axis, performs the movement, and plots the result.

Note after the axis has been enabled, digital IO bits 8 and 9 have automatically been configured as outputs for use by Step and Direction Generator #0.

Watch a video showing slow and smooth acceleration of this configuration up to 12,500 full steps per second (1.6 MHz @ 128 microsteps/full step).