Ah, the fact that it's a theoretical school project makes a difference
As far as keeping the spacing intact, I'd probably look at something along the following lines:
- The second conveyor (the one closest to the packing robot) stops when a carton is at the end of it. Once the robot removes the carton, the conveyor will restart. This bit seems straightforward
- The first conveyor (furthest from the robot) stops if a carton appears at the end of it, and the downstream conveyor is stopped OR the previous carton has not progressed far enough along the second conveyor to maintain required gap. This one is a little more complicated. The "stop if a carton gets to the end and the second conveyor is stopped" bit is easy, but the "maintain the required gap" bit is not so much. First, you'll have to take a stab at a "time gap" - for example, let's say that based on the conveyor speeds, the cartons need to be a minimum 2 seconds apart to maintain the required physical gap. So you need to know that since the previous carton left the first conveyor, the downstream conveyor has had more than two seconds to take it away before your first conveyor can discharge the next carton. If a second carton appears within that two second window, your first conveyor has to stop until that two seconds has elapsed.
Remember, that two seconds has to be two seconds
with the downstream conveyor running. So if it's been two seconds since it left, but the downstream conveyor was stopped for one of those seconds, you still have one second to go once the downstream conveyor restarts, before your first conveyor can discharge a carton.
Hopefully that will get you moving