DEV Community

PackForge Industries
PackForge Industries

Posted on

Modeling a Stretch Wrapper Recipe in Code: Turntable RPM, Wrap Counts and Cycle Time

Industrial machines often store "recipes": named sets of parameters that a PLC loads so the same machine can handle different loads consistently. A stretch wrapping machine is a nice, concrete example to model in code.

What a stretch wrapper actually does

  • A turntable rotates the load.
  • A film carriage travels up and down a tower, laying stretch film around the load.
  • Pre-stretch stretches the film before it reaches the load, so each load uses less film.
  • A PLC stores named programmes, so one machine can wrap several load types the same way every time.

A recipe as data

from dataclasses import dataclass

@dataclass
class WrapRecipe:
    name: str
    turntable_rpm: float      # e.g. 3 to 12 rpm on a pallet wrapper
    bottom_wraps: int
    top_wraps: int
    up_down_passes: int       # carriage travels
    load_height_mm: int
    carriage_speed_mm_s: float

    def cycle_time_s(self) -> float:
        sec_per_rev = 60 / self.turntable_rpm
        wraps_time = (self.bottom_wraps + self.top_wraps) * sec_per_rev
        travel_time = self.up_down_passes * self.load_height_mm / self.carriage_speed_mm_s
        return round(wraps_time + travel_time, 1)

    def loads_per_hour(self) -> int:
        return int(3600 // self.cycle_time_s())

heavy = WrapRecipe("heavy pallet", turntable_rpm=10, bottom_wraps=3, top_wraps=2,
                   up_down_passes=2, load_height_mm=1500, carriage_speed_mm_s=60)
print(heavy.cycle_time_s(), "s per load")      # 80.0 s per load
print(heavy.loads_per_hour(), "loads per hour") # 45 loads per hour
Enter fullscreen mode Exit fullscreen mode

The numbers above are illustrative, but the structure is exactly why PLC recipes exist: change one field (more bottom wraps for a heavy base, slower rpm for a tall unstable load) and every operator gets the same result.

Validating recipes against machine limits

A recipe should never ask for more than the machine can do. Encode the limits next to the data:

LIMITS = {"turntable_rpm": (3, 12), "max_load_kg": 2000}

def validate(r: WrapRecipe, load_kg: float):
    lo, hi = LIMITS["turntable_rpm"]
    if not lo <= r.turntable_rpm <= hi:
        raise ValueError(f"rpm {r.turntable_rpm} outside {lo}-{hi}")
    if load_kg > LIMITS["max_load_kg"]:
        raise ValueError("load exceeds turntable rating")
Enter fullscreen mode Exit fullscreen mode

Those limits are taken from a real spec: a pallet wrapper with a 2000 kg turntable and 3 to 12 rpm speed range. Real machines quote roughly 20 to 40 loads per hour, which is a good sanity check for your model.

If you want to see how the physical machines compare (pallet vs box wrappers, top press, PLC models), this stretch wrapping machine buying guide lays out the real specs behind the numbers used here.

Top comments (0)