Design and Development of a Low Cost Rapid Control Prototyping System Applied to an Air Suspension System

Design and Development of a Low Cost Rapid Control Prototyping System Applied to an Air Suspension System

Proceedings of the 9th IFAC Symposium Advances in Control Education The International Federation of Automatic Control Nizhny Novgorod, Russia, June 19...

3MB Sizes 0 Downloads 19 Views

Proceedings of the 9th IFAC Symposium Advances in Control Education The International Federation of Automatic Control Nizhny Novgorod, Russia, June 19-21, 2012

Design and Development of a Low Cost Rapid Control Prototyping System Applied to an Air Suspension System G. Berisch, H. Donath, F. Heinrich, I. Huebener, T. Lipke, T. Mende, M. Schriefer, H. Schulte, M. Zajac HTW Berlin - Department of Electrical Engineering, Control Laboratory, University of Applied Sciences, Berlin, Germany (e-mail: [email protected]). Abstract: A low cost and easy to use rapid control prototyping system which is based on the Arduino Uno, Matlab/Simulink and hardware- and software-add-ons is introduced. Design and development of the hardware- and software-add-ons is described and the rapid control prototyping system is applied to an air suspension system. A mathematical model of the air suspension system is deduced and on its base a suitable controller is designed and tested with software in the loop and experimental validation. Keywords: Control Education, Model Based Control, Simulation 1. INTRODUCTION The intention for developing the system described in this paper is to have an easy to use and more importantly, low cost rapid control prototyping (RCP) system which can be utilized for control engineering education in university, higher education schools and by control engineering students. Especially at the HTW-Berlin students are supposed to apply their knowledge about linear system SISO design methods, by designing and implementing a control structure from the given model to a digital controller. Low cost systems enable unexperienced users to experiment with hardware without fearing high financial damage. Furthermore, the access barrier is much lower, especially for not well financially situated persons, institutions and education programs. The easy to use aspect provides advantages aswell. Unexperienced users are able to achieve results quicker than with other systems and do not get stuck in problems regarding usage which may be discouraging. Laboratory supervising staff in education facilities can be kept at a minimum and students are able to work freely at their projects and assignments and gain important experience in control engineering by themselves. The RCP system proposed in this paper has a overall cost of about 230 e assuming already exsisting laboratory infrastructure including a MATLAB/Simulink license. A RCP system requires certain abilities (Abel, 2006): • Modeling, simulation and controller design with a convenient graphic programming environment • Software-/Hardware-in-the-loop testing ability • code generation for the target system. By combining the hardware of the Arduino Uno and the abilities of MATLAB/Simulink the requirements to a RCP system are satisfied. An Arduino Target Toolbox for MATLAB/Simulink is available for code generation. Especially due to the usage of MATLAB/Simulink students are able 978-3-902823-01-4/12/$20.00 © 2012 IFAC

194

to learn with software that is spread thoughout the control engineers around the world. The Arduino Uno is an open source, low cost, easy to use integrated development environment for physical computing. The idea behind the Arduino project is that developers with low or even no engineering experience are able to realize their projects even if they lack the knowledge of designing and assembling a microcontroller based integrated system. Originally developed in 2005 by Massimo Banzi and David Cuartielles (Banzi, 2009) at the Interaction Design Institute Ivrea, Italy in the meantime the Arduino Project grew because of its open source philosophy to a frequently used development platform which has been redesigned, extended and adapted by many other developers. Because of the ability of the Arduino to interact with it’s environment via sensors and actuators which can be easily wired to the board, the Arduino is very common among designers and artists who work with light and interactive installations. A huge number of different projects realized with the Arduino not only in the art sector but also in every-day-use gadgets and even robotics can be found on the Internet. 2. RAPID CONTROL PROTOTYPING SYSTEM BASED ON ARDUINO 2.1 System overview The Arduino Uno consists of an Atmega328 microcontroller with a flash-memory size of 32KB, a 1KB EEPROM and 2KB of RAM . For connecting sensors and actuators to the Arduino Uno there are 13 digital I/O. Six of those digital I/O-pins are capable of pulse width modulation. For analog signal processing there are six analog input pins which convert the analogue input signal to a digital 10-bit signal. To program the microcontroller it is possible to connect the Arduino Uno to a PC via the built in USBconnector and use the Arduino-Software 022 which can be found on the Arduino website and also downloaded 10.3182/20120619-3-RU-2024.00021

