Pro
18 min

Motion 03 — Home, then move

motionhomingencodercounterCTUlimit-switchovertravelpositioning

Ready to build this?

Sign up free — no credit card required. This scenario requires the Pro plan.

Sign up to play this scenario →

Already have an account? Log in

Motion 03 — Home, then move

Briefing

A carriage on a short rail is driven forward and backward by JOG_FWD and JOG_REV. An encoder sends ENC_PULSE for every 10 mm it moves, but it only counts distance, in either direction: at power-up the PLC has no idea where the carriage is. A home switch (HOME_LS, TRUE at the home end) gives the one place that is known. Press HOME_CMD and the carriage creeps in reverse until HOME_LS trips, then stops and HOMED_LAMP lights. The position count must be zero when the carriage is on the home switch. After that, MOVE_CMD drives forward 30 counts (300 mm) and lights IN_POSITION. MOVE_CMD must be ignored until the axis is homed. JOG_FWD_PB jogs forward while it is held. Beyond 400 mm the overtravel switch LIMIT_FWD trips (TRUE when tripped): forward drive must stop even if the button is held, FAULT_LAMP latches and homing is lost. (On a real machine a limit like this is normally wired normally closed, so a broken wire also reads as tripped. Here the tag is already inverted for you, TRUE meaning tripped.) Homing again, which drives in reverse and so is always allowed, clears the fault. STOP ends any move or homing. Training material. Follow your site procedures, local electrical code and the manufacturer's instructions. Lockout/tagout and a qualified person are required for real equipment. A real axis also needs an end-of-travel limit that cuts power independently of the PLC.

Objectives

  • MOVE_CMD does nothing until the axis has been homed
  • HOME_CMD creeps in reverse until HOME_LS, then stops and lights HOMED_LAMP
  • The count is zero at home; MOVE_CMD then travels exactly 30 counts and lights IN_POSITION
  • The overtravel switch stops forward motion, latches FAULT_LAMP and loses the homed state
  • Homing again clears the fault; STOP ends any move or homing

Hints

  • An encoder knows how far you have moved, not where you are. Decide what makes position meaningful, and when the PLC is allowed to trust it.
  • Homing is a small sequence: start on a momentary command, move until a switch trips, then record that the position is known and make the count zero. Position counts taken before home are meaningless.
  • A move is the same idea as an index: count pulses from a known zero and stop at the preset. The move must be refused until the reference is known, and anything that makes the reference untrustworthy has to forget it.
  • Hold the jog button into the overtravel switch: forward drive must stop anyway, and the machine must remember the fault until the axis has been homed again, which means reverse must not be blocked by the fault.

I/O Table

Inputs

HOME_CMD

Home command push-button (momentary)

BOOL · %I0.0

MOVE_CMD

Move command push-button (momentary)

BOOL · %I0.1

JOG_FWD_PB

Jog forward push-button (held)

BOOL · %I0.2

STOP_PB

Stop push-button (TRUE = pressed)

BOOL · %I0.3

HOME_LS

Home switch (TRUE when carriage is at home)

BOOL · %I0.4

LIMIT_FWD

Forward overtravel switch (TRUE = tripped)

BOOL · %I0.5

ENC_PULSE

Encoder: one pulse per 10 mm, both directions

BOOL · %I0.6

Outputs

JOG_REV

Drive reverse (towards home)

BOOL · %Q0.0

JOG_FWD

Drive forward (away from home)

BOOL · %Q0.1

HOMED_LAMP

Axis homed lamp

BOOL · %Q0.2

IN_POSITION

Move complete, in position lamp

BOOL · %Q0.3

FAULT_LAMP

Overtravel fault lamp

BOOL · %Q0.4

Your program will be tested against:

All test cases run automatically when you submit. Assertions are hidden until you pass.

  1. #1MOVE before homing → nothing moves

    The axis position is not known yet

  2. #2HOME_CMD → creeps in reverse, not homed yet

    Homing runs towards the home switch

  3. #3Carriage at the home switch → stopped and homed

    Reaching HOME_LS ends homing and records it

  4. #4MOVE after homing → drives forward

    A homed axis accepts the move

  5. #5Move complete → stopped at 300 mm, in position

    Thirty pulses from home end the move

  6. #6Jog into the overtravel switch → stops, fault, reference lost

    Forward drive is blocked by LIMIT_FWD even with the button held

  7. #7STOP during homing → stops and stays stopped

    STOP ends homing

  8. #8Overtravel, release, home again → fault cleared and homed

    Reverse stays available so homing can recover from a fault

Ready to build this?

Sign up free — no credit card required. This scenario requires the Pro plan.

Sign up to play this scenario →

Already have an account? Log in