Eric Nelson
Lifetime Supporting Member + Moderator
We installed a dual camera vision system a little over a year ago. The customer finally got around to using it recently. They called me in the other day because the trigger output to the first camera stops working. I revisited the program and found a couple of typos. I downloaded the new program, and everything seemed fine.
They called me today to say that it still isn't working. After it runs for a few hours, the trigger output for camera 1 stops working. If they power cycle the system, it will run fine, then stop again after the same time period. This is actually the same issue they were having in the first place, but they failed to tell me about the 'after a few hours' problem, so I thought my typos were the only problem. I will have to stop in again and see what's happening, but in the meantime, I thought maybe some of our resident Siemens gurus might have a look at my program.
The system consists of a conveyor mounted encoder, a product sensor, 2 cameras, and a reject cylinder. The encoder is a measuring wheel style that measures the distance the belt travels (1000 pulses per inch), connected to the high-speed counter in the PLC. The cameras are mounted on either side of the conveyor, looking at the front and back labels on a bottle. Due to the limited space, the product sensor is mounted slightly upstream of the cameras. The reject cylinder is located downstream of the cameras, and simply knocks off any bottle that fails inspection. Here's a short video I took of the system the other day. It is working properly in the video.
http://www.youtube.com/watch?v=9KkjUG8Z7B0
This was my first (and hopefully last) experience with the S7-1200 and the TIA Portal software. My explanations are often confusing (even to me), but here's an attempt at explaining how it functions...
Each time a bottle is detected by the product sensor, the current encoder position is loaded into multiple queues, and those queue pointers are incremented. I can have up to 2 bottles in the queue (there will never be more than this) between the sensor and the cameras, and up to 6 between the sensor and reject station. There are never that many in the reject queue, but I left room in case the reject station gets moved father downstream.
The camera queues track the bottle(s) between the sensor and cameras. When each bottle reaches the camera location, it turns on an output to trigger the camera. The cameras aren't directly opposite each other, so I have separate queues for each camera.
The reject queues track the bottle(s) between the sensor and reject station. If the camera gives a "PASS" result, this latches a bit associated with the current reject queue position for that bottle. When each bottle reaches the reject location, I query the "PASS" bits for that bottle. If either is OFF, I fire the reject cylinder.
When I wrote the original program, I started with just one camera subroutine. When I had it all working properly, I just copied this logic into a new subroutine for the second camera. I then went though that subroutine and changed the registers from 'camera 1' to 'camera 2'. This is why I find it really strange that the trigger stops working for camera ONE! If I had a typo or something, it should be in the camera 2 subroutine...
Since this takes hours to fail, I suspect it might be something like exceeding the maximum value in a register? The processor is not faulting though. It continues to run, just without the camera 1 trigger output. Camera 2 is triggering just fine. I am not looking forward to troubleshooting this system. I don't know enough about the S7-1200, and struggle with the software as well.
I'm hoping that a fresh set of eyes might notice something I've overlooked. I know there are probably better ways to write this program, but at this point, I'd just like to figure out why this one doesn't work for more than a few hours.
A bit too big as an attachment, so here's a link to a zipped version of the program...
http://www.dericn.com/files/DualCamera.zip
And a PDF printout of the ladder if you don't feel like firing up TIA Portal...
http://www.dericn.com/files/DualCamera.pdf
Any ideas?...
-Eric
P.S. I found a thread I started back when I first programmed this system. Might help in understanding how the system works.
http://www.plctalk.net/qanda/showthread.php?t=59595
They called me today to say that it still isn't working. After it runs for a few hours, the trigger output for camera 1 stops working. If they power cycle the system, it will run fine, then stop again after the same time period. This is actually the same issue they were having in the first place, but they failed to tell me about the 'after a few hours' problem, so I thought my typos were the only problem. I will have to stop in again and see what's happening, but in the meantime, I thought maybe some of our resident Siemens gurus might have a look at my program.
The system consists of a conveyor mounted encoder, a product sensor, 2 cameras, and a reject cylinder. The encoder is a measuring wheel style that measures the distance the belt travels (1000 pulses per inch), connected to the high-speed counter in the PLC. The cameras are mounted on either side of the conveyor, looking at the front and back labels on a bottle. Due to the limited space, the product sensor is mounted slightly upstream of the cameras. The reject cylinder is located downstream of the cameras, and simply knocks off any bottle that fails inspection. Here's a short video I took of the system the other day. It is working properly in the video.
http://www.youtube.com/watch?v=9KkjUG8Z7B0
This was my first (and hopefully last) experience with the S7-1200 and the TIA Portal software. My explanations are often confusing (even to me), but here's an attempt at explaining how it functions...
Each time a bottle is detected by the product sensor, the current encoder position is loaded into multiple queues, and those queue pointers are incremented. I can have up to 2 bottles in the queue (there will never be more than this) between the sensor and the cameras, and up to 6 between the sensor and reject station. There are never that many in the reject queue, but I left room in case the reject station gets moved father downstream.
The camera queues track the bottle(s) between the sensor and cameras. When each bottle reaches the camera location, it turns on an output to trigger the camera. The cameras aren't directly opposite each other, so I have separate queues for each camera.
The reject queues track the bottle(s) between the sensor and reject station. If the camera gives a "PASS" result, this latches a bit associated with the current reject queue position for that bottle. When each bottle reaches the reject location, I query the "PASS" bits for that bottle. If either is OFF, I fire the reject cylinder.
When I wrote the original program, I started with just one camera subroutine. When I had it all working properly, I just copied this logic into a new subroutine for the second camera. I then went though that subroutine and changed the registers from 'camera 1' to 'camera 2'. This is why I find it really strange that the trigger stops working for camera ONE! If I had a typo or something, it should be in the camera 2 subroutine...
Since this takes hours to fail, I suspect it might be something like exceeding the maximum value in a register? The processor is not faulting though. It continues to run, just without the camera 1 trigger output. Camera 2 is triggering just fine. I am not looking forward to troubleshooting this system. I don't know enough about the S7-1200, and struggle with the software as well.
I'm hoping that a fresh set of eyes might notice something I've overlooked. I know there are probably better ways to write this program, but at this point, I'd just like to figure out why this one doesn't work for more than a few hours.
A bit too big as an attachment, so here's a link to a zipped version of the program...
http://www.dericn.com/files/DualCamera.zip
And a PDF printout of the ladder if you don't feel like firing up TIA Portal...
http://www.dericn.com/files/DualCamera.pdf
Any ideas?...
-Eric
P.S. I found a thread I started back when I first programmed this system. Might help in understanding how the system works.
http://www.plctalk.net/qanda/showthread.php?t=59595