9th IFAC Symposium Advances in Control Education Nizhny Novgorod, Russia, June 19-21, 2012

Fig. 1. Real plant for free. Especially when it comes to control engineering MATLAB/Simulink is an unavoidable software-tool for many control engineering tasks. With the Arduino Target Toolbox for MATLAB/Simulink, it is possible to design a control system within MATLAB/Simulink and convert it to Arduino code via auto-code-generation. The Arduino Uno Target Library for Simulink makes it easy to communicate directly from Simulink to the Arduino Uno and vice versa. The DAC-Shield or digital-to-analog-converter compensates for the lack of analog output. A shield is a hardware add-on for Arduino Uno based boards which extends the functionality of the Arduino Uno or any other Arduino version for which it is suitable. 2.2 Hardware development The main components of the shield are three voltage regulators, an LT1366 DAC by Linear Technology, four dual operational amplifiers and eight potentiometers. The LT1366 is a 12-bit digital to analog converter with an I2 C-Bus and four output channels. Each channel contains a dual operational amplifier to set up a signal gain and offset. The voltage regulators LM7815, LM7915 and the potentiometers enable the shield to supply an output voltage from Uout = ±14V. The shield needs a power supply with positive and negative voltages. To avoid short circuits there are two rectifiers after the connectors. Furthermore there are connectors for the four output voltages. The offset and gain for each channel can be set up with one pair of potentiometers. Of each pair the left potentiometer changes the offset and the right potentiometer of each pair changes the gain. The DAC 195

Fig. 2. Block diagram of Arduino and DAC Shield I2C

I2C

I2C

I2C DAC

Open Bus

Write

Close Bus

Conversion

Fig. 3. I2 C Library is addressed by the I2 C-Bus. For using the DAC-Shield with Simulink it was created a user defined library (Fig. 3) from templates of the Arduino Target. The S-Functions are written in C programming language. There are three different S-Functions to open, close and write data on the I2 C Bus. A fourth S-Function prepares the data for the DAC-Shield, this means it sets the channel and the function of the digital to analog converter. In addition to the user defined library there is a tutorial which explains how to write further S-Functions for the Arduino Board. 2.3 Development tools for auto-code generation As a part of this research paper, an m-file shall be written to simplify the settings of the Arduino boards in MATLAB/Simulink. To allow for an optimal use of ArduinoTarget, it is beneficent to extend the m-file in order to facilitate platform independent operations. Consequently, the respective board can be used in its full diversity. Applications in control engineering can be developed and tested more quickly as the models Simulink code will be both automatically converted into ANSI-C and loaded onto the

9th IFAC Symposium Advances in Control Education Nizhny Novgorod, Russia, June 19-21, 2012

board. In order to use the Arduino Target Toolbox for auto code generation, MATLAB version R2010a or newer and the following toolboxes have to be installed: (1) Simulink (2) Simulink Coder (3) Embedded Coder MathWorks recommends additionally: (1) Stateflow (optional) (2) Stateflow Coder (optional) (3) Instrument Control Toolbox (optional) (The MathWorks, Inc., 2011) The Arduino Target Library for Simulink v1.0 (TheMathWorks, 2011) (Fig. 4) was provided for the 32-bit version of MATLAB for the Arduino board Duemilanove. As 64-bit computers will be the prevailing system in the future and MATLAB is available in a 64-bit version, the blocks were converted into 64-bit by the mex-compiler. Therefore, the software packages Microsoft Visual Studio 2010 Express and Microsoft Windows SDK for Windows 7 and .NET Framework 4 were installed. This library can now use

Pin 2 Digital Input

Pin 0

Pin 13 Digital Output

Pin 10

Analog Input

Analog Output

Serial Read

Serial Write

Serial Read

Serial Write

Table 1. Arduino-Board basic settings Arduino Board Duemilanove Uno Mega Mega2560

Bootloader

Controller

UploadRate

stk500v1 stk500v1 stk500v1 stk500v2

Atmega328p Atmega328p Atmega1280 Atmega2560

57600 115200 57600 115200

