Strange Bug

zblum

Member
Join Date
Mar 2016
Location
Ohio
Posts
38
View attachment edited_POSITION TRACKING V2 (THINNED O.pdf
I am dealing with a weird bug in my program, and am looking for some help.
I do not know if my issue stems from the flow of the program, or if I am just utilizing a command incorrectly.
My program is pretty basic, there is just a little bit of complexity in the handling of the data. I am using an encoder attached to a conveyor motor to track the position of plastic bottles on the conveyor. They get sorted into empty boxes off the side of the conveyor using air nozzles.
I am using a photoeye to trigger the storage of the current HSC.ACC value when a bottle is detected. This value is moved to a Long data file and gets an 'offset' added to it; this is the number of encoder pulses between the photoeye and the air nozzle of whichever box is empty.
I use a counter with indirect addressing to 'queue' multiple bottle positions in these long data files (Ladder 4). In another subroutine (Ladder 5), I use another counter to monitor which position in the 'queue' it should be looking for.
MY PROBLEM IS THIS: when the first station finishes and bottles start to be filled into another box, the very first position in the Long data files for the next boxes seems to get skipped. If 320 bottles are sent to the first box, and 320 bottles are knocked into the first box, the next 320 bottles will get sent to the second box, but only 314 will get knocked off. The number of bottles that aren't knocked off seem to correlate to the number of times the counters 'loop' through the Long data files. I observe the very first position in the long data files being updated with a new bottle position, however, it seems to get skipped when it is being monitored for knocking the bottle off.
It seems C5:20 from Ladder 5, Rung 6 gets reset, but when it resets, it doesn't reset to zero, it immediately hops to 1. What is weird is that if Box 1 is already full, and I trigger Box 2 to fill, it doesn't demonstrate this behavior; it will knock off the entirety of the bottles assigned to it.
Any help is appreciated.
Thanks
 
can't see your picture - so this is just a GUESS ...

instead of using an RES (Reset) instruction to reset the counter - try using a CLR (Clear) instruction to drive the counter's Accumulator to ZERO instead ...

IF (that's a big IF) then let us know and someone will explain ...
 
Try adding a ONS to the counter input line. It is not necessary for just the counting, but without the ONS, if the counter is Reset while the input is on, it appears to reset to value 1.
 
Try adding a ONS to the counter input line. It is not necessary for just the counting, but without the ONS, if the counter is Reset while the input is on, it appears to reset to value 1.

Thanks Jaden.
That was what I assumed it must be, but I actually tried this already, and it exhibited the same symptoms.
 
Last edited:
can't see your picture - so this is just a GUESS ...

instead of using an RES (Reset) instruction to reset the counter - try using a CLR (Clear) instruction to drive the counter's Accumulator to ZERO instead ...

IF (that's a big IF) then let us know and someone will explain ...

Ron,
I think that fixed it. Must have been because the input was still on when the counter was reset, and since the status bits were reset, it immediately increased the count to 1.
 
Maybe nothing but, in LAD4, rung 12, 16, 20, etc., the rung comment doesn't match what is happening in the SUB instruction. Might L17:nn end up with a negative value?

ladder compare.PNG
 
Maybe nothing but, in LAD4, rung 12, 16, 20, etc., the rung comment doesn't match what is happening in the SUB instruction. Might L17:nn end up with a negative value?

Doug,
It shouldn't end up negative. The HSC will never go over the OVF value. I have that code in there to prevent the addition of the 'offset' causing one of the stored position values in L12, etc., to be greater than what the HSC can actually accumulate.
 

Similar Topics

Hello all, I am facing an issue with my Commander SK that I cannot solve on my own, I am struggling on it since several days :confused: The...
Replies
9
Views
996
Hi. I'm doing an upgrade of an old 1400e to a new panel view plus 7 standard using ftv studio v 12,which will be communicating to a slc 5/04 via...
Replies
15
Views
2,558
Can someone explain the jumper between the elements? Does it do anything? See attached jpeg.
Replies
4
Views
667
We have an OPC server getting data from a Compactlogix PLC. The PLC also communicates with a Panelview and a couple VFDs via Ethernet/IP...
Replies
3
Views
1,148
I have a small system controlled by a Siemens S7-1200 PLC. I created a totalizer function block (TIA v17), where I'm counting total revolutions...
Replies
16
Views
2,966
Back
Top Bottom