Project Overview

I am trying to implement PID control with a heater controlled through a Solid State Relay (SSR). The process variable is the temperature measured using a type K thermocouple at the point of interest.The set point (temperature) can be controlled using a numeric control on the front panel.

The output is given as a number between -100 and 100; this represents the percentage of ON/OFF for pulse width modulation (PWM). Essentially it tells you what percentage of the time a 1 or 0 is represented. If the output is 70, then the pulse will be ON 70% of the time and then OFF for 30% of the time for each cycle.

The output is not in a form that can be directly connected to the heater output, so PWM must be implemented. The heater is controlled through a SSR which is fed a digital signal (ON/OFF). Thus, we must convert the output to a digital signal.


For each iteration, I want to do the following:

  1. Calculate the OUTPUT using the subVI
  2. Create a loop that will send an ON signal to the SSR for a percentage of time and OFF signal the rest of the time
  3. END


The following is an image of the VI I have created:

Pseudocode of the VI

  1. Ask for inputs
  2. Set Point
  3. PID Settings
  4. Output Range
  5. Total number of steps to run through (iterations the for loop will run through)
  6. Calculate the number of iterations the digital signal will be ON by multiplying the number of iterations by the OUTPUT (%)
  7. for each iteration, if i < (iterations * output), send ON to the SSR, otherwise send OFF
  8. Move on to the next Cycle


Using this process and implementing a quick step test, you get something like the following:

Clearly, the loop still needs to be tuned, but this is a good start! If you have any ideas on how to improve this method, please fork the code and try it yourself.