Board sorting line

Seems like it's being overly complicated. Two choices:

If the resolution is such that the array isn't enormous, then use a shift register of array type UDT that contains whatever info is needed for a board. That UDT can be populated at the beginning or any stage along the way with additional info.

If the resolution is such that the array becomes unwieldy, create an array of the total possible boards in transit instead. Same UDT, except an additional field holds the current position. Every array element is then updated every X counts with a simple ADD. You could do it with a virtual axis tied to the encoder and use the motion event trigger which is going to be in the 2ms range. Then the eject trigger points are just comparing current position element of the UDT.
 
if you subtract 2^32-1 from 2 the difference will be 3. No problem.
Don't worry about rollover. Use 32 bit numbers. Have a 32-bit global encoder count that gets incremented by the physical encoder. Now you don't need to worry about rollover. Think about it. At each station store the current global encoder + the encoder offset till the next station and a code for what that station is. every scan compares the global encoder with the stored encoder for each board to see if the global encoder is greater. If so, then execute the function determined by the function code.
Don't make it difficult.
say a board shows up on a scan cycle when the global encoder count of 232-2, and the board is destined for the station at 5000, so according to the logic proposed above, the code store(s) the current global encoder + the encoder offset i.e. it stores 4998 (=(232-2) + 5000) at that station*,

On the next scan, the code compares the global encoder value, which has now incremented to 232-1, which global encoder is greater than 4998, and so the code executes the function: problem.

* never mind that there might be another board destined for that station that comes along and overwrites that 4998 before that 4998 triggers the ejection.
 
Here are the guts of the FIFO/Shift Register approach.

Obviously there would be a lot more (start/stop/run/fault/etc.) in the full application, but these first two rungs to set it up and keep it running. The code shifts the array down, so the grader is at "index" 1250 and the last ejection station is at index 0, so the MOVE_BLK_VARIANT can be used (I assume it has the same limitation as COP in RSLogix).

The last rung has the logic to actual drive the ejection stations, which could be run through a TOF to stretch the duration of the discrete output signal voltage.

Also, the values of the indices (≡ positions) of the ejection stations (625, 500, 375, 125, 0) could be stored in tags that could be adjusted to tune the system.


1734110864425.png
 
Think about using signed numbers. S7s can use signed numbers.
signed/unsigned does not matter; the bits are the same when adding/subtracting/incrementing; the application does not care about the absolute value of the encoder counter.

Bottom line: it will not work as you described in Post #14; it should work as you more or less described in Post #17, but that is what I was referring to as dealing with rollover in the first place.
 
Here are the guts of the FIFO/Shift Register approach.

Obviously there would be a lot more (start/stop/run/fault/etc.) in the full application, but these first two rungs to set it up and keep it running. The code shifts the array down, so the grader is at "index" 1250 and the last ejection station is at index 0, so the MOVE_BLK_VARIANT can be used (I assume it has the same limitation as COP in RSLogix).

The last rung has the logic to actual drive the ejection stations, which could be run through a TOF to stretch the duration of the discrete output signal voltage.

Also, the values of the indices (≡ positions) of the ejection stations (625, 500, 375, 125, 0) could be stored in tags that could be adjusted to tune the system.


View attachment 74756
Now I understand the concept of operation
 
I found some typos:
  • the destination of the MOVE_BLK_VARIANT should be mydb.fifo[0] (not [1]!);
  • element value at index 1250 should be written as 0 after the shift;
  • added a screenshot of the DB.
 

Attachments

  • 1734114227604.png
    1734114227604.png
    52.5 KB · Views: 5
  • 1734114320409.png
    1734114320409.png
    9.1 KB · Views: 5
signed/unsigned does not matter; the bits are the same when adding/subtracting/incrementing; the application does not care about the absolute value of the encoder counter.

Bottom line: it will not work as you described in Post #14; it should work as you more or less described in Post #17, but that is what I was renfnerring to as dealing with rollover in the first place.
Yes, it will. If we are dealing with a 16 bit counter, 5 is only 7 away from 65536-2 or 65534. You need go think modulo 65536 in this case.

Don't shift data. That is very slow. Move indexes. For best speed use multiple queues. One for each station. Queues internally move indexes and don't move the data.
 
Yes, it will.
sigh. not it will not, see detailed Example from Post #14 below.

If we are dealing with a 16 bit counter, blah blah blah
please. the bitboy does not need to have bits explained ;).

