AutomateDirectUSAMotion LibraryIndustrial monitors & PCs

How-to

Homing an Absolute Encoder Axis to a Reference Sensor

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

Short answer

Homing an absolute encoder axis to a reference sensor is two steps: a controlled search move that captures the axis position at the sensor transition, then a relative encoder adjustment whose correction is the reference position minus the captured value. For a zero reference at the sensor, that correction is the negative of the captured position, and the stopped coordinate after the search does not need to be zero.

On this page
  1. What does homing an absolute encoder axis actually do?
  2. Why does MC_Home Mode 7 alone not find the sensor?
  3. Which motion blocks run the reference search?
  4. How do I set the search direction and search velocity?
  5. Which sensor edge becomes machine zero?
  6. How do I calculate the offset from the captured position?
  7. Why is the stopped coordinate not zero after homing?
  8. What bounds the search if the sensor never triggers?
  9. Questions asked

Pressing a button on the HMI and having the axis drive itself to the reference sensor, stop, and call that point machine zero takes two steps you write in the PLC program. First the axis runs a controlled search move: MC_MoveVelocity drives it toward the sensor, the controller captures the actual position at the sensor transition, and MC_Halt brings it to a standstill. Then a relative absolute encoder adjustment, MC_Home with Mode = 6, applies the offset calculated as reference position minus captured measured value — for a zero reference at the sensor, the negative of the captured value. The Mode = 7 adjustment that works after a manual jog is the manual variant of that second step; it sets the origin wherever the axis happens to stand, which is why the automatic search has to be its own sequence.

What does homing an absolute encoder axis actually do? #

Homing an absolute encoder axis writes the relationship between the encoder's own coordinate system and the machine's, so the offset you calculate turns every encoder reading into a machine coordinate anchored at the reference sensor.

An absolute encoder reports a coordinate immediately at power-up, without recounting from a reference mark. That reading still lives in the encoder's own frame, and for an absolute encoder the reference to the axis is established once, at initial commissioning, then rewritten whenever the origin moves. The sensor defines machine zero; the offset is what translates the encoder reading into machine coordinates.

Homing therefore splits into a motion problem and a coordinate problem. The motion problem — bringing the axis to the sensor under power, without a hand on the shaft — is done with ordinary motion instructions. The coordinate problem — deciding what number the controller displays at that spot — is done with the encoder adjustment. Mode = 7 solves only the second, after you have solved the first by jogging. An incremental axis faces a different job altogether, because it must re-find a reference mark after every power-up; that sequence is the subject of Homing an Incremental Encoder Axis Without a Proximity Switch.

Why does MC_Home Mode 7 alone not find the sensor? #

MC_Home with Mode = 7 is the manual absolute-encoder adjustment: it writes the offset at whatever position the axis already sits at and never commands motion, so it sets the origin after your manual jog but cannot run the sensor search you want.

MC_Home writes coordinates in every mode. Mode = 7 takes the axis position as it stands and corrects the offset there — the button pressed today after jogging to the plate by hand. What the manual jog silently supplies is an axis standing at a known spot relative to the sensor, and the automatic version has to supply that itself.

The traveling is motion-block work: MC_MoveVelocity drives, the capture latches the position, MC_Halt stops, and only then does MC_Home run again in its relative form, Mode = 6, which shifts the current coordinate by the Position value it is given. The block names are the PLCopen motion vocabulary, so the sequence reads the same on most motion controllers, but the mode numbering belongs to each vendor's instruction help — read the entry for the installed version instead of picking a mode by its name.

The search is ordinary position-controlled motion, not a homing mode: MC_MoveVelocity drives the axis toward the sensor, the first sensor transition is captured once, MC_Halt brings the axis to a standstill, and only then does the adjustment run.

