A Microcontroller Based Test Platform for Controller Design Savaş Şahin1, Yalçın İşler2 and Cüneyt Güzeliş3 Ege University, Ege Vocational School, Department of Control and Automation, Bornova, İzmir, 35100, Turkey 2 Zonguldak Karaelmas University, Department of Electrical and Electronics Engineering, İncivez, Zonguldak, 67100, Turkey 3 Dokuz Eylül University, Department of Electrical and Electronics Engineering, Kaynaklar, Buca, 35160, İzmir, Turkey 1
[email protected] ;
[email protected] ;
[email protected] 1
Abstract-This paper presents a microcontroller based emulator which is developed for the design-test-and-redesign of controllers through examining the controller candidates on the emulated plants operating under the created real-time and real environmental conditions. The analog and digital peripheral units of the plant emulator provide the recreation of the real environmental conditions such that the whole emulator runs as if the real plant whenever the model implemented in the microcontroller is a right model for the plant. The emulator has the flexibility of changing the plant model and/or its parameters manually and it also enables to apply, in an automatic way, analog disturbances and analog parameter perturbations to the plant model. The developed plant emulator communicated with the simulator of the controller part both managed by a graphical user interface implemented in the computer constitutes a controller design-test-redesign platform which has the advantages of using simulated plants in the controller design providing a test-flexibility and also of testing the controller candidates on the emulated plants operating under the conditions very close to the real situations, so assuring the desired controller performances.
I.
INTRODUCTION
The design of a controller working well for the given real plant needs the consideration of the real behavior of the plant under the real operating conditions [1]-[3]. Such a controller design problem can be attempted to be solved as examining the controller on the simulated plant under the simulated operating conditions [4] or as working on the real plant under the real environment [5],[6]. Examining the controller candidates directly on the real plant may not be possible in the laboratory environment or might be dangerous due to possible damages caused [7]. On the other hand, mimicking the real plant in real-time and in real environmental conditions especially together with its analog/digital interface units is not only complicated in software simulations but also it yields unreliable simulators sensitive on the unavoidable modeling errors occurred at each simulated unit [8], [9]. Simulation of control systems is preferred, in general, i) for understanding the behavior of the plant together with its actuator and sensory devices models obtained, i.e. for the analysis, and ii) for testing the designed controllers if the design specification are met, i.e. for the synthesis. The analysis of the plant may yield remodeling of a considered real plant and its peripheral units; and even redesign thus rebuilt of the whole or some part of the plant [4]. On the other
978-1-4244-6391-6/10/$26.00 ©2010 IEEE
hand, in the controller synthesis case, testing the controllers is followed by a redesign and/or tuning procedure. The concern in this paper is not on the modeling and simulation of the plants but the design-test-redesign of the controllers based on the emulated plants together with their (real-world) hardware peripheral unit which may include an actuator, a set of sensory devices and/or environmental conditioners, i.e. external disturbance and parameter perturbation signal drivers and also analog/digital controller hardware. Depending on the implementation of the controller, plant and peripheral unit as simulation, emulation or real hardware, the developed platform CDTRP can be operated in 24 different real time operation modes (See Tables I-III.) which are called as real time simulation modes. Some of them correspond to the well-known “hardware-in-the-loop” [10][14], the other simulation modes correspond to the “control prototyping” and “software-in-the-loop” [10]. With all the above mentioned capabilities, the developed Controller-Design-Test-Redesign-Platform (CDTRP) covers a broad range of simulation environments with additional features, which are not available in the literature up to the authors’ knowledge, such as having a real-time running plant emulator managed by an advanced GUI and, as might be more interesting for the sake of recreation of a real environment, a (real world) hardware peripheral unit communicated to the emulated plant via analog and digital interfaces for augmenting the emulated plant by embedding the (real) analog and/or digital actuators, sensory devices, the external disturbance and parameter perturbation signal derivers and also analog/digital controller hardware. CDTRP can be used i) for comparison of the performances of the different controller design methods, so serving as a test-bed for researchers in examining their immature controller design method in its development phase, ii) for verification and validation of a plant-model [15] based on the emulated plants with the emphasis running in the real-time and in the real environment, iii) for controller design requiring a controller parameters training procedure based on the measurements and also calculations on an emulated (identified) plant model as in done artificial neural networks based controller design methods [16]-[18], and iv) for low-cost real-time implementation of control systems based on the benchmark plants of educational value but hard or impossible to be realized in an educational laboratory [19]. Similar real-time
36
simulation platforms have been realized in the literature [1][3], [11], [20] and [21], however; i) they are restricted either to a specific control application, e.g. robot, specific electrical motors, pantograph or dynamometer or to a certain type simulation such as software-in-the-loop or hardware-in-theloop, ii) none of them possesses a (real world) hardware peripheral unit which comprises all of the (real) analog and digital actuators, sensory devices, the external disturbance, parameter perturbation signal derivers and analog/digital controller hardware components, so (they are) able to recreate a real environment in a more restricted sense, iii) they are not dedicated to be a general purpose design-test-redesign controller platform, iv) and moreover they do not have such a GUI unit capable of monitoring and controlling of the overall simulation platform as in the CDTRP. The paper is organized as follows. In Section II, the developed platform CDTRP is briefly described presenting its sub-units and GUI managing the overall platform. In Section III, the operating modes of the platform CDTRP are demonstrated on the several plants for verification platform. The experimental results on the analog hardware realization for deriving a real DC motor plant are included in Section III, for validating platform. The conclusions and possible future directions for further development are given in Section IV. II.
DESCRIPTION OF THE DEVELOPED PLATFORM CDTRP
A. Structure and Functions of the CDTRP The developed platform CDTRP comprises four main units which are a real-time simulator running in a PC, a real-time plant emulator realized in a plant emulator card, a hardware peripheral unit for recreation a real environment for the plant emulator, and a GUI in the PC which manages the whole platform. The structures of CDTRP are depicted in Fig. 1.
User
Grap hical User Interface (GUI) Unit in PC
Contro ller/ Plant Simulator in PC
Digital Interfaces
Hardware Peripheral Unit C ard Plan t Emulator
Analog & Digital Interfaces
Plant Emulator Card
•Controller •Actuators •Sensors •Disturbance & Perturbation Signal Drivers
Fig. 1 Structure of Controller-Design-Test-Redesign-Platform (CDTRP)
The first unit is the software simulator implemented in the PC. It aims to simulate the controller and the plant depending on the real-time simulation modes of the platform. The second unit is the plant emulator card whose core is the PIC microcontroller which possesses digital and analog interfaces. The third unit is the hardware peripheral unit card. It contains (analog and/or digital) hardware controller, actuators, sensory devices and signal drivers corresponding to the external disturbance and parameter perturbations to recreate the real environmental conditions for the plant emulator. The fourth unit, the GUI, is implemented by MATLAB’s GUI designer tool (with more than 2000 lines of MATLAB codes). A view of the front panel of the GUI is given in Figure 2.
Fig. 2 Front panel of the GUI for the platform
The main features and management (i.e. monitoring and controlling.) facilities of the GUI are listed as follows: i) it is a user-friendly GUI, i.e. easy to be used via a set of interface entries such as start, stop, exporting to excel, randomizing and all zeroing of the initial conditions ii) a set of benchmark plants are available in the menu of CDTRP for the users. The users can also define their own plant models via browser as a M-file iii) the controller algorithm can be loaded on the front panel via browser as a M-file iv) the time steps for the controller and the plant can be determined in an arbitrary way and also independently from each other v) the external analog signals, which are intended to be generated in the hardware peripheral unit and then fed to the emulator, are selected by using the menu of ADC inputs, i.e. U, X1, X2, X3, D_U, D_X1, D_X2 and D_X3 which take place in the front panel. vi) Noise box in the front panel is used for magnifying or reducing the amplitude of the noise constituting a part of the external analog signals generated D_U which is aimed to be used as additive to the control signal vii) Parameter variation signals, which constitute a second part of the external analog signals generated in the hardware peripheral unit, can be applied via D_X1, D_X2 and D_X3 ports of the plant emulator card in a multiplicative way to each state of the plant emulator viii) The front panel of the GUI has five monitors for the desired (plant) outputs, the error signals, the control signals, the plant state variables, and the actual plant outputs ix) Two (digital to analog) converters’ outputs of the plant emulator card can be configured via the output options in the front panel x)The data related to the control systems variables can be exported to the excel file as a data logger. B. Taxonomy of Real Time Simulation Modes Realized by CDTRP The developed simulation platform CDRTP can implement 24 different real time operating modes given in Table I-III. The S-E-E, E-E-E and R-E-E modes of CDTRP constitute a contribution to the real time simulation literature since there is no such an interface possibility of the simulators running on the PCs and the available emulators in the literature. S-SS, S-E-S, E-S-S, E-E-S, S-S-E, S-E-E, E-S-E and E-E-E operating modes where the controller, plant and peripheral unit are all implemented in the simulator (PC) or emulator would be considered as “software-in-the-loop simulation” in the literature [10]. In a similar way, the modes S-R-S, E-R-S, R-R-S, S-R-E, E-R-E, S-R-R and E-R-R where the plant under test is real would be considered as “prototyping mode”
37
[10] and the modes R-S-S, R-E-S, R-S-E, R-E-E and R-R-E where the controller is implemented as real hardware while the plant as simulated would be considered as “hardware-inthe-loop” simulation [10]-[14]. TABLE- I TAXONOMY OF REAL-TIME SIMULATION MODES OF CDRTP: PERIPHERAL UNIT IMPLEMENTED IN THE SIMULATOR (PC) Plant Controller Simulator (in PC) Emulator Real (Hardware)
Simulator (in PC)
Emulator
Real (Hardware)
S-S-S E-S-S R-S-S
S-E-S E-E-S R-E-S
S-R-S E-R-S R-R-S
MS Windows XP and MATLAB 7.04 software. The signal generator as a part of the hardware peripheral unit card is included as providing an external analog signal noise (D_U). Power supplies constituting another part of the hardware peripheral unit card are used as dc variacs changed manually for generating the perturbations of the plant variables (D_X1, D_X2 and D_X3).
TABLE- II TAXONOMY OF REAL-TIME SIMULATION MODES OF CDRTP: PERIPHERAL UNIT IMPLEMENTED IN THE EMULATOR Plant Controller Simulator (in PC) Emulator Real (Hardware)
Simulator (in PC)
Emulator
Real (Hardware)
S-S-E E-S-E R-S-E
S-E-E E-E-E R-E-E
S-R-E E-R-E R-R-E
TABLE- III TAXONOMY OF REAL-TIME SIMULATION MODES OF CDRTP: PERIPHERAL UNIT IMPLEMENTED AS REAL HARDWARE Plant
Simulator (in PC)
Emulator
Real (Hardware)
Controller Simulator (in PC) _ S-E-R S-R-R Emulator _ E-E-R E-R-R Real (Hardware) _ R-E-R R-R-R - The first column modes are not realized in CDTRP without using an additional analog interface extension for the PC.
Fig. 4 Experimental set-up for the whole CDTRP platform
III.
VERIFICATION AND VALIDATION OF THE CDTRP PLATFORM BASED ON BENCHMARK PLANTS
A. Verification of the Operating Modes of the Platform: A set of benchmark plants which can be chosen by the users via the plant selection button in the front panel of the GUI are included in the menu of the CDTRP Platform for helping the users to examine their control methods on these selected benchmark plants in a quick way. These plants have been used for operating modes in Table IV. It can be stated that S-S-S and S-E-R modes can be used in order to designtest-redesign of controllers.
C. Implementation of the Plant Emulator Card Microcontrollers which are single-chip computers with limited computer’ features [22] are widely used for control applications with digital and analog input interfaces. The plant emulator card of CDTRP has been realized with a PIC18F452 microcontroller. The schematic diagram of the plant emulator card is given in Fig.3. The plant emulator has eight channel analog inputs via 10-bit ADCs, four channel digital input/outputs, and two analog output ports via DAC.
TABLE IV BENCHMARK PLANTS OF CONTROL-DESIGN-TEST-REDESIGN-PLATFORM Operating Benchmark State Model and Associated References Modes Plant (BP) BP1 [17] S-S-S, S-E-S x1 (k +1) = sin(x1 (k)) + u(k)(5 + cos(x1(k)u(k))) S-E-E, S-E-R y(k) = x (k) 1
BP2
x1 ( k + 1) = 0.1x1 (k ) + 2
S-S-S, S-E-S [17],[23] S-E-E, S-E-R
u (k ) + x2 (k ) 1 + (u (k ) + x2 (k ))2
x2 ( k + 1) = 0.1x2 (k ) + u ( k )(2 +
u 2 (k ) 1 + x12 ( k ) + x22 (k )
)
y (k ) = x1 (k ) + x2 ( k )
BP3
BP4
MgL k sin q 1 − ( q 1 − q 2 ) I I k 1 q2 = ( q 1 − q 2 ) + u J J q1 = −
k R 1 x1 − m x 2 + u L L L k b x 2 = m x 1 − m x 2 J J x 1 = −
BP5
x1 = − 2 x1 + 8448 u
BP6
x 1 = x 2
Fig. 3 Schematic diagram of the plant emulator card
[16], [24]-[25] S-S-S, S-E-S S-E-E, S-E-R
y = x1
D. Experimental Set-up of the Developed CDTRP The experimental set-up of the developed CDTRP platform is given in Figure 4. The CDTRP platform set-up is composed of a plant emulator card, a PC, a signal generator, power supplies and an oscilloscope. The PC is chosen to constitute a minimum configuration necessary for running
x 2 =
BP7
M +m 1 x1 − u Ml Ml
B r x1 − u I I
S-S-S, S-E-S S-E-E, S-E-R S-R-S, S-R-R [27] S-S-S, S-E-S S-E-E, S-E-R S-S-S, S-E-S [28]S-E-E, S-E-R
x1 = x 2 x 2 = −
38
y = x1
S-S-S, S-E-S
y = x2 [26] S-E-E, S-E-R
y = x1
B. Validation of the Platform on a Real DC Motor: Validation of the developed platform on the real DC motor has been achieved in the following four stages: i) Implementation of a real plant: In order to validate the platform on a real plant, a real DC motor has been chosen as the test plant for the plant emulator and the developed CDTRP platform has been examined in S-S-S, S-E-R and SR-R operating modes for the DC motor with encoder. The speed of the motor is considered as the output. The DC motor driver card (See Figure 5) has been realized PIC driver unit.
∫
Fig.5 Real DC motor hardware based on PIC for S-R-R mode
The microcontroller based driver unit drives the DC motor speed revolutions per minute (rpm) via pulse width modulation (PWM) in S-R-R operating mode. ii) Identification stage: The input-output data pairs of the real DC motor have been measured via the hyper-terminal of the PC. Then, the transfer function of the plant is found under the assumption of single-input single-output (SISO) linear dynamical system. It is known [25], [29] that the real DC motor plant has been modeled as a first-order delayed dynamical system. The first-order system defined in the Laplace and time-domain as follows:
K H ( s) = e − Ls Ts + 1 h(t ) = K (1 − e −(t −L) / T ) ≅ K (1 − e −t / T )
(1)
L