# how to map a pid controller to a process

How do you "map" the output of a PID controller to a process?

Say you have a resistor, a thermometer, and a PID controller. The thermometer provides feedback, and the PID controller can control the electric current of the resistor. You want the resistor to run at X degrees, so you use the PID to regulate the current going through the resistor.

Do you connect the PID such that the controller sets the current to a certain level, or do you connect the PID such that the controller adds/subtracts current to the instantaneous current to reach the desired level?

That is, does a PID's output directly control the process output or does the controller's output keep changing a processes output to reach a desired level?

EDIT: Whooo man, did I write this? I asked this question 2 years ago when I was first fiddling around with a PID. Now, I can barely understand what I was asking. At any rate, @spehro pefhany's answer provided what I think I was looking for back then: a comparison of position- vs velocity-based control.control.

• What do you mean by 'map'? The PID input is the error, which is the difference between required and actual temperatures - both of which are normally represented by direct voltage levels. The PID output drives some form of amplifier that adjusts the voltage across the resistor (or current through, depending on amplifier type). There is a nonlinear relationship between resistor voltage and temperature, but the closed loop will deal with it. – Chu Jul 21 '15 at 6:46
• @Chu I didn't phrase my question very well. I'm confused on how to connect the output of a PID to a process. Will the PID output always be amplified? Or will there be some function that converts PID output to process output? Or does it all depend on the system? – techSultan Jul 21 '15 at 14:04
• The PID output will usually be a low power signal from a DAC that will need some form of amplification. For the system you describe it may be convenient to use a current source. – Chu Jul 21 '15 at 15:44

Do you connect the PID such that the controller sets the current to a certain level, or do you connect the PID such that the controller adds/subtracts current to the instantaneous current to reach the desired level?

There are different PID algorithms that do either of those two things. The latter type is called a velocity algorithm (because it controls the velocity of a hypothetical mechanical valve motion rather than the position of the valve). Since the valve performs the integration there were once some advantages to this method- for one thing it automatically stops integrating when the actuator hits the limit, which helps with overshoot due to integrator windup. However, if you are using derivative control it must be double differentiated- which tends to make that contribution very noisy.

By the way, controlling the current through the resistor is usually not a good idea. What you want to do (typically) is to control the power. The resulting nonlinearity from voltage control will usually make the controller hard to tune well over a range of setpoints (it will either be too sluggish or not stable enough).

• Hey @Spehro, well said. Would you mind adding more info to how would the current be mapped to the temperature and how "nonlinearity from voltage control will usually make the controller hard to tune". I will be really thankful :) – Pe Dro Oct 20 '20 at 16:27
• @PeDro Heat loss to the environment is pretty complex in general, as it involves radiation losses and fluid dynamics, but if we assume it's linear (more or less exactly true for conducted heat loss) then you have linearly higher heat losses at a higher temperature vs. the environment but square law higher power with controller output if you are feeding current to a fixed resistance (I^2R). A first approximation is to use the square root of the controller output from 0..1 for 0..1 output, so at 50% controller output you have 70.7% current but 50% of full power. – Spehro Pefhany Oct 20 '20 at 16:50
• Ohk. That sounds quite intuitive. By "from 0..1 for 0..1 output" do you mean re-scaling the temperature range to range of the current ? i.e., if the temperature in Kelvin was in range (273 to 300) and is measured as 300, its root comes out 17.32 and this then scaled to the current range (0 to 2A).. is this what you meant ? – Pe Dro Oct 21 '20 at 5:23
• @PeDro Modifying the output of the controller from 0..1 (= 0..100%). It's not directly related to temperature, it's after the PID calculation. – Spehro Pefhany Oct 21 '20 at 6:16

If you consider current as your output then it "keeps changing" as you say. However if temperature of the resistor is your output then it keeps it at desired level. That is what PID is for. Your feedback should be your temperature and your input is "feedback - desired level" (which is called 'error'). PID deals with current, you don't.

• Yes, but how should I connect the PID to my system? Will the output of the PID = current, or is there some function that converts PID output to the necessary current? I'm confused on how to connect the PID output to my process (which isn't this thermometer/current example). – techSultan Jul 21 '15 at 14:06
• Do you know the transfer function of your system? You need to obtain the transfer function of the system and that function will give you the idea of how the current is related to the temperature. And yes, output of the PID is current. – zgrkpnr89 Jul 22 '15 at 17:53
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.6211499571800232, "perplexity": 766.4977239033157}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2021-17/segments/1618038072082.26/warc/CC-MAIN-20210413031741-20210413061741-00536.warc.gz"}