The whole sequence, in order:

  1. Confirm readiness: the axis is enabled, no other motion command is active, and the sensor input reads its configured inactive state with the plate clear of the sensing zone.
  2. Start the search: call MC_MoveVelocity with the search velocity and the direction that approaches the sensor — negative in the machine this sequence is written for.
  3. Capture once: on the first sensor transition, latch the event and save the actual position as the measured value, so a held level or contact chatter cannot overwrite it while the axis brakes.
  4. Stop: command MC_Halt, which per its documentation brakes the axis to a standstill with the configured deceleration, and wait for the standstill confirmation before the next step.
  5. Adjust: run MC_Home with Mode = 6 and the calculated correction at the Position input.
  6. Return if needed: when the process wants the axis physically standing at machine zero, run an ordinary absolute positioning move to zero after the adjustment is done.

One commissioning note before the first automatic search: clear the travel path, confirm the limit switches are active, and keep the search slow enough to stop inside the remaining travel; the machine's risk assessment governs how commissioning moves are safeguarded.

How do I set the search direction and search velocity? #

Start the search at a slow, controlled velocity, for example 20 mm/s on a machine axis with millimeter units, because the velocity decides how far the axis coasts past the transition before deceleration and how much capture delay costs you.

Set the direction in the axis configuration first: the Absolute homing direction setting of the homing configuration defines the travel direction the sequence uses, and the instruction help for the installed version documents its values. Then verify it physically, because a direction that is wrong in software is wrong at speed. Jog a short move in the intended search direction and read the actual position: on a negative search it must decrease. If it increases, correct the direction or the feedback polarity before any automatic search — an automatic move that travels away from the sensor only ends up at a limit switch.

The velocity sets the repeatability budget. Every millisecond between the physical transition and the capture costs velocity × time: at 20 mm/s, 10 ms of input filter, scan time and task time together is 20 mm/s × 0.010 s = 0.2 mm of error in the captured value. Slow the search until that budget fits the machine's tolerance, and size the search velocity against the stopping distance the configured deceleration needs, not against cycle time.

Which sensor edge becomes machine zero? #

Pick one edge and write it down: the transition made when the target plate enters the sensing zone is normally the reference, whichever level change that is in the wiring, because the entering and leaving transitions sit at different physical positions and cannot stand in for each other.

Test the sensor path before any motion logic runs. With the plate clear, the input must read its configured inactive state; if it sits active, the polarity, wiring, plate position or input assignment is wrong, and no sequence can rescue an ambiguous input. With the plate in the sensing zone, the input must show one clean, repeatable transition; no transition means a sensor, wiring or clearance problem to fix first.

One rule keeps the origin honest: if the input is already active when the sequence starts, do not treat that level as the event. Drive a defined clearance move away from the sensor and approach fresh, or abort with a fault — an origin taken from a level the axis was already sitting in is not a position.

How do I calculate the offset from the captured position? #

The offset is reference position minus measured value, so with a zero reference at the sensor and a transition captured at −325.0 mm, the correction is +325.0 mm, applied with MC_Home Mode = 6.

Worked example, in millimeter units, for a negative search and a zero reference at the entering edge — example inputs and a calculated result for those inputs, not a measured result:

  • Reference position: 0.0 mm, defined at the sensor's entering edge.
  • Captured measured value: −325.0 mm, the actual position latched at the transition.
  • Correction = reference position − measured value = 0.0 mm − (−325.0 mm) = +325.0 mm.
  • Apply MC_Home with Mode = 6 and Position = +325.0 mm, after MC_Halt has confirmed standstill.

After the adjustment, the coordinate at the sensor location reads 0.0 mm and the axis counts as referenced; every coordinate the controller reports from then on is a machine coordinate.

Why is the stopped coordinate not zero after homing? #

The stopped coordinate after adjustment is the distance the axis traveled past the sensor while decelerating, not an error: in the running example the axis stops 15.0 mm beyond the reference and the controller correctly shows −15.0 mm there.

MC_Halt decelerates along the configured ramp, so the axis keeps moving while it brakes, and the stopping point lands wherever the search velocity and the deceleration put it. In the running example it stops at −340.0 mm raw, and after the Mode = 6 adjustment the controller displays −340.0 mm + 325.0 mm = −15.0 mm at that spot — 15.0 mm past the sensor edge, exactly what it should show. Forcing the stopped coordinate to zero would assign machine zero to wherever the ramp happened to end instead of to the sensor.

