For a teacher with a class? The classroom edition has the full plan, slides and standards.

Homeschooling PDF

Family edition

PLC Lab: Count It, Sort It, Counters and Latches on a Packing Line

Ages 15-18 ยท about 45 minutes, in one sitting

In PLC Lab your teen programs a pretend packing line: count six boxes into each case, then sort metal cans from plastic tubs. Nothing in the app drives real hardware.

What you need

Before you start: try it once yourself

Open mytekdev.com/try/plclab?lesson=count-it-sort-it&ref=fam-plclab-3. A short guide opens over Job 3, Fill a Case, on the Build it tab. At the end of the belt, boxes drop into a shipping case that holds six; an eye across the case mouth sees each one fall in.

  1. The wiring list. Start, Stop and Motor, plus Reset at %IX0.2 (the yellow button), Eye at %IX0.3 (through-beam, OFF for a moment as each box drops in) and CaseFull at %QX0.1, a lamp on the panel.
  2. The starting program. The seal-in and the belt. Run the shift: twelve boxes, six in the case, six on the floor.
  3. Job 3's answer. A normally closed Eye to a Counter named Count, preset 6; normally open Reset to Reset to zero (RES, under More) on Count; normally closed Count.DN in the Motor rung; Count.DN to CaseFull. The crew swaps the case after Case full lights, then presses Reset.
  4. Job 4. Pick Sort the Metal. Metal at %IX0.2 (an inductive sensor: it cannot see plastic), Eye at %IX0.3 in front of the pusher, PusherOut at %IX0.4 (a reed switch at the end of the stroke), and Pusher at %QX0.1 (a single solenoid valve; a spring brings it back). Eight parts, four cans and four tubs. The starting program pushes on Metal, while the can is still far up the belt: no can reaches the bin.
  5. Job 4's answer. Normally open Metal to Set IsMetal (a new bit); normally closed Eye and normally open IsMetal to Set Pusher; normally open PusherOut to Reset Pusher and Reset IsMetal.
In the wiring list, Field is the wire at the PLC's terminal right now, and Image is the PLC's own copy, taken at the start of each scan. Image only changes while the line is on. The app calls the counter reset instruction Reset to zero. The hint box on Job 3 calls it Reset timer or counter: it is the same RES button, under More.

The ideas, in plain words

A box blocks the case eye for about 150 ms, which is 15 scans at 10 ms. A counter that counted every scan the rung was true would count 15. Counters count the rung turning true, the rising edge, so one box is one count. Children who have used a loop counter in a programming class often expect the other answer.

A counter's done bit stays on until something resets the count. Here that is the crew's Reset button, after they have swapped the case. In this app, as in OpenPLC, the count stops at the preset; an Allen-Bradley counter keeps counting past it with done still on. Both stop the belt here.

Job 4's pusher is a single solenoid valve: ON pushes, and a spring brings it back. Set holds it out until PusherOut, the reed switch at the end of the stroke, proves the push is done and resets it. The same input resets IsMetal, because the can that bit stood for has now been pushed.

Job 4's sorter has room for one part between its sensor and its pusher. Job 9, Rush Hour, closes the gap and needs a shift register.

Do it together

  1. Open mytekdev.com/try/plclab?lesson=count-it-sort-it&ref=fam-plclab-3 together and press Run the shift. Watch the end of the line.

    You'll know it worked when: Six boxes land in the case and six fall on the floor.

  2. Follow the hints on the right to add a Counter named Count with a preset of 6, and stop the belt when it is done.

    If you get stuck: Show me how gives the exact moves.

    You'll know it worked when: The belt stops at six.

  3. Light the CaseFull lamp from Count.DN, and clear the count on Reset with Reset to zero (under More). Run the shift.

    You'll know it worked when: Twelve boxes, two cases, nothing on the floor.

  4. Pick Job 4, Sort the Metal, and run the shift with the program it starts with.

    You'll know it worked when: The pusher fires too early, and no can reaches the metal bin.

  5. Use Set to remember a can, push it at the eye, and Reset at the end of the stroke. Run the shift.

    You'll know it worked when: Four cans in the metal bin, four tubs ride on.

  6. Talk it over: why does the remembered can get forgotten when the pusher is all the way out, and not sooner?

    You'll know it worked when: Your teen explains that PusherOut proves the push happened.

Talk about it

Ask these while you work together. A child who has understood it can answer them without help:

The last question is the one that matters. PusherOut proves the push happened. A child who resets on the eye could forget the can before the pusher had finished.

For younger and older kids

Younger: For a younger teen, finish Job 3 and stop there.

Older: For an older teen, try Job 9, Rush Hour, where the parts come twice as close together.

Keep going

Bring it into other subjects

For your records

Ready to copy into an hour log, a portfolio or a transcript.

LessonPLC Lab: Count It, Sort It, Counters and Latches on a Packing Line
SubjectsCareer and technical education, Engineering
Time45 minutes
What we didProgrammed a simulated packing line with an up counter and reset to fill cases of six, and sorted metal from plastic by latching a sensor reading until the part reached a pusher.
Skills practicedPLC counters; Latch and unlatch logic; Sensors

PLC Lab: Count It, Sort It, Counters and Latches on a Packing Line

Activity sheet (optional)

Name: ______________________________ Date: ______________

Open the app: scan the QR code, or go to mytekdev.com/try/plclab?lesson=count-it-sort-it

Essential question: How does a PLC keep track of something it can no longer see?

Warm-up: A door counter and a person standing in the doorway: how many counts, and why? ________________________

  1. Vocabulary. Up counter, rising edge, reset to zero, set (latch), reset (unlatch): write each in your own words.
  2. First shift. With the program Job 3 starts with: ______ boxes in the case, ______ on the floor.
  3. Job 3. The contact that counts a box: ________ The contact that stops the belt: ________ The input that clears the count: ________
  4. Job 4. The input that sets IsMetal: ________ The two contacts that push: ________ The input that resets Pusher and IsMetal: ________
  5. Shifts. Job 3 passed (circle): yes no Job 4 passed (circle): yes no

1. A box blocks the eye for about 15 scans. Why does the counter count it only once?

2. Why is IsMetal reset when PusherOut turns on, and not when the eye clears?

Quick check

Name: ______________________________

1. A counter's preset is 6. After the sixth box, what turns its done bit off again? (A) the next box (B) a reset of the count (C) turning the line off

2. A bit is Set when the metal sensor sees a can and never Reset. What happens to the next tub? (A) it rides on (B) it is pushed into the metal bin (C) the belt stops

3. Why does a counter count each box once, even though the box blocks the eye for many scans?

Answers

QuestionAnswerWhy
1BThe done bit stays on until the count is reset. In Job 3 the crew's Reset button clears it with RES.
2BThe bit still says a can is coming, so the pusher fires on the next part at the eye, can or tub.
3Open answerA counter counts its rung turning true, the rising edge, not each scan the rung stays true.

If your state or umbrella school asks, this lesson covers Texas Programmable Logic Controller II (innovative course N1303690) (2)(C), Texas Programmable Logic Controller II (innovative course N1303690) Recommended activity, Texas Programmable Logic Controller I (innovative course N1303689) (6)(B), Texas Programmable Logic Controller I (innovative course N1303689) (6)(D), Massachusetts Robotics and Automation Engineering Technology, July 2025 Standard 9, PMMI Mechatronics: Programmable Logic Controllers 1 PLC 1 competency, PMMI Mechatronics: Programmable Logic Controllers 1 PLC 1 competency, SACA C-207 Programmable Controller Systems 1 C-207 key skills, CSTA 2017 3A-AP-16.