Free
8 min

Motion 01 — Encoder distance

motionencodercounterCTUconveyorpositioningfundamentals

Ready to build this?

Sign up free — no credit card required. This scenario is included in the free tier.

Sign up to play this scenario →

Already have an account? Log in

Not ready to sign up? Run a live lab now — no signup →

Motion 01 — Encoder distance

Briefing

A belt carries parts to a station. An incremental encoder on the drive roller sends one pulse (ENC_PULSE) for every 10 mm the belt moves, so the PLC can measure distance by counting pulses. It only pulses while the belt is really moving. Tap START and the belt runs. Count the pulses with a counter; when the belt has moved 200 mm it must stop and AT_TARGET must light. Work out how many pulses 200 mm is. STOP pauses the belt without losing the count, so START carries on to the same 200 mm mark. RESET clears the count so the next move can begin.

Objectives

  • START runs the belt (BELT_RUN stays on after the button is released)
  • The belt keeps running until 200 mm of travel has been counted
  • At 200 mm the belt stops and AT_TARGET lights
  • STOP pauses the belt without clearing the count
  • RESET clears the count so a new move can start

Hints

  • A distance is just a number of pulses: how far does the belt move for each pulse, and how many pulses is the whole move?
  • A counter adds one to its count for every rising edge on its count input. Its done output turns on when the count reaches the preset, and that is the moment to stop the belt.
  • STOP and the counter's done output are two different reasons to stop the belt. Only RESET should clear the count, so a paused move can be resumed.
  • If the belt never stops, compare your preset with the number of 10 mm pulses in 200 mm. If it stops at the wrong place, the preset is off by a factor.

I/O Table

Inputs

START_PB

Start push-button (momentary NO)

BOOL · %I0.0

STOP_PB

Stop push-button (TRUE = pressed)

BOOL · %I0.1

RESET_PB

Count reset push-button (momentary)

BOOL · %I0.2

ENC_PULSE

Encoder: one pulse per 10 mm of belt

BOOL · %I0.3

Outputs

BELT_RUN

Belt motor run command

BOOL · %Q0.0

AT_TARGET

Target distance reached lamp

BOOL · %Q0.1

Your program will be tested against:

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

  1. #1Tap START → belt runs, target lamp off

    A momentary START latches the belt on

  2. #2After 3.6 s (about 170 mm) → still running

    The count has not reached the target yet

  3. #3After 4.6 s → stopped at 200 mm, target lamp on

    Twenty pulses stop the belt and light AT_TARGET

  4. #4STOP during the move → belt off and stays off

    STOP switches the belt off without lighting the target lamp

  5. #5STOP then START → carries on to the same 200 mm mark

    STOP does not clear the count

  6. #6RESET clears the count → target lamp off, START runs again

    RESET reaches the counter and a new move can begin

Ready to build this?

Sign up free — no credit card required. This scenario is included in the free tier.

Sign up to play this scenario →

Already have an account? Log in

Not ready to sign up? Run a live lab now — no signup →