Sie sind auf Seite 1von 5
Available online at ScienceDirect Procedia Engineering 129 ( 2015 ) 922 – 926 International

Available online at


Procedia Engineering 129 ( 2015 ) 922 – 926

ScienceDirect Procedia Engineering 129 ( 2015 ) 922 – 926 International Conference on Industrial Engineering

International Conference on Industrial Engineering

Development of control algorithms in Matlab/Simulink

Martyanov A.S.*, Solomin E.V., Korobatov D.V.

South Ural State University, 76, Lenin Avenue, Chelyabinsk, 454080, Russian Federation


The progress in the development of computing machinery and software leads to new opportunities in design and research of different hardware. One of the popular instruments for scientists and engineers is MATLAB/Simulink software package which allows not only making complex mathematical calculations but also various hardware simulations. Simulink library contains a wide spectrum of computer devices and modules models. However, the existing data bank content in some cases does not correspond with the software user requirements. The present paper describes the opportunities of MATLAB/Simulink resources expansion by building extra computer models based on S-Function module usage.

© 2015 The Authors. Published by Elsevier Ltd.

© 2015 The Authors. Published by Elsevier Ltd. This is an open access article under the CC BY-NC-ND license

Peer-review under responsibility of the organizing committee of the International Conference on Industrial Engineering (ICIE-


Peer-review under responsibility of the organizing committee of the International Conference on Industrial Engineering (ICIE-2015)


Keywords: MATLAB, Simulink, S-Function, simulation, control system.

1. Introduction

Digital control systems prevalence more and more in the World. At the same time, engineers and scientists develop and improve such aids of design and analysis as software support for mathematic modeling and computational analysis, high-level languages, software development as well as hardware-controlled capabilities of computing machinery. The usage of simulation approaches on the R&D stage of control system development enables not only the significant shortage of research, development and experiment expenses but reduces the development time. Today there are many software packages intended for simulation (MATLAB, Scilab, VISSIM) [1]. However, there is a lack of computation models and approaches that would simplify the research of features of the machinery

* Corresponding author. E-mail address:

1877-7058 © 2015 The Authors. Published by Elsevier Ltd. This is an open access article under the CC BY-NC-ND license


Peer-review under responsibility of the organizing committee of the International Conference on Industrial Engineering (ICIE-2015)


A.S. Martyanov et al. / Procedia Engineering 129 (2015) 922 – 926

on the early stages of its development [2].

2. Problem definition


Research of the development process efficient improvement and development of complex object control systems with the help of mathematic modelling, numerical methods and software packages using the multipurpose controller as a sample [3,4]. The system model should support the programming with the high-level language to provide the transferability of control program on the target system. The widely distributed and well known by scientists and engineering organizations MATLAB/Simulink software package for mathematic computation from Mathworks Incorporation, is used as the instrument for research and development [5,6].

3. Theoretical base

MATLAB solver is a component of the Simulink software solver. The Simulink buildup for the solver was

developed by Mathworks Incorporation to simplify the modeling process of different systems. This product provides an extensive library of solvers, each of which determines the time of the next simulation step and applies numerical methods to make mathematic operations with different objects (numbers, vectors, matrices) as well as to solve the sets of ordinary differential equations that represent the model. In the process of solving this initial value problem, the solver also satisfies the accuracy requirements specified by operator. In addition, the Simulink library provides the big library of different device models with mathematic description documentation. However during the development of control system not only control object models are required, but also the model of controlling device which complexity varies from task to task which in turn generates a challenge of universal approach for the development of controlling device model. The building structures could be simplified significantly in this case and would not contain the long line of repetitive blocks [7, 8]. Operator may generate individual blocks and combine them in libraries for the further usage in Simulink. There are generally two approaches: graphical and programming. Graphical approach allows the building of the model from standard Simulink blocks for simulating the control system functions [9]. This approach is not universal [10- 12], as the transfer of the development results on the target control system requires time-consuming operations for adaptation of developing control device features to the results of computer model built. Programming approach is more universal due to the capability of building a computer model of the device, which is based on the features, and algorithms of control device operation [13, 14]. In turn the operation of this device should be supported by the software written on the high-level language suitable both for computer model control and target device. The task is to build a user block simulating the operation of control system in accordance with the built-in algorithm using the programming code of target system with microprocessor control Experimental procedure The S-Function block is provided by Simulink for capability of building the user block with different properties. This block should be supplied with the description of its operation and associated with the program written on the high-level language. The description of the operation of the block could be made on “C” language which will allow a simple transfer of this program on the target device. As a sample of building a computer model with the help of S-Function, we used a battery charger. The general view of the model is presented on Fig.1. The model contains the following main blocks:


phase source – three phase electric energy source for charging device;


phase load – block simulating the loading of electric grid and containing current and voltage sensors for each

phase, and controlled resistors for loading simulation; Controller – block with the functions of battery charger controller, containing S-Function block communicating with control program on the high-level language; Battery array – the array of battery elements simulating the behaviour of a real battery and generating a signals carrying information about the battery status for charging controller; Scope – software-based oscilloscope for registering different signals during numerical experimental testing; Solver Configuration – block of numerical experiment parameter adjustment required for correct models



A.S. Martyanov et al. / Procedia Engineering 129 (2015) 922 – 926

et al. / Procedia Engineering 129 (2015) 922 – 926 Fig. 1. General view of the

Fig. 1. General view of the model.

Thereby the base of controlling device is the «Controller» block receiving the measured system parameters from sensors and forming the control signals. The structure chart of this block is presented on Fig. 2.

The structure chart of this block is presented on Fig. 2. Fig. 2. Structure chart of

Fig. 2. Structure chart of control device.

The structure chart of control device shows that the controlling device is based on the S-Function block built with the help of software written on the high-level language. MATLAB/Simulink software environment has the built-in file editor for editing the source text of the initial software without using the off-site programs. The editor window is presented on Fig.3.

A.S. Martyanov et al. / Procedia Engineering 129 (2015) 922 – 926


et al. / Procedia Engineering 129 (2015) 922 – 926 925 Fig. 3. Program text editor

Fig. 3. Program text editor window.

The text of the program presents the C-code containing “C” language operators and functions as well as a callback-functions with macro commands communicating with Simulink data types and running the commands and functions of this package. The callback functions data are activated not by C-file itself but with Simulink environment. Macro commands of callback functions have a prefix “ss” and directed on the operation with the SimStruct structure containing all information used for modelling. These macro commands support the communicating of the program with the computer model during the numerical experimental testing. In addition to the callback functions C-file may contain the instructions activating the interface functions available in Matlab package. These operations are controlled by functions with “mex” prefix.

4. Results and conclusions

The usage of S-Function technology may help to build any required block which logic and operation algorithm is written on the high-level language. The part of code, describing the block operation, may be transferred on the target system, which simplifies the development of software of control system operating under microprocessor control. The proposed approach of S-Function block usage is being universal for building any block for computer model, without limitation of researcher or developer by the finite Simulink library block set. The given approach helps to increase the efficiency of the process of design and development the control systems of complex objects using the mathematic modelling, numerical methods and software packages. The practical result of the research is the computer model of the multi-functional battery-charging device intended for the virtual testing of control system parameters under different charging strategies and control algorithms. Research was supported in part by R.F. Ministry of Education under Grant 14.577.21.0154 dated of 28.11.2014 (unique identifier is RFMEFI57714X0154).


[1] V.P. D'yakonov, VisSim + Mathcad + MATHLAB. Vizual'noe matematicheskoe modelirovanie, SOLON-Press, Moscow, 2004. [2] A.S. Mart'yanov, E.V. Solomin, Razrabotka matematicheskoy modeli vetroenergeticheskoy ustanovki moshchnost'yu 3 kVt proizvodstva OOO «GRTs-Vertikal' v pakete Matlab, Al'ternativnaya energetika i ekologiya, NIIES. 5 (2011) 41–44. [3] A.S. Mart'yanov, E.V. Solomin, Kontroller zaryada vetroenergeticheskoy ustanovki, Mezhdunarodnyy nauchnyy zhurnal «Al'ternativnaya energetika i ekologiya». 1(81) (2010) 106–109.


A.S. Martyanov et al. / Procedia Engineering 129 (2015) 922 – 926

[4] A.S. Mart'yanov, Regulirovanie moshchnosti v vetroenergeticheskoy ustanovke, Nauchnyy poisk: materialy tret'ey nauchnoy konferentsii aspirantov i doktorantov. Tekhnicheskie nauki. 2 (2011) 206–209. [5] I.M. Kirpichnikova, A.S. Mart'yanov, E.V. Solomin, Modelirovanie generatora vetroenergeticheskoy ustanovki, Elektrotekhnika. 10 (2013)


[6] A.S. Mart'yanov, Modelirovanie potrebleniya elektroenergii, Nauka YuUrGU: materialy 65-oy Nauchnoy konferentsii. Sektsiya tekhnicheskikh nauk. (2013) 174–177. [7] V.I. Karlashchuk, Universal'noe zaryadnoe ustroystvo dlya li-ion akkumulyatorov, Vestnik rossiyskogo universiteta druzhby narodov. Seriya:

Inzhenernye issledovaniya. (2014) 22–26. [8] D.N. Ovsyannikov, V.N. Oskolkov, Razrabotka struktur skhem zaryadnykh ustroystv model'nogo ryada, Vestnik permskogo natsional'nogo issledovatel'skogo politekhnicheskogo universiteta. Seriya Elektrotekhnika, informatsionnye tekhnologii, sistemy upravleniya, Permskiy natsional'nyy issledovatel'skiy politekhnicheskiy universitet. (2012) 262–266. [9] J. Yan, G. Xu, H. Qian, Model Predictive Control-Based Fast Charging for Vehicular Batteries, Shenzhen Institutes of Advanced Technology. The Chinese Academy of Science. Shenzhen. Energies. 4 (2011) 1178–1196. DOI:10.3390/en4081178. [10] J. Deng, C.C. Mi, R. Ma, S. Li, Design of LLC Resonant Converters Based on Operation-Mode Analysis for Level Two PHEV Battery Chargers. IEEE/ASME Transactions on Mechatronics. (2014). DOI: 10.1109/TMECH.2014.2349791. [11] S.Q. Ali, D. Mascarella, G. Joos, Integrated battery charger for delta connected machines in plug-in hybrid electric vehicles, Conference Paper, Electrical and Computer Engineering Department, McGill University Montreal, Canada. IEEE Peterborough Section, IEEE Toronto Section Publisher: Institute of Electrical and Electronics Engineers Inc. DOI: 10.1109/CCECE.2014.6901072. [12] M.A. Tabari, A. Yazdani, Stability of a dc distribution system for power system integration of plug-in hybrid electric vehicles, IEEE Transactions on Smart Grid. 5(5) (2014) 2564–2573. DOI: 10.1109/TSG.2014.2331558. [13] Y. Huang, J.J. Ye, X. Du, L.Y. Niu, Simulation study of system operating efficiency of EV charging stations with different power supply topologies, Conference Paper, Applied Mechanics and Materials. 494-495 (2014) 1500–1508. DOI: 10.4028/