To enable an automatic loading of the basic settings from the ArduinoSimulink.m file, the files Prefs.m and runAvrDude.m of the Arduino Target from MathWorks were changed. The function uploadRate was removed from the Prefs.m and replaced by the following code. function setMcu(mcu) assert(~(mcu),’Arduino MCU preference must be non-empty’); arduino.Prefs.setPref(’ArduinoMcu’, mcu); end function uploadRate = getUploadRate uploadRate = arduino.Prefs.getPref(’UploadRate’); assert(~isempty(uploadRate),... ’Arduino UploadRate preference must be set’); end function setUploadRate(rate) assert(~isempty(rate),’Arduino UploadRate preference must be non-empty’); arduino.Prefs.setPref(’UploadRate’, rate); end function protokoll = getBootloader protokoll = arduino.Prefs.getPref(’Bootloader’); assert(~isempty(protokoll),’Arduino Bootloader-Protokoll preference must be set’); end function setBootloader(proto) assert(~isempty(proto),’Arduino BootloaderProtokoll preference must be non-empty’); arduino.Prefs.setPref(’Bootloader’, proto); end

3. MODELBASED CONTROLLER DESIGN OF AN AIR SUSPENSION SYSTEM 3.1 Plant description

Serial Config

Copyright 2009−2010 The MathWorks, Inc.

Fig. 4. Arduino Libary for Simulink

Simulink to address the respective inputs and outputs of the Arduino board. The created m-file ArduinoSimulink.m generates a menu navigation which necessitates the path selection of the Arduino environment, the Arduino board as well as the COM-Port. Hence, all basic settings for the respective Arduino board will be loaded automatically. Table 1 shows the basic settings of the Arduino board. The m-file is structured in switch-case statements, whereby different or newer Arduino boards can be added easily. 196

The air suspension hardware consists mainly of the Arduino Uno, a simple 12V DC-Motor, an ultrasonic proximity sensor, a 0.65 m high acrylic glass tube with a 0.12 m diameter and a polystyrene ball with a 0.1 m diameter. To program the microprocessor, a PC running MATLAB/Simulink is connected via USB to the Arduino. The goal is to let the polystyrene ball hover at a preset height inside the acrylic glass tube by the force of the air stream produced by the fan at the bottom of the tube. A simple DC-motor powering the fan is connected to a digital output (PWM) of the Arduino. In order to be able to run the DC-motor at a variable speed, a digital output provides a pulse width modulated signal. Because the output-voltage of the Arduino is too low to power the DC-motor, it has to be fed by an external voltage source. In order to connect the external voltage-source to the DC-motor, and still be able to modulate the width of the voltage pulses, a powerswitch-MOSFET is used.

9th IFAC Symposium Advances in Control Education Nizhny Novgorod, Russia, June 19-21, 2012

Table 2. Nomenclature symbol m

value 1 · 10−3

Ab

7.86 · 10−3

Aag

1.65 ·

10−3

kL

5.27 · 10−5

air drag constant

kV

1.14 · 10−4

fan constant

kR



10−3

unit kg

ball cross sectional area

m2

air gap cross sectional area

m2 kg m m3

stream reduction constant

kM

35

uM

-

motor voltage

DC-motor constant

Fg

-

weight force

Fd

-

g

9.81

drag force gravity

x

-

ball position

Vsp

-

air stream speed in the air gap

qsp

-

air gap volume flow

qf an

-

fan volume flow

qred

-

volume flow reduction

qrev

-

opposing volume flow

Fd =

2 kL Vsp

 = kL

qsp Asp

m2 s 1 Vs V kg m s2 kg m s2 m s2 m m s m3 s m3 s m3 s m3 s

2 .

(3)

Whereby the relative air stream in the gap qsp consists of three elements:

Fig. 5. Air suspension system technical scheme At the bottom of the acrylic glass tube are wings for easing the turbulences of the air-stream inside the tube. The proximity sensor at the top of the tube measures the position of the polystyrene ball and feeds back an analog signal to the Arduino analog input (AIN1). The proximity sensor needs a 24V input voltage in order to operate correctly and is powered directly by an external 24V source. To keep the ball at the desired height inside the tube, an appropriate control routine has to be implemented in MATLAB/Simulink and uploaded to the Arduino flash memory. 3.2 Nonlinear physical model As the basis for the controller design and validation a mathematical model of the system has been set up. This model describes the dynamic behavior of the system via differential equations. Using MATLAB/Simulink it is possible to examine the model in detail and design and validate a appropriate controller for the system. For mathematical description the motion equation (1) has been applied mx ¨ = Fd − Fg . (1) With the weight force Fg which equals Fg = m g,

