LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling a digital PWM output with a PID control - Need ideas

Here is the scenario.

 

Am using LV 8.6 to run a test stand.  I special product needs to be tested at certain levels of [brushless] motor power consumption (watts).

 

The power consumption is manipulated by adjusting the PWM of the onboard controller using a pulsed logic signal. (using a counter/timer @ 20kHz tuning to between ~20 to 100% duty cycle)

 

I then read the current from the primary power supply and calculate the motor power consumption. Then feed this into a PID function and I use the ouput value to adjust the PWM input up or down.  I am running the output through some math to get an adjustment that isn't severe so it doesn't just reciprocate the level from high end to low end.

 

I am using the advanced PID function to try and tweak the control to be smooth and accurate.  It seems that even tiny changes in the PID values, specially the integral and derivative have a huge impact on the output.

 

Another option I have used before and am likely to have to use on this is to be able to select a different set of PID (and perhaps other) values dependent on the wattage range I am trying to achieve. This may go further and also be dependent on the driving voltage.  I am using this technique to select PID values for a third party pressure regulator (Tescom ER3000) and it works very well. Depending on the pressure range I need to achieve, I use different PID values to optimize the response.

 

Anyhow, I have attached the code and am just looking for any thoughts or ideas from anyone who has experience with the PID functions that might shorten my development time some.

 

I could upgrade to the latest version if there is a justifiable reason that would help me with this particular condition but as it would be a change on the test system, I would have to perform some level of re-validation and I don't want to spend time doing that if I don't have to.

 

 Thanks for any assistance

 

Doug

Doug

"My only wish is that I am capable of learning each and every day until my last breath."
0 Kudos
Message 1 of 7
(10,731 Views)

How did you obtain your PID gains?  Did you go through a standard algorithm to get good initial values?  Do you know that you need derivative control?  If your system is fast but noisy, you probably do not want any derivative gain.  For systems that react quickly, I like the Ziegler-Nichols closed-loop approach described in the LabVIEW PID manual.  The explanation of the method is OK, although the math could be clearer.  If you follow those directions, note that they do calculations in Proportional Band (PB) and then convert it to proportional gain, and that all times are in minutes (not seconds).

 

You should not need the math after the PID output; that suggests to me that you need to improve your tuning.  Eliminate that math and use the PID output limits in place of the "In Range and Coerce" node to get the output within the 20-100% range.

0 Kudos
Message 2 of 7
(10,721 Views)

I used simply the trial and error method to achieve my initial PID values. I started reading the LV PID manual on Friday but got a headache. A good manual, but not great for someone who has minimal experience with PID algorithms.

 

If I don't use integral and derivative values, I cannot eliminate the oscillation.  The other contributing factor is that the motor is running a small air pump that has to be set at a load and as the wattage is adjusted, the load fluctuates as well.  A high quality regulator controls the load quite well but this is just another variance on the load of the motor as I am trying to control the wattage.

 

Controlling the motor via wattage is a customer requirement so I can not deviate from that.

 

I will try using the output limits vs the math again but my earlier trials had no success with this.

 

Any other thoughts would be appreciated.

 

Doug

Doug

"My only wish is that I am capable of learning each and every day until my last breath."
0 Kudos
Message 3 of 7
(10,688 Views)

 


@dacad wrote:

I used simply the trial and error method to achieve my initial PID values. I started reading the LV PID manual on Friday but got a headache. A good manual, but not great for someone who has minimal experience with PID algorithms.


It's very difficult to get PID gains right through trial and error, especially if you have limited experience tuning PID loops.  I learned this a few years ago - after spending most of an hour trying to tune a PID loop through trial and error, a senior controls engineer came over, said "Let me show you the right way," and went through the Ziegler-Nichols tuning process with me.  A few minutes later it worked great.


@dacad wrote:

