HMI stepper preset positions: separate jog, teach and run

8 min read · Published November 7, 2026

Jog, teach and preset run are three different jobs, so give the stepper axis three PLC states and home before any move. The HMI writes only a slot number from 1 to 16 and requests actions, while the PLC resolves the slot to its retained position and runs one fixed trapezoidal profile in which only the target position changes.

Give the axis three states and the panel gets simple. Jog, teach and preset run are different jobs with different rules, and the PLC owns all three. The HMI's role stays small: it writes a slot number from 1 to 16, it requests jog, store or run, and it shows where the machine stands. On the motion side, home first, refuse every move until a homed flag is set, and run every preset with one fixed velocity profile, changing only the target position. This page sets that structure up for a stepper slide with two travel limit switches, one of which serves as home, and 16 nonnegative taught positions.

One key, two meanings, one owner

The quick way to wire this machine is also the way that misfires: patch the Up and Down key bits straight to motion commands and reuse Enter for a stored move. The keys mean different things in different states. In idle, Up and Down scroll through 16 text lines. In jog, the same keys move the tool. Enter starts a preset run from idle and does nothing in any other state. When the PLC owns the state machine, each key press carries exactly one meaning, and a stale bit cannot start motion.

The same split applies to the numbers. Line 7 on the screen is an index, a place in a list. The distance for slot 7 lives in a separate retained word that only a teach action writes. The run logic resolves index to position when Enter is pressed, and normal running never writes the position words.

State Operator action PLC task
Idle Scroll Up and Down to a line, press Enter Hold the index, refuse a run while the homed flag is clear
Jog Hold Up or Down Pulse the chosen direction at jog speed, stop on release or at a limit
Teach Jog to the spot, press Store Copy the current position into the indexed slot, set its validity flag
Run Press Enter once Resolve the slot to its position, run the fixed profile, wait for in-position

What you need

  • A PLC with a pulse output block on two transistor outputs. The running example uses pulses on Y0, direction on Y1, and the pulse block in Mode 30 for one-axis pulse-and-direction operation. A mechanical relay cannot switch a pulse train, so the pulse line goes to a transistor output.
  • A stepper drive with step and direction inputs, microstepping set once and left at that value. The example drive: 8 microsteps per step on a 200 steps-per-revolution motor, which gives 1600 pulses per revolution.
  • Two travel limit switches on inputs; the switch at the negative end doubles as home.
  • A text panel with Up, Down and Enter keys, plus a Store key or a mode selector that puts the panel in teach.
  • Retained memory for 16 position words, 16 validity flag bits, a homed flag and a state number.

Set the pulse scale first

Every position on this machine is a pulse count, so work out one conversion before any logic: pulses per millimetre equals pulses per revolution divided by millimetres per revolution. The example drive gives 1600 / 5 mm = 320 pulses/mm on a 5 mm lead screw. Jog speed, homing speed, every taught position and every limit check come out of that one number, so a scale off by a factor makes every slot wrong by the same factor. Home sits at 0 and every target is a positive distance from it, which is why the 16 positions never go negative.

Build the states in the PLC

  1. Clamp the selection. The panel writes a slot number into an index word, and the logic rejects anything outside 1 to 16 before the value reaches any decision. The clamp pattern used to bound HMI numeric entry limits in PLC ladder logic is exactly this, with 1 and 16 as the bounds.
  2. Home before anything moves. On a home request, drive away from the home switch until it clears, then creep back at 1 mm/s and stop at its edge. Zero the position register, set the homed flag and return to idle. Jog, teach and run are refused while the flag is clear, so a machine stopped mid-travel after a power cut cannot start until the axis has a reference.
  3. Jog only in jog. A held Up or Down key pulses the axis at 2 mm/s in that direction. Motion stops on key release, on a state change or at a limit. Block both keys together, and enforce HMI increment and decrement value limits in PLC logic here too, so a jog past a limit is impossible however many repeats the panel sends.
  4. Teach as a one-shot write. Store is accepted only when the axis is stopped and homed. One press copies the current position into the slot the index selects and sets that slot's validity flag. Nothing else in the program writes the position words.
  5. Run from idle only. Enter is a one-shot accepted from idle. The PLC checks the homed flag, the slot's validity flag and the target against travel, then starts the positioning operation with the fixed velocity set: one starting velocity, one target velocity, one accel/decel time and one ending velocity. Only the target position changes between slots, and the automatic trapezoidal profile handles accelerate, cruise and decelerate. The run state waits for in-position before returning to idle, and idle demands a fresh press, so a held or latched Enter cannot restart a move. If the positioning operation refuses to start, check those conditions first; the diagnosis of a stepper advanced function block that will not enable starts in the same place.
  6. Latch a limit trip. A trip stops motion toward that switch and blocks that direction until an operator jogs clear and resets. That is the validated recovery and safe states pattern for motion faults: return the machine to a defined state, under control, before production resumes.
  7. Keep the taught table in retained memory. Put the 16 positions and 16 flags in the retained data range the PLC manual defines, then power-cycle the machine and confirm every value survives. A slot that reads 0 after a restart points at the write path or the memory area, the same mechanism behind an HMI timer preset that resets to zero in the PLC.

