AutomateDirectUSAMotion LibraryIndustrial monitors & PCs

How-to

Stepper rail binary position selection: one writer, all bits

Servo and stepper motion Published 6 min read By AutomateDirectUSA engineering team

Short answer

Five digital inputs, read as a binary address, select any of 32 stored positions on the drive. The reliable way to run this from a robot controller is a single continuously running thread that owns the five selection outputs, writes the complete bit pattern for every selection, and leaves each profile's next field blank so the drive never chains to a move the program did not request.

On this page
  1. Why binary mode and not Modbus
  2. Give one thread exclusive ownership of the outputs
  3. Map request numbers to bit patterns deliberately
  4. Leave the next field blank and time the acceptance
  5. Worked example: two positions in a UR-style thread
  6. Checklist before you run it
  7. Questions asked

Five digital inputs, read by the stepper drive as a five-bit binary address, are enough to select any of 32 stored positions from a robot controller while the robot keeps moving through its waypoints. The two things that make it work reliably are output ownership and complete bit writes: one routine, and only one, ever touches the five selection outputs, and it writes all five bits on every selection, never just the ones that change. Get either of those wrong and the drive executes an address nobody requested.

Why binary mode and not Modbus #

The drive offers digital inputs and outputs, analogue inputs, CANopen and ModbusTCP, and with the digital interface the operating manual's Drive Profile page is where you select Binary from the drop-down. For a fixed set of stored travels, binary mode wins: the robot program does nothing but drive five outputs, and every position, speed, acceleration and deceleration lives in the drive's own profile table, entered through its web interface. Tip/Teach mode runs on the same inputs but exposes fewer stored positions, which is usually the reason to leave it.

ModbusTCP remains the right choice when the application later needs live position targets, jogging or status data the digital interface does not carry. Switching protocols to obtain a handful of fixed moves is unnecessary work; the binary interface already addresses 32 profiles.

This is the same division of labour as running a stepper axis from a controller's pulse outputs, covered in the article on running a stepper conveyor from a PLC pulse output (article:running-a-stepper-conveyor-from-a-plc-pulse-output): the controller issues simple commands, the drive holds the motion parameters.

Give one thread exclusive ownership of the outputs #

The failure mode that bites this setup is two writers. If a subroutine in the main program sets DI1 while a background thread sets DI3 through DI5, the electrical address during and after the writes can be a mixture of both intentions, and the drive accepts whatever address it sees when it accepts the command.

The fix is structural. Create a continuously running thread on the robot controller that contains a case statement driven by a variable such as Position_select. Every routine in the program requests a position by assigning that variable, for example Position_select := 1, and never touches the outputs directly. The thread is the only code that writes the five outputs.

A snapshot of the selection variable at the top of each pass also matters. Reading Position_select once into a local variable such as switch_1 means each pass evaluates one consistent value even if the main program changes the request mid-pass.

Map request numbers to bit patterns deliberately #

Five independent bits give 2 to the power 5, which is 32 addresses. Drive-side inputs are labelled DI1 through DI5, and the decimal address each pattern produces depends on which input carries which binary weight, so read the drive's binary selection table and confirm the bit order before writing the mapping. The robot's request numbers do not have to equal the binary values: request 1 can legitimately be the all-low pattern.

Request DI5 DI4 DI3 DI2 DI1 Decimal address if DI1 is weight 1
1 False False False False False 0
2 False False False False True 1
other profile True False True True False 13

The all-low address selects whatever profile is stored at address 0. That profile might travel to a home coordinate, or it might perform a reference-seeking move; those are different operations, and the profile table, not the bit pattern, decides which. Verify what each address selects before wiring the request numbers into production code.

Leave the next field blank and time the acceptance #

Two drive-side configuration points decide whether the rail goes where the program asked and stops there.

First, the chaining field. Each travel profile has a next entry that names the profile to run afterwards. For individually requested moves, leave next blank. A filled-in field makes the drive chain into another travel as soon as the first completes, which looks exactly like a wrong selection from the robot's side.

Second, command acceptance. Writing five outputs one at a time means the electrical address passes through intermediate patterns for a few milliseconds. What counts is the address present at the moment the drive accepts the request, and the binary mode documentation for the drive states whether that acceptance follows a selection change or a separate start input. Sequence the writes so the settled pattern is in place before the drive can accept; if the drive uses a separate start input, strobe it only after the last bit is written.

Address selection and motion completion are separate events as well. The robot needs its own arrival decision, from a drive output, a fieldbus bit or a physical sensor on the rail, before any action that depends on the rail being there.

Worked example: two positions in a UR-style thread #

Inputs: the rail drive is in Binary mode with selection inputs DI1 through DI5; robot outputs 1 through 5 are wired to DI1 through DI5 respectively, which you must confirm against the actual wiring and the controller's output numbering; the application defines position 1 as home with all selection inputs low and position 2 with only DI1 high, giving decimal address 1. Both profiles have next blank. The thread runs continuously and Position_select is an integer written only by the main program.