designation ball mass

(2)

and the force of the air drag equals

qsp = qf an − qred − qrev .

(4)

Thereby is qf an the volume flow produced by the fan, qred the reduction of the volume flow depending on the polystyrene balls distance from the fan and qrv air flow that countervails the polystyrene ball depending on the polystyrene balls speed. qsp = kv kM uM − kr x1 − Ab x2

(5)

Combining (3) and (5) the equation describing the air drag force reads as follows  2 kV kM uM − kR x1 − Ab x2 Fd = kL . (6) Asp With (1) and (6) the modelling equation reads as follows:  2 kL kV kM uM − kR x1 − Ab x2 x ¨= −g (7) m Asp With the definition:     x x x= = 1 x˙ x2

(8)

y = x = x1 and (7) the nonlinear state space model reads as follows:

197

9th IFAC Symposium Advances in Control Education Nizhny Novgorod, Russia, June 19-21, 2012

    x˙ f (x, u) = 1 x ¨ f2 (x, u)   x2  2  =  kL kV kM uM − kR x1 − Ab x2 −g m Asp

GS (s) =

x˙ =

(9)

y = C x = [1 0] x. Model parameters have been measured if possible (e.g. the weight of the polystyrene ball). If it was not possible to measure a certain parameter, for instance the propeller coefficient kv , it was iteratively estimated. For this purpose the behavior of the model has been compared to the behavior of the real process until the model provided a sufficiently satisfying behavior in comparison to the real process. Simultaneously the model has been validated by this iterative process. In figure 6 the combined results of the parameter estimation and model validation is shown. It is visible that the model behavior is not at an optimum. However this result is sufficiently precise to be used in the following steps. ball position 0.45

real Model Model

0.4 0.35

position [m]

0.3

(11)

This can be done using (10) and the coherence GS (s) = C (s E − A)−1 B.

(12)

The transfer function is GS (s) =

5.702 . s2 + 6.846 s + 4.358

(13)

Hence the PI controller can be designed. The reason for choosing a PI controller is that only this way stationary precision can be achieved. The controller coefficients has been determined based on the frequency response method. GR (s) =

kP s + kI s

(14)

Therefore the systems pole with the highest value was compensated with the controllers root. In addition the systems disturbance reaction was rated using a Bodechart. The coefficients of the disturbance reaction transfer function are GR (s) =

0.25

∆x(s) . ∆u(s)

20 s + 14.21 . s

(15)

0.2 0.15

Feed-forward is calculated using (7) at the stationary operating point x ¨ = 0 and equals uc = 3.44V .

0.1 0.05 0 −0.05

0

2

4

6

8

10

12

14

16

18

20

t [s]

Fig. 6. model validation In the next step the model has been linearized at the certain operating point xc = [0.4 0]T . With ∆x = x − xc , u = uM and ∆u = u − uc the linearized state-space model reads as follows: x˙ = A ∆x + B ∆u     0 1 0 = ∆x + ∆u −4.358 −6.846 3.471 (10) y = C ∆x = [1 0] ∆x

Fig. 7. Controller structure

3.4 Software-in-the-Loop Validation

3.3 Feed-forward controller design The controller structure is shown in Fig. 7 including the linearized plant model and a Feed-Forward-PI-Controller. The Feed- Forward term of the controller is for positioning the polystyrene ball roughly around the operating point (xc = [0.4 0]T ). The PI term of the controller is responsible for stationary precision and for handling parasitic errors. The approach for designing the controller is described as follows. After linearizing the state space model it has to be transformed to a transfer function of the form: 198

Subsequently the controller has to be tested on the nonlinear and linear model. For this purpose the controller has been implemented in Simulink along with the system model. The structure for the linear model has been already shown in Fig. 7. For validation the system was excited with a disturbance signal. In Fig. 8 the disturbace signal and the systems response is shown. It is visible that the controller regulates the disturbance quickly. Furthermore at about t = (2..4)s it is visible that the controller regulates permanent disturbances exactly.

