← All exercises

VFD Speed Ref

medium

Clamp an operator percent to 0-100 and convert it to the raw 0-32767 speed reference a VFD expects.

What it teaches

Composition: clamp, then scale. The percent arrives from an HMI and can be garbage outside 0-100, and the drive wants raw counts, not percent — so pin the input to its valid range first, then scale 0-100 to the 0-32767 DINT reference. First exercise that chains two known patterns into one block: the shape of every real signal-conditioning chain.

Inputs and outputs

TagTypeDefaultDescription
In_PercentREAL50Operator percent speed reference from HMI
Out_SpeedRefDINTRaw speed reference for the VFD (0-32767)

Required behavior

  • Out_SpeedRef is clamped to 0 when In_Percent is less than or equal to 0.
  • Out_SpeedRef is clamped to 32767 when In_Percent is greater than or equal to 100.
  • Out_SpeedRef scales linearly between 0 and 32767 for In_Percent values between 0 and 100, rounded to the nearest whole number.