CogniPilot

MODELICA LIBRARY · ENGINEERING REFERENCE

function

Vehicles.Interfaces.centeredPwmToUnit

Map centered PWM microseconds to [-1, 1]

Public declarations

Explicit source declarations; dimensions, modifications and defaults are shown as written, without evaluation.

RoleNameTypeDimensions / attributes / defaultDescription
inputpwm_usReal
outputcommandReal

Modelica declarations and implementation

Show parameters, interfaces and source

Parameters, inputs, outputs, defaults and equations from the source file.

function centeredPwmToUnit "Map centered PWM microseconds to [-1, 1]"
  input Real pwm_us;
  output Real command;
algorithm
  command := MathUtilities.clip((pwm_us - 1500.0) / 500.0, -1.0, 1.0);
  annotation(Inline = true);
end centeredPwmToUnit;