Implementation of Automatic PLC Code From MATLAB Simulation Model Using B&R Automation Target For Simulink
Implementation of Automatic PLC Code From MATLAB Simulation Model Using B&R Automation Target For Simulink
net/publication/295073176
CITATIONS READS
6 2,853
3 authors, including:
2 PUBLICATIONS 6 CITATIONS
Pravara Rural Engineering College Loni
28 PUBLICATIONS 160 CITATIONS
SEE PROFILE
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by Pratap Vikhe on 23 November 2017.
Abstract
In this research work, auto generation of PLC code is explained. This work is carried out in real time. Mathematical Model created in
MATLAB/Simulink gets automatically translated in C code using Real-Time workshop and later PLC Control implementation is done by
using B&R Automation Target for Simulink software that can generate PLC code and HMI screens. The algorithm developed to connect
simulation model and PLC-Automation Studio is elaborated. To show applicability of methodology, color mixing process model is
described. Seamless integration into an Automation Studio project work makes the development process perfect guaranteeing maximum
performance of the generated source code.
1. Introduction
390
be created, tested and used by applying mathematical programming efforts are reduced to a minimum and in
models. many cases actually not required.
MATLAB Simulink includes B&R Toolbox in simulation
environment provides interface blocks, which handles
1.3. B&R Automation Target for Simulink communication between the automatically generated
program unit and the rest of the components of the
The realization of MATLAB/Simulink models starts with Automation Studio project.
the automatic code generation. With this product “B&R In this paper the Section II explains Methodology,
Automation Target for Simulink” B&R Industrial Section III deals with detailed algorithm for integrating
Automation provides a tool with highest level of integration simulink model and B&R target PLC Section IV gives
with model based design software Math works. This tool verification & validation of results. Section V is conclusion
allows testing and implementing MATLAB/Simulink and finally future work with an acknowledgement.
models on the PLC hardware. Thus, the manual
2. Methodology
The algorithm written in this paper for generating
The module created in Simulink is automatically automatic PLC code is elaborated in steps to follow.
translated using Real-Time Workshop and Real-Time
Workshop Embedded Coder (optional) into the optimal
language for the B&R target system 3.1. Step I-Developing Process Model in MATLAB
The block diagram described in this paper employs, Simulink
designing of mathematical model using formulas. Later,
implementation of mathematical model of Color Mixing The Color Mixing Process studied here was also studied
process using MATLAB Simulink is build with the help extensively by [1], [2] and [3].The Mathematical model of
of simulink library blocks. The next step is to be carried mixing process is developed in MATLAB Simulink
out in an Automation Studio environment. In this we have environment. COLOR mixing plant consists of a mixing
to build model with the help of B&R blocks which are tank in which colors are mixed from the two auxiliaries In
available in B&R toolbox in a simulink library. After order to find an adequate control for the mixing process;
doing configuration settings we are able to translate the corresponding mathematical model is developed. The
simulink models into a PLC code on a click of button. mathematical model for one tank is considered, knowing
Above in the Fig1, the sequence of code generation is that the all three tanks have the same one. The model
given for Color Mixing Process. The execution of developed for color mixing process is as shown in Fig2.
extended parameter is based on the algorithm defined in These equations were modeled using MATLAB/
the subsequent sections. Simulink as illustrated in Fig2. The control system for the
fluid mixer is designed in order to maintain the coloration
of the output at the desired set-point and the level in the
3. Algorithm for Integrating Simulink Model with mixer in the neighboring of its set-point, not allowing it to
B&R Automation Studio be empty or to overflow. The output flow is considered
as a disturbance.
The Color Mixing Process is on-line implemented
using PLC and has been written in a specific language 3.2. Step II- Using B&R Automation Studio Toolbox;
Automation Studio of B&R PLC [4]. For understanding Creating Simulink Model which Translates Automatically
the control process written in AS C language the into C-Code
corresponding sequence control for a tank is described.
The model shown in Fig.3 is Color Mixing Process Model
391
of the system for the configuration of the interface
between Simulink and Automation Studio.
392
3.4. Step IV: Adding B&R Automation Studio Libraries Simulink. Within fraction of second’s message will
appear in the MATLAB command window indicating that
In order to be able to run the automatically generated the code generation has been done successfully. Then the
source code on the B&R target two B&R Automation automatically generated source code is compiled in
Studio libraries are required in the project: Add Automation Studio and transferred to the target system.
‘brsystem’& ‘sys_lib’ from exiting libraries. The simulink model from Matlab has been successfully
transferred into C language source code in Automation
3.5. Step V: Integration of Project: Automatic Code Studio as shown in fig 4. With the ‘automatic transfer’
Generation & Project Download option being enabled the generated program is included
into the Automation Studio project, the entire project is
After completing all above settings start the Automatic compiled and then transferred to the target system
Code Generation by using the menu item Tools Real- automatically.
Time Workshop. Build Model using (Ctrl+B) or using the
corresponding button on the toolbar in MATLAB
393
4. Verification & Validation of the Results
5. Conclusion
Fig. 6 Output Traced in B&R Automation Studio
This paper demonstrated a method for automatically
generating PLC code and controlling the process through
simulation model. The methodology combines the high
level simulation and lower level PLC controlled devices
thus improves the fidelity between high level system
model and lower level. It reducing PLC code generation
time, as a result, can reduce the designing and
implementation time for PLC controlled manufacturing
industries. The strength of the scheme is that this
mechanism develops the HMI which the operators find
very easy to operate. Model-Based Design, together with
automatic code generation creates shorter and more cost
efficient design workflows. Also adds many advantages to
mixing process: high quality control, adequate set points
can be on-line numerically fixed.
Acknowledgement
394
[6]M.Fabian, K. kesson, and D. Spensieri. Automatic Model Generation [7]Kurt W Leucht,Glenn S Semmel,Automated Translation of Safety
and PLC-Code Implementation For Interlocking Policies In Critical Application Software Specification into PLC Ladder Logic,
Industrial Robot Cells. Proc. of Control Engineering Practice,11, pp. Aerospace Conference,2008 IEEE.
1416-1426(1), 2007. [8]Petter Falkman, Erik Helander, MikaelAndersson, Automatic
Generation: A way of Ensuring PLC and HMI Standards, Aerospace
Conference, IEEE ETFA'2011.
395