9th IFAC Symposium Advances in Control Education Nizhny Novgorod, Russia, June 19-21, 2012

ball position

theory and application in control engineering education can be closed. This shows the importance of easy to use RCP systems.

1.2

disturbing pulse [V] regulated ball position [m]

1 0.8

5. CONCLUSION AND FUTURE WORK

0.6 0.4 0.2 0 −0.2

0

1

2

3

4

5

6

7

8

t [s] Fig. 8. controller validation 3.5 Rapid control prototyping The developed control code was successfully validated by the software-in-the-loop procedure. Subsequently, the code was implemented on Arduino Uno using the Arduino Target via Auto-Code generation. Therefore, the input and output of the developed controller were linked with the hardware elements of the Arduino-Board using the blocks in Simulink shown in Fig. 4 from the ArduinoTarget. The structure of the complete Simulink program (Fig. 9) then consists of the four main elements: Pin13, Measurement, Controller, and Set Value. Subsystem Pin13 toggles the digital output 13; it changes its state in each cycle from 0 to 1 or vice versa. This subsystem is implemented to monitor the cycle time of the Arduino using an oscilloscope. The analog value of the ultrasonic sensor are imported to the subsystem Measurement, which measures the current position of the ball. This is done using the block Analog Input. In addition, the position of the ball is scaled to mm, xc was subtracted from the actual position and xd was set to zero. The controller code is implemented in the subsystem Controller, as described in Section 3.3. The subsystem Set Value contains a control value limitation and an analog or PWM output using analog output blocks, as well as another subsystem: the motor release. This subsystem realizes the locking or the release of the engine with a switch block via a digital input.

Fig. 9. Controller model in Simulink 4. EXPERIMENTAL RESULTS The designed controller is not sufficient to control the plant. Several technical issues which were not considered in the air suspension systems mathematical model are responsible for a suboptimal closed-loop behavior. Using a RCP-system like the one introduced in this paper unforeseen problems can be examined and the gap between 199

Combining the hardware of the Arduino Uno, the DAC shield and the powerful functions of MATLAB/Simulink including the Arduino Target Extension a low cost and easy to use RCP system has been developed. Due to various analog and digital I/O ports and MATLAB/Simulink as the RCP systems programming interface this RCP system is eligible for applications in control education. For testing purpose the RCP system has been applied to an air suspension system. The controller for the air suspension system has been designed using MATLAB/Simulink based on a model of the air suspension system and tested with the plant. As mentioned in chapter 4 the performace of the designed controller was poor. The controller was not designed under consideration of plant specific problems. One issue is the DC-motor which had been used. The DCmotor used is highly time-variant due to wear out.The characteristic curve changes due to thermal influence during operation. It is possible to use a DC-motor with a higher quality which has better long term use characteristics, furthermore it is possible to control the DC-motors speed first and then control the position of the polystyrene ball as a cascade. A further problem is that the Arduinos PWM resolution is not sufficient to be used for such a fine control application. This problem can be solved using an analog signal, like the DAC shield provides. Another important problem is the bandwidth of the ultrasonic proximity sensor and the proximity sensors low sampling rate. While designing the new controller it is important to take the proximity sensors slow sampling rate into accout. This may improve the controlled systems performance. REFERENCES Abel, D. (2006). Rapid Control Prototyping. Springer. Banzi, M. (2009). Getting started with Arduino. O’Reilly. C.-W. Chuang, H.-C. Sun (2006). A Study on FeedForward Control Applied to the Air Suspension Systems. 9th International Conference on Engineering and Education, Northumbria University, Newcastle upon Tyne, UK. G.C. Goodwin, S.F. Graebe, M.S. (2001). Control system design. Prentice Hall. G.F. Franklin, J.D. Powell, A.E.N. (1995). Feedback control of dynamic systems. Addison-Wesley. G.F. Franklin, J.D. Powell, M.W. (1998). Digital control of dynamic systems. Addison-Wesley. M. Odenwahl, J. Finn, A.W. (2009). Arduino - Physical Computing f¨ ur Bastler, Designer und Geeks. Springer Verlag. Scherf, H. (2007). Modellbildung und Simulation dynamischer Systeme. Oldenbourg. The MathWorks, Inc. (2011). Simulink support for arduino. http://www.mathworks.de/academia/arduino -software/arduino-simulink.html.