ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB...

67
1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008 This manual was written to guide the students of the University of Guelph through the lab requirements for the ENGG4420 (Real-Time Systems Design) course. The manual is in its first version and the author hopes that the students will understand this and help with suggestions and corrections. Acknowledgments: The author wishes to acknowledge my graduate student Matthew Mayhew, the undergraduate students Louis du Toit, Richard Hlavek, Peter Kucharczyk, and the lab technician Hong Ma that have contributed to the testing of the labs presented in this manual.

Transcript of ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB...

Page 1: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

1

ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB

MANUAL

Developed By

Radu Muresan

School of Engineering

University of Guelph

August 2008

This manual was written to guide the students of the University of Guelph through the lab requirements for the ENGG4420 (Real-Time Systems Design) course. The manual is in its first version and the author hopes that the students will understand this and help with suggestions and corrections. Acknowledgments: The author wishes to acknowledge my graduate student Matthew Mayhew, the undergraduate students Louis du Toit, Richard Hlavek, Peter Kucharczyk, and the lab technician Hong Ma that have contributed to the testing of the labs presented in this manual.

Page 2: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

2

TABLE OF CONTENTS

1. Lab 1: Modeling the PT 326 Process Trainer System – Simulation/Experimentation ..…3 1.1 Background for Modeling and System Control...........................................................3

1.1.1 Dynamic Model for the PT 326 Process Trainer ...............................................3 1.1.2 PID Control in LabView.....................................................................................9 1.1.3 Tuning Controllers Manually............................................................................14 1.1.4 Using the PID VIs ............................................................................................16

1.2 Embedded Development Board .................................................................................17 1.2.1 Introduction ......................................................................................................17 1.2.2 Introduction to the Embest Development Tools...............................................22

1.3 Lab 1 Requirements....................................................................................................22 1.3.1 Task 1: LabView Model for PT 326 ................................................................22 1.3.2 Task 2: LabView Implementation of the System ............................................23 1.3.3 Task 3: PID Tuning ..........................................................................................23 1.3.4 Task 4: Transmit Process Value to Embest .....................................................24 1.3.5 Task 5: Demo The System ...............................................................................24 1.3.6 Task 6: Prepare the Lab 1 Report ....................................................................25

2. Lab 2: Real-Time Control of a Hot Air Plant using RTOS uC/OSII ................................xx 2.1 Hot Air Plant Description ..........................................................................................xx 2.2 DDC Algorithms and Their Implementation.............................................................xx 2.3 LabVIEW Hot Air Plant Model .................................................................................xx 2.4 Hot Air Plant Control Tasks.......................................................................................xx 2.5 Lab 2 Requirements....................................................................................................xx

2.5.1 Task 1: LabView Model for Hot Air Plant Process ........................................xx 2.5.2 Task 2: Real-Time uC/OS Implementation .....................................................xx 2.5.3 Task 3: Demo the System ................................................................................xx 2.5.4 Task 1: Prepare the Lab 2 Report ....................................................................xx

3. Lab 3 Real-Time Automotive Suspension System Simulator...........................................xx 3.1 Background on Modeling the Automotive Suspension System in LabView ...........xx 3.2 PID Tuning Using the LabView Control Box ...........................................................xx 3.3 Lab 3 Requirements ...................................................................................................xx

4. Lab 4 Multi-Core Real-Time Suspension Controller using LabVIEW Real-Time OS ...xx 4.1 LabVIEW Real-Time OS Background ......................................................................xx 4.2 Multi-Core Real-Time Suspension System Presentation ..........................................xx 4.3 Lab 4 Requirements ...................................................................................................xx

Page 3: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

3

1. LAB 1: Modeling the PT 326 Process Trainer Using LabView – Simulation/Experimentation Lab The goal of this lab is four-fold: develop LabView simulation model for the PT 326 Process Trainer, develop LabView feedback system model using a PID controller with the PT326 simulation model, tuning the PID controller using the Ziegler and Nichols approach, transmit the PV output that is the temperature from the PT326 simulation model using a NI DAQ board to the Embest embedded board and display the values on the LCD screen.

1.1 Background for Modeling and System Control of a Simple Hot Air Blower

1.1.1 Dynamic Model for the PT 326 Process Trainer