The rule: one case per valid request, and every case writes all five outputs, high or low.

switch_1 = Position_select
if (1 == switch_1):
    # Position 1: all selection inputs low, address 0
    set_digital_out(5,False)
    set_digital_out(4,False)
    set_digital_out(3,False)
    set_digital_out(2,False)
    set_digital_out(1,False)
elif (2 == switch_1):
    # Position 2: DI1 high, address 1
    set_digital_out(5,False)
    set_digital_out(4,False)
    set_digital_out(3,False)
    set_digital_out(2,False)
    set_digital_out(1,True)
end
sync()

The result: with the main program assigning Position_select := 1 or := 2, the thread presents the matching settled address and the drive moves to the corresponding stored profile, with no other routine able to corrupt the bits. The sync() call yields the thread so the controller can schedule other work; it is a scheduling point, not a drive acknowledgement and not a motion-complete signal.

The decision for each case: single-writer binary selection with full five-bit writes whenever the moves are a fixed set of stored travels; ModbusTCP only when the program must change position targets live; and if an axis misbehaves at drive power-up before the robot software has loaded anything, that is a different failure, covered in the article on a stepper axis running at drive power-up before software loads (article:a-stepper-axis-running-at-drive-power-up-before-software-loads).

One safety note: this wiring puts a driven axis under software control with no hard stop of its own, so the rail still needs its guard, its risk assessment and the drive's own limit switches per the machine's applicable safety requirements before anyone works inside its reach.

Checklist before you run it #

  1. Drive is in Binary mode on its Drive Profile page, and you have read the binary table for the actual bit order.
  2. Exactly one thread writes the five selection outputs; no other routine touches them.
  3. Every case writes all five bits, high and low.
  4. Each profile's next field is blank.
  5. You know from the drive documentation whether acceptance follows a selection change or a separate start input.
  6. A separate motion-complete signal exists for anything downstream that depends on rail position.
  7. Robot output numbering matches the physical wiring to DI1 through DI5, verified at the terminals, not assumed from the channel numbers.

Questions asked

Do I need Modbus to select stored positions on the drive?

No. Binary mode over digital inputs already addresses up to 32 stored profiles with five bits, and it needs no communications stack in the robot program. ModbusTCP is worth the extra work only when the application needs functions the digital interface does not offer, such as live position targets or extensive status feedback beyond move complete.

What happens if I leave a selection output in its old state?

The drive reads the old bit as part of the new address. For example, moving from the pattern with only DI1 high to the all-low pattern while DI1 stays high leaves an unintended address latched. Writing all five outputs in every case, high or low, removes this failure entirely.

How many positions does five-bit selection give me, and can I extend it?

Five bits give 2 to the power 5, which is 32 distinct addresses and therefore up to 32 stored profiles. Six bits would give 64 and eight bits 256, but only if the drive exposes that many selection inputs in its binary mode. Check the drive's binary table for the inputs it actually assigns before planning beyond 32.

Why did the rail move to a second position right after the first one?

The first profile most likely has an entry in its next field, so the drive chains into that travel profile after finishing the first. Blank the next field of every profile the robot selects individually, and the drive will hold position until the program presents a new address.

Does writing the address bits start the motion?

Not necessarily. Address selection and command acceptance are separate events: the drive decides when to accept a request, whether on a selection change or on a separate start input, and the manual's binary mode section states which. Until acceptance, an intermediate bit pattern during the write is harmless; after acceptance, only the settled address counts.

Keep reading

  • Troubleshooting

    Why a Stepper Axis Runs at Drive Power-Up Before Software Loads

    Motion that starts when drive power arrives and stops when the drive trips its own position error is an enable-sequencing fault, not replayed motion: until the controller configures its outputs, pulse inputs float and noise can be counted as steps. Route every servo-on circuit through one controller-controlled relay, keep it off until initialization finishes, then energize the enable relay, and run a StatusRequestCounter watchdog so closing the PC software also disables the drives. The reported machine went from roughly one runaway in ten starts to none.

    Servo and stepper motion

  • Troubleshooting

    Why an EtherCAT CSP Stepper Axis Enables but Does Not Move

    Holding torque on Servo On proves only that the power stage energizes the windings. In cyclic synchronous position mode the axis moves only when the drive accepts each new 0x607A target and no internal limit refuses it, so check Statusword bit 11 first, then the drive's speed, current and software position limits, then the position unit scaling between controller and drive.

    Servo and stepper motion

  • Troubleshooting

    Why a Closed Loop Stepper Will Not Move Above 200 kHz

    The axis sits dead because the kernel exceeds the drive's documented step input limit, making each high or low state narrower than the input can latch. Set the kernel to half the ceiling, derive steps per mm from the drive's command resolution divided by the screw's travel per revolution, and verify the encoder A-channel polarity at the drive terminals.

    Servo and stepper motion