This is the same example as HBridge_RL
but using a triangle (instead of a sawtooth) as pwm reference signal.
This enables an easy sampling of the current in the middle of the pwm period, which delivers with good approximation the mean current:
Compare meanCurrent.y
and zeroOrderHold.y
.
For discrete or quasi-continuous control it is essential to sample the correct mean current with low effort once during the pwm period.