# MOBY-DIC TOOLBOX

Model-based synthesis of digital electronic circuits for embedded control

## Contents

MOBY-DIC toolbox has been developed within MOBY-DIC European project www.mobydic-project.eu.

## Control systems

The aim of the toolbox is to provide an automated design flow, which allows to implement embedded digital controllers starting from the definition of the system to control and of the constraints to be fulfilled. The resulting circuit, described in VHDL language, can implement an exact or approximate Model Predictive Control (MPC) law. The toolbox also provides tools for the closed-loop system simulation and for the stability analysis. The flow of the toolbox is described in the picture below.

The first step is the creation of two objects, linearSystem and constraints, defining the linear system to control and the constraints you want to fulfill, respectively. The generateMPC function computes, by interfacing with external toolboxes such as Hybrid Toolbox or Multi Parametric Toolbox, an MPC control law, which results in a Piecewise Affine (PWA) function of the system states and parameters. Such function is represented, in MOBY-DIC toolbox, as a pwag object. The stability properties of the closed-loop system, controlled with the pwag function, can be studied by resorting to function stabilityTest. Eventually the VHDL files describing an architecture (pwag_ser, pwag_par) or implementing such control law can be automatically generated with method synthesize. A Simulink model for the simulation of the closed-loop system by taking into account the effects of sata quantization and circuit delays can be generated with method generateSimulinkModel.

If the circuit implementing the exact MPC controller (pwag function) is too complex or slow, it is possible to approximate such controller with a simpler one, more suitable for a digital circuit implementation. The pwag function can be approximated with another PWA function defined over a simplicial partition (pwas function) or over a hyper-rectangular partition (pwar function). The two approximations techniques are realized by resorting to functions pwasApproximation and pwarApproximation. The maximum approximation error can be computed with function suboptimalityAnalysis. The obtained pwas and pwar objects can be used exactly as the pwag one, i.e. a stability analysis can be performed, digital architectures can be generated (pwas_ser, pwas_par, pwar_par, pwar_par) and a Simulink model is available for closed-loop simulations.

## Virtual sensors

Moby-dic toolbox also allows to implement Piecewise Affine Simplicial (PWAS) virtual sensors, for the estimation of a unmeasurable output of a dynamical system. The flow of the toolbox is shown in the picture below.

The first step is the creation of a virtualsensor object. The virtual sensor is then identified with method identify starting by measures of the dynamical system inputs (u), measurable outputs (y) and outputs measurable only for a finite amount of time (z). All these measures are possibly corrupted by noise. Then, a validation of the virtual sensor can be performed with method validate, starting from a different set of measures (test set). Once the virtual sensor has been identified and validated it can be implemented on a circuit with method synthesize by obtaining vs_ser or vs_par architecture. A pwas object can be estracted from the virtualsensor object with method getFunction.

## Requirements

- Matlab R2008a or newer
- Hybrid Toolbox
- Multi Parametric Toolbox
- Yalmip
- Simulink and Xilinx System Generator (only for closed-loop HDL simulations)

## Installation

Read file INSTALL.TXT

Launch script *installMOBYDIC* and follow instructions.

## Classes

linearSystem - Linear discrete-time system

constraints - Linear inequality constraints on state and input variables

pwaFunction - Piece-Wise Affine function object

pwag - Piece-Wise Affine Generic function object

pwas - Piece-Wise Affine Simplicial function object

pwar - Piece-Wise Affine Hyper-Rectangular function object

pwaSystem - Piecewise affine discrete-time dynamical system object.

virtualsensor - Piece-Wise Affine Simplicial virtual sensor object

## Functions

generateMPC - Generates an MPC control law.

pwasApproximation - Performs a PWAS constrained approximation of an MPC controller.

pwarApproximation - Performs a PWAR constrained approximation of an MPC controller.

suboptimalityAnalysis - Find the maximum approximation error between a pwag and a pwas function

stabilityTest - Provides a sufficent condition to verify stability and invariance of the closed-loop system resulting from the application of a piecewise-affine control law of any kind (pwag, pwas, pwar).

## Circuits

pwag_ser - Circuit for the implementation of pwag controllers - serial architecture

pwag_par - Circuit for the implementation of pwag controllers - parallel architecture

pwas_ser - Circuit for the implementation of pwas controllers - serial architecture

pwas_par - Circuit for the implementation of pwas controllers - parallel architecture

pwar_ser - Circuit for the implementation of pwar controllers - serial architecture

pwar_par - Circuit for the implementation of pwar controllers - parallel architecture

vs_ser - Circuit for the implementation of pwas virtual sensors - serial architecture

vs_par - Circuit for the implementation of pwas virtual sensors - parallel architecture

## References

The algorithms, techniques and circuits employed in the toolbox are described in the following publications:

