Simple counting routine

infer

Member
Join Date
Feb 2021
Location
UK
Posts
13
Guys,

I know it will be silly but can't get my head around it.

I have 3 conveyors, every one on a separate servo drive, and 2 lifters/lowerators. I need to count boxes in each section of the machine. Every conveyor has slightly different motion profile so different index times. They are off not more than 250ms though

The layout is like this, an arrow indicates a presence sensor, goes high when the box is there.

I need to count how many boxes do I have between each pair of sensors, so:
- 1 to 2
- 2 to 3
- 3 to 4

Whtat I did is:

Rung 1) Conveyor1.PC and Sensor 1 is high - one shot - ADD 1 to C1 (DINT)
Rung 2) Conveyor2.PC and sensor 2 is high - one shot - SUB 1 form C1 (DINT)

Rung 3) Conveyor2.PC and sensor 2 is high - one shot - ADD 1 to C2 (DINT)
Rung 4) Conveyor2.PC and sensor 3 is high - one shot - SUB 1 from C2 (DINT)

Rung 5) Conveyor2.PC and sensor 3 is high - one shot - ADD 1 to C3 (DINT)
Rung 6) Conveyor3.PC and sensor 4 is high - one shot - SUB 1 from C3 (DINT)

It works but only ish.
If I put 1000 boxes on the conveyor 1 and let them go past and all conveyors are empty I would expect C1 C2 and C3 to be zero, however they are not. I'm getting C1 or C3 to be 1 when the conveyors are empty. There is obviously something wrong in my thinking. My brain is fogged :),

Cheers

Untitled.jpg
 
Are you actually using counters or inc/dec words, I suggest you do the latter, what PLC are you using, perhaps also put a small time delay on each sensor to make sure the sensor is covered before doing the one shot I prefer using words rather than counters.
 
Are you actually using counters or inc/dec words, I suggest you do the latter, what PLC are you using, perhaps also put a small time delay on each sensor to make sure the sensor is covered before doing the one shot I prefer using words rather than counters.

Hi, It's L73 , see below

Capture.JPG
 
typo, fourth rung, XIC TON[3?].DN

also,

  • the ADDs for C2 and C3 could be paired with the SUBs for C1 and C2, respectively, and the XIC/XIC/TON/XIC/ONS/ADD rungs could be deleted for C2 and C3,
  • the [LES count 0] checks should either be removed or set an alarm
 
Last edited:
You should not need the .DN contact just wire it to the .DN output of the timer onto the oneshot. as Brian says remove a lot of the code as he has displayed, you could also use >= 0 in-line with the code so it can never decrement below 0 i.e. negative.
 
You should not need the .DN contact just wire it to the .DN output of the timer onto the oneshot. as Brian says remove a lot of the code as he has displayed, you could also use >= 0 in-line with the code so it can never decrement below 0 i.e. negative.

Hi, I'm doing ladder logic so how can I skip using timer.dn bit ?
 
That's crazy, IEC convention is normally where the DN output or (Q) is used so that it can be directly connected like this.

Count.png
 
I'm familiar with it.

Logix does not support any ability to connect a rung/branch to specific outputs or inputs of an instruction.
 
Not FBD in reality or IEC convention
I only used some ladder here with FBD as it looks more like ladder, I would normally use only FBD like this, also most instructions on this platform have a oneshot function i.e. +P the "P" means one shot pulse rising

Count.png
 
Hi All,

Does it look okay now?

Sensor_High contains the conveyor stopped and the carton present
Index_Step - this simply is high when the conveyor is on certain indexes

Capture2.jpg
 

Similar Topics

Hello again..trying something on an existing poorly written program and just wanted to double check something system is an A-B MicroLogix 1200 In...
Replies
5
Views
173
Hi all, Writng a FB in ST on Beckhoff TC for a pulser which turns on and off on a cycle, is paused by turning bControlInput to FALSE, but resumes...
Replies
6
Views
260
I'm trying to build my Classic Step 7 programming skills this weekend. I get stuck on little things that are not covered in YouTube tutorials. I'm...
Replies
7
Views
320
I have a program that does a 7 second "scan" sensor calibration routine whenever a setting (setting is called assistance level or "AL" and ranges...
Replies
3
Views
215
Hi all, I have a simple question that I have overcomplicated and gotten stuck on. I have a variable, we can call it "light" that I need to stay...
Replies
4
Views
322
Back
Top Bottom