© ABB
Advanced control and optimization on PLC using code generation
Amit Purohit, Vinay Kariwala, Saurabh Deshpande, C&O INCRC/MATLAB Expo, August 21, 2013
08 August 2013 | Slide 1
© ABB
Process Automation Layers Big Process Plant – Refinery, Power Plant etc.
08 August 2013 | Slide 2
Figure adapted from xstrata process control
• Regulatory control is done using PLC/PAC
• Advanced control and optimization is carried out on computers
© ABB
Harsh environment (Temperature, Humidity, Dust etc.)
No computers available for advanced control and optimization
Process Automation Small/Medium Process Plants
08 August 2013 | Slide 3
Regulatory Control
(PLC/PAC)
Water Treatment Plant Wind Farm Solar Power Plant
© ABB Group
August 8, 2013 | Slide 4
PLC Controlled Process Plants Potential Automation Benefits
Figure adapted from xstrata process control
• Significant potential benefits if advanced control and optimization
algorithms can be run on PLC, as done in this paper
Current
Practice
This
Paper
© ABB Group
August 8, 2013 | Slide 5
Programmable Logic Controller ABB AC500 Specification
© ABB Group
August 8, 2013 | Slide 6
Advanced Algorithms on PLC
1. Computation done on centralized PC
PLCs act as transmitters/receivers
2. All computation done locally on individual PLC
Infrequent data transfer to centralized PC for recording
3. Computation done off-line; solution implemented on PLCs as charts
Compromise between other modes
Different Workflows for Implementation
PLC 1
Measurements
PLC 2 PLC 3
Decisions
Coefficient-1 Coefficient-2
Region-1 9 3.1
Region-2 10 2.2
Region-3 12 3.52
Region-4 11 4.12
Region-5 14 3.15
Explicit Model predictive Control
© ABB Group
August 8, 2013 | Slide 7
Advanced Algorithms on PLC
Hardware Limitations
Memory and processing power constrained environment
Programming Limitations (focus of this paper)
Typically programmed using Structured Text (ST)
No standard advanced math libraries in ST
Longer turnaround time for implementation and testing
Challenges – Computation on PLC
© ABB Group
August 8, 2013 | Slide 8
Advanced Algorithms on PLC
Matlab code
C code PLC executable
Code development and testing in MATLAB®
Conversion to C code using MATLAB® Coder
AC500 specific compilation using ABB C code tool chain
Download library as IEC61131 Function Block on PLC
Solution
Case Study Model Based Predictive Control on
PLC
© ABB Group
August 8, 2013 | Slide 10
Feedback Control
Process output y(t) is compared with Setpoint
Controller, e.g. Predictive Functional Controller (PFC),
manipulates process input u(t) to bring y(t) back to Setpoint
Same steps continue at every time step
Overview
© ABB Group
August 8, 2013 | Slide 11
Model-based Predictive Control
Model is used to predict future process behavior
Inputs are calculated to keep outputs close to setpoints
Constraints and interactions are accounted (unlike PID control)
Similar to driving car (see – predict – react)
Central Idea
© ABB Group
August 8, 2013 | Slide 12
Predictive Functional Control (PFC)
Typical model-based predictive
controllers require solving
mathematical program online
Not suitable for PLC
PFC adopts two step approach
to enable implementation on
PLC:
1. Unconstrained problem is
solved with polynomial
approximation for u
2. Heuristic constraints
satisfaction on u and Δu
using saturation blocks
Simplified Model-based Predictive Control
min 𝑦 − 𝑟 2 + µ Δ𝑢 2
𝑦 = 𝑓(𝑢, 𝑑)
𝑦𝐿 ≤ 𝑦 ≤ 𝑦𝑈
𝑢𝐿 ≤ 𝑢 ≤ 𝑢𝑈
Δ𝑢𝐿 ≤ Δ𝑢 ≤ Δ𝑢𝑈
Richalet J. and O’Donovan D. (2009). Predictive Functional Control: Principles and
Industrial Applications, Springer.
© ABB Group
August 8, 2013 | Slide 13
Predictive Functional Control
Function Development steps –
MATLAB Code C code generation AC500 specific compilation
PFCSISO Function Block
Easily downloadable on PLC hardware
Compatible with Codesys IDE and IEC61131 programming language
PLC Control Block
© ABB Group
August 8, 2013 | Slide 14
Test Set up
PFC and Process Model function separate function blocks on PLC produced from C code tool chain
Set point change sent to the PFC FB
PFC Control output sent to Process Model FB
Process model output sent to the PFC FB
Loop continues until process value reaches Set point
Close Loop Simulation
© ABB Group
August 8, 2013 | Slide 15
Test Results
• Change in set point from 30 to 44
• Control move start increasing
• Process value follows control move and start increasing
• Process value settles at Set point
• Change in set point from 44 to 30
• Control move start decreasing
• Process value follows control move and start decreasing
• Process value settles at set point
Close Loop Simulation on AC500
Scenario 1 Scenario 2
© ABB Group
August 8, 2013 | Slide 16
Conclusions
MATLAB Coder is an efficient tool for conversion of m-file
to C-code
Significant savings in R&D efforts
Possibility of using Simulink for testing purposes
without re-coding
Easier code maintenance
MATLAB Coder – potential areas of improvement
Global variable initialization
Generated Constant initialization
Handling of advanced toolboxes, e.g. Optimization
toolbox