If the process needs the axis physically standing at zero, follow the adjustment with an ordinary absolute move to zero; the axis is referenced, so a normal positioning command now lands correctly. The stored offset is retained from then on. When that adjustment is instead gone at the next power-up, that is its own fault, covered in Why MC_Home Absolute Encoder Adjustment Is Lost After Power Cycle.

What bounds the search if the sensor never triggers? #

Bound the search with a travel distance or a time limit computed from the machine geometry, for example 700.0 mm of travel on an axis with 900.0 mm of usable stroke, and if the sensor never triggers, stop, keep the previous offset, and report a failed search.

Those two numbers are an illustration: the real bound comes from the usable stroke, the stopping distance at the search velocity, and the lag from capture to standstill, with a margin kept below the soft limits. What the bound must guarantee is that it trips before a mechanical limit does. When it trips, stop the axis, leave the previously stored offset untouched so the axis keeps its last valid coordinate relationship, and report the fault with what matters: distance traveled, search direction, and the sensor state at abort.

Handle the trigger as a request, not a level. One press of the button starts one search-and-adjust sequence; a request that arrives while the sequence runs is ignored until it finishes or aborts. Before the process logic starts trusting the axis coordinate, it checks the done status of the adjustment — the same discipline as waiting for a jog to finish before starting a cycle.

Questions asked

Does an absolute encoder axis need homing again after every power-up?

No. Once the offset from the adjustment is stored, the encoder reports its position directly at every power-up and the axis coordinate is valid immediately. Re-referencing is only needed after mechanical changes to the axis, encoder replacement, or when the stored adjustment has actually been lost — which is a fault to diagnose, not a routine step.

Does a drive-side hardware capture change the sequence?

No. The search move, the stop and the Mode = 6 adjustment stay exactly as described; only the capture step takes its position from the drive's timestamped input instead of a PLC scan. The captured coordinate becomes more repeatable because the input filter, scan and task delays drop out of the measurement, which matters most at higher search velocities.

What if machine zero is not at the sensor edge?

The formula stays the same and only the reference position changes. If machine zero sits 5.0 mm positive of the sensor's entering edge, for example, the correction is 5.0 mm − (−325.0 mm) = +330.0 mm, applied with the same Mode = 6 relative adjustment; the measured value still comes from the same latched transition.

Why is my MC_MoveVelocity search move rejected before it starts?

Read the command diagnostics before changing the sequence. A rejection usually means the axis is not enabled, another motion command is still active, or an interlock in the logic blocks new motion. Repeatedly calling the homing instruction will not clear an unrelated interlock: the search and the adjustment are separate commands, and each needs its own readiness conditions met.

Keep reading

  • Troubleshooting

    Why MC_Home Absolute Encoder Adjustment Is Lost After Power Cycle

    The MC_Home offset is stored retentively in the CPU technology object, not in the encoder, so it survives a power cycle only when the TO encoder type is Absolute, MC_Home reported Done = TRUE, and nothing cleared retentive memory in between. Mode 6 is relative, so Position = 0.0 correctly changes nothing; use Mode 7 for an absolute adjustment.

    Servo and stepper motion

  • How-to

    Homing an Incremental Encoder Axis Without a Proximity Switch

    Home once after each power-up, then re-home after any slip, fault, or unpowered movement. Without a proximity switch, retract to the negative stop under a torque limit as the coarse reference, arm the home with the Z index trigger, and creep forward until the latch; without a Z channel, set the position at the verified stop.

    Servo and stepper motion

  • Troubleshooting

    Fixing a grid align error after a servo motor rebuild

    The zero-return switch made, but the control finished its alignment move without seeing the encoder's marker pulse. Verify the encoder connector, cable and the Index Invert A and Index Invert B fields first; if those are right, loosen the motor coupling, rotate the motor 180 degrees on the ballscrew and re-home — the documented field fix that clears the alarm when the marker sits outside the alignment move.

    Servo and stepper motion