AutomateDirectUSAMotion LibraryIndustrial monitors & PCs

Explainer

Why an external encoder drives a servo through cyclic position targets

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

Short answer

Wire the external encoder to the counter inputs of the X20DMF320, read the one cyclic INT count the module exposes, scale it into a position target, and stream it to the ACOPOS P3 every cycle with MC_BR_MoveCyclicPosition. The encoder stays a reference, the drive closes its loop on its own motor encoder, and the target stream must stay jump-free. Capture event positions with the counter's latch, not with polled input bits.

On this page
  1. The path from encoder to axis
  2. One INT count, not three phase words
  3. Setting up the counter on the X20DMF320
  4. Scaling the count into a target
  5. Streaming it with MC_BR_MoveCyclicPosition
  6. Scaling 8192 counts to a 10.00 mm target
  7. Capturing positions with the latch
  8. Reference or closing feedback
  9. Questions asked

An external encoder drives a servo axis as a reference, not as feedback, and the bridge between them is a cyclic target. The encoder lands on the ABR counter inputs of the X20DMF320, whose counting electronics total the edges between fieldbus cycles and expose one INT count in the I/O mapping. Your PLC scales that count into a position target and hands it to the ACOPOS P3 every cycle with MC_BR_MoveCyclicPosition, which switches the axis into cyclic position setting mode. The drive keeps closing its position loop on its own motor encoder; the external encoder only steers the target. When a position has to be captured at an event, the counter's latch does it in hardware, because the mapped input bits refresh only once per fieldbus cycle.

The path from encoder to axis #

The chain has four links and each does exactly one job. The encoder's A, B and Z (R) signals go to the counter inputs of the X20DMF320 on pins 1, 3 and 5. The module counts in its own electronics and publishes one cyclic data point: the ABR counter value in INT format. The PLC reads it, applies your math, and streams the result to the drive with MC_BR_MoveCyclicPosition; from then on the axis executes whatever target arrives each cycle. The module can also expose those same pins in two other forms, and the three are not interchangeable:

What the module exposes How it behaves Use it for
ABR counter value one cyclic INT data point, counted in hardware between bus cycles the source value you scale into a target
Digital input bits on the same pins bits refreshed once per fieldbus cycle slow status checks and wiring diagnostics
Latch value a separate data point written when the configured event occurs stamping a position at a defined moment

One INT count, not three phase words #

There is no array of high-speed A, B and Z values waiting to be mapped. Configure an array and you get the digital-input bits, which update once per fieldbus cycle: a strobe snapshot of signals toggling thousands of times faster, useless for counting or position. The counting belongs in the module's electronics, between bus cycles, and the INT total is the only high-speed result the ABR counter hands over. The same refresh-interval trap, seen from the PLC side, is why a counter card skips encoder pulses between PLC updates. The INT type itself is fixed by IEC 61131-3 as a 16-bit signed whole number, so the raw value spans -32768 to +32767 and wraps; remember that when you scale.

Setting up the counter on the X20DMF320 #

  1. Match the encoder electrically before plugging anything in; the single-ended-versus-differential and signal-level questions are covered in matching an incremental encoder to a PLC high speed counter.
  2. Wire A, B and Z (R) to the module's ABR inputs, pins 1, 3 and 5.
  3. In Automation Studio, open the module configuration and enable the counter with ABR evaluation; the counter registers are documented in the X20DMF320 hardware documentation. Set the edge evaluation deliberately: the counts-per-revolution your scaling assumes must be the one the module actually applies.
  4. Look at the I/O mapping: one cyclic data point now carries the counter value. Map it into the PLC application.
  5. Verify direction with the drive disabled: turn the encoder by hand in the machine's defined positive direction and confirm the count grows. If it shrinks, fix it in one place, either by swapping A and B at the terminal or by changing the evaluation, never both.
  6. Other PLC platforms walk the same path in different software; configuring a CP1H high-speed counter for an encoder input shows the outline on one of them.