Post #14:
Don't worry about rollover. Use 32 bit numbers. Have a 32-bit global encoder count that gets incremented by the physical encoder. Now you don't need to worry about rollover. Think about it.
Oh please.

At each station store the current global encoder + the encoder offset till the next station and a code for what that station is.
Example:
  • scan N:
    • board is graded as needing ejection after moving 10000mm (10k increments of global encoder counter)
    • current global encoder value is 2147483647 (=232-1)
    • adding 10k to current global encoder yields value 9999,
      • which is stored as the encoder value for the 10k ejection station to check
every scan compares the global encoder with the stored encoder for each board to see if the global encoder is greater. If so, then execute the function determined by the function code.
  • scan N+1 (~1ms after scan N):
    • current global encoder has not changed, is still 2147483647
    • per your description,
      • the logic "compares the global encoder [value (2147483647)] with the stored encoder [value (9999)] for [this] board to see if the global encoder [value] is greater"
        • it is so, i.e. 2147483647 is greater than 9999, so the ejection station at 10000mm from the grader is activated,
          • even though the board that activated it is still within a mm of the grader, 10000mm upstream
            • whoops.
Don't make it difficult.
Don't suggest stuff that won't work.

Not only that, but your model also needs an array of stored encoder, values plus another array of function codes, for each active board, and code to manage the elements of those arrays which are active, which are not, etc. I have written stuff like that; it is far more difficult than a FIFO array,
  • whether the values in the array are shifted
    • to model the boards moving relative to the conveyor elements (grader, ejection station) at fixed positions,
  • or the indices are incremented
    • to model the conveyor elements moving relative to the boards at fixed positions.
I have coded it both ways; there is nothing new under the sun.
 
Don't shift data. That is very slow. Move indexes. For best speed use multiple queues. One for each station. Queues internally move indexes and don't move the data.
Yes it is more efficient with regard to CPU cycles, not to mention very elegant and satisfying.

Yes, I have done that as well, but I was naive back then; I thought about posting an example here, but it would only be a distraction.

Because CPU cycles efficiency in a world with Moore's Law is not what makes the most money (or loses the least money).

Clear, concise, simple to understand code is what makes money.

If you can implement a moving index version that is cleaner than the first screenshot image in Post #23, then there will be something to discuss. But you can't, so there isn't. Stop misleading others down a primrose path to nowhere. Only in an application with an array much larger than OP's would it be necessary to use the fixed-boards/moving-stations/moving-indices model; it would never be clever, only necessary.

"Best speed" (i.e. low CPU usage) is not always a money-making metric.
 
I know what I would do (if Mitsubish PLC), however, probably would work on Siemens or most others but not done high speed sinces the days of S5.
First, use a sensor to measure the length with the encoder, (32 bit) shoulkd have no problem with rollover) so on sense of front edge reset the HSP counter, measure the board so you have the length regardless if you use conversion to mm etc.
Then I would Write a little bit of simple logic so store currrent count, when current count is >= to some fixed value (for example say 100 counts) use this as a pulse to drive the shift register, & update the store. pretty simple to trap when the count is reset so reasonably accurate pulse can still be calculated but probably not required, the shift register probably only needs to be small as only used for registration for the diverts & if sensors are used on the diverts just compare a range when sensor coverd, therefore you have accurate size & pretty well an accurate enough track of the board size.
 
