A method
BMAN
You have two problems: The need to detect an event at one station while performing the event at another; and a variable number of objects betwee the two stations.
Take the problems one at a time.
The solution to the first problem is a FIFO (or bit shift, since you only need pass on one bit of data).
The solution to the second is a pointer / indirect address.
Let's assume that the maximum number of pallets that can fit between the Wrapper INFEED (where the red is detected) and the Strapper INFEED is 16.
You'll want logic that sets (resets? - you may need to use latching logic to make this work) a bit that says that the pallet currently in the Wrapper needs to be strapped. I'm not clear (nor does it really matter) whether you detect the red on entry, or immediately before.
You will need a photoeye (and I think you say you have one) on the EXIT from the Wrapper. When that photoeye sees the pallet, it needs to do two things: Trigger the bit shift, and increment the Pointer.
When the photoeye at the entrance to the Strapper detects a pallet entering the strapper, it decrements the pointer.
Now for some code/illustration.
You create a Bit Shift Register at B10:0 (for example).
B10/0 will represent the pallet in the wrapper.
N7:0 will be the number of pallets between the wrapper and strapper. In the example below, the current number is 5
B10/[N7:0] will therefore represent the pallet that is currently in the strapper.
NEEDS_STRAPPING B10/0
----| |--------------------------------------------( )-
||
||
\/
B10:0 /7 /6 /5 /4 /3 /2 /1 /0
Current Values 0 1 0 1 0 0 1 0
||
||
\/
B10/[N7:0] DO_STRAPPING
--------------------------| |----------------------------( )-
WRAPPER_EXIT_PE +------- BSL ---+
-----| |------------[OSR]--------+-------| File: #B10:0 |
| | Bit: B10/0 |
| | Len: 16 |
| +---------------+
|
| +--------- ADD ---+
+-------| N7:0 = N7:0 + 1 |
+-----------------+
STRAPPER_ENTRY_PE +--------- SUB ---+
-----| |----------[OSR]-----------------| N7:0 = N7:0 - 1 |
+-----------------+
Now there's all sorts of extra code to put in here: debounce logic to make SURE that one and only one signal is triggered per pallet, and some reset logic so that the pointer (N7:0) can never get below 0 or above 16; but that's the general outline.
This will work well enough, except for one MAJOR problem. It's all too possible for the system to get out of synch. If a pallet is removed between the wrapper and strapper, or is someone climbs onto the conveyor to fix something, and block either photoeye enough to cause pointer to get off, then you'll be strapping the wrong pallet, which is not good. And you will always, consistantly be one off (or two, or three).
The way to fix this is to provide the operator with a "sanity check". The operator needs to see how many pallets that the PLC "thinks" are between the two devices, and give him the ability to change that setting. This can be as simple as a BCD LED display with two pushbuttons (increment, decrement), or as fancy as an HMI/SCADA. But that control MUST exist.
The very minimum "sanity checker" would be a "reset" button where would set the pointer to 'zero' (or 'one', depending). Your operaors would have to have a procedure that, if the system got out of synch, to run out all the pallets beween the wrapper and strapper, (which would only decrrement the pointer), and then pressing the reset button (to clear any "ghost" pallets that the PLC thinks is there).
This strategy can also be applied to "detect"/"reject" stations that are separated by a variable number of bottles/objects.
Good luck