Menu
CoddyTech

Tally by Size

Part of the Counters and Numbers section of Coddy's PLC Programming journey. Lesson 16 of 17.

The shift report wants two numbers: how many tall boxes and how many short ones. Keep each in an INT tag and add 1 per box, with a P contact so each box counts once.

Tall boxes are easy: one rising edge of Tall each. Short ones have no sensor of their own. But now that sorting works, every tall box leaves the belt before the end, so every box that reaches the Eye is a short one.

challenge icon

Challenge

Medium

Make two INT tags, TallBoxes and ShortBoxes. Add 1 to TallBoxes for each tall box and 1 to ShortBoxes for each short box.

Try it yourself

{"v":1,"lang":"ld","tags":[{"name":"Wait","type":"BOOL"},{"name":"C1","type":"CTU"},{"name":"T1","type":"TON"},{"name":"T2","type":"TP"}],"rungs":[{"els":[{"t":"par","branches":[[{"t":"no","tag":"Start"}],[{"t":"no","tag":"Belt"}]]},{"t":"no","tag":"Stop"},{"t":"nc","tag":"C1.Q"},{"t":"coil","tag":"Belt"}]},{"els":[{"t":"no","tag":"Belt"},{"t":"coil","tag":"Lamp"}]},{"els":[{"t":"no","tag":"Eye"},{"t":"CTU","inst":"C1","pv":6,"r":"Start"}]},{"els":[{"t":"move","src":"C1.CV","dst":"Display"}]},{"els":[{"t":"par","branches":[[{"t":"p","tag":"Tall"}],[{"t":"no","tag":"Wait"}]]},{"t":"nc","tag":"T1.Q"},{"t":"coil","tag":"Wait"}]},{"els":[{"t":"no","tag":"Wait"},{"t":"TON","inst":"T1","pt":"T#2400ms"}]},{"els":[{"t":"no","tag":"T1.Q"},{"t":"TP","inst":"T2","pt":"T#300ms"},{"t":"coil","tag":"Pusher"}]}]}

All lessons in Counters and Numbers

Practice on your own: PLC playground