Scaling the count into a target #

State the rule before coding it: revolutions equal counts divided by counts per revolution, and the target equals revolutions times travel per revolution. Counts per revolution come from the encoder's pulse rating times the evaluation factor; quadrature x4 gives four counts per pulse. Travel per revolution comes from whatever the encoder rides on: a screw lead, a pinion's pitch circumference, a measuring wheel's circumference. Add a fixed offset if the machine zero and the counter zero differ. And unwrap the INT window first: when the raw count jumps by roughly 65536 between two cycles, a wrap occurred, and a revolution offset you maintain yourself absorbs it. Any other value the PLC already holds may feed the calculation alongside the count; the cyclic target does not care where the math came from, only that the result is continuous.

Streaming it with MC_BR_MoveCyclicPosition #

This block switches the axis to cyclic position setting mode and initializes the movement parameters connected to it; every call after that delivers a fresh target. Two rules from the general documentation for PLCopen-style MC blocks apply directly: call the block cyclically, because a target only takes effect when the block executes, and treat the position input as a value in the axis coordinate system, so scaling errors move real metal.

The stream has one hard requirement: jump-free and matched to the drive's dynamics. Between two calls the target may advance no more than the axis can actually travel, so velocity limit times cycle time is the ceiling on each step. Start with the first target equal to the axis's current position, or the mode switch itself is a step. Run the sign and scaling checks with the axis disabled, and make the first tracked moves at a reduced velocity limit behind the closed guard: an axis that now moves whenever the master moves is a hazard your machine's risk assessment under ISO 12100 must record.

Scaling 8192 counts to a 10.00 mm target #

Inputs, with their sources. These are example values standing in for your encoder datasheet, your mechanics and your own counter reading; the result is a calculated example, not a measurement:

  • Encoder resolution: 1024 pulses per revolution, an example datasheet value.
  • Evaluation: quadrature x4, as configured in the counter.
  • Mechanics: encoder rigidly coupled to a lead screw with 5 mm of travel per revolution, an example.
  • Count read this cycle: 8192 counts, an example reading from the mapped data point.
  • Tracking speed 250 mm/s at a 2 ms PLC cycle, example settings for the continuity check.

The rule, in words: counts per revolution equal pulses per revolution times the evaluation factor; revolutions equal counts divided by counts per revolution; the target equals revolutions times travel per revolution; the per-call step equals speed times cycle time.

The arithmetic:

  • 1024 pulses/rev x 4 = 4096 counts/rev
  • 8192 counts / 4096 counts/rev = 2.000 rev
  • 2.000 rev x 5 mm/rev = 10.00 mm
  • 250 mm/s x 0.002 s = 0.50 mm per call
  • wrap horizon: 32767 counts / 4096 counts/rev, about 8.0 rev before the INT window ends

Result: this cycle's call carries a target of 10.00 mm, advancing 0.50 mm per call.

Decision: send it and keep streaming. The per-call step sits at or below velocity limit times cycle time for any axis limited above 250 mm/s, so the stream is followable. If the master can outrun the axis, put a slew-rate limit between the scaler and the block. And keep the unwrap in place: at these counts one missed rollover throws the target by 65536 counts, 16.0 rev, an 80 mm step, and the following-error monitoring stops the axis.

Capturing positions with the latch #

A mark sensor, an index pulse, a product arriving: anything that must stamp a position does it through the latch. Latch mode copies the current counter value into a separate data point the moment the configured event occurs; the module's latch registers define which channel and which level triggers the copy. The documented pattern is a positive edge on the Z (R) signal copying the count into the latch data point, a once-per-revolution stamp with no fieldbus delay because the copy runs in the module's electronics. Poll the same signal as a mapped input bit instead, and the stamp is late by up to one fieldbus cycle of travel. Verify it live: move the encoder, fire the event, confirm the latch value froze while the raw count kept changing, then repeat and confirm the stamp lands at the same shaft angle on every pass.