If I don't use integral and derivative values, I cannot eliminate the oscillation.  The other contributing factor is that the motor is running a small air pump that has to be set at a load and as the wattage is adjusted, the load fluctuates as well.  A high quality regulator controls the load quite well but this is just another variance on the load of the motor as I am trying to control the wattage.


If you cannot eliminate the oscillation, either you're not lowering the proportional gain enough, or you have another source of noise in your system.  If you can't get a stable (although offset) response with a very small P value, try filtering the input to eliminate other noise.  It is also possible that PID isn't the best control algorithm for your system, if it responds in a way that PID isn't designed to handle.

0 Kudos
Message 4 of 7
(10,672 Views)

It will also make more sense (and is generally what the PID block expects) to convert your PV and SP to %, the PID palette has vi's for this.

0 Kudos
Message 5 of 7
(10,660 Views)

OK, I decided to regroup a little on this.  I started by reviewing the basic approach of the Ziegler-Nichols formulas and found a short tutorial that in layman terms, gave me a process for the tuning.  I did indeed start out with no integral or derivative values and adjusted the proportional value up and down until I got a smooth change with virtually no oscillation.

 

It seemed at this point, making adjustments to the Int. or Der. actually worsened my response. Even miniscule values in the range of .0001 - .0005 would have a detrimental effect.

 

I also went through and did an iteration modifying the input to a percentage and the output from a percentage and it really ended up doing about the same thing as entering the set point directly and using my little math sequence to manipulate the output.

 

Back to the root of things, by using just the Pro., I can get a relatively smooth, albeit slower than desired, transition to the desired set point.  This is as long as the motor [air pump] is under no loading.  As soon as I start to add load, I get significant oscillation at the beginning and it is much slower in finally leveling out.  Because I have to start and stop the pump as we3ll as open and close valves during the test sequence, there is a lot of load changing that occurs during the sequence and if my set point response for this variable is too slow, it affects the results of my other readings during the test (air flow, back pressure, etc.)

 

I have not tried the built in auto tuning sequence yet but my gut tells me this will not work since I am intentionally modifying my process and conditions throughout the test.

 

You mentioned that perhaps PID was not my best option.  I’m not sure what other options are available unless I create my own pseudo PID routine.  I could certainly do this but am not sure it would be as efficient as the built in PID functions.

 

Making slow progress but still accepting ideas…..

 

Thanks

 

Doug

Doug

"My only wish is that I am capable of learning each and every day until my last breath."
0 Kudos
Message 6 of 7
(10,642 Views)

 


@dacad wrote:

OK, I decided to regroup a little on this.  I started by reviewing the basic approach of the Ziegler-Nichols formulas and found a short tutorial that in layman terms, gave me a process for the tuning.  I did indeed start out with no integral or derivative values and adjusted the proportional value up and down until I got a smooth change with virtually no oscillation.

 

It seemed at this point, making adjustments to the Int. or Der. actually worsened my response. Even miniscule values in the range of .0001 - .0005 would have a detrimental effect.


This is progress.  What you want is a stable oscillation so that you can measure its period, in minutes.  That will let you calculate reasonable I and D terms (you may not need the D).

 

Before increasing the I and D terms, did you first change the P term to less than the value that gives you minimal oscillation?  Most approaches for PID tuning recommend that the P term be about half the ultimate gain (the gain that produces a stable oscillation).  If you leave the P at the oscillating point, you'll have trouble getting a stable response with an integral term.

 

The Integral term is in minutes, and it is the length of time that it will take for the Integral response to duplicate the Proportional response (assuming a constant setpoint and process variable).  Using a small value for I will increase the effect of the integral, because it reduces the amount of time necessary for the integral to have the same output.  Internally the PID algorithm divides the Proportional gain by the Integral time, and uses that as the Integral gain.  This is a standard form that gives a physical meaning to the I term, and is in the manual.  Similarly the Derivative gain is actually the product of the P and D terms.

0 Kudos
Message 7 of 7
(10,632 Views)