ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview PID controller PWM

Solved!
Go to solution

Hello everyone.

 

Iam working on a Labview temperature control program which makes use of a PDI controller, a heater and a thermocouple reading the temperature.

Iam able to read the sensor and I think I have managed to implement the PID as well.

What I need to do now is to convert the output of the PID into an appropriate Duty Cycle in % to energize/de-energize a Solid State Relay for the heater supply voltage.

 

To generate a square wave I thought using the Square Waveform.VI. (see image below)

 

The output for the PID is in the range of 0...5V so I guess I have to scale this output in some way?

 

Thanks in advance  for any help,

 

best regards,

MichaelPID_temp.png

0 Kudos
Message 1 of 8
(7,083 Views)
Solution
Accepted by topic author ´MikeSv

I haven't seen that Simple PID VI in a while, and if you have access to the PID toolkit (now included with non-Base versions of LabVIEW) you should use that one instead. In either case, though, the output limits are set by the inputs to the VI - in your case, the "lower limit" and "upper limit" controls. Change those so they're 0 and 100 and then use the output as the duty cycle.

0 Kudos
Message 2 of 8
(7,070 Views)
Solution
Accepted by topic author ´MikeSv

Is it a linear relation between 0-5V and 0-100% duty cycle?  If so, it should be pretty simple to do a linear conversion. 

 

For example, if you get 3.7V from the PID, solve the equation:

3.7V / X % = 5V / 100%

X = 74% Duty cycle

 

If you have the PID toolkit from NI, I think this functionality is built-in to the PID.vi.  You simply specify the output range and the VI will handle the rest. 

aputman
0 Kudos
Message 3 of 8
(7,069 Views)

Oh man....

Sure it is linear. It's too late at my place.

 

Thank you!

 

Regards,

 

Michael

0 Kudos
Message 4 of 8
(7,053 Views)

Thanks for your reply. I actually have access to the toolkit.

I think I found the old PID VI in some exemple code.

 

I didnt know it was that easy to scale (If this is the right word here) the output of the PID that easy.

 

regards,

 

Michael

0 Kudos
Message 5 of 8
(7,050 Views)

Thanks for your reply. I actually have access to the toolkit.
I think I found the old PID VI in some exemple code.

I didnt know it was that easy to scale (If this is the right word here) the output of the PID that easy.

regards,

Michael

0 Kudos
Message 6 of 8
(7,049 Views)

@´MikeSv wrote:

I didnt know it was that easy to scale (If this is the right word here) the output of the PID that easy.

You're not scaling anything here, it's just a limit on the output. The proportional gain scales the output to the input. So, you could use the 0-5 output and scale it to 0-100 as aputnam suggested, or you could take the direct route of changing the output limits, in which case you would need a proportional gain (Kp) 20x larger (to turn 5 into 100) for the same results. Mathematically these are identical.

0 Kudos
Message 7 of 8
(7,036 Views)

Hi again.

 

Thanks for the explaination! Smiley Happy

 

Regards,

 

Michael

0 Kudos
Message 8 of 8
(7,032 Views)