How to get two slow WPM outputs based on one analogue input form a PID function (or from all other kind of analog value) ?

This subroutine provides two digital outputs:

  • one for the “hot” function
  • one for the “cold” function

with slow PWM function over a given period depending on an analogue input, a setpoint and the selected period

  • PID_Output: The analog input value from, most of the time, the PID output tool
  • PID_OutMax/Min: The min and max value of the PID_Output value. (For determinate the total range of the analog input)
  • PID_Target: Where you want to go
  • Periode: Total periode of the slow PWM
  • GoUp/GoDown: 2 digital outputs for the “Hot” and “Cold” fonction

You can download the example program with its subroutine here