Vision System Camera Scan

Hello, we have a vision system on one of our lines. Vision captures an image every 1.5 seconds. When there is a bad image, vision system send image to an external hard drive. Each time there is a bad image or no good data, vision send a signal to an Allen Bradley PLC. If there are three bad images in a row, engineer wants me to set an alarm. Issue is that there can be a one no good data on one capture but a good image on the next capture.
Since each of the images are captured every 1.5 seconds, engineer wants to see three bad images right after another. What is the best way to program this? I have set up a counter to count up each time there is a no good signal (bad image) sent to the PLC. I have set up if the counter counts up to , this starts a 1.5 second timer. When that timer is done this sets a latch bit. When this latch bit is on, no good signal is true and the counter equal is to 2, this start another 1.5 second timer. When this timer is done a latch bit is set. When the latch bit is on, another no good signal is true and counter is equal 3 this start another 1.5 second timer. When this timer is done a latch bit is set. When the latch bit is on, another no good signal is true and counter is equal to 4. This signals an alarm in the PLC. One the alarm is acknowledged, all of the previous latch are unlatched. Process starts again.
 
Does the good/bad signal pulse or does it just stay on? What triggers an image? Is it a timer?

In my (limited) experience with vision systems and PLCs, the PLC sends a trigger signal to the camera and waits "x" time for the result. In some cases, the result stayed high for "y" time, in others it just held the last result until the result changed. In the latter case, you'd wait the required time after the trigger to make sure the result was valid and then increment the counter as needed.
So...
<trigger a capture>
<wait for result>
<if result = bad, CTU>
<if counter DONE, trigger alarm>
<if result = good, RES counter>

If the vision system is automatically triggering itself every 1.5s and only sending a bad result to the PLC (no good result, just "bad" or "not bad", then you'll use a timer, starting when the "bad" signal first appears.

If the bad signal stays on until a good test result, then you can just do:
Code:
XIC badResult   TON badTime
badTime's PREset would be 4.5s, or a little longer, like 5s to allow for a slight delay in the result updating.
 
PLC is sending capture bit to the vision system every 1.5 seconds. Vision system captures an image, timer in PLC starts for 1.5 seconds, then another signal is sent to the vision to capture an image.
 
Since it's a pulse signal, and there's no "good result" pulse, you'll have to set up a timer to track a "result valid" window starting when you send the capture bit and ending some interval that's a little longer than your vision system takes to send a bad pulse. If you get a bad pulse, increment a counter. If no bad pulse during the result window, reset the counter.

I don't have my RSLogix PC running, or I'd throw together a quick rung or two of code as a first pass. Basically, use the the capture bit with a ONS to start a "result window" TON instruction (seal around the capture bit and ONS with the timer's TT bit). Use XIO badResult before the TON instruction to unseal everything if there's a bad result. If the timer times out (DN bit goes high), then no bad result happened during the window and you can reset the bad result counter. Any time badResult goes high, increment the counter, with its PRE set to 3. When counter is DN, trigger the alarm.

In RSLogix mnemonics, something like this (not verified or tested):

Code:
BST XIC "capturePulse" ONS holdingBit NXB windowTime.TT BND XIO badResult BST TON windowTime nxb XIC windowTime.DN RES badCount

XIC badResult CTU badCount
 
Top