![]() ![]() ![]() ![]() ![]() ![]() |
||
![]() |
||
![]() ![]() ![]() ![]() This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc. |
||
![]() |
![]() |
#1 |
Member
![]() ![]() Join Date: Nov 2019
Location: Seoul
Posts: 15
|
![]()
Dear Experts,
I need a little help with a project that involves an Omron Vision used for quality control of cylindrical products (arranged in 2 lanes) on a servo motor-driven conveyor belt. Each lane of the belt ends with an ejector rod (air solenoid vale) which should kick out the product that did not pass the QC. I'll try to provide as much details as possible and I hope someone would be able to give me some new ideas to try. ![]() The details are as follows: There is an Omron FH-5050-10 Vision system with 4 camera aligned in a 4x2 configuration. That is, 4 cameras placed sequentially and are looking at the product passing underneath them on the conveyor belt. The products are cylinders which are fed into the conveyor with a minimum distance of about half of its length (e.g. 170 mm long cylinders come in with at least 70~80 mm space between them). There are 2 optical sensors at the beginning at the end of the conveyor belt. The sensor at the end is followed by the ejector rod, which can be extended and retracted quite quickly. The ejector is controlled by a S7-1500 series PLC, linked to the Omron Vision system by a RS232 serial link. Obviously, the PLC gets an info about the product condition via this serial link. It checks the data, decides whether the product is OK or NG and activates the ejector based on that. The belt is driven by the servo motor with an encoder of 8000+ ppr. The PLC gets the encoder feedback (actual position) via a Profibus connection to the servo drive. The belt speed is controlled by the PLC and is constant, but can vary slightly depending on external factors. Normally, it takes about 500~600 ms for each product to pass through the entire conveyor belt. Finally, the belt has 2 identical lanes, left & right, so let me focus on the Left lane only. That's the basic setup. Now, the tricky part is, the Omron Vision cameras are operated based on a a fixed cycle of 280 ms. That cycle time gives all 4 cameras a chance to take 1-2 snapshots of the product. The PLC can measure this cycle time, but the cycle itself is not synced to the signal from the sensor at the beginning of the belt. That cycle runs as long as the belt is moving, regardless of whether the product is present on it or not. At the end of every cycle the RS232 interface on the PLC gets a 32-byte message containing coordinates (4x 32-bit integers in camera pixels x1000) of the defect found. If no product is present, or no defect found, there is 0 or another pre-defined number if sent. Also, as the product passed under each of 4 cameras, there is no way to tell which camera may spot the defect. Sometimes, it could be 2, 3 or even 4 cameras which spot the defect in the same product. The data (1D pixel coordinates of the defect) can be translated to the number of encoder pulses at a fixed ratio. The position of the object is always known from the moment its beginning passes the 1st (entry) sensor to the moment it passes the 2nd (exit) sensor and then (maybe) gets by the ejector rod. Thanks for reading and considerations this far! Now my ultimate questions are: 1. What would the best (100% error-proof) algorithm to track the be location of each product as it passes through the belt under the cameras, get the RS232 data from the Vision and activate the ejector at the time as the product marked as "bad" passes by it? (preferably, around the mid-point of its length). 2. How can I "attach" RS232 data messages (coming in at fixed intervals) to a specific product on the conveyor? Please keep in mind that there could be any number (from 1 to 5) of products on the conveyor passing by cameras each of 4 camera at rapid succession. 1 or more of them could be marked "defective" by 1 or more cameras. 3. Would it help to increase the RS232 link speed between the Omron Vision and the PLC (from current 9600 bps to 38400 or even 115200)? I would greatly appreciate any help you could provide! Feel free to ask me any questions or to request more details. Thanks a lot in advance, AK |
![]() |
![]() |
#2 | |
Lifetime Supporting Member
|
Quote:
Background Any computer program is a model of something in the real world. Bits (e.g. encoder pulses, or proximity sensors), numbers (e.g. 1D position of a defect), etc. represent some state or quantity in that model. PLC programs are about time i.e. how the program model changes over time, as measured at discrete moments called scan cycles. Cylinder defects With those statements in mind, let me restate the key question in a slightly different way:
Likewise, if some time ago the cameras detected a defect that was located at a distance of M encoder pulses from the entrance prox, and there have been K pulses since then, then the program should be able to predict where that defect is now, again in units of encoder pulses from the entrance prox. Note that we no longer associate the defect with a cylinder, but rather we associate independent 1D positions of both cylinders and defects relative to the entrance prox/ejector rod line. Model assumptions
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() v) I probably have the highest ratio of forum posts to actual applications in the field (but no longer ∞ ![]() vi) Hakuna matata. vii) Bookkeeping. |
|
![]() |
![]() |
#3 |
Lifetime Supporting Member
|
Here is a model for the PLC that uses two bit-FIFOs to keep track both of cylinders and of defects. By using a FIFO that is triggered by conveyor encoder pulses, almost all scaling, other than knowing how much distance one encoder pulse represents, is eliminated. This model essentially keeps track, for each encoder increment in position past the Entrance Proximity Sensor, of two binary states: [1=cylinder] or [0=no cylinder]; [1=defect] or [0=no defect].
In the diagram below, one encoder pulse represents 17mm, or one-tenth of a cylinder length, so ten consecutive 1s in the upper bit-FIFO represent the presence of 170mm of cylinder, and five consecutive 0s in the upper bit-FIFO represent ~85mm of space between cylinders. Those bits are placed at each rising edge of the encoder:
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() v) I probably have the highest ratio of forum posts to actual applications in the field (but no longer ∞ ![]() vi) Hakuna matata. vii) Bookkeeping. Last edited by drbitboy; August 5th, 2022 at 03:51 PM. |
![]() |
![]() |
#4 |
Lifetime Supporting Member
|
And here are the guts of the ladder logic. I don't know Omron or how it does a bit-FIFO shift or how it addresses individual bits, so the actual syntax is again left as an exercise for the user.
Front end
Middle
Back end
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() v) I probably have the highest ratio of forum posts to actual applications in the field (but no longer ∞ ![]() vi) Hakuna matata. vii) Bookkeeping. |
![]() |
![]() |
#5 | ||||
Member
![]() ![]() Join Date: Nov 2019
Location: Seoul
Posts: 15
|
![]()
Dear drbitboy,
First of all, Thank you so much for a very quick and very detailed reply! I'm now in process of digesting your posts before converting them to the actual PLC logic (BTW, it's a SIEMENS S7-1500 PLC series, not Omron). A few notes and comments along the way. Quote:
Quote:
Quote:
The Omron Vision system reports the exact pixel value (1D coordinate in range from 1 to 1600) of the defect for each camera. If there is no defect (or no product on the belt) a certain known "default" value is sent instead. However, this information comes to PLC in the form of serial communication messages which are fixed in time but are not synced to the entrance prox edge. It is typical for the system to receive 2 or 3 of these messages during the time it takes for the cylinder to pass through the belt. Also, please consider that other cylinders would enter the belt before the cylinder that we are "focused" on leaves. Quote:
I am still looking at your algorithm in detail and will reply to them later on. Thank you so very much again for your help and all the time you put into following this issue! ![]() |
||||
![]() |
![]() |
#6 | |||||||
Lifetime Supporting Member
|
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
* Remember that PLC programs are about detecting when events happen (are measured) and when to act on those events. As noted earlier, we are keeping track of cylinder presence and defect presence independently in two different FIFOs, but those FIFOs are aligned (starting at the entrance prox) and shifted synchronously (i.e. together) via the encoder input, so if a contiguous sequence of 1s in cylFIFO, indicating a length of cylinder, is aligned with a corresponding contiguous sequence of all 0s in defFIFO (i.e. at the same indices as the cylinder 1s), then that cylinder has no defects. If even one of the defFIFO values at those indices is a 1 i.e. not a 0, then there is a defect in that cylinder. In addition, if a defect is detected, it is probably worthwhile setting some buffer bits 1 or 2 indices to either side of the nominal defect index as well; as long that buffer is small enough and the gaps between cylinders is big enough, the buffer bits will not affect the adjacent cylinders upstream or downstream. Quote:
Clarification (1/4.1) means there may not be a 1:1 scaling from encoder count to FIFO index, but it is linear which is good enough; sub-sampling may be the way to go. The important thing is that there are contiguous sequences of 1s for cylinder presence and contiguous sequences of 0s for gaps (cylinder absence). Clarification (2/5) means we may not need cylFIFO if we use the trailing edge of the exit prox to choose when to trigger (or not) the ejector rod, but in any case we will need to know the index in defFIFO that corresponds to that exit prox, because any 1 at that index in defFIFO, while the exit prox is 1, means that cylinder should be rejected when the exit prox has its falling edge to 0 at the trailing edge of that cylinder.
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() v) I probably have the highest ratio of forum posts to actual applications in the field (but no longer ∞ ![]() vi) Hakuna matata. vii) Bookkeeping. Last edited by drbitboy; August 6th, 2022 at 01:16 AM. |
|||||||
![]() |
![]() |
#7 |
Member
|
I agree with Brian, as we have discussed this many times on this forum (suggest you search the forum for conveyor or part tracking).
The only thing I will add is that an encoder will probably give too many pulses per x distance, this would require a massive shift register & probably would increase the scan time & possibly shut it down. Other methods could be add a separate cogged wheel & a proximity to give for example a pulse every x mm (does not have to be exact but enough pulses to give a reasonable registration of the position of a defective part it would depend on the length of the conveyor from the detection to the reject station). For example, using Brian's nice picortial of the shift the number of pulses could be as little as 3 or 4 per width of the part, also a window i.e. if the reject sat at a relative position 100 pulses from the detection area, then the reject window could be position 98 to 102, if a sensor was also used at the reject station then then the front end of the part was detected & shift one of the positions 98 to 102 was a "1", then reject, this ensures the part is in the exact position for reject in other words the window is just the width of the part. or smaller but not a single register position if it spanned more than the part width. Trying to do it with maths i.e. take the actual encoder value at detection then add an offset for the reject position then move them along a shift register would be processor hungry, also would have to detect roll over of the encoder count this becomes a little complex well for my old brain anyway. |
![]() |
![]() |
#8 |
Lifetime Supporting Member
|
+1 ![]() And I agree with @parky. One way to deal with this, assuming the encoder rollover is a power of 2 (e.g. 8192 = 213), is to use one of the bits of the encoder that will always take at least one or two PLC scan cycles to change. Simple calculation of encoder rate
Those are just sample estimates based on earlier posts and a guess at the encoder/conveyor wheel diameter, but it should be illustrative of the process. If it is close then it means that
If that calculation is not close, then that only means a different bit in the encoder count would be used to trigger the bit shifts; the key is to pick a bit for which the scan cycle never fails to detect an edge. If the encoder count rollover is not a power of two, then it gets messier, but still solvable.
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() v) I probably have the highest ratio of forum posts to actual applications in the field (but no longer ∞ ![]() vi) Hakuna matata. vii) Bookkeeping. Last edited by drbitboy; August 6th, 2022 at 09:36 AM. |
![]() |
![]() |
#9 |
Member
![]() ![]() Join Date: Nov 2019
Location: Seoul
Posts: 15
|
Thank you, @drbitboy and @parky for all your answers and very detailed explanations!
Going through them, I do have a few questions. But I shall first try to find the answers to them myself first, before posting them here... I'm working on that. Best Regards, AK5fa |
![]() |
![]() |
#10 |
Lifetime Supporting Member
|
Glad to help.
P.S. Siemens does not have a FIFO instruction, so you will have to roll your own. Easiest way is to leave the bits in place (Array[0..2047] of Bool) and shift the position of the Entrance Prox to the left (equivalent of IndexOfEntranceProx := (IndexOfEntranceProx + 2047) & 16#7FF ![]()
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() v) I probably have the highest ratio of forum posts to actual applications in the field (but no longer ∞ ![]() vi) Hakuna matata. vii) Bookkeeping. |
![]() |
![]() |
#11 |
Lifetime Supporting Member
|
It works pretty much as expected. Siemens/TIA Portal is missing the convenience of a built-in FIFO, but rolling our own with fixed bits and shifting indices was straightforward.
It would be easier (but boring) to do at least some of this in SCL. Rename the .zip to .zap14. In the image below:
The physical elements (proximity sensors; encoder) are simulated/emulated, so the four program block that start with emu_, out of the ten total, can be ignored. Everything is running off of encoder counts, so varying the speed of the conveyor, over a range of perhaps 5-150% of nominal, should not cause any problems, although the timing of the ejector rod is at best a wild guess, and could be a brittle parameter at varying speeds. Untitled.png
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() v) I probably have the highest ratio of forum posts to actual applications in the field (but no longer ∞ ![]() vi) Hakuna matata. vii) Bookkeeping. |
![]() |
![]() |
#12 |
Lifetime Supporting Member
|
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() v) I probably have the highest ratio of forum posts to actual applications in the field (but no longer ∞ ![]() vi) Hakuna matata. vii) Bookkeeping. |
![]() |
![]() |
#13 |
Member
![]() ![]() Join Date: Nov 2019
Location: Seoul
Posts: 15
|
Dear all,
Sorry, for not informing you earlier. I've been away for a week or so. I manage to solve the issue with some help from the Omron Vision system (in form of clarification). The missing crucial detail was that the 4 cameras are producing the sequential 1D coordinates of the defects they see. In other words, if the 1st camera may give the coordinates in 0~1600 range (pixels), the 2nd would give the coordinates from 1550 to 3150 and so on. Brian, thank you so very much again for the wealth of detailed and practical information that you shared with us! Regards, AK5fa Last edited by AK5fa; August 23rd, 2022 at 12:27 AM. Reason: clarity |
![]() |
![]() |
#14 | |
Lifetime Supporting Member
|
Quote:
Interesting. Assuming the cameras are in fixed positions, that only changes the scaling from [pixel location of a defect] to [the index into the boolean array], i.e. the camoffset and camdivisor inputs of the Camera FB; specifically, it is possible that the camoffset could be negative for the later cameras.
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() v) I probably have the highest ratio of forum posts to actual applications in the field (but no longer ∞ ![]() vi) Hakuna matata. vii) Bookkeeping. |
|
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Omron CJ2M string data from vision system | andepand | LIVE PLC Questions And Answers | 13 | September 21st, 2022 01:55 AM |
Most versatile machine vision | DavidRojas | LIVE PLC Questions And Answers | 1 | September 1st, 2021 12:46 PM |
Omron FZ4-L355 Vision & Profinet | Mike_RH | LIVE PLC Questions And Answers | 0 | February 24th, 2012 04:03 PM |
Omron Communications Cable | SouthPahw | LIVE PLC Questions And Answers | 8 | June 14th, 2011 07:54 PM |
Omron Vision Sensor | Tim | LIVE PLC Questions And Answers | 9 | October 25th, 2003 12:34 AM |