Here is some rather quick code based on something I did some years back.
The encoder value would be reset on the front edge of the photocell, when the photocell clears (board left) then that value is then compared to my fixed board lengths (note: here I'm just using the counts as length perhaps you would use a conversion into mm/inch etc.). & if the board is > than the fixed lengths then it would set the board type i.e. 1,2,3 (only showing 3 & perhaps you would have a > AND < so any out of spec perhaps travelled passed the diverts to a scrap pile.
The encoder pulses are also divided & fed to a counter which effectively gives a pulse every x mm, this then shifts the board types into the array, the reason for this division & count is that if using pulses directly from the encoder would need a massive array, so you could just have the board type move down the array in a scaled measurement then pick the array nearest to the end of the divert do a compare for example lets say divert small was word 20 of the array use this for the compare for 1 (small board). Ideally, using a PE on the divert & checking say 3 registers in the array any sloppyness or coarse shifting of the array would ensure the board is in correct position to divert.
No need for any way of tracking HSC over multiple bits of logic, the small error of 2 pulses would be insignificant as for position especially if the sensors are used on the civert positions.

1734201487457.png
 
What I suggested does work. 1 o'clock is two hours ahead of 11 o'clock. The difference isn't 10.
The limitation is that you can't add and offset more than half a revolution or have the encoder change by more than half a revolution. Since an S7 has 32 bit registers, this should NEVER be a problem,
The OP still hasn't defined a tact. Irregular spacing makes no difference.
Here is an example of irregular spacing.
The potato strips, they aren't fries yet, are dumped on to the belt randomly. There are 32 lanes, and the viewer are staggered and there are two knifes per lane. There is a long queue, but the data isn't shifted. An index is moved instead so it is a circular queue. Offsets are added to the current encoder count for when the one of the knives to fire. Yes, some of the offset can look like they overflow the encoder some limit checks can handle that. Actually, I like to make everything a power of 2 elements long because it makes things simple.
https://peter.deltamotion.com/Videos/Delta Fry Cutting Machine Demo.mp4
My first job out the navy was a lumber sort and in an a few months I was running the computer compartment.
Later, at Delta we made these automatic defect removal machines for potato strips.

I agree with the statement above, "Don't reset the encoder". It isn't necessary and a fraction of a count is lost each time you do.

BTW, the video also shows the motion profile for a clipper like device. The knife or clipper must come down and the tip should match the horizontal line speed so when the knife or clipper meets the material, it doesn't move the material forward or back relative to the line. In the case of the potato machine above, if the first knife moves the strip relative to the belt then the second cut will not be in the correct position.

So many of these questions can be answered in face to face for 5 minutes and yet they drag on for days.
 
What I suggested does work. 1 o'clock is two hours ahead of 11 o'clock. The difference isn't 10.
The limitation is that you can't add and offset more than half a revolution or have the encoder change by more than half a revolution. Since an S7 has 32 bit registers, this should NEVER be a problem,
The OP still hasn't defined a tact. Irregular spacing makes no difference.
Here is an example of irregular spacing.
The potato strips, they aren't fries yet, are dumped on to the belt randomly. There are 32 lanes, and the viewer are staggered and there are two knifes per lane. There is a long queue, but the data isn't shifted. An index is moved instead so it is a circular queue. Offsets are added to the current encoder count for when the one of the knives to fire. Yes, some of the offset can look like they overflow the encoder some limit checks can handle that. Actually, I like to make everything a power of 2 elements long because it makes things simple.
https://peter.deltamotion.com/Videos/Delta Fry Cutting Machine Demo.mp4
My first job out the navy was a lumber sort and in an a few months I was running the computer compartment.
Later, at Delta we made these automatic defect removal machines for potato strips.

I agree with the statement above, "Don't reset the encoder". It isn't necessary and a fraction of a count is lost each time you do.

BTW, the video also shows the motion profile for a clipper like device. The knife or clipper must come down and the tip should match the horizontal line speed so when the knife or clipper meets the material, it doesn't move the material forward or back relative to the line. In the case of the potato machine above, if the first knife moves the strip relative to the belt then the second cut will not be in the correct position.

So many of these questions can be answered in face to face for 5 minutes and yet they drag on for days.

I think the problem is you say "don't worry about rollover, a 32bit number will take care of it". I dont care if it's 8 bit, 16 bit, 32 or 64 bit, you still have to manage the eventual rollover. Noone is suggesting resetting the encoder. Encoder should be cyclic. But we are saying you have to manage rollover. In your example of 11 o'clock to one o'clock, you managed rollover at the 1259 postion, by knowing the next position is less than the previous on a continuously increasing encoder.
 

Similar Topics

We have some Z-312J board PLCs, there is a project to integrate Cobots, and the PLC program needs to be modified, How can we get the software for...
0
Replies
101
Views
This is WinCC V17, no I don't know if it is "flexible" "comfort" "professional" "Advanced" or any other snappy marketting word. Attached is a...
10
Replies
301
Views
I have a Siemens s1214. I made the mistake of hot swapping an RS485 board, one mounted at the front. At first the plc would flash lights randomly...
0
Replies
135
Views
There is a pad batch machine and 10 Lenze 9300 servo inverters are used. One of them is the master and they communicate via CN-bus. Additionally...
3
Replies
324
Views
Hi folks, Working on a Power Flex 755 drive that uses a 20-750-UFB-1 Universal Feedback Board to read an analog sin/cos encoder. Experiencing...
0
Replies
437
Views
Top