Show the state on the panel

Give the panel a state line and the operator stops guessing: IDLE, JOG, TEACH, RUN or NOT HOMED. Print each text line with its slot number and taught value, such as "12: 37.5 mm", and show an untaught slot as "12: not taught" until its flag is set. The panel mirrors a state number the PLC publishes, the way PLC-driven HMI graphics represent equipment states, and the PLC stays the only writer.

Example: slot 12 at 37.5 mm

Take the running example through one move. The scale is 1600 pulses per revolution on a 5 mm lead screw, so 1600 / 5 = 320 pulses/mm. Slot 12 was taught with the tool at 37.5 mm, so the retained target is 37.5 × 320 = 12,000 pulses.

The fixed profile: starting velocity 4 mm/s (1280 pulses/s), target velocity 40 mm/s (12,800 pulses/s), accel 0.25 s, decel 0.25 s, ending velocity 4 mm/s. The peak rate of 12.8 kHz sits far below the 100 kHz that transistor pulse outputs are typically rated for.

Acceleration from 4 to 40 mm/s over 0.25 s averages 22 mm/s and covers (4 + 40) / 2 × 0.25 s = 5.5 mm. Deceleration covers the same 5.5 mm, down to 4 mm/s. Cruise covers 37.5 - 5.5 - 5.5 = 26.5 mm, which takes 26.5 / 40 = 0.6625 s at 40 mm/s. The whole move takes 0.25 + 0.6625 + 0.25 = 1.1625 s, about 1.16 s.

The operator scrolls to line 12 and presses Enter once. The PLC resolves index 12 to 12,000 pulses, confirms the homed flag and the slot flag, runs the profile and holds the panel in RUN until in-position. Scrolling or renaming the lines changes no target; only a Store press in teach rewrites 37.5 mm.

How to check it worked

Commission at reduced speed with hands and tools clear of the slide; a reversed direction sign or a doubled scale drives a taught position into hardware fast.

  • Command a short positive move and watch the slide travel away from home. A reversed direction sign shows here, before any taught value exists.
  • From home, command 3200 pulses and measure the travel. At 320 pulses/mm the slide must sit at exactly 10 mm.
  • Release a jog key mid-move and confirm the axis stops. Press Up and Down together and confirm nothing moves.
  • Trip each limit during jog and during a run. Motion toward the tripped switch stops, that direction stays blocked until a controlled jog clears it, and the other direction still works.
  • Run the homing sequence five times. The position register reads 0 every time and the mechanical stop lands on the same spot.
  • Teach slot 1 at 0 mm and slot 16 near the far limit, then run both. Slot 1 and the last slot are the two that break first.
  • Hold Enter through an entire run and confirm exactly one move starts.
  • Select an untaught slot and press Enter. The run is refused and the panel shows not taught.
  • Cycle power and re-read all 16 positions and flags.

The decision

Recommendation: run jog, teach and preset move as three separate PLC states, accept Enter only from idle, gate every motion on the homed flag, and store the 16 positions with their validity flags in retained memory while the panel keeps to an index, requests and status. That structure carries the application as specified: fixed starting velocity, target velocity, accel/decel time and ending velocity, one automatic trapezoidal profile, nonnegative targets, two travel limits with home on the negative switch, 16 slots. If the axis later grows a second motor, queued targets or an absolute encoder, move up to the positioning instructions the PLC documents and keep the same state split.

If the cell also needs a standalone board for shift counts, andon status or notices, that job belongs to shop-floor signage displays built for the floor, not to the machine's text panel.

Questions

Can a taught slot hold position 0?

Yes. Home is position 0, so a slot taught at the home switch is a real position. Give each slot a validity flag in its own bit and never let the value 0 or an empty register mean untaught: the run logic tests the flag first, then reads the value. Sixteen slots need 16 retained position words and 16 flag bits.

Why do taught positions come back as zeros after a power cut?

The teach routine wrote into a volatile area. Move the 16 positions and flags into the retained data range the PLC manual defines and repeat the power-cycle test. If values still vanish, check the write path: a store action aimed at the wrong address, or a value overwritten every scan, produces the same symptom as a preset that resets to zero in the PLC.

How do I extend the setup past 16 positions?

Scale three things together: the retained table, the index clamp and the scroll lines on the panel. Thirty-two slots need 32 position words and 32 validity flags, and the clamp range becomes 1 to 32. The state machine itself, homing, jog, teach and run, stays unchanged.

Should the axis home at every start-up?

Pick one rule and hold to it. Auto-homing at start-up suits a slide that always parks between its limits. A request-based home suits an axis that may be left sitting on the home switch, where the sequence must drive clear first and creep back. Either way the homed flag gates jog, teach and run, so no move starts without a reference.

Planning information, not legal or engineering advice. Rules differ by place: check codes and permits with your local authority and your licensed trades.

Keep reading

Build your signAsk for a quote