Control Design for L7 Project

Introduction

In your Level 7 project it is not sufficient to just use some available example code and trial and error or some autotuning functions to come up with a PID controller without any real understanding of how it works. You can do this and get it working but we will be looking for a good fundamental understanding of control design and a systematic approach to the task. This document is provided to help guide you through this task. While it focuses on the implementation of PID control using LabVIEW, the principles apply to any system.

Control Design Methodologies

In designing a controller for a system there are two basic methods you can follow, model based design or design based on plant testing.

Often the model based approach is preferable as you can use software (e.g. SIMULINK) to do most of the work on the control design, minimising the time that you need to spend on plant testing. This saves taking the plant off-line (and out of production) for long periods of time or in the case of a newly installed system, reduces commissioning time. With more complex systems it may not be possible to achieve good quality control by plant testing alone and some model-based approach will be necessary. The drawback of the Model-based approach is that of course you need a model and it is not always easy to get a good model of the process.

PID controllers can be designed with or without a model. If you cannot model your system very well, there are some established techniques for tuning the PID values by plant testing. You might have to adopt these anyway if your model-based attempt doesn’t work out (due to non-linearity, excessive lag and/or noise in the real system for example).

Guidelines for Control Design Process

Here is a basic overview of the steps you should go through in developing your PID controller:

1)Specify the performance your system requires

  • What are the main requirements of your system? Is speed of response most important, or do you need to avoid any overshoot? Set out some performance specifications for system, e.g. Settling Time = 5s and Overshoot not more than 10%.

2)Can you obtain a model of your system?

  • You may be able to model from theory of how your system works (e.g. there are equations you can use to model say, the speed response of a motor) however, in most cases you probably won’t know all the parameters you need. In these cases you will need a ‘System Identification’ approach – i.e. You carry out an open loop plant test and use the system response data to work out the model.
  • If you apply a step input does the response look like a first or second order response? If so you can determine the gain, time constant or natural frequency and damping ratio and come up with a Transfer Function model. You can then use SIMULINK to simulate how the plant will respond to different PID values.
  • At this point you should apply the control theory you have covered in lectures and how the PID values affect the poles and zeros of the system and hence the system response.

Further Work using SIMULINK (If you have time)

  • You can improve your SIMULINK model by taking better account of the practical system. You should include a ‘saturation’ block to apply the same limit to the controller output as actually exists on the real system (for example, you cannot actually output a signal of 200V when in practice the output signal is limited to say 0-5V, or generate a 200% pulse width for PWM). There is a ‘Saturation’ block in the ‘Discontinuities’ library of SIMULINK.
  • Further refinements of the model you might like to look at may includeadding some noise to your feedback signal to simulate the noise on the sensor. (e.g. using the‘Band-limited White Noise’ Block in the ‘Sources’ library. Adjust the power so that the amplitude of the noise matches your real signal noise).
  • You can also use the ‘Discrete’ library to model your control system as a digital system to reflect how it is actually implemented in LabVIEW. You can change the simulation settings to match the sample rate that you use in your LabVIEW programme. (See sections below on Implementing PID and sample rates).

3)Implementing PID control in LabVIEW

See this link for a basic tutorial on PID andLabVIEW

The following describes how LabVIEW actually implements the PID algorithm. Ensure you understand this.

Some main points to note are:

  • The PID algorithm has to be implemented digitally – with a PC based controller you are dealing with a sampled system, i.e. LabVIEW acquires the current value of the sensor signal at a certain time, t; implements the control algorithm on that sample and updates the output signal; it then acquires the sensor data at time t+t and so on. t is the sample period (time between samples) and depends on the loop rate of your labVIEW program. Hence Integration and Differentiation have to be done numerically.
  • The PID.vi can automatically work out the sample period t, this is important as if the sample period changes this affects the calculation of Integral and Derivative action. Sometimes you may not be able to achieve the loop rate you set and you may not be aware that the time between samples is changing. If you let the PID.vi calculate the sample time using the system clock, you don’t have to worry about it.
  • Note that the PID.vi executes differential action on the value of the Process Variable and not the error.
  • The PID.vi automatically handles ‘Integral Windup’ using ‘Integral Sum Correction’. (A good explanation of Integral Windup is available here )’

4)Setting the Sample rate

The sample rate is an important consideration in a digital control system. According to control theory, a control system must sample a physicalprocess at a rate about 10 times faster than the fastest time constant in thephysical process. For example, when you carry out your open loop step test (Stage 2 above) you might find that your system has a time constant of around 6 seconds. This means that your sample period should 0.6s or faster. NOTE that in the open loop step test you should not use loop-timed single-point data acquisition – use continuous acquisition which uses buffering to give you much higher sample rates. I suggest 1kHz. However when you are actually running your control loop you should generally sample one point at a time.

You can set the sample period using the timing function VIs (e.g. the ‘Wait until next ms’ vi) to control the timing of your control loop. In practice it is difficult to get deterministic sample rates much higher than 10Hz with this ‘software timing’ method, depending on your processor.This is because it is a Windows based system and the processor time is split between running the vi and any other programs, also actions such as mouse activity and window scrollinginterfere with these rates. If faster rates are required you need more sophisticated hardware which does the timing instead of the PC. Obviously we don’t expect you to go out and buy some expensive DAQ board at this stage in your project – just show that you recognise the issue and look into some possible hardware options.

5)Manually Tuning the PID values (If model-based approach doesn’t work)

See page 3-4 of the LabVIEW PID Control Toolkit Manual for some more information on manual tuning of PID values.

This in addition to the information given in the basic tutorial (Section 2 above).

6)Test and Fine-Tune

The final stage is to test your PID design and if necessary fine tune the parameters with trial and error.

Writing up the report

In the report explain the approach you took in designing your PID controller. Some good discussion points may include (not all will be relevant):

  • What are the main features of the open loop system response? (e.g. overshoot, settling time, stability, noise, gain....
  • What sampling rate do you need to be able to control the system well?
  • Is this system nonlinear? I.e. the system may not respond to inputs below a certain threshold (e.g. it takes 3V to get the motor to move). Does the gain or time constant change depending on the value of the step input? Nonlinear systems are difficult to model and PID control usually only works well if the system is kept within a fairly narrow range of operation over which the system is reasonably linear.
  • What are the effects of P, I and D action on the system response? If you have a model you can develop the closed loop Transfer Function and show how the various value of gains affect for example the Final Value (Use Final Value Theorem) or the time constant, natural frequency, damping ratio...
  • What are the differences between your simulation and the real system?
  • How well does the model based approach perform relative to the practical testing approach?
  • Do you get better performance from one or other tuning method?
  • Can you satisfy your performance demands? If not, why not? Is the sample timing inadequate? Is your actuator power sufficient to give you the necessary speed of response?
  • If you are implementing your control system with LabVIEW and you are able to obtain a model of your system you could investigate application of Digital Control Techniques (if you have time). What performance can you achieve with these techniques relative to PID?
  • Your examiner will be looking for evidence that you have formed a link between control theory and the practical application of your project. E.g.Try to relate the system response at all stages to the location of the system poles and zeros and the influence on them of your controller.