Heat Flow The dynamic models of temperature control systems involve the flow and storage of heat energy. Heat energy flows through substances at a rate proportional to the temperature difference across the substance; that is,

);(121 TT

Rq −= (0a)

Where, q is the heat energy flow in joules per second (J/sec), R is the thermal resistance in oC/J*sec, and T is the temperature in oC. The net heat-energy flow into a substance affects the temperature of the substance according to the relation:

;1netq

CT =& (0b)

Where, C is the thermal capacity. Typically, there are several paths for heat to flow into or out of a substance, and q is the sum of heat flows obeying the equation. Example. A room with all but two sides insulated (1/R = 0) based on the above equations has the following differential equation that determines the temperature in the room:

( );111

21Io

II TT

RRCT −

+=& (0c)

Where, CI is the thermal capacity of air within the room; To is the outside temperature; TI is the inside temperature; R2 is the thermal resistance of the room ceiling; and R1 is the thermal resistance of the room wall.

Page 4: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

4

Normally the material properties are given in tables as follows: 1. The specific heat at constant volume vc , which is converted to heat capacity by:

vmcC = where m is the mass of the substance;

2. The thermal conductivity k, which is related to thermal resistance R by: ,1l

kAR=

where A is the cross-sectional area and l is the length of the heat-flow path. In addition to flow due to transfer, as expressed by Equation (0a), heat can also flow when a warmer mass flows into a cooler mass, or vice versa. In this case,

),( 1 sv TTwcq −= (0d) Where w is the mass flow rate of the fluid at T1 flowing into the reservoir at T2.

Description of the PT326 Apparatus The PT 326 Process Trainer models common industrial situations in which temperature control is required in the presence of transport delays and transfer lags. The process contained in the PT 326 involves air that is drawn from the atmosphere by a centrifugal blower, and is heated as it passes over a heater grid before being released into the atmosphere through a duct. The control objective is to maintain the temperature of the air at a desired level. Temperature control is achieved by varying the electrical power supplied to the heater grid. The air temperature may be sensed by using a bead thermistor placed in the flow at any of the three positions along the duct. The spatial separation between the thermistor and the heater coil introduces a transport delay into the system. Figure 1.1 shows the front panel of the PT 326 apparatus. The mass flow of air through the duct can be adjusted by setting the opening of the throttle. The temperature sensor can be placed at any of the three locations marked P1, P2, and P3. The leads of the temperature sensor are connected to the terminals marked “detector”. The variation in the resistance of the temperature sensor is converted to a voltage variation by a bridge circuit, and is available at terminal Y. The output of the temperature sensor can be used for feedback by connecting terminals X and Y. The desired temperature may be indicated by adjusting the knob labeled “set value”. An additional step change in the set value can be commanded by throwing the switch marked “internal”. An external reference input can be provided at terminal D labeled “external”. The difference between the reference input + set value and the feedback signal is available at terminal B, and can be applied to the heater power supply through a gain that can be adjusted by using the knob marked “proportional band”. A proportional band of PB % corresponds to a gain factor of 100/PB. The signal at B is available at terminal A after amplification by the gain factor. The signal at A may be applied directly to the heater power supply by using the switch S to select “continuous control”. Alternatively, the signal may be used in an on-off controller by using the switch S to select “two-step control”. The on-off controller commands maximum heater power when on, and zero heater power when off. The

Page 5: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

5

hysteresis in the on-off controller can be adjusted by using the knob marked “overlap” while the maximum heater power to be supplied can be adjusted by using the knob marked “max heater power”. The signal driving the heater power supply can be monitored at terminal C.

Figure 1.1. Front panel of the PT326 apparatus

System Modeling The physical principle which governs the behavior of the thermal process in the PT326 apparatus is the balance of heat energy. The rate at which heat accumulates in a fixed volume V enclosing the heater is:

toia qqqqq −−+= (1) Where q is the rate at which heat is supplied by the heater, qi is the rate at which heat is carried into the volume V by the coming air, qo is the rate at which heat is carried out of the volume V by the outgoing air and qt is the heat lost from the volume V to the surroundings by radiation and conduction. Figure 1.2 shows the volume V and the heat transfer rates associated to it.

Page 6: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

6

The accumulation of heat in the volume V causes the temperature T of air in V to rise. Assuming a uniform temperature in the volume V, the rate of heat accumulation is also given as:

,dtdTCqa = (2)

where C is the heat capacity of the air occupying the volume V.

Figure 1.2. Heat transfer from the volume V

The rates at which the air flow carries heat in and out of the volume V are given respectively by:

,1;; TR

qmTcqmTcq tvoavi ∆=== where cv is the specific heat capacity of air

at constant volume, m is the mass flow rate, Ta is the ambient air temperature and R is the thermal resistance. Assuming that the rise in air temperature aTTT −=∆ is small, the rate qt at which heat is lost from the volume V is proportional to the temperature rise ∆T. Also, if we consider that the heat exchange between the resistor R and the air in volume V is instantaneous then the heat accumulated in volume V plus the heat lost from the volume V due to radiation is equal to the heat generated by the resistors as given by the following equation:

qTRdt

TdC =∆+∆ 1 (3)

Taking Laplace transform yields:

Page 7: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

7

1)()(

)(1)(

)()(1)(

1

+=

=+

=∆+∆

sk

sqsT

sqR

RCssT

sqsTR

sTsCs

τ

(4)

Where, k1 = R and τ = RC is the time constant. Assuming the heater heat supply rate to be proportional to the heater input voltage Vi, Eq. (4) yields the transfer function between the heater input voltage and the temperature rise as:

;1)(

)( 21

+=

∆skk

sVsT

i τ (5)

Where, k2 is the proportionality constant between q and Vi. In Equation (5), ∆T represents the increase in temperature of the air constrained in the volume V considered above. The temperature sensor produces a voltage Vo that is proportional to ∆T, that is Vo = k3∆T. However, since the sensor is physically located at a certain distance from the heat source, the sensor output responds to a temperature change with a pure time delay τd, which is the time taken by the flowing heated air to cover the distance between the heater and the sensor. Thus, the transfer function between the heater input voltage and the sensor output voltage is:

1)()(

+=

sKe

sVsV s

i

od

τ

τ

; (6)

Where K = k1k2k3 is the DC gain of the system. The term sde τ− in (6) arising due to fluid transport is called a ‘transport delay’, while term 1)1( −+sτ arising due to the heat transfer dynamics is called ‘transfer delay’. Figure 1.3 bellow illustrates Equations (5) and (6).

Page 8: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

8

Figure 1.3. Block diagram of the PT326 process. QUESTION: How are the parameters k, τd, and τ affected by the sensor location and throttle opening?

System Step Response The output of the temperature sensor Vo and the heater input voltage are related by the first-order transfer function given in Equation (6) for small temperature changes from the ambient. The transfer function in Equation (6) is characterized by two parameters, namely, the DC gain K and the time constant τ. Both of these parameters can be determined from the response of the temperature to a step increase in the heater input voltage from a state of thermal equilibrium. To find an expression for the unit step response of the temperature variation, recall that the Laplace transform of a unit step input is 1/s. Hence the Laplace transform of the response of the temperature variation ∆Vo to an increase of 1 V in the heater input voltage is:

;)1(

)(+

=∆−

ssKesV

s

o

d

τ

τ

(7)

Taking inverse Laplace transform yields:

);1()( /)( ττ dto eKtV −−−=∆ (8)

We notice that ∆Vo, the change in temperature from the initial equilibrium value, converges to the value K. Thus the DC gain K is simply the ratio of the steady state change in the output to the steady state value of the input. We also observe that, at

,dt ττ += the value of the output is .6321.0)1()( 1 KeKVo =−=∆ −τ

Page 9: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

9

Giving step inputs to the open-loop system we recorded the following data for the PT326 Process Trainer that is in our lab. TABLE 1: Process Data Blower Opening (°) Gain, K Τs (s) Τd (s)

15 1.37 2.0 0.195 30 1.33 2.0 0.190 45 1.26 2.0 0.185 60 1.22 2.0 0.180 75 1.18 2.0 0.170 90 1.13 2.0 0.160

TABLE 2: Temperature and Observed Output

Temperature (°C) Output Voltage (mV)

20 0 30 1.13 35 1.669 40 3.611 45 5.326 50 6.154 55 7.611 60 7.783 80 9.689

1.1.2 PID Control in LabView – Extract from the PID Control Toolset LabVIEW User Manual A typical control objective in thermal systems is to maintain the temperature of some component at a user specified value called the set point. Figure 1.4 below depicts a closed-loop system designed to maintain the output temperature of the PT326 apparatus at a desired set point. Loosely speaking the controller uses the error signal between the desired temperature and actual temperature to manipulate the heater input voltage in such a way that the actual temperature converges to the set point value.

Page 10: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

10

Figure 1.4. Closed loop control of a thermal system Currently, the Proportional-Integral-Derivative (PID) algorithm is the most common control algorithm used in industry. Often, people use PID to control processes that include heating and cooling systems, fluid level monitoring, flow control, and pressure control. In PID control, you must specify a process variable and a setpoint. The process variable is the system parameter you want to control, such as temperature, pressure, or flow rate, and the setpoint is the desired value for the parameter you are controlling. A PID controller determines a controller output value, such as the heater power or valve position. The controller applies the controller output value to the system, which in turn drives the process variable toward the setpoint value. You can use the PID Control Toolset VIs with National Instruments hardware to develop LabView control applications. Use I/O hardware such as DAQ devices, FieldPoint I/O modules, or a GPIG board, to connect your PC to the system you want to control. You can use the I/O VIs provided in LabView with the PID Control Toolset to develop a control application or modify the examples provided with the Toolset. Using the VIs described in the PID Control section of the manual, you can develop the following control applications based on PID controllers: proportional (P), proportional-integral (PI), and proportional-integral-derivative (PID) algorithms; gain-scheduled PID; PID autotuning; error-squared PID; lead-lag compensation; setpoint profile generation; multiloop cascade control; feedforward control; override (minimum/maximum selector) control; ratio/bias control. You can combine these PID Control VIs with LabView math and logic functions to create block diagrams for real control strategies. The PID Control VIs use LabView functions and library subVIs, without any Code Interface Nodes (CINs), to implement the algorithms. You can modify the VIs for your application in LabView, without writing any text-based code. In Lab 1 we will use the PID Control VIs to implement the feedback thermal system for the PT326 apparatus and tune the PID controller using the manual approach based on the work of Ziegler and Nichols. The PID parameters determined from the implementation will be used in Lab 2 where a real-time embedded implementation of the PID controller is developed.

Page 11: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

11

The PID Algorithm The PID controller compares the setpoint (SP) to the process variable (PV) to obtain the error (e).

,PVSPe −= Then, the PID controller calculates the controller action, u(t), where Kc is controller gain.

,1)(0

++= ∫ dt

deTedtT

eKtu dt

ic

If the error and the controller output have the same range, -100% to 100%, controller gain is reciprocal of proportional band. Ti is the integral time in minutes, also called the reset time, and Td is the derivative time in minutes, also called the rate time. The following formula represents the proportional, integral and derivative actions respectively:

,)( eKtu cp = ,)(0∫=t

i

cI edt

TK

tu ,)(dtdeTKtu dcD =

Implementing the PID Algorithm with the PID VIs This section describes how the PID VIs implement the positional PID algorithm. The subVIs used in these VIs are labeled so you can modify any of these features as necessary. Error Calculation. The following formula represents the current error used in calculating proportional, integral, and derivative action:

),()( fPVSPke −= Proportional Action. Proportional action is the controller gain times the error, as shown in the following formula:

),()( keKku cP = Trapezoidal Integration. Trapezoidal Integration is used to avoid sharp changes in integral action when there is a sudden change in PV or SP. Use nonlinear adjustment of integral action to counteract overshoot. The larger the error, the smaller the integral action, as shown in the following formula:

,2

)1()()(1

tieieTK

kuk

ii

cI ∆

−+

= ∑=

Partial Derivation Action. Because of abrupt changes in SP, only apply derivative action to the PV, not to the error e, to avoid derivative kick. The following formula represents the Partial Derivative Action:

( ),)1()()( −−∆

−= kPVkPVT

Kku fft

dcD

Controller Output. Controller output is the summation of the proportional, integral, and derivative action, as shown in the following formula:

),()()()( kukukuku DIP ++= Output Limiting. The actual controller output is limited to the range specified for control output:

Page 12: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

12

If max)( uku ≥ then ,)( maxuku = and if min)( uku ≤ then ,)( minuku = The following formula shows the practical model of the PID controller:

,)(1)()(0

−−+−= ∫ dt

dPVTdtPVSP

TPVSPKtu f

dt

ic

The PID VIs use the integral sum correction algorithm that facilitates anti-windup and bumpless manual to automatic transfer. Windup occurs at the upper limit of the controller output, for example, 100%. When the error e decreases, the controller output decreases, moving out the windup area. The integral sum correction algorithm prevents abrupt controller output changes when you switch from manual to automatic mode or change any other parameters. The default ranges for the parameters SP, PV, and output correspond to percentage values; however, you can use actual engineering units. Adjust corresponding ranges accordingly. The parameters Ti and Td are specified in minutes. In the manual mode, you can change the manual input to increase or decrease the output. You can call these PID VIs from inside a While Loop with a fixed cycle time. All the PID control VIs are reentrant. Multiple calls from high-level VIs use separate and distinct data. Note. As a general rule, manually drive the process variable until it meets or comes close to the setpoint before you perform the manual to automatic transfer. Gain Scheduling. Gain scheduling refers to a system where you change controller parameters based on measured operating conditions. For example, the scheduling variable can be the setpoint, the process variable, a controller output, or an external signal. For historical reasons, the term gain scheduling is used even if other parameters such as derivative time or integral time change. Gain scheduling effectively controls a system whose dynamics change with the operating conditions. With the PID controls, you can define unlimited sets of PID parameters for gain scheduling. For each schedule, you can run autotuning to update the PID parameters.

Designing a Control Strategy When you design a control strategy, sketch a flowchart that includes the physical process and control elements such as valves and measurements. Add feedback from the process and any required computations. Then use the Control VIs in this toolset, combined with the math and logic VIs and functions in LabView, to translate the flowchart into a block diagram. Figure 1.5 is an example of a control flowchart and the equivalent LabView block diagram. The only elements missing from this simplified VI are the loop-tuning parameters and the automatic-to-manual switching. You can handle the inputs and outputs through DAQ devices, FieldPoint I/O modules, GPIB instruments, or serial I/O ports. You can adjust polling rates in real time. Potential polling rates are limited only by your hardware and by the number and graphical complexity of your VIs.

Page 13: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

13

Figure 1.5. Control flowchart and block diagram.

Setting Timing The PID and Lead-Lab VIs in this toolset are time dependent. A VI can acquire timing information either from a value you supply to the cycle time control, dt, or from a time keeper such as those built into the PID VIs. If dt is less than or equal to zero, the VI calculates new timing information each time LabView calls it. At each call, the VI measures the time since the last call and uses the difference in its calculations. If you call a VI from a While Loop that uses one of the LabView timing VIs. Located on the Time & Dialog palette, you can achieve fairly regular timing, and the internal time keeper compensates for variations. However, the resolution of the Tick Count (ms) function is limited to 1 ms in Windows 2000. Because of this limitation, do not try to run the PID VIs faster than 5 or 10 Hz when dt is less than or equal to zero. Refer to the LVREADME.WRI file for more information about increasing your time resolution. If dt is a positive value in seconds, the VI uses the value in the calculations, regardless of the elapsed time. Use this method for fast loops, such as when you use acquisition hardware to time the controller input. Refer to the Demo-HW Timed PID VI located in the example library prctlex.llb for an example of using hardware timing with the

Page 14: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

14

combined PID and DAQ VIs. In this example, LabView samples the analog input at precisely timed intervals, inverts the actual scan rate parameter from the AI Start VI, and wires the actual scan rate into the dt input. IMPORTANT !!!. According to control theory, a control system must sample a physical process at a rate about 10 times faster than the fastest time constant in the physical process. For example, a time constant of 60 s is typical for a temperature control loop in a small system. In this case, a cycle time of about 6 s is sufficient. Faster cycling offers no improvement in performance. In fact, running all your control VIs too fast degrades the response time of your LabView application. All VIs within a loop execute once per iteration at the same cycle time. To run several control VIs at different cycle times and still share data between them, as for example in a cascade, you must separate the VIs into independently timed While Loops. Figure 1.6 shows an example of a cascade with two independent timed While Loops. A global variable passes the output of Loop A to the PV input of Loop B. You can place both While Loops on the same diagram. In this case, they are in separate VIs. Use additional global or local variables to pass any other necessary data between the two While Loops. If the front panel does not contain graphics that LabVIEW must update frequently, the PID Control VIs can execute at kilohertz (kHz) rates. Remember that actions such as mouse activity and window scrolling interfere with these rates.

Figure 1.6. Cascaded control functions.

Page 15: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

15

1.1.3 Tuning Controllers Manually The following controller tuning procedures are based on the work of Ziegler and Nichols, the developers of the Quarter-Decay Ratio tuning techniques derived from a combination of theory and empirical observations. For different processes, one method might be easier or more accurate than another. For example, some techniques that work best when used with online controllers cannot stand the large upset described here. To perform these tests with LabView, set up your control strategy with the PV, SP, and output displayed on a large strip chart with the axes showing the value versus time. Use the Close-Loop (Ultimate Gain) Tuning and Open-Loop (Step Test) Tuning techniques described in the following subsections. Closed-Loop (Ultimate Gain) Tuning Procedure. Although the closed-loop (ultimate gain) tuning procedure is very accurate, you must put your process in steady-state oscillation and observe the PV on a strip chart. Due to the fact that the process must be brought to steady-state oscillation this procedure might not be suitable to all types of processes. Complete the following steps to perform the closed-loop tuning procedure:

1. Set both the derivative time and the integral time on your PID controller to 0; 2. With the controller in automatic mode, carefully increase the proportional gain

(Kc) in small increments. Make a small change in SP to disturb the loop after each increment. As you increase Kc, the value of PV should begin to oscillate. Keep making changes until the oscillation is sustained, neither growing nor decaying over time.

3. Record the controller proportional band (PBu) as a percent, where PBu = 100/Kc; 4. Record the period of oscillation (Tu) in minutes; 5. Multiply the measured values by the factors shown in Table 2 and enter the new

tuning parameters into your controller. Table 2 provides the proper values for a quarter-decay ratio.

If you want less overshoot, increase the gain Kc. Proportional gain (Kc) is related to proportional band (PB) as Kc = 100/PB.

TABLE 3. Closed-Loop-Quarter-Decay Ratio Values

Controller PB (percent)

Reset (minutes)

Rate (minutes)

P 2.00PBu - -

PI 2.22PBu 0.83Tu -

PID 1.67PBu 0.50Tu 0.125Tu

Open-Loop (Step Test) Tuning Procedure. The open-loop (step test) tuning procedure assumes that you can model any process as a first-order lag and pure deadtime. This method requires more analysis than the closed-loop tuning procedure, but your process

Page 16: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

16

does not need to reach sustained oscillation. Therefore, the open-loop tuning procedure might be quicker and more reliable for many processes. Observe the output and the PV on a strip chart that shows time on the x-axis.

Figure 1.7. Output and Process Variable strip chart. TABLE 4. Open-Loop-Quarter-Decay Ratio Values

Controller PB (percent)

Reset (minutes)

Rate (minutes)

P T

KTd100 - -

PI T

KTd100 3.33Td -

PID T

KTd80 2.00Td 0.50Td

Complete the following steps to perform the open-loop tuning procedure:

1. Put the controller in manual mode (open loop), set the output (of the controller) to a nominal operating value, and allow the PV to settle completely. Record the PV and output (of the controller) values;

2. Make a step change in the output (of the controller). Record the new output value; 3. Wait for the PV to settle. From the chart, determine the values as derived from the

sample displayed in Figure 1.7. The variables represent the following values: a. Td – Deadtime in minutes; b. T – Time constant in minutes; c. K – Process gain = (change in output)/(change in PV).

Page 17: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

17

4. Multiply the measured values by the factors shown in Table 3 and enter the new tuning parameters into your controller. The table provides the proper values for a quarter-decay ratio. If you want less overshoot, reduce the gain, Kc.

1.1.4 Using the PID VIs Although there are several variations of the PID VI, they all use the algorithms described in this lab in Section PID Algorithms. The PID VI implements the basic PID algorithm. Other variations such as PID Advanced VI, Multi-Loop PID Control, PID Lead-Lag VI etc, provide additional functionality as described in the “PID Control Toolset User Manual”. You can use these VIs interchangeably because they all use consistent inputs and outputs where possible. In this Lab, you are required to use the standard PID VI. The PID VI. The PID VI has inputs for setpoint, process variable, PID gains, dt, output rand and reinitialize?. The PID gains input is a cluster of three values – proportional gain, integral time, and derivative time. You can use output range to specify the range of the controller output. The default range of the controller output is -100 to 100, which corresponds to values specified in terms of percentage of full scale. However, you can change this range to one that is appropriate for your control system, so that the controller gain relates engineering units to engineering units instead of percentage to percentage. The PID VI coerces the controller output to the specified range. In addition, the PID VI implements integrator anti-windup when the controller output is saturated at the specified minimum or maximum values. You can use dt to specify the control-loop cycle time. The default value is -1, so by default the PID VI uses the operating system clock for calculations involving the loop cycle time. If the loop cycle time is deterministic, you can provide this input to the PID VI. Note that the operating system clock has a resolution of 1 ms, so specify a dt value explicitly if the loop cycle time is less then 1 ms. The PID VI will initialize all internal states on the first call to the VI. All subsequent calls to the VI will make use of state information from previous calls. However, you can reinitialize the PID VI to its initial state at any time by passing a value of TRUE to the reinitialize? input. Use this function if your application must stop and restart the control loop without restarting the entire application.

1.2. Embedded Development Board One of the goals of this lab is to introduce the students to embedded development environment that will be used to develop RTOS based applications. uC/OS-II is a real-time preemptive multitasking kernel. It is written in C with the exception of a small CPU-specific assembly module. This means that uC/OS can be ported easily to different processors. In fact, it has been ported to a large number of processors ranging from simple 8-bit controllers like 8051 to large 32-bit CPUs. The good thing about the uC/OS-II is that it is completely documented by its author Jean J. Labrosse in his book “MicroC/OS-II, The Real-Time Kernel Second Edition”. Also, the uC/OS-II kernel is simple and has been used in various commercial products.

Page 18: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

18

1.2.1. Introduction The embedded development platform used in this lab is the Embest Development System for ARM. The Embest Development System is simple, cost effective and suitable for university environment. The tools provide a complete software and hardware package that can be used in developing complex practical implementations. I have chosen these tools due to the fact that all of the hardware interfaces are supported by working examples. This allows the students to focus more on complex applications; they don’t have to spend a lot of time in writing low level interfacing programs. Also, Embest has ported the uC/OS-II to the development board and has provided some programming examples that use the uC/OS-II real-time kernel. Lab 1 and Lab 2, in this manual, will use the e-book “Embedded System Development and Labs; English Edition, 2005” Edited by Radu Muresan. The book is available on-line on the Engg*4420 webpage and also, one hardcopy of the book can be found in the lab and one on reserve at the library. ARM architectures are well known for their low-power consumption features and for the Thumb instruction set. ARM Inc. is a chipless company. However, the ARM processor cores are adopted by many leading semiconductor companies such as TI, Philips, Intel, Samsung, etc. ARM has established its lead position in the embedded technologies and due to its low-power design features it is widely used in the wireless and portable applications. In 2002, ARM processors occupied 79.5% of the 32-bit and 64-bit microprocessor market in the world. Nowadays, ARM processors are almost in everybody’s pocket because almost all of the mobiles phones and PDAs are developed based on ARM cores. The Embest Development Tools for ARM use a development board based on the Samsung’s S3C44BOX 16/32-bit RISC microprocessor. The Samsung S3C44BOX was developed using an ARM7TDMI core, 0.25 um CMOS standard cells and a memory compiler. Its low-power and fully static design is particularly suitable for cost-sensitive and power sensitive applications. The main feature of the S3C44BOX is its CPU core, a 16/32-bit ARM7TDMI RISC processor (66 MHz). The architectural enhancements of ARM7TDMI include Thumb decompressor, an on-chip ICE breaker debug support and a 32-bit hardware multiplier. By providing a complete set of common system peripherals, the S3C44BOX minimizes overall system costs and eliminates the need to configure additional components. The following are the integrated on-chip functions that are described in the User’s Manual. Most of these features are explained in the “Embedded System Development and Labs” book with practical examples.

• Static ARM7TDMI CPU core with 8Kb cache. (SAMBA II bus architecture up to 66MHz);

• External memory controller. (FP/EDO/SDRAM Control, Chip Select logic); • LCD controller (up to 256 color DSTN) with 1-ch LCD-dedicated DMA; • 2-ch general DMAs / 2-ch peripheral DMAs with external request pins; • 2-ch UART with handshake (IrDA1.0, 16-byte FIFO) / 1-ch SIO; • 1-ch multi-master IIC-BUS controller; • 1-ch IIS-BUS controller; • 5-ch PWM timers & 1-ch internal timer; • Watch Dog Timer; • 71 general purpose I/O ports / 8-ch external interrupt source;

Page 19: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

19

• Power control; Normal, Slow, Idle, and Stop mode; • 8-ch 10-bit ADC; • RTC with calendar function; • On-chip clock generator with PLL.

Features of the S3C44BOX RISC Microcontroller

Architecture • Integrated system for hand-held devices and general embedded applications; • 16/32-Bit RISC architecture and powerful instruction set with ARM7TDMI CPU

core; • Thumb de-compressor maximizes code density while maintaining performance; • On-chip ICEbreaker debug support with JTAG-based debugging solution; • 32x8 bit hardware multiplier; • New bus architecture to implement Low-Power SAMBA II (Samsung' ARM CPU

embedded Micro-controller Bus Architecture);

System Manager • Little/Big endian support; • Address space: 32Mbytes per each bank (Total 256 Mbytes); • Supports programmable 8/16/32-bit data bus width for each bank; • Fixed bank start address and programmable bank size for 7 banks; • 8 memory banks:

o 6 memory banks for ROM, SRAM etc. o 2 memory banks for ROM/SRAM/DRAM (Fast Page, EDO, and

Synchronous DRAM); • Fully Programmable access cycles for all memory banks; • Supports external wait signal to expend the bus cycle; • Supports self-refresh mode in DRAM/SDRAM for power-down; • Supports asymmetric/symmetric address of DRAM.

Cache Memory & Internal SRAM • 4-way set associative ID(unified)-cache with 8Kbyte; • The 0/4/8 Kbytes internal SRAM using unused cache memory; • Pseudo LRU(Least recently used) Replace Algorithm; • Write through policy to maintain the coherence between main memory and cache

content; • Write buffer with four depth; • Request data first fill technique when cache miss occurs;

Page 20: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

20

Clock & Power Manager • Low power; • The on-chip PLL makes the clock for operating MCU at maximum 66MHz; • Clock can be fed selectively to each function block by software; • Power mode: Normal, Slow, Idle and Stop mode. Normal mode: Normal

operation mode; Slow mode: Low frequency clock without PLL; Idle mode: Stop the clock only for CPU; Stop mode: All clocks are stopped;

• Wake up by EINT[7:0] or RTC alarm interrupt from Stop mode.

Interrupt Controller • 30 Interrupt sources; (Watch-dog timer, 6 Timer, 6 UART, 8 External interrupts,

4 DMA, 2 RTC, 1 ADC, 1 IIC, 1 SIO); • Vectored IRQ interrupt mode to reduce interrupt latency; • Level/edge mode on the external interrupt sources; • Programmable polarity of edges and level; • Supports FIQ (Fast Interrupt request) for very urgent interrupt request.

Timer with PWM (Pulse Width Modulation) • 5-ch 16-bit Timer with PWM / 1-ch 16-bit internal timer with DMA-based or

interrupt-based operation; • Programmable duty cycle, frequency, and polarity; • Dead-zone generation; • Supports external clock source.

RTC (Real Time Clock) • Full clock feature: msec, sec, min, hour, day, week, month, year; • 32.768 KHz operation; • Alarm interrupt for CPU wake-up; • Time tick interrupt.

General-Purpose input/output Ports • 8 external interrupt ports; • 71 multiplexed input/output ports.

UART • 2-channel UART with DMA-based or interrupt based operation; • Supports 5-bit, 6-bit, 7-bit, or 8-bit serial data transmit/receive; • Supports H/W handshaking during transmit/receive; • Programmable baud rate;

Page 21: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

21

• Supports IrDA 1.0 (115.2 kbps); • Loop back mode for testing; • Each channel have two internal 32-byte FIFO for Rx and Tx;

DMA Controller • 2 channel general purpose Direct Memory Access controller without CPU

intervention; • 2 channel Bridge DMA (peripheral DMA) controller; • Support IO to memory, memory to IO, IO to IO with the Bridge DMA which has

6 type’s DMA requestor: Software, 4 internal function blocks (UART, SIO, Timer, IIS), and External pins;

• Programmable priority order between DMAs (fixed or round-robin mode); • Burst transfer mode to enhance the transfer rate on the FPDRAM, EDODRAM

and SDRAM; • Supports fly-by mode on the memory to external device and external device to

memory transfer mode.

A/D Converter • 8 channel multiplexed ADC; • Max. 100KSPS/10-bit.

LCD Controller • Supports color/monochrome/gray LCD panel; • Supports single scan and dual scan displays; • Supports virtual screen function; • System memory is used as display memory; • Dedicated DMA for fetching image data from system memory; • Programmable screen size; • Gray level: 16 gray levels; • 256 Color levels.

Watchdog Timer • 16-bit Watchdog Timer; • Interrupt request or system reset at time-out.

IIC-BUS Interface • 1 channel Multi-Master IIC-Bus with interrupt-based operation; • Serial, 8-bit oriented, bi-directional data transfers can be made at up to 100Kbits/s

in the standard mode or up to 400 Kbits/s in the fast mode.

Page 22: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

22

IIS-BUS Interface • 1 channel IIS-bus for audio interface with DMA-based operation; • Serial, 8/16bit per channel data transfers; • Supports MSB-justified data format.

SIO (Synchronous Serial I/O) • 1 channel SIO with DMA-based interrupt-based operation; • Programmable baud rates; • Supports serial data transmit/receive operations 8-bit in SIO.

Operating Voltage Range / Operating Frequency / Package • Core: 2.5V I/O: 3.0V to 3.6V; • Up to 66 MHz; • 160 LQFP / 160 FBGA

1.2.2. Introduction to the Embest ARM Development Tools In this part of the lab you will get familiar with the Embest Development System and learn how to use the software tools. Specifically, you will learn how to create projects, how to compile assembly and C language programs, how to link the object files, how to initialize the system, how to debug your applications, etc. Also, you will learn basic programming methods and interfacing for common peripherals. Feel free to experiment with the hardware and software tools and learn as much as possible about the tools and about the microcontroller and its peripherals. The following are the lab requirements for this part:

1. Study Chapter 2 of the “Embedded System Development and Labs” book (on-line link from my webpage).

2. Perform ARM Assembly Instruction Lab 1 of Section 3.1, C Language Program Lab 1 of Section 3.5, C Language Program Lab 1 of Section 3.6, and Sum up Programming Lab of Section 3.8. (Note: The exercise sections are not required).

3. Perform the labs of Chapter 4 (Note: The exercise sections are not required). These labs are in order: Memory Lab; I/O Interface Lab; Interrupt Lab; Serial Communication Lab; Real-Time Timer Lab; 8-SEG LED Display Lab.

4. Perform the labs of Chapter 5 (Note: The exercise sections are not required). These labs are: LCD Display Lab; 4x4 Keyboard Control Lab; Touch Panel Control Lab.

5. Talk to your TA when you have completed this part.

Page 23: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

23

1.3. Lab 1 Requirements The goal of this lab is 4-fold: develop LabVIEW simulation model for the PT 326 Process Trainer; develop LabVIEW feedback system model using a PID controller with the PT326 simulation model; tuning the PID controller using the Ziegler and Nichols approach; transmit the PV output that is the temperature from the PT326 simulation model using a NI DAQ board to the Embest embedded board and display the values on the LCD screen. The general block diagram of the system development for Lab 1 using LabVIEW software, NI hardware, and the Embest development board is presented in Figure 1.8. As you can see from this figure, you need to implement the plant model and the PID controller using the LabVIEW software, connect the process variable (PV) to the DAQ board, get the temperature signal from the Connector Block and input it to the A/D converter of the Embest board; write the A/D plus the LCD temperature display task. The Embest board is connected to the PC for programming and debugging purposes through the serial and parallel ports.

Figure 1.8. Lab 1 Block Diagram. The following outlines the tasks required by this lab. These tasks should be implemented in the specified order.

1.3.1. Task 1: LabView Model for the PT326 Process Trainer Develop a LabView model for the PT326 Process Trainer using the process response Equation (8) and the data recorded in Table 1 and Table 2. Plot the output process variable (output temperature).

Page 24: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

24

1.3.2 Task 2: LabView Implementation of the System Develop a LabView implementation of the closed loop control system presented in Figure 1.4. For this implementation use the model developed at Task 1 as your process and the PID VIs that are found in the LabView PID Control Toolset to implement the PID Controller. Implement the manual and auto control of the process. Plot the control variable (input to the process) and the process output variable (output temperature). Experiment with the manual control feature.

1.3.3 Task 3: PID Tuning Tune the PID controller for the system developed at Task 2 using the closed-loop tuning procedure and the open-loop tuning procedure. Record the measured data and calculate the PID parameters using the relations presented in Table 3 and Table 4.

1.3.4 Task 4: Transmit Temperature Process Value to Embest Perform the required hardware connections from the PC to the Embest board. Connect the temperature signal generated by the system implemented at Task 3 to one of the A/D inputs of the Embest board. The transmitted value should be scaled between 0 and 2.5 V. Develop one uC/OS task that performs the A/D conversion of the temperature signal and display the average temperature over 5 s interval on the LCD. Test the system response in the following conditions:

• Change the setpoint (SP) value by +∆T and by –∆T; • Introduce a process disturbance within the system as shown in Figure 4. The

process disturbance can be materialized in temperature variation of the process output. In this case, the Equation (8) modeling the process must be augmented with a small +δT and a small – δT.

Record the system response for all experiments on the LabVIEW chart and verify that your LCD display gets the correct values. Record the results for your report and present them in the Lab report.

1.3.5 Task 5: Demo the System Demo the implementations developed at Task 1, Task 2, Task 3, and Task 4 to the TA. Make sure that you understand the background theory of the lab and your implementations are functional. The TA will ask questions related to the implementations, the plant modeling, and the system control. Also, the course exams will test some of the Laboratory material.

1.3.6 Task 6: Prepare the Lab 1 Report Develop a Lab 1 report and submit it for marking. In your report the important features that are related to the implementations. Things that you are happy about the way you implemented or solved. Explain well your implementations and their functionality. The following is an outline that you can use. However, this outline is not mandatory; you can enhance it or tailor it to suit your application. 1. Introduction

Page 25: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

25

1.1 Problem description 1.2 System requirements (similar to what I've presented in the lectures, but it can be simplified) 2. Background 2.1 Short overview of the benefits of using LabView in simulating this system. 2.2 Short overview of the PID control and tuning results. 3. Implementation 3.1 Present a top-down functional implementation of the system 3.2 Present implementation details such as code and LabView diagrams. Explain the manual and auto modes functionality. 3.4 Simulation results – show simulation graphs and present supporting data. 3.4 Present the uC/OS task and discuss sampling time values and PID tuning results. Justify why you choose to control the plant in this way. What are the parameters values used in designing the PID ... Observation on how these parameters affect the functionality of the plant. Present your simulation/experimentation design and explain the experiments conducted using the Embest board. Here you can present some functionality graphs that support your design.

Page 26: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

26

2. LAB 2: Real-Time Controller of a Hot Air Plant using RTOS uC/OSII The goal of this lab is three-fold: develop LabVIEW simulation model for a hot air plant application using the results of Lab1; interface the Embest board (hardware/software) with the LabVIEW hot air plant model; develop complete real-time control software application on the Embest board using the uniprocessor RTOS uC/OSII. Real-time embedded systems are difficult to develop and debug due to lack of realistic simulation, specifically, when implementing embedded systems that need to perform data acquisition, system control, and signal measurements. The ultimate goal of this lab is to introduce the students to the concept of simulation/experimentation of real-time computer control systems using LabView software and embedded boards. LabView is a powerful simulation and development software tool for industrial applications. In this lab, the students will learn two important principles that can be used in the development of the real-time computer control applications. These principles are: simulation of the environment of a control application through modeling, and experimentation through physical implementation of real-time control software. During the lab, the students will learn the basic usage of LabView software by modeling a simple plant – hot-air blower. They will build the system by using the built-in modules provided by the LabView software. They will implement manual and auto functionality of the system using a PID feedback control developed on the ARM based board (Embest). The simulation/experimentation technique will allow the students to develop and debug the real-time C implementation. Figure 2.1 presents the block diagram with the main components used in this lab.

Figure 2.1. System block diagram for Lab 2 implementatoin.

Page 27: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

27

Design points: • Through LabView the designer can generate real-time analog and digital signals

that can be interfaced with the output world through DAQ boards; • The Embest S3CEV40 ARM provides an A/D converter that can be used to

interface the Embest board with the real-time process model developed in LabView;

• The real-time operating system uC/OS-II is installed on the Embest board and can be used for development of real-time tasks;

The NI PCI-6229 board is data acquisition board with A/D and D/A converter interfaces that work directly with the LabVIEW software and can be used as a bridge between the LabVIEW software application and the Embest board.

2.1 Hot Air Plant Description The hot-air blower is a simple plant that illustrates various operations of a computer control system. Let us consider the hot-air blower shown in Figure 2.2. A centrifugal fan blows air over a heating element and into the tube. A thermistor bead is placed at the outlet end of the tube and forms one arm of the bridge circuit. The amplified output of the bridge circuit is available at B and provides a voltage, in the range of 0 to 10 V, proportional to the temperature. The current supplied to the heating element can be varied by supplying a DC voltage in the range 0 to 10 V at point A.

The position of the air-inlet cover is adjusted by means of a reversible motor. The motor operates at a constant speed and is turned on or off by a logic signal applied to its controller; a second logic signal determines the direction of rotation. A potentiometer wiper is attached to the air-inlet cover and the voltage output is proportional to the position of the cover. Micro-switches are used to detect when the cover is fully open and fully closed.

The operator is provided with a panel from which the control system can be switched from automatic to manual mode and vice versa. In manual mode, the heat output and cover position can be adjusted using potentiometers. Switches are provided to operate the fan and heater. Panel lights indicate fan on, heater on, cover fully open, cover fully closed, and auto/manual status. The desired output temperature (this is known as the set point for the control system) is set by the operator using a slider potentiometer, the setting of which can be read by the computer. The operator can also adjust the fan cover position. The operation of this simple plant using a computer requires that software be provided to support monitoring, control and actuation of the plant. A general schematic of the system is shown in Figure 2.3.

Monitoring involves obtaining information about the current state of the plant. In the above example the information is available from the plant instruments in the following two forms:

1. Analog signals: air temperature and fan-inlet cover position 2. Digital logic signals: fan-inlet cover position (fully open, fully closed); status

signals: auto/manual, fan motor on, heater on.

Page 28: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

28

Figure 2.2. A simple plant – hot-air blower.

Figure 2.3. Computer control of a hot-air blower.

Page 29: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

29

Control involves the digital equivalent of continuous feedback control for the control of temperature (direct digital control, DDC) and for position control of the fan-inlet cover. Sequence and interlock control operations are also required since for the example, the heater should not be on if the fan is not running. The computer also has to handle automatic change-over from simply tracking (monitoring) the manual control operations to controlling the system when the operator request a change from manual to automatic control. This change over should be carried out without disturbing the temperature of the air at the output of the tube (a change-over which does not cause plant disturbance is referred to as a bumpless transfer). These actions may involve parallel logic operation, time-sequential control and timing of operations. Actuation requires provision of a voltage proportional to the demanded heat output to drive the heater control; logic signals indicating on/off, the direction in which the fan-inlet cover is to be moved and logic signals for the operator display.

A simplified block diagram of a sampled feedback control system is shown in Figure 2.4. The computer control model for this application will have the following software tasks: plant input tasks; plant output tasks; and control tasks.

Figure 2.4. Simplified block diagram of a sampled feedback control system: c(nT), r(nT), e(nT), u(nT) are sampled values of c(t), r(t), e(t), u(t) at sample times nT where n is an integer and T is the sampling interval.

In Figure 2.4, r(t) = set point, c(t) = controlled variable, e(t) = r(t) – c(t) = error, and m(t) = manipulated variable.

2.2 DDC Algorithms and Their Implementation The differential equation for a PID controller is:

]/)(()(/1)([)(0

dttedTdtteTteKtm dt

ip ++= ∫ ; where e(t) = r(t) – c(t), r(t) is the desired

value (set point), c(t) the value of the variable being controlled and m(t) the output from the controller. The differential equation is the time domain representation of the controller. The equivalent frequency domain representation is:

++== sT

sTK

sEsMsG d

ipc

11)()()( .

In the frequency domain the overall system of the controller and plant can be represented by a block diagram as shown in Figure 2.5.

Page 30: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

30

Figure 2.5. General form of a control system: (a) continuous form; (b) discrete form

Both time domain and frequency domain representations are continuous representations. To implement the controller using a digital algorithm we have to convert from a continuous to a discrete representation of the controller. There are several methods of doing this; the simplest is to use first-order finite differences. Considering the time domain version of the controller we replace the differential and integral terms by their discrete equivalents by using the following relationships:

∆++

∆−−

=

∆=∆−

=

∑∫

=

=

n

kk

idp

n

kk

kk

k

teT

tet

neneTKnm

tedttetff

dtdf

1

1

1

1)()1()()(

)(,

(2.1)

Where m(n) represents the value of m at some time interval n∆t where n is an integer. By introducing new parameters ( ) ( )sdpdispi TTKKTTKK /;/ == ; where Ts = ∆t = the sampling interval, Eq. 2.1 can be expressed as an algorithm:

)]1()([)()()()()1()(

−−++=+−=

neneKnsKneKnmnensns

dip (2.2)

Where s(n) = the sum of the errors taken over the interval 0 to nTs.

Page 31: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

31

2.3 LabVIEW Hot Air Plant Model We will implement a simplified model of the hot air plant presented in Figure 2.1. Specifically, we will consider that the fan motor speed is constant and the fan inlet cover has 3 fixed positions (30%, 60%, and 90% opening). In order to implement the real-time model for the hot air plant we will use the plant model equations and the data presented in Lab 1. For this lab, the LabVIEW model implements the process with only 2 inputs and one output. The inputs are the inlet cover position that is local to LabVIEW model and the control input to the plant u(t) that is provided by the real-time controller implemented on Embest. The output is the process temperature c(t) that must be displayed within the LabVIEW model on a chart and also must be sent as an analog signal through the DAQ to the Embest software (real-time controller). Figure 2.6 presents a block diagram of the LabVIEW hot air plant model. Depending on the position of the inlet cover (that can be implemented as a 3 position selector switch) the LabVIEW implementation chooses the corresponding model equation. Note that depending on the cover opening the model equation presented in Lab 1 has different parameters. The LabVIEW software acts strictly as the hot air process. The PID controller and all other control and monitoring features are implemented on the Embest board.

Figure 2.6. LabVIEW block diagram of the hot air plant model.

Page 32: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

32

2. 4 Hot Air Plant Control Requirements You should use this example to develop the design and the report for this lab. For the hot-air blower described in this lab it is assumed that the planning phase has been completed and a specification document has been prepared. The following is a simplified version of such document: A. Introduction. The system comprises one device arranged along a conveyor belt that is one hot-air blower with a stand alone embedded controller. B. Plant Interface B.1. Input from plant Outlet temperature: analog signal, range 0 – 10 V, corresponding to 20C to 64C, linear relationship. B.2. Output to plant Heater control: analog 0 V to -10 V, corresponding to full heat (0 V) to no heat (-10 V), linear relationship. C. Control A PID controller with a sampling interval of 200 ms is to be used. (Note: Due to NI board sampling limitations this sampling interval may be changed to suit your specific data). The controller parameters are to be expressed to the user in standard analog form that is proportional gain, integral action time, and derivative action time. These parameters are to be determined using the Lab 1 tuning procedure. The set point and the controller parameters are to be variable and are to be entered from the Embest keyboard. D. Operator communication D.1. Display The following Table details the information to be displayed on the Embest LCD.

The values on the display will be updated every 5 seconds. The units on the display can be adjusted to show reasonable values.

Page 33: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

33

D.2. Operator input The operator can at any time enter a new set point or new values for the control parameters. This is done by pressing the ‘ESC’ key. In response to ‘ESC’ a menu is shown on the bottom of the display screen. The screen is shown in the figure below. In response to the number entered, the present value of the item selected will be deleted from the display and the cursor positioned ready for the input of a new value. The process will be repeated until item 7 is selected at which time the bottom part of the display will be cleared and the new values shown in the top part of the display.

E. Management information

On selection of item 6 of the operator menu a management summary of the performance of the plant over the previous 10 min will be given. The summary provides the following information: (a) Average error in C in 10 min period. (b) Average heat demand %FS in 10 min period. (c) For each 2 minute period:

• Average demanded temperature; • Average error; and • Average heat demand

(d) Date and time of output. Note: the management information can be simplified.

Hardware Design For more complex systems there are many different possibilities for the hardware structure (See lecture notes). For this lab application we will implement stand alone real-time embedded control.

Software design Examining the specification shows that the software has to perform several different functions:

• DDC for temperature control; • Operator display; • Operator input; • Provision of management information; • System start-up and shut-down; and

Page 34: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

34

• Clock/calendar function The various functions and type of time constraints are shown in Figure 2.7.

Figure 2.7. Real-time software block diagram for the hot air control. The control module has a hard constraint in that it must run every 200 ms. In practice this constraint may be relaxed a little to 200ms +-10 ms with an average value over 1 minute of, say, 200 ms +- 5 ms. In general the sampling time can be specified as Ts+-es with an average value, over time T, of Ts +-ea. The requirements may also be relaxed to allow, for example, one sample in 100 to be missed. These constraints will form part of the test specification. The clock/calendar module must run every 100 ms in order not to miss a clock pulse. This constraint can be changed into a soft constraint if some additional hardware is provided in the form of a counter which can be read and reset by the clock/calendar module. The constraint could now be, say, an average response time of 1 second with a maximum interval between reading the counter of 5 seconds.

Page 35: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

35

The operator display, as specified, has a hard constraint in that an update interval of 5 seconds is given. Common sense suggests that this is unnecessary and an average time of 5 seconds should be adequate; however, a maximum time would also have to be specified, say 10 seconds. Similarly soft constraints are adequate for operator input and for the management information logs. These would have to be decided upon and agreed with the customer. They should form part of the specification in the requirements document. The start-up module does not have to operate in real-time and hence can be considered as a standard interactive module. There are obviously several different activities which can be divided into sub-problems. The sub-problems will have to share a certain amount of information and how this is done and how the next stages of the design proceed will depend upon the general approach to the implementation. There are three possibilities: single program; foreground/background system; and muti-tasking.

2.5 Lab 2 Requirements The goal of this lab is three-fold: develop LabVIEW simulation model for a hot air plant application using the results of Lab1, interface the Embest board (hardware/software) with the LabVIEW hot air plant model, develop complete real-time control software application on the Embest board using the uniprocessor RTOS uC/OSII. Figure 2.1 presents the complete block diagram of the system implementation for Lab 2. The following outlines the tasks required by this lab. These tasks should be implemented in the specified order.

2.5.1. Task 1: LabView Model for the Hot Air Plant Implement LabView model for the hot air plant using the data from Lab 1 (process response Equation (8) and the data recorded in Table 1) and the plant model presented in Figure 2.6. Plot the output process variable (output temperature) for the different inlet cover openings.

2.5.2 Task 2: Real-Time uC/OSII Implementation of the Control Use the hot air plant model developed at Task 1, perform the hardware setup presented in Figure 2.1, and implement the real-time control for the hot air plant as described in Section 2.4. Test the system for various parameter values. Specifically, change the setpoint value, the PID parameters, and introduce temperature disturbance in the LabVIEW process model. Record your results for each new setup. Before you develop the hot air plant control application using uC/OS II learn the real-time development tools from the “Embedded System Development and Labs” book.

1. Perform the uC/OS Porting Lab of Section 7.1 (Note: The exercise section is not required).

2. Perform the uC/OS Application Lab of Section 7.2 (Note: The exercise section is not required).

3. Perform the uC/OS Start-Stop Watch application example of Section 7.3. This example was developed based on the Stop-Watch application presented in the “Embedded Microcontrollers” by Todd D. Morton.

Talk to your TA when you have completed this part.

Page 36: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

36

2.5.3 Task 3: Demo Demo the finalized PID controller running on the Embest board. Your final implementation should incorporate a display and interactive menu similar to what is shown in section 2.4.D. The system model should also be changeable in LabVIEW. The ability to change both the model and PID parameters will be tested and an appropriate response should be observable. The timing for the average value updates will also be checked, although some +/- is permissible. Make sure that you understand the background theory of the lab and your implementation is functional. The TA will ask questions related to the implementations, task allocation, and general coding in uC/OS. Also, the course exams will test some of the Laboratory material.

2.5.4 Task 4: Prepare Lab 2 Report Develop a Lab 2 report and submit it for marking. In your report, mention any important features that you feel are critical to your implementation. Things that you are happy about the way you implemented or solved. Fully document your implementations functionality. The following is an outline that you can use. However, this outline is not mandatory and can be changed to suit your application. 1. Introduction 1.1 Problem description 1.2 System requirements (similar to what I've presented in the lectures, but it can be simplified) 2. Background 2.1 Short overview of the benefits of using the Embest development board and uC/OS RTOS. 3. Implementation 3.1 Present a top-down functional implementation of the system 3.2 Present implementation details such as code and LabVIEW diagrams. Explain each task used and justify priority selection 3.3 Simulation results – show simulation graphs and present supporting data. Some values representing the percentage use of resources of the board at various points of operation from your implementation should be presented. These can be obtained using OSStatInit() and checking OSCPUUsage. 3.4 Discuss varying aspects of the embedded implementation.

Discuss any differences in response versus the PID on the Embest board and the LabVIEW implementation from lab one.

How well do your PID values hold when the system model is changed? Discuss any issues found in timing accuracy and response (i.e. control, display,

input) Present your simulation/experimentation design and explain the experiments conducted using the Embest board.

Any relevant graphs showing performance/functionality can be presented in this section.

Page 37: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

37

3. LAB 3: Real-Time Automotive Suspension System Simulator – Simulation/Experimentation Lab The objective of Lab 2 and Lab 3 is to introduce the students to complex real-time system implementation through simulation and experimentation using commercial software such as LabVIEW Real-Time OS. LabVIEW Real-Time is a deterministic RTOS that uses multi-core scheduling algorithms. In this lab we will develop the mathematical plant model for the automotive suspension system and implement the semi-active suspension control in Real-Time LabVIEW. The half-car suspension model is implemented on the host computer using the LabView software and the semi-active controller is implemented on a target dual-core computer using Real-Time LabVIEW software. Lab 3 will develop the model and analysis on the host computer and Lab 4 will implement the controller. Figure 3.1 presents the system level diagram for the Lab 3 and Lab 4 implementations.

Figure 3.1. Block diagram for the automotive car suspension system.

3.1 Background on Modeling the Automotive Suspension System in LabView

Dynamics of Mechanical Systems Newton’s Law for Translational Motion. The cornerstone for obtaining a mathematical model or the equations of motions, for any mechanical system is Newton’s law,

F = ma, (3.1) where

Page 38: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

38

• F is the vector sum of all forces applied to each body in the system, newtons (N) or pounds (lb),

• a is the vector acceleration of each body with respect to an inertial reference frame (that is, one that is neither accelerating nor rotating with respect to the stars); often called inertial acceleration, m/sec2 or ft/sec2, and

• m is the mass of the body, kg or slug. Note, in the above equation, the bold type indicate that the quantity is a matrix or vector, possibly a vector function.

Application of this law typically involves defining convenient coordinates to account for the body’s motion (position, velocity, and acceleration), determining the forces on the body using a free-body diagram, and then writing the equations of motion from Eq. (3.1). The procedure is simplest when the coordinates chosen express the position with respect to an inertial frame, because in this case the accelerations needed for Newton’s law are simply the second derivatives of the position coordinates. Newton’s Law for Rotational Motion. Application of Newton’s law to one-dimensional rotational systems requires that Eq. (3.1) be modified to:

,αIM = (3.1a) where

• M = the sum of all external moments about the center of mass of a body, Nm or lb.ft,

• I = the body’s mass moment of inertial about its center of mass, kg.m2 or slug.ft2, • α = the angular acceleration of the body, rad/sec2.

An example application of the rotational motion equations is the satellite attitude control model. Example of A Simple System; Cruise Control Model (translational motion). In this example we write the equations of motion for the speed and forward motion of the car shown in Fig. 3.1 assuming that the engine impacts a force u as shown. Take the Laplace transform of the resulting equation to find the transfer function between the input u and the output v. Equations of motion: for simplicity we assume that the rotational inertia of the wheels is negligible and that there is friction retarding the motion of the car that is proportional to the car’s speed (normally the aerodynamic friction force is proportional to v2 but here we use a linear approximation). The car can then be approximated for modeling purposes using the free-body diagram seen in Figure 3.2, which defines coordinates, shows all forces acting on the body (heavy lines), and indicates the acceleration (dashed lines). The coordinate of the car’s position x is the distance from the reference line shown and is chosen so that positive is to the right. Note that in this case the inertial acceleration is simply the second derivative of x (that is, xa &&= ) because the car position is measured with respect to an inertial reference. The equation of motion is found using Eq. (3.1). The friction force acts opposite to the direction of motion; therefore it is drawn opposite the direction of positive motion and entered as a negative force in Eq. (3.1).

Page 39: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

39

Figure 3.1. Cruise control model

Figure 3.2. Free-body diagram for cruise control The result is:

,,,muv

mbvor

mux

mbxorxmxbu =+=+=− &&&&&&& (3.2)

For the case of the automotive cruise control the variable of interest is the speed, v(= x& ). To obtain a solution for the above equation you assume a solution of the form steVv 0= given an input of the form steUu 0= . Then, since stesVv 0=& the differential equation in v can be written as:

,

1

,1

0

000

mbs

mUV

oreUm

eVmbs stst

+==

+ (3.3)

The result of Eq. (3.3) is usually written as:

Page 40: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

40

,

1

)()(

mbs

msUsV

+= (3.4)

The expression of Eq. (3.4) is called the transfer function of the differential equation (3.2). This transfer function was obtained from Eq. (3.2) by substituting operator s for d/dt (See your System Design or System Control course). The transfer function can be used to obtain the time response to various inputs using MATLAB or LabVIEW. We will use LabVIEW in this lab to analyze the car suspension system.

Mathematical Model Quarter-Car Suspension The goal of this section is to develop a simplified mathematical model that can be used to describe the behavior of an automotive suspension system. A common suspension setup is the McPherson suspension system composed of a coil spring and a damper located inside of the spring as shown in Figure 3.2.

Figure 3.2. McPherson suspension geometry. A system consisting of one of the four wheel suspensions is usually referred to as a quarter-car model. The quarter-car model will be extended to the 4-wheel car model. The system can be approximated by the simplified system shown in Figure 3.3. The coordinates of the two masses, x and y, with the reference directions as shown, are the displacements of the masses from their equilibrium conditions. The equilibrium positions are offset from the springs’ un-stretched positions because of the force of gravity. The shock absorber is represented in the schematic diagram by a dashpot symbol with friction constant b. The magnitude of the force from the shock absorber is assumed to be proportional to the rate of change of the relative displacement of the two masses – that is,

Page 41: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

41

to )( xyb && − . The force of gravity could be included in the free body diagram; however, its effect is to produce a constant offset of x and y. By defining x and y to be the distance from the equilibrium position, the need to include the gravity forces is eliminated.

Figure 3.3. The quarter-car model. The force from the car suspension acts on both masses in proportion to their relative displacement with spring constant ks. Figure 3.4 shows the free-body diagram of each mass. Note that the forces from the spring from the spring on the two masses are equal in magnitude but act in opposite directions, which is also the case for the damper. A positive displacement y of mass m2 will result in a force from the spring on m2 in the direction shown and a force from the spring of m1 in the direction shown. However, a positive displacement x of mass m1 will result in a force from the spring ks on m1 in the opposite direction to that drawn in Figure 3.4, as indicated by the minus x-term for the spring force. The lower spring kw represents the tire compressibility, for which there is insufficient damping (velocity-dependent force) to warrant including a dashpot in the model. The force from this spring is proportional to the distance the tire is compressed and the nominal equilibrium force would be that required to support m1 and m2 against gravity. By defining x to be the distance from equilibrium, a force will result if either the road surface has a bump (r changes from its equilibrium value of zero) or the wheel bounces (x changes). The motion of the simplified car over a bumpy road will result in a value or r(t) that is not constant.

Page 42: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

42

Figure 3.4. Free-body diagrams for suspension system As previously noted, there is a constant force of gravity acting on each mass; however, this force has been omitted, as have the equal and opposite forces from the springs. Gravitational forces can always be omitted from vertical-spring mass systems if:

• The position coordinates are defined from the equilibrium position that results when gravity is acting, and

• The spring forces used in the analysis are actually the perturbation in spring forces from those forces acting at equilibrium.

In the case of the quarter-suspension we have a two-mass system. Applying Eq. (3.1) to each mass and noting that some forces on each mass are in the negative (down) direction yields the system of equations:

,)()()( 1xmrxkxykxyb ms &&&& =−−−+− (3.5) ,)()( 2 ymxybxyks &&&& =−−−− (3.6)

Some rearranging results in

,)()(1111

rmk

xmk

yxmk

yxmbx wws =+−+−+ &&&& (3.7)

,0)()(22

=−+−+ xymk

xymby s&&&& (3.8)

The most common source of error in writing equations for systems like these is sign errors. The method for keeping the signs straight in the preceding development entailed mentally picturing the displacement of the masses and drawing the resulting force in the direction that the displacement would produce. Once you have obtained the equations for a system, a check on the signs for systems that are obviously stable from physical reasoning can be quickly carried out. A stable system always has the same signs on similar variables. For this system Eq. (3.7) shows that the signs on the ,−x&& −x& , and −x terms are all positive, as they must be for stability. Likewise the signs on the −y&& , −y& , and −y terms are all positive in Eq. (3.8). The transfer function is obtained in a similar manner as for the cruise control example. Substituting s for d/dt in the differential equations yields:

Page 43: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

43

( ) ( )

( ) ( ) ,0)()(2

)()()(

),()()()()()()(

2

2

1111

2

=−+−+

=+−+−+

sXsYmk

sXsYmbssYs

sRmk

sXmk

sYsXmk

sYsXmbssXs

s

wws

which, after some algebra rearranging, yields the transfer function:

,)()(

2121

2

121

3

21

4

21

mmkk

smmbk

smk

mk

mk

smb

mbs

bk

smmbk

sXsY

swwwss

sw

++

+++

++

+

= (3.9)

To determine numerical values for the transfer function of Eq. (3.9) we need to know the car mass m2, the wheel mass m1 and the constants b, ks, kw. Some practical values for these parameters for a small car with total mass of 1580 kg are: m2 = 1580/4 kg = 375 kg, m1 = 20 kg, ks = 130,000 N/m, kw = 1,000,000 N/m, and b = 9800 Nsec/m.

( ) ( ) ,07733.1)06307.1(04685.51.516

)3.13(0631.1)()(

234 esesessse

sXsY

+++++

= (3.10)

7 DOFs (Degrees of Freedom) Suspension System In the mathematical model of the automotive suspension, the sprung mass is the mass of the car supported by the suspension system, and the unsprung mass represents the mass of the suspension, tire, brakes, etc (masses not supported by the suspension). The four independent suspension systems are joined together by the body of the car (that can be modeled as a flat plate). Roll and pitch dynamics are modeled in order to capture the effect of the individual wheels hitting a bump in the road. The quarter car model equations can be used to develop the four-wheel suspension model based on the vehicle axes system presented in Figure 3.6. In this figure, the x-axis runs through the center of gravity along the length of the car and the y-axis runs along the width of the car (also passing through the center of gravity). The car rolls about the x-axis and pitches about the y-axis denoting counter-clockwise as positive. We assume that the roll and pitch axes run along the x and y axes, respectively. The motion equations that model the sprung and unsprung masses together with the dynamic equations that model the roll and pitch applied at the center of gravity will form the mathematical model for the four wheel suspension. The motion of the sprung mass at the four wheels can be obtained through the knowledge of the vertical movement of the center of gravity and the roll and pitch angles. We will present, quarter car and half car models for passive, semi-active, and active suspension systems. The full car model will not be implemented in these labs. However, here we show how the degrees of freedom for a full car model are considered. The equation for the mass moment of inertia of a uniform rectangular solid that has dimensions LxWxH about an axis through its center of gravity perpendicular to side LxW is given by:

Page 44: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

44

)(12

22 WLmI += (3.11)

Figure 3.6. Vehicle axis system.

Tasks of Automotive Suspension System An automotive suspension system supports the vehicle body (sprung mass) on the axles (unsprung mass) and has the following three basic tasks:

1. To isolate a car body from road disturbances in order to provide good ride quality. We can measure ride quality by the vertical acceleration of the passengers’ locations. Roll and pitch accelerations are not important to improve the ride quality even though they are critical quantities for handling issues. Note that the ride quality is a subjective parameter.

2. To keep good road holding and handling on a rough and bumpy road, a winding road, and maneuvers of acceleration, lane change and braking. The handling issues are subjective as well and it is difficult to quantify them. The easiest quantity is road holding which is represented by the tire deflection. To this extent, tire force variations are directly related to tire deflection, reducing tire deflection results in improved traction, braking, and cornering.

3. To support the vehicle static weight. This task is measured by the suspension deflection (rattle space) and depends on the type of suspension used.

These three basic tasks are interrelated.

Page 45: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

45

Semi-Active Suspensions and Control Laws Automotive electronic suspensions have aroused a great deal of interest due to their potential to improve the traditional ride quality/handling trade-off. The automotive industry is developing modulated, semi-active, and fully active suspensions. Active suspensions for ground vehicles have been a subject of research since 1970s. Design techniques have been developed assuming full state feedback and limited sensor availability. The literature states that the fully active suspension systems have some major drawbacks:

• The actuators in fully active suspensions require large power. • The malfunctions of controllers may cause catastrophic failure of the vehicle.

An alternative exists in the semi-active control of active dampers which combines the advantages of passive and fully active suspension systems. The active dumper is a self powered, high-gain device which produces control action when energy is dissipated from the suspension system. Only a small power source is required for instrumentation, signal-processing and low-power sensors. If the mechanical power induced by an acting force, which is determined by a certain control law, is always dissipating, i.e. the system does not require an energy supply from an outer system, we call it a “semi-active” control system. Thus, only “signal” level power is required for modulation of the passive elements. Usually, the system requires sensors, signal conditioners, and modulation devices. Mathematically, for the fully active control force fa (see Fig. 3.5a, the mechanical power is defined as follows:

( )usa zzfP && −−=

Fig. 3.5a 1/4 car models for fully active (left) and semi-active suspensions (right) The sign convention used is that the power is dissipated when P ≥ 0 and power is supplied when P < 0. Thus, the control law for semi-active suspension has to be considered under the constraint P ≥ 0 (for all t). Semi-active suspensions have also been considered for many years but studies are still going due to the nonlinear nature of most component modulation schemes.

Page 46: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

46

A number of ad-hoc methods, the most popular of which is the so called “clipped optimal”, have been suggested with numerical simulation results to show comparisons with passive and fully active designs; most of the works have the same concept of clipped control law:

as ff = (determined by any control strategy) if P ≥ 0 0=sf if P < 0

Usually, the semi-active force fs is implemented by a shock absorber with a variable orifice. Thus, fs is represented as:

( )uss zzvf && −−= For this representation, the semi-active constraint is v ≥ 0. i.e. time variable damper coefficient v can be modulated for v ≥ 0. From practical point of view, the variable damper coefficient v has some upper limitation vmax. In general two types of semi-active system exist.

1. A continuous damper modulation control which requires a complex electro-mechanical servo valve to modulate the orifice area continuously.

2. An “on-off” damper modulation control which requires a simple valve which takes two positions, a hard position (a small orifice area) and a soft position (a large orifice area). The switching speed of this control needs to be faster than the conventional adjustable passive suspension system.

The control laws for these types of system are determined by intuitive engineering sense or the direct inspection of the fully active control law fa (fa is obtained by the absolute control law). The ad-hoc methods do not guarantee the existence of the “optimal” semi-active suspension control law in the performance index sense like LQR (Linear Quadratic Regulator) or LQG (Linear Quadratic Gaussian) method.

Further Notes on Optimal Passive Suspensions Studies on optimal passive suspensions have been done using the quarter car model of Figure 3.3 that is repeated here (Fig. 3.5b) with different notations. This a linear two degree-of-freedom (DOF), lumped element model with motion in the vertical direction only. The suspension is simply modeled by a spring and a damper. This model can be used to determine the optimal passive suspension parameters ks and bs.

Page 47: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

47

Fig. 3.5b. 1/4 care model of passive suspension. The passive suspension shown in Fig. 3.5b is modeled as a linear spring of stiffness ks and a linear damper of damping rate bs. The tire is simply modeled by a spring of stiffness kt, i.e., tire damping is assumed to be zero. We assume that the tire does not leave the ground and that zs and zu are measured from the static equilibrium position. The linearized equations of motion can be easily derived as follows:

( ) ( )( ) ( ) ( ) 0

0=−+−−−−

=−+−+

rutussussuu

ussussss

zzkzzkzzbzmzzkzzbzm

&&&&

&&&& (3.11)

The state variables are chosen to be: us zzx −=1 suspension deflection (rattle space)

szx &=2 absolute velocity of sprung mass (3.11a)

ru zzx −=3 tire deflection

uzx &=4 absolute velocity of unsprung mass Therefore, equations (3.11) can be rewritten in state space representation using the state variable definitions as:

r

usutusus

ssssss z

xxxx

mbmkmbmk

mbmbmk

xxxx

&

&

&

&

&

−+

−−−

=

01

00

////1000/0//1010

4

3

2

1

4

3

2

1

(3.12)

Therefore, rzLAxx && += ; A very common road input model that has been used by many authors is to assume that the road input rz is a stationary Wiener process and that its derivative rz& is white noise with intensity Ξ i.e., [ ] VASorttztzE rzrr r

=Ξ=−Ξ=+ )(,);()()( ωτδτ &&& ; Where rA is a roughness parameter and V is the vehicle speed. Also, assume that: [ ] 0)( =tzE r& for all t ≥ 0. However, in our experiments we will use different road inputs.

The block diagram of the state space representation (3.12) can be shown in figure below. This figure shows that the passive suspension is the disturbance (road velocity input) rejection open-loop system.

Figure 3.5c Block diagram of passive suspension.

Page 48: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

48

The performance index to evaluate this system is given by:

( )

( )∫

++++=

+−++−+=

∞→

∞→

T

T

T

urusussT

dtxxxxxEJ

or

dtzzzzzzzEJ

0

244

233

222

211

22

0

24

23

22

21

2

][lim

])()([lim

ρρρρ

ρρρρ

&

&&&&

(3.13)

Where 4321 ,,, ρρρρ are weighting factors. In a matrix form the equations (3.13) can be transformed to:

][1lim0∫∞→

=T T

TQxdtxE

TJ (3.14)

Passive elements sk and sb have the following physical and engineering constraints

maxminmaxmin ; bbbkkk ss ≤≤≤≤ ; (3.15) The problem is to find the optimal passive elements sk and sb such as to minimize equation (3.14) under the equation of motion (3.12) and the constraints (3.15). Using the following vehicle parameters for 1/4 car model:

;1;/1000;/000,160;/000,16;36;240 =Ξ===== mNbmNkmNkkgmkgm stsus with the following constraints and weighting factors:

( ) ( )16;400;16;400,,,;/4000/500;/000,20/1000

4321 =≤≤≤≤

ρρρρmNsbmNsmNkmN ss

the minimal cost and optimal sk and sb are: mNsbmNkJ ss /5.956;/1000;2807 === .

The weighting factors used emphasize the improvement of ride quality. The weighting factors can be increased to emphasize the tire deflection and rattle space. In this case the cost function J and the optimal passive elements sk and sb will increase as well. The optimal passive suspension developed in this section can be used to compare the performance of the fully active, and semi-active systems with that of the passive systems.

Notes on Control Laws for Automotive Fully Active Suspensions The two degree of freedom model presented below can be used to evaluate alternative control laws. Control laws presented in this section are full state feedback, sprung mass absolute velocity feedback and LQG regular using suspension deflection as the measurement. The equations of motions for this model are:

( ) ( )( ) ( ) ( )rutaussussuu

aussussss

zzkfzzbzzkzmfzzbzzkzm

−+−−+−=+−−−−=

&&&&

&&&& (3.16)

The road input model defined in the previous section is used in this section as well.

Page 49: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

49

We also introduce again the choice for the state variables presented in equation (3.11a) and we present the state equation system in this case.

Figure 3.5d Quarter car model for fully active suspensions In state variable form we have:

ra zLBfAxx && ++= (3.17) Where fa is the scalar active force and A, B, and L are the appropriate matrices which are obvious from equations (3.16) i.e.,

−−−

=

usutusus

ssssss

mbmkmbmk

mbmbmk

////1000/0//1010

A ;

−=

=

01

00

;

/10

/10

LB

u

s

m

m; (3.18)

The block diagram of the equation (3.17) is shown in Fig. 3.5e. Unlike the passive suspension system this active system has one more input (actuator force input) besides the road velocity input. Our task is to determine the actuator force fa to reject the road velocity input rz& . Thus this becomes a closed-loop disturbance (road velocity input) rejection regulator problem (See “Feedback Control of Dynamic Systems” book).

Figure 3.5e Block diagram of active suspension open loop system.

Page 50: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

50

Three transfer functions (acceleration, rattle space and tire deflection) are of interest in this system and have been defined as follows:

;)(

)()()(;

)()()(

)(;)()(

)(sz

szszs

szszsz

sszsz

sr

ru

r

us

r

s

&&&&

&& −=

−=≡ RDRSA HHH (3.19)

A full state feedback equation can be considered to derive asymptotic properties using the above transfer functions.

;44332211 Gxfa −=−−−−= xgxgxgxg (3.20) Analysis of the acceleration asymptotes shows that low frequency acceleration asymptote is independent of both the passive and active parameter and the high frequency asymptote depends on the active gain, g3, and rolls off at 20db/decade. It is interesting to note that the passive system (fa=0) has a high frequency asymptote that rolls off at 40db/decade. In fact it can be shown that the presence of g3 leads to a high frequency harshness when compared to the passive system. Setting g3 to 0 eliminates the high frequency harshness and has little impact on the low frequency performance. From the analysis of the rattle space asymptotes for the active and passive systems it can be shown that high frequency asymptotes have same roll-off but the low frequency characteristics are entirely different. The tire deflection asymptotes for both passive and active suspensions are independent of the active suspension force. Also, a dynamic compensator for active suspensions can be designed (See reference book). Full State Feedback. Many authors have used linear optimal control theory to design full state feedback laws. First, a quadratic performance index,

( )( )∫∫

++=

+−++−+=

∞→

∞→

T

T

T

urusussT

dtE

dtzzzzzzzE

0

0

24

23

22

21

2

][lim

])()([lim

2aa

TT RfSf2xQxx

J &&&& ρρρρ (3.21)

is defined and then the weighting factors ( 4321 ,,, ρρρρ ) are chosen to emphasize either ride quality, suspension travel or tire deflection. The active force which minimizes equation (3.21) is the well known linear quadratic regulator problem whose solution results in a state feedback law (3.20) whose gains (g1,g2,g3,g4) depend on the weighting factors ( 4321 ,,, ρρρρ ). The feedback gain G=(g1,g2,g3,g4) is determined by solving the following Riccati equation:

)()()()(

SPBRG0PBPBRSRSQSBRAPPSBRA

T1

T11T1T1

+=

=−−+−+−−

−−−−

(3.22)

The gain matrix G in equation (3.22) consists of two parts PBR T1− which is a designed feedback gain matrix and SR 1− which works to cancel out the passive elements ks and bs. Therefore, the acting force to the sprung mass is independent of the passive elements ks and bs. In other words, the optimal fully active force does not change even though the passive elements are changed if the weighting factors in the performance index are fixed.

Page 51: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

51

It is very difficult to obtain the closed form solution of Riccati equation (3.22) because of nonlinearity. However, since this system has only 4 states we can obtain the following approximated closed form solutions under the assumption that the tire stiffness kt is much greater than each feedback gain g1,g2,g3, and g4.

{ };

;)2(

;2

solution)exact an is (This;

44

12413

122

11

ss

s

ss

ss

bmg

mg

bmg

kmg

+=

+−=

−+=

−=

ρ

ρρρρ

ρρ

ρ

(3.23)

The closed-loop state equation can be obtained by substituting equations (3.20) and (3.22) in equation (3.17) as follows:

;)( rzLxBGAx && +−= (3.24) The block diagram of equation (3.24) is shown in Fig. 3.57.

Figure 3.5f Block diagram of fully active suspension closed loop system (LQR) It is very difficult or expensive to measure all 4 states, especially the tire deflection (x3) and the absolute velocity of unsprung mass (x4). The problem to reduce the number of sensors is very crucial without deteriorating the output responses such as the acceleration of sprung mass, the suspension deflection, and the tire deflection. Fortunately, since we can set g3 = 0, it is not necessary to measure tire deflection (x3). Furthermore, the absolute velocity of unsprung mass (x4) can be reconstructed by the measurement values either ( 221 ,, xxx & ) or ( 4221 ,, xxxx − ) from the state equation (3.17). Absolute Velocity Feedback. Since most of the performance improvements in ride quality at 1 Hz are due to the absolute sprung mass velocity feedback term it makes sense to consider a much simpler active control law:

;22 xg−=af (3.25)

Page 52: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

52

Increasing g2 results in a substantial increase in damping of the 1 Hz mode with very little deterioration of the wheel-hop mode. The absolute velocity feedback captures all the nice properties of the full state ride quality design without the high frequency harshness problem. It also has the advantage of being very easy to design since there is only one parameter to choose. The only negative aspects are the need for a possibly expensive accelerometer and the low frequency suspension problem. In practice the latter problem would be alleviated by bandpass filtering the acceleration signal thus very little law frequency content would be in the filtered integrated acceleration signal. The active suspension problem is difficult since one control must provide a trade off between ride quality, suspension travel, and road holding ability. Both, full state feedback and absolute sprung mass velocity feedback could be designed to provide significant improvements in ride quality (near 1 Hz) without degrading road holding; however, some additional filtering would be required to keep the suspension travel from becoming too large. Designs which emphasize road holding rely on feeding back tire deflection which is very difficult to measure and which causes high frequency harshness problems in the acceleration transfer function. Detailed design analysis of these laws and of a dynamic compensator using suspension deflection are presented in [PhD ref].

Notes on Local and Global Control Laws In this section we look to the difference between two control design procedures of active suspension systems; local and global control laws. When controlling the full car model, we could control each suspension force using only the local information as if each suspension was independent. This design method is very attractive because each suspension uses only local sensors. However, if the coupling effect between suspensions is strong, the performance of this method deteriorates. On the other hand, as presented in [PhD ref] each suspension force can be determined using all the states of the vehicle (global information). Although this approach is “optimal”, the number of states increases. For example, the 1/4 car model has 4 states, the 1/2 car model has 8 and the full car model has 14. The former approach gives us the local control law, the later the global control law. Here we will compare these two methods and make clear the advantages and disadvantages using a half car model. We divide the 1/2 car model of Figure 3.5g into two quarter car models as presented in Figure 3.5h; where,

;; 21rf

fcs

rf

rcs LL

Lmm

LLLm

m+

=+

= (3.25)

The performance indices are as follows: (Assume that each road input is 0)

( )∫ +−++−+=T

urusussF dtzzzzzzz0

2114

21113

2112

21111

21 )()( &&&& ρρρρJ (3.26a)

( )∫ +−++−+=T

urusussR dtzzzzzzz0

2224

22223

2222

22221

22 )()( &&&& ρρρρJ (3.26b)

Page 53: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

53

Figure 3.5g. Half car model

Figure 3.5h. Divided quarter car models (Left: Front suspension Right: Rear suspension) From LQR theory, each suspension active force T

aa ff ),( 21=af can be obtained respectively:

;)()(

;)()(

24223222212

14113121111

urrursrusr

ufrufsfusf

zgzzgzgzzg

zgzzgzgzzg&&

&&

−−−−−−=

−−−−−−=

a

a

ff

(3.27)

Equation (3.27) can be rewritten in the following matrix form:

;xGf La = (3.28)

Page 54: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

54

Where,

;;0

00

00

00

0

2

1

22

11

2

1

22

11

4

4

3

3

2

2

1

1

−−

−−

=

=

u

u

ru

ru

s

s

us

us

r

f

r

f

r

f

r

f

zz

zzzz

zz

zzzz

gg

gg

gg

gg

&

&

&

&

xG L (3.29)

Global Control Law. The equation of motion for the half car model of Fig. 3.5g can be derived as follows: Sprung Mass

=

−−

+

+

−−

+

2

1

22

11

2

1

22

11

2

1

110

011

0011

00

a

a

rfus

us

s

s

rf

us

us

s

s

rfc

c

c

c

ff

LLzzzz

bb

LL

zzzz

kk

LLz

Im

&&

&&

&&&&

θ (3.30)

The relationship between ( ) ( )Tss

Tcc zzz 21 andθ is as follows:

−+

=

=

−=

2

1

2

1

111;

11

s

s

r

f

rfc

c

c

c

c

c

r

f

s

s

zz

LL

LLzzz

LL

zz

θθθTR (3.31)

By substituting (3.31) into equation (3.30) we get:

+

−−

−−

−=

2

1

22

11

2

1

22

11

2

1

2

1

00

0011

/100/1

11

a

a

us

us

s

s

us

us

s

s

rfc

c

r

f

s

s

ff

zzzz

bb

zzzz

kk

LLIm

LL

zz

&&

&&

&&

&&

(3.32)

Equation 3.32 can be rewritten using vector notation as follows:

];)()([ a1

sT

s fzzBzzKRMRz +−−−−= −ussuss &&&& (3.33)

Page 55: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

55

Unsprung Mass

−−

+

+

−−

−−

=

2

1

22

11

2

1

22

11

22

11

2

1

2

1

2

1

00

00

00

/100/1

a

a

us

us

s

s

ru

ru

t

t

us

us

s

s

u

u

u

u

ff

zzzz

bb

zzzz

kk

zzzz

kk

mm

zz

&&

&&

&&

&&

(3.34)

Or in vector notation:

];)()()([ a1

s fzzBzzKzzKMz −−+−−−−= −ussrstussu &&&& (3.35)

The performance index for this system (in matrix form) is as follows:

( );

)()()()(0

43

RF

Ts2us1

Tuss

Ts

JJ

zWzzzWzzzWzzzWzzzzJ

+=

+−−++−−+= ∫T

uTururu

Ts dt&&&&&&&&

Where the matrices W1, W2, W3, and W4 are weighting matrices such that:

;0

0;

00

;0

0;

00

24

14

23

13

22

12

21

11

=

=

=

=

ρρ

ρρ

ρρ

ρρ

1111 WWWW

Using LQR theory, we can determine the global optimal control law fa as follows:

;xGfa G= (3.36) Where,

;;

2

1

22

11

2

1

22

11

2827262524232221

1817161514131211

−−

−−

=

=

u

u

ru

ru

s

s

us

us

zz

zzzz

zz

zzzz

gggggggggggggggg

&

&

&

&

xG L (3.37)

The elements of the control gain matrix GL (Local control law (3.29)) for the front suspension are independent of those for the rear suspension. However, the elements of the global control gain matrix GG (3.37) depend upon each other. Comparison between Local and Global Control Laws. The simulation results show that the difference between the local and global control laws is very little using our weighting factor matrices based on the quarter car model design. In fact, we cannot distinguish the difference in the acceleration of the sprung mass, the suspension deflection, the tire deflection, etc. In this section we look at how the front and real suspensions are correlated and what their coupling effect gives to the vehicle system, which will give us the reason why the difference between the two methods is negligible.

Page 56: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

56

The coupling effect is only caused by the term RMR 1s

T − in Equation (3.33) if the performance index J is decoupled by JF and JR terms. i.e., the weighting matrices W1, W2, W3, and W4 are diagonal matrices.

;//1//1

//1//12

2

+−−+

=−

crccrfc

crfccfc

ILmILLmILLmILm

RMR 1s

T (3.38)

If the pitching moment of inertia Ic is equal to mcLfLr (i.e. Ic = mcLfLr), the off-diagonal terms of Equation (3.38) becomes zero, which means that the equation of motion of the half car model is completely decoupled and that the local control law becomes the same as the global control law. (The diagonal terms of Equation (3.38) become the same as Equation (3.25)). The physical meaning of Ic = mcLfLr is that the two lumped masses distribute to the locations of the front and rear suspensions and that these two masses are connected by a massless rigid bar as shown in the figure below:

Figure 3.5i. Lumped mass half car model. Using Equation (3.25),

;)( 212

22

1 rfcrfssrsfsc LLmLLmmLmLmI =+=+= The effect of the coupling depends only on the pitching moment Ic. Thus, the performance costs [PhD ref] for the local and global control laws and the passive suspension can be calculated while varying the pitching moment Ic from 500 kgm2 to 2500 kgm2. Figure 3.5j shows that there exists little difference between the local and global control laws around the given pitching moment. This analysis is valid not only for front-rear suspension relations but also for right-left suspension relations. Thus, it is true that the local control law works almost as well as the global control law under a full car model.

Page 57: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

57

Figure 3.5j. Coupling Effect for half car model. Table 3.1. Vehicle parameters for half car model mc = 730 kg; Ic = 1230 kgm2; mu1 = 40 kg; mu2 = 35.5 kg; ks1 = 19,960 N/m; ks2 = 17,500 N/m; kt = 175,500 N/m; bs1 = 1290 Nsec/m; bs2 = 1620 Nsec/m; Lf = 1.011 m; Lr = 1.803 m; Table 3.1a. Other parameters used for the half car model Drag Coefficient (Cd) = 0.5; Cross Sectional Area (A) = 3 m2; Air Density (ρ) = 1.225 kg/m3;

Semi-Active Suspensions Introduction. A semi-active suspension system utilizes a variable damper or other variable dissipation component in the automotive suspension. An example of a variable dissipater is a twin tube viscous damper in which the damping coefficient can be varied by changing the diameter of the orifice in a piston:

Page 58: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

58

Fig. 3.6. Schematic of a variable orifice damper Figure 3.6 shows the schematic of a twin tube variable orifice damper in which the orifice diameter can be varied with electronic control. As the piston move inside the cylinder, it causes fluid flow through the orifice. A larger orifice provides less dissipative resistance while a smaller orifice provides increased dissipative resistance. To use the variable orifice damper as a semi-active actuator, the opening of the orifice is determined in real-time by feedback control laws. Thus the damping provided by the device is varied in real-time by feedback control. Another example of a semi-active dissipater is a magneto rheological (MR) damper which uses MR fluid. A MR damper is shown in Figure 3.7. Magnetorheological (MR) fluids are materials that respond to an applied magnetic field with a change in rheological behavior. Typically, this change is manifested by the development of a yield stress that monotonically increases with applied magnetic field. The dissipative force provided by the damper can be controlled by the controlling the electromagnetic field.

Figure 3.7. Bender and Carlson commercial linear MR fluid-based damper. The dissipative force as function of velocity across the piston of the MR damper is shown in Figure 3.8 for different values of current in the electromagnetic coil. Thus, with different levels of current, different levels of dissipative force can be obtained. This

Page 59: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

59

section focuses on the development of control systems that utilize variable dissipaters in the suspension system to improve the performance of the automotive suspension. Such a suspension system that utilizes a variable dissipater which is controlled in real-time is called a semi-active suspension.

Figure 3.8. Performance curves for the linear MR damper. Advantages of a Semi-Active Suspension System. Compared to fully active suspension systems, semi-active systems consume significantly less power. The power consumption in a semi-active system is only for purposes of changing the real-time dissipative force characteristics of the semi-active device. For example, power is used to change the area of the piston orifice n a variable opening damper or to change the current in the electromagnetic coil of a MR damper. External power is not directly used to counter vibratory forces. Another advantage of semi-active system over the active systems is that they cannot cause the suspension system to become unstable. This is due to the fact that they do not actively supply energy to the vibratory suspension system but only dissipate energy from it. Semi-Active Suspension Model. A quarter care semi-active suspension system is shown in Figure 3.9. The variable damper )(tbsemi is constrained to be between the following values:

max)(0 btbsemi ≤≤ (3.26)

Page 60: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

60

Figure 3.9. Quarter-car semi-active automotive suspension. The equations of motion of the two-degree-of-freedom quarter-car suspension shown in Figure 12.4 are:

( ) ( )( ) ( ) ( ) ))((

))((

ussemiussussrutuu

ussemiussussss

zztbzzkzzbzzkzmzztbzzkzzbzm

&&&&&&

&&&&&&

−=−−−−−+−−=−+−+

(3.27)

The state space model of the quarter-car active automotive suspension system can be written as (Yue, et. Al. 1988):

rsemi0rsemi0rsemi0 zLBxAzLNxxAzLBFxAx &&&& +−+=++=++= )( 42 xxbb (3.28) Where the variables are as follows:

us zzx −=1 suspension deflection (rattle space)

szx &=2 absolute velocity of sprung mass (3.28)

ru zzx −=3 tire deflection

uzx &=4 absolute velocity of unsprung mass

semiF semi-active force ( )( ussemi zzb && −−= )

42 xx − relative suspension velocity

Page 61: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

61

−−−

=

usutusus

ssssss

mbmkmbmk

mbmbmk

////1000/0//1010

0A ; ;

/10

/10

=

u

s

m

mB

−=

−=

01

00

;

/10/10

0000

/10/10

0000

LN

u

s

u

s

m

m

m

m

The equations presented in (3.28) are different representations that have been used in literature for the same semiactive suspension system. Note that the term semiNxb involves a product of the states Nx and the control input semib . Hence the semi-active system is not linear, but is a bilinear system. Theoretical analyses for optimal semi-active suspensions are presented in (Butsen, 1989). The analyses are based on the equivalence theorem that states the following: The two systems shown in Figure 3.10 below (the force control and the modulated damper control systems) are equivalent in the modulated damper rate, bsemi(t), takes all real values.

Figure 3.10. Equivalence of force control and unconstrained modulated damper control systems.

Page 62: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

62

Here we present notes on the interpretation of the optimal semi-active control law. Let the optimal active control force be given as:

( )xSPBRForxxbxkKxF Tassa 0

1421 );( +−=−+−= − (3.29)

Where the passive suspension force is: xSRxxbxk ss 0

1421 )( −−=−+ (3.30)

And the optimal state feedback force component obtained from the LQR solution for the fully active system is:

PxBRKx T1−=− (3.31) Thus the total active force is expressed by the second part of equation (3.29).

Considering that 42

)()(xx

FxSPNx aT

−≡+ , the optimal semi-active control law can be

written in terms of the suspension variables as:

)(:bygiven is force active-semi ingcorrespond theand

;

;0

;0)(0

42*

max42

max*

max4242

*

42*

xxbF

bxx

Fifbb

bxx

Fif

xxF

b

xxFifb

semisemi

asemi

aasemi

asemi

−−=

>−

−=

≤−

<−

−=

≤−−=

(3.32)

Figure 3.11 shows the semi-active control law schematically. When the fully active force Fa and the relative suspension velocity x2-x4 have the same sign, then the required active force is in the same direction and the relative velocity. Such an active force cannot be provided by a dissipative device, since a dissipative device can only provide a force which is opposite to the relative velocity. In this case, the value of damping semib in the semi-active device is chosen to be zero. When the fully active force Fa and the relative velocity (x2-x4) have the opposite sign, then a dissipative device can indeed provide the desired force. In this case, the value of the semi-active damping coefficient semib is

chosen to be 42 xx

Fb a

semi −−= . If this value exceeds the maximum available damping

coefficient maxb , then semib is set to be equal to maxb .

Page 63: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

63

Fig. 3.11. Semi-active control law shown schematically as a function of Fa and relative velocity. The semi-active control law is also summarized in the table below. Table 3.2. Summary of Semi-Active Control Law Symbol Nomenclature Equation

aF Optimal fully- )( ussssa zzbzkKxF &&& −++−= active force

semib Semi-active ;0)(0 42* ≤−−= xxFifb asemi

(variable) ;0 max4242

* bxx

Fif

xxF

b aasemi ≤

−<

−−=

damping ;max42

max* b

xxF

ifbb asemi >

−−=

coefficient and, )( 42* xxbF semisemi −−=

Page 64: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

64

Notes on Determination of Lateral and Longitudinal Weight Transfers. The desired variable to be obtained when a car is taking a corner is the lateral load transfer. This is obtained through knowledge of the velocity of the vehicle and the turning radius, as well as structural parameters of the car.

Figure 3.12. Lateral load transfer The lateral acceleration is obtained by applying the following equation to the vehicle velocity V and the turning radius R:

gRVAy ⋅

=2

, where R is expressed in g units.

Fig. 3.13 shows the lateral load transfer when the car takes a right hand turn. Summing the moments about O we can derive the following equations:

,2

,2

thWAWW

hWAtWtW

yL

yL

+=

+= (3.16)

Since the car is symmetrical, the weight normally supported by the two left tires is W/2. Thus, the change in weight can be expressed as the weight supported by the left tires during cornering minus W/2.

thWAWWW y

LLat =−=∆2

, (3.17)

It can be assumed that the extra weight will be equally supported by the two outside tires, and hence the additional weigh placed on each tire is: .2/LatW∆ Braking or accelerating creates a longitudinal acceleration. Similarly, we can derive the longitudinal weight transfer to be:

Page 65: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

65

lhWA

W xLong =∆ , 3.18)

The equations governing the load transfer to each wheel are shown below:

22

22

22

22

4

3

2

1

Longlat

Longlat

Longlat

Longlat

WWW

WWW

WWW

WWW

∆+

∆=∆

∆−

∆=∆

∆−

∆−=∆

∆+

∆−=∆

(3.19)

Calculation of Forward Velocity. The “Fapp = User Defined” is the user-applied force (through the gas pedal or brake pedal). The counter force is the aerodynamic drag on the car. For this model the frictional force of the tire and the road is neglected, but should be included in a more comprehensive model. The drag-induced force is equal to the drag coefficient of the car, times the cross-sectional area, times the air density, times the car’s velocity squared over 2 (the drag force is proportional to V2):

2

2VACF dd ⋅⋅⋅= ρ (3.20)

The net force working on the car is the difference between the applied force and the drag force and is equal to overall mass, times the longitudinal acceleration:

,

,

,,

mFF

A

FFmA

FFFmAF

appx

dappx

dappnet

xnet

−=

−=

−==

(3.21)

The velocity is then calculated by simply taking the previous velocity and adding that by the longitudinal acceleration multiplied by the sampling interval:

,12 tAVV x∆+= (3.22)

Page 66: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

66

3.2 Lab 3 Requirements The objective of this lab is three fold: implement the half car semi-active suspension model using LabVIEW on the host computer; implement the local control law for the semi-active suspension to control the model; compare the passive suspension with the semi-active suspension. The detailed requirements will be presented by the TA.

Page 67: ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL · 1 ENGG4420: REAL-TIME SYSTEMS DESIGN - LAB MANUAL Developed By Radu Muresan School of Engineering University of Guelph August 2008

67

4. LAB 4: Multi-Core Real-Time Suspension Controller using LabVIEW Real-Time OS – Simulation/Experimentation Lab The objective of this lab is to implement the semi-active controller (Table 3.2) for a semi-car suspension model on the target computer using Real-Time LabVIEW OS and connect it with the suspension model simulator developed in Lab3. The controller will target one, two, three and four processor cores and the performance of the system will be analyzed using the Real-Time LabVIEW tools.

4.1 Real-Time LabVIEW Background Setting Up the Target PC for Real-Time LabVIEW OS. … Real-Time LabVIEW OS Features. Developed in the lectures.

4.2 Lab 4 Requirements Presented by the TA.