Reference or closing feedback #

Be exact about which loop you built, because the two are constantly confused. Here the external encoder steers a target and the drive closes on its motor encoder, so everything between motor and load, belts and gearboxes and backlash included, stays outside the correction. That is the right architecture whenever the axis must follow or hold registration to an external master: a feeder, a handwheel, a line, a measuring wheel.

It is the wrong one when the axis must be corrected to a measurement taken at the load itself; then the external encoder has to enter the drive's position loop, and what an external encoder position loop needs to close is the checklist for that job. On a pulse-train controller the option does not exist at all, and why a PTO axis cannot close the loop with an external encoder explains the mechanism. When the master is simply another servo's motor encoder, using a servo motor encoder as external machine feedback covers wiring it as the reference. The same fieldbus refresh limit that shapes all of this is the reason why a counter card skips encoder pulses between PLC updates.

The decisions:

  • The axis follows an external master: this path. Counter, scaling, MC_BR_MoveCyclicPosition every cycle, stream kept jump-free.
  • The axis must be corrected to load-side measurement: an external position loop in the drive, not a cyclic target.
  • A position must be stamped at an event: the counter's latch, never a polled input bit.

Questions asked

Is MC_BR_MoveCyclicPosition the same as MC_MoveAbsolute?

No. MC_MoveAbsolute commands one point-to-point move to a fixed position and takes the axis through its discrete-motion state. MC_BR_MoveCyclicPosition switches the axis into cyclic position setting mode, where every call refreshes a moving target. Use the absolute block for go-to moves and the cyclic block for tracking an external encoder.

What makes a cyclic target jump in practice?

Three usual suspects: a counter rollover you did not unwrap, a sign mismatch between the counter direction and the axis coordinate system, and a master that accelerates harder than the axis can follow. Each hands the drive a step it cannot track, and the following-error monitoring trips. Correct the source instead of masking it with gains: unwrap the count, fix the sign in one place, or ramp the master.

Why does the latch configuration ask for a high or low level?

The level setting selects which state or transition of the trigger channel performs the copy; the documented example is a positive edge of the Z (R) signal. The two edges of one index pulse sit at slightly different shaft angles, so choose the transition that lands where you want the position stamped, then confirm it by triggering a test event and reading the latch value.

Can several axes follow the same encoder?

Yes. Read and scale the master count once per PLC cycle, then call MC_BR_MoveCyclicPosition for each axis with its own target: the same value for parallel tracking, or the value multiplied by each axis's gear ratio. Each drive still closes its loop on its own motor encoder, and every axis needs its own jump check and velocity limit.

Keep reading

  • How-to

    Synchronizing a servo motor and encoder through an S7-1200 PLC

    You never synchronize a servo motor's own encoder from the S7-1200: the drive aligns it at commissioning. The PLC's job is the outer loop only — read an external encoder on a high-speed counter, scale it to engineering units, and trim an analog speed reference to the drive while the current and speed loops stay inside the drive.

    Servo and stepper motion

  • Explainer

    Why a servo feeder stops on motor position, not strip position

    The servo stops on its motor encoder's position, so the strip encoder can never be the stop condition itself. Read the strip encoder in the controller and correct the running relative move through its documented continuous-update distance input — a position reset needs the axis stopped and cannot recover lost travel. Begin deceleration early: braking travel v²/(2a) plus v·t of command delay; at 300 mm/s and 2,000 mm/s² with 10 ms delay that lead is 25.5 mm.

    Servo and stepper motion

  • Explainer

    What an External Encoder Position Loop Needs to Close

    The axis reference an encoder block returns is a measurement, not a loop: an external encoder closes the servo position loop only where the drive or motion controller documents a secondary feedback assignment for the commanded axis. Verify direction, scaling, motion-block compatibility and encoder-loss faulting before you enable, and tune for the reversal transient the backlash now creates inside the loop.

    Servo and stepper motion

Stepper Pulse Count Needed for a Given Encoder Target