Skip to content

MAG — Motion Axis Gear

Category
Motion
Type
Output
Availability
Stepper axes only (Explorer ▸ Axes); master and follower must both report position

MAG instruction block: a block labelled MAG with rows Axis: Follower, Master: Feed and Ratio: 2


MAG (Motion Axis Gear) makes one axis, the follower, track the position of another, the master, at a fixed ratio. While its rung is true, every scan the follower’s target is set to the master’s position multiplied by Ratio, and the follower runs toward it at its own speed and acceleration. When the master stops, the follower catches up and rests; when the rung goes false the follower stays where it is. Use MAG for a second carriage that must keep station with a first, or for an electronic 2:1 between two feeders. Do not expect a hard lock: this is position-following gearing on a small controller, so the follower lags the master by the distance it has not yet caught up.


Operand Type Format Valid Range Required Description
Axis Axis Axis name A stepper axis with a driver Yes The follower: the axis MAG drives.
Master Axis Axis Axis name A stepper axis, not the follower itself Yes The axis whose position is followed.
Ratio REAL Literal or tag Any value; negative reverses Yes Follower target = master position × Ratio, both in raw counts.

Nothing.

Nothing new is commanded. The follower finishes the last target it was given and holds. EN clears once it is at rest.

Every scan: follower target = master counts × Ratio. If that leaves distance to go, EN = 1 and the axis service steps the follower toward it, setting IP and InMotion. With no distance to go the follower rests with EN = 0; a geared pair standing still is not a fault. DN and PC are not used by gearing.

Nothing.

Condition Follower EN Follower IP Follower motion
Rung true, master moving 1 1 Catching up to master × Ratio
Rung true, master at rest, follower behind 1 1 Catching up
Rung true, both at rest 0 0 Holding at master × Ratio
Rung false 0 after the last target 0 Holds where it is

The members below are the follower’s. The master is only read.

Member Data type Set by Cleared by Description
CmdPos REAL MAG every scan (master × Ratio, in units), MAM, MSR — Commanded target in axis units.
EN BOOL MAG while there is distance to go, MAM, MAJ Caught up, MAS, MSF A motion command is engaged.
IP BOOL Axis service while steps are being produced Motion stops Motion in process.
DN BOOL MAM reaching its target, MSR Next MAM or MAJ Not used by MAG.
PC BOOL Same as DN Same as DN Not used by MAG.
ActualPos REAL Axis service every scan — Follower position in axis units.
Counts DINT Axis service every scan MSR, ResetCounts Raw step counts. Ratio applies to counts, not units.
InMotion BOOL Axis service Axis service Steps produced this scan.
Dir BOOL Axis service Axis service 1 = forward.
DriverOn BOOL MSO MSF The drive is enabled.
Error BOOL Watchdog mismatch, TMC2130 driver fault MAFR Axis fault.
RedefinePos REAL MSR — Value of the last MSR.
ResetCounts BOOL Your logic (write 1) Firmware, after zeroing Zero the counts without an MSR.
Watchdog INT (ms) Axis properties; your logic may overwrite — Mismatch tolerance before Error sets.

Scenario: The Follower carriage keeps station with the Feed carriage at twice its travel. Both drives were enabled on the MSO page; both axes have 80 counts per mm, so a ratio of 2 in counts is 2 in millimetres too.

Tags:

  • Gear_On — Gear follower to feed, BOOL
  • Feed — master, stepper axis
  • Follower — follower, stepper axis

Rung 1:

—|XIC Gear_On|———[MAG Follower Master Feed Ratio 2]———

Scan 1 — Gear_On = 0. Both axes at 0 mm and at rest.

Figure 1 — MAG rung false: Gear_On off, wire dark, the block showing Master Feed, Ratio 2

Scan 2 — Gear_On = 1, then the MAM page’s move sends Feed to 150 mm. Every scan Follower.CmdPos = 2 × Feed.ActualPos; when Feed arrives at 150 the follower’s target is 300 and it runs there: Follower.EN = 1, Follower.IP = 1 until it arrives, then both 0 with Follower.ActualPos = 300.

Figure 2 — MAG rung true: Gear_On on, the wire lit through the block

Values before and after: Feed.ActualPos 0 → 150; Follower.CmdPos 0 → 300; Follower.ActualPos 0 → 300, arriving later than the master.


  • MAM — Motion Axis Move (sets the follower’s speed and acceleration)
  • MAS — Motion Axis Stop
  • MSO — Motion Servo On (enable both drives first)
  • Motion Instructions — Category index

Set the follower’s speed first. MAG has no speed or acceleration operands; the follower runs at the values its last MAM gave it. A follower that has never executed an MAM runs at the stepper library’s default of one step per second, which looks like nothing at all. Run one MAM on the follower before gearing, for example an incremental move of 0 at the speed you want.

Ratio is in counts. Master counts × Ratio = follower counts. With different counts per unit on the two axes, work the ratio out in steps, not in millimetres.

Negative ratio reverses the follower.

Following, not locking. The follower always trails the master by whatever it has not yet caught up. At low master speeds the lag is a few steps; at high speeds it can be large. A jerk of the master is followed with the follower’s own acceleration.

Not on DC axes. Both axes must report position; a DC axis is refused as master or follower at build time. An axis cannot be geared to itself.

Retargeting the master. MAM, MAJ and MSR on the master all move the follower through the gear. An MSR that redefines the master’s position makes the follower drive to the new master × Ratio.

Applies to LadderIDE >=1.2.2 · Last reviewed 2026-09-11 · Screenshots verified 2026-09-11