- V. Spinu, A. Oliveri, M. Lazar, M. Storace, M., "FPGA Implementation of Optimal and Approximate Model Predictive Control for a Buck-Boost DC-DC converter", in Proceedings of the IEEE Multi-Conference on Systems and Control, Dubrovnik, Croatia, October 3-5, 2012, in the press
- A. Oliveri, D. Barcelli, A. Bemporad, B.A.G. Genuit, W.P.M.H. Heemels, T. Poggi, M. Rubagotti, M. Storace "MOBY-DIC: A MATLAB Toolbox for Circuit-Oriented Design of Explicit MPC", in Proceedings of the IFAC Conference on Nonlinear Model Predictive Control, Noordwijkerhout, The Netherlands, August 23-27, 2012, in the press
- F. Comaschi, B.A.G. Genuit, A. Oliveri, W.P.M.H. Heemels, M. Storace, "FPGA implementations of piecewise affine functions based on multi-resolution hyperrectangular partitions", IEEE Transactions on Circuits and Systems I, accepted, 2012
- M. Rubagotti, S. Trimboli, A. Bemporad, "Stability and invariance analysis of uncertain discrete-time piecewise-affine systems", IEEE Transactions on Automatic Control, conditionally accepted, 2012
- B.A.G. Genuit, L. Lu, W.P.M.H. Heemels, "Approximation of explicit Model Predictive Control using regular piecewise affine functions: an input-to-state stability approach", IET Control Theory and Application, vol. 6, n. 8, pp. 1015-1028, 2012
- T. Poggi, M. Rubagotti, A. Bemporad, M. Storace, "High-speed piecewise affine virtual sensors", IEEE Transactions on Industrial Electronics, vol. 59, n. 2, pp. 1228-1237, 2012
- A. Bemporad, A. Oliveri, T. Poggi, M. Storace, "Ultra-Fast Stabilizing Model Predictive Control via Canonical Piecewise Affine Approximations", IEEE Transactions on Automatic Control, vol. 56 (12), pp. 2883-2897, 2011
- M. Storace, T. Poggi, "Digital architectures realizing piecewise-linear multivariate functions: Two FPGA implementations", International Journal of Circuit Theory and Applications, vol. 39 (1), 2011, pp. 1-15
- T. Poggi, F. Comaschi, M. Storace, "Digital circuit realization of piecewise affine functions with non-uniform resolution: theory and FPGA implementation," IEEE Transactions on Circuits and Systems-II: Transaction Briefs, vol. 57, 2010
- L. Lu, W.P.M.H. Heemels, A. Bemporad, "Synthesis of low-complexity stabilizing piecewise affine controllers: A control-Lyapunov function approach", 50th IEEE Conference on Decision and Control/European Control Conference 2011, Orlando, USA
- M. Rubagotti, S. Trimboli, D. Bernardini, A. Bemporad, "Stability and invariance analysis of approximate explicit MPC based on PWA Lyapunov functions", in Proceedings of the 18th World Congress of the International Federation of Automatic Control (IFAC), Milano, Italy, August 28th - September 2nd, 2011, pp. 5712-5717
- B.A.G. Genuit, L. Lu, W.P.M.H. Heemels, "Approximation of PWA Control Laws Using Regular Partitions: An ISS Approach", in Proceedings of the 18th World Congress of the International Federation of Automatic Control (IFAC), Milano, Italy, August 28th - September 2nd, 2011, pp. 4540-4545
- A. Oliveri, G.J.L. Naus, M. Storace, W.P.M.H. Heemels, "Low-complexity approximations of PWA functions: A case study on adaptive cruise control", in Proceedings of the 2011 European Conference on Circuit Theory and Design (ECCTD'2011), Linköping, Sweden, August 29-31, 2011, pp. 694-697
- T. Poggi, M. Storace, "Digital architectures implementing piecewise-affine functions: an overview," in Proceedings of the 2010 IEEE International Symposium on Circuits and Systems (ISCAS'2010), Paris, France, May 30th – June 2nd, 2010, pp. 3304-3307
- A. Bemporad, A. Oliveri, T. Poggi, M. Storace, "Synthesis of stabilizing model predictive controllers via canonical piecewise affine approximations," in Proceedings of the 2010 IEEE Conference on Decision and Control (CDC'2010), Atlanta, USA, December 15-17, 2010, pp. 5296-5301
- A. Bemporad, W.P.M.H. Heemels, M. Lazar, “On the synthesis of piecewise affine control laws,” in Proceedings of the 2010 IEEE International Symposium on Circuits and Systems (ISCAS'2010), Paris, France, May 30th – June 2nd, 2010, pp. 3308-3311
- A. Oliveri, A. Oliveri, T. Poggi, M. Storace, "Circuit implementation of piecewise-affine functions based on a binary search tree", in Proceedings of the 2009 European Conference on Circuit Theory and Design (ECCTD'2011), Antalya, Turkey, August 23-27, 2009, pp. 694-697

## Acknowledgments

**Developers**

- Alberto Oliveri (alberto.oliveri@unige.it) - University of Genoa, Italy
- Tomaso Poggi (tpoggi@essbilbao.org) - University of Genoa, Italy
- B.A.G. Genuit (b.a.g.genuit@tue.nl) - Eindhoven University of Technology, The Netherlands
- Davide Barcelli (davide.barcelli@imtlucca.it) - IMT Institute for Advanced Studies Lucca, Italy
- Carlo Alberto Pascucci (ca.pascucci@imtlucca.it) - IMT Institute for Advanced Studies Lucca, Italy
- Francesco Comaschi (francesco_comaschi@hotmail.it) - University of Genoa, Italy
- Matteo Rubagotti (matteo.rubagotti@imtlucca.it) - IMT Institute for Advanced Studies Lucca, Italy
- Macarena C. Martinez Rodriguez (macarena@imse-cnm.csic.es) - University of Seville, Spain
- Piedad Brox (brox@imse-cnm.csic.es) - University of Seville, Spain