Get Introduction to Microcontroller Programming for Power Electronics Control Applications: Coding with MATLAB® and Simulink® 1st Edition Mattia Rossi free all chapters
Get Introduction to Microcontroller Programming for Power Electronics Control Applications: Coding with MATLAB® and Simulink® 1st Edition Mattia Rossi free all chapters
com
OR CLICK HERE
DOWLOAD NOW
https://ebookmeta.com/product/c-programming-for-the-pic-
microcontroller-demystify-coding-with-embedded-programming-hubert-
henry-ward/
ebookmeta.com
https://ebookmeta.com/product/chess-explained-the-c3-sicilian-1st-
edition-sam-collins/
ebookmeta.com
https://ebookmeta.com/product/figures-of-natality-reading-the-
political-in-the-age-of-goethe-1st-edition-joseph-d-oneil/
ebookmeta.com
Advances in Organic Farming Agronomic Soil Management
Practices 1st Edition Vijay Singh Meena (Editor)
https://ebookmeta.com/product/advances-in-organic-farming-agronomic-
soil-management-practices-1st-edition-vijay-singh-meena-editor/
ebookmeta.com
https://ebookmeta.com/product/forensic-science-the-basics-4th-edition-
mirakovits/
ebookmeta.com
https://ebookmeta.com/product/mozart-and-the-mediation-of-
childhood-1st-edition-adeline-mueller/
ebookmeta.com
https://ebookmeta.com/product/an-introduction-to-partial-differential-
equations-zhilin-li-larry-norris/
ebookmeta.com
https://ebookmeta.com/product/incredible-comic-book-women-the-kick-
ass-guide-to-drawing-hot-babes-1st-edition-tom-nguyen/
ebookmeta.com
Teaching Outside the Box Five Approaches to Opening the
Bible with Youth 1st Edition Andrew Zirschky
https://ebookmeta.com/product/teaching-outside-the-box-five-
approaches-to-opening-the-bible-with-youth-1st-edition-andrew-
zirschky/
ebookmeta.com
Introduction to
Microcontroller
Programming for
Power Electronics
Control Applications
Introduction to
Microcontroller
Programming for
Power Electronics
Control Applications
Coding with MATLAB® and
Simulink®
Mattia Rossi
Nicola Toscani
Marco Mauri
Francesco Castelli Dezza
MATLAB® is a trademark of The MathWorks, Inc. and is used with permission. The MathWorks
does not warrant the accuracy of the text or exercises in this book. This book’s use or discussion of
MATLAB® software or related products does not constitute endorsement or sponsorship by The
MathWorks of a particular pedagogical approach or particular use of the MATLAB® software.
Reasonable efforts have been made to publish reliable data and information, but the author and
publisher cannot assume responsibility for the validity of all materials or the consequences of their use.
The authors and publishers have attempted to trace the copyright holders of all material reproduced in
this publication and apologize to copyright holders if permission to publish in this form has not been
obtained. If any copyright material has not been acknowledged please write and let us know so we may
rectify in any future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced,
transmitted, or utilized in any form by any electronic, mechanical, or other means, now known or
hereafter invented, including photocopying, microfilming, and recording, or in any information
storage or retrieval system, without written permission from the publishers.
For permission to photocopy or use material electronically from this work, access www.copyright.com
or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923,
978-750-8400. For works that are not available on CCC please contact mpkbookspermissions@tandf.
co.uk
Trademark notice: Product or corporate names may be trademarks or registered trademarks, and are
used only for identification and explanation without intent to infringe.
Library of Congress Cataloging‑in‑Publication Data
DOI: 10.1201/9781003196938
Typeset in LM Roman
by KnowledgeWorks Global Ltd.
Foreword xiii
Preface xvii
Acknowledgments xix
Biographies xxi
I Embedded Development:
Hardware Kits and Coding 13
2 Automatic Code Generation through MATLAB® 15
2.1 Model-Based Design and Rapid Prototyping . . . . . . . . . 16
2.2 Workflow for Automatic Code Generation . . . . . . . . . . . 18
2.3 Generate Code for C2000™ Microcontrollers . . . . . . . . . 22
2.4 TI C2000™ Processors Block-set . . . . . . . . . . . . . . . . 24
vii
viii Contents
4 Software Installation 39
4.1 TI Support Packages:
Code Composer™ Studio and ControlSUITE™ . . . . . . . . 39
4.2 MATLAB® Support Package:
Embedded Coder for Texas Instruments C2000 Processors . 41
4.3 Installation Procedure . . . . . . . . . . . . . . . . . . . . . . 41
8 Basic Settings:
Serial Communication COM and Hardware Target 101
8.1 Virtual Serial Communication through COM port . . . . . . 101
Bibliography 423
Index 427
Foreword
xiii
xiv Foreword
Most people go about their day blissfully unaware of the electric motors that
are spinning the world around us. We wake up staring upwards at a ceiling
fan, silently rotating in a circle. We jump into our car and rely on up to
40 motors—pumps, fans, locks, and lifts—to get us to our destination. We
power up our laptop computers and hear the soft whine of fans working to
keep the electronics cool. Motors are everywhere because they are one of the
main ways that an electronic circuit can interact with the real world, i.e. a
power electronic-based system. They are “lectromechanical, turning analog
and digital signals into real and visible mechanical motion. It is estimated
that electric motors consume 45 percent of the total worldwide electricity—
this is a stunning statistic! As we look to reducing energy consumption and
enabling a greener future, electric motors present a huge potential for efficiency
improvements.
Few engineering students are aware of the impact of electric motors on
the world around them, and even less are versed in the design and control of
motor systems. This is a problem! We need engineers growing in competency
in this field to create better and more efficient motor drive systems.
Motor drive and control is an incredibly multidisciplinary field. Real-time
digital processing is implemented in microcontrollers to be the “brain” behind
the motor system; controlling speed, power, and efficiency from the digital
domain. A wealth of analog components from power management (voltage
regulators & gate drivers) and signal chain (amplifiers & sensors) interface
the microcontroller to the motor through a power converter while providing
sensing, safe operation, and support for the system. Texas Instruments has
over 25 years of experience in the field of real-time control and also provides
a comprehensive analog portfolio covering every block of the motor drive and
control system.
This book presents very practical and important lessons to engineers and
engineering students alike on the topics of motor drive and control, covering
not only general concepts but details on how to create a motor drive system.
It provides an excellent resource to encourage the next generation of engineers
to grow and develop skills in the area of electric motors and power electronics,
introducing them the tools they need to make an impact on the world.
Politecnico di Milano is an outstanding academic partner, and the focus
of the Electrical Machines, Drives and Power Electronics Research Group on
cutting-edge power electronic-based technologies helps shape quality engineer-
ing minds. We wish the best of success to this publication and to the continued
collaboration between industry and academia.
Can you write the 100 million lines of code that are needed to build an average
modern car? The answer is pretty obvious: of course you can, it’s just a matter
of time. And how would you compare the complexity of this problem to writing
the 4501 lines of assembly code needed to build the first version of UNIX in
1971? While both tasks appear to be at a similar level of dauntlessness, the half
century separating them has witnessed the emergence of high-level languages
that enable programmers to address highly complex problems on their own
while reusing the legacy of their peers.
At MathWorks Inc., we relentlessly work on providing the best high-level
programming tools to automate the implementation of your ideas into embed-
ded systems. Simulink allows you to design and simulate complex algorithms
that you can translate into thousands of lines of embedded code with a click
of a button via our code generation technology.
The book Introduction to Microcontroller Programming for Power Elec-
tronics Control Applications will teach you how to use these modern techniques
to create control algorithms for systems involving complex physics. The re-
markable work of Mattia Rossi, Nicola Toscani, Marco Mauri and Francesco
Castelli Dezza from Politecnico di Milano, Italy, clearly explains deep concepts
to the reader in the field of embedded programming for power electronics ap-
plications using Model-Based Design.
The copyrighted material included in this book is reprinted with permission of The
MathWorks, Inc.
xvi Foreword
While the shift to digital is now largely dominating the industry of mo-
tor control, this revolution is just starting for power conversion applications.
The material in this book provides state of art techniques to train the many
engineers that the world needs tomorrow in a field that is at the core of the
indispensable transition to clean energy.
In recent conversations with Mattia and Nicola, while they politely thanked
us for our help, it was clear to us that the quality and the amount of effort
in this book deserved much more thanking from our side. With this foreword,
we extend all our gratitude to this outstanding contribution to accelerating
the pace of engineering and science, our core mission.
Power electronics-based systems are the key enabling technology to meet most
of the future sustainable challenges from grid to motor applications.
Standard textbooks and courses about power electronics and electrical ma-
chines deal with analysis in continuous-time, averaged modeling of switched-
mode power converters, and continuous-time control theory. Nevertheless, real
control algorithms and management functions around power converters are
implemented digitally, thus, extending the field of fundamentals studies to
discrete-time modeling and digital control concepts specific to power electron-
ics. The necessary background is achieved by combining specific textbooks
and courses from both power electronics and digital control theory. However,
students who approach the design of digitally controlled power converters for
the first time may not fully understand and successfully practice for a targeted
problem due to such fragmented references.
In this book, we attempt to fill this gap by treating the fundamental as-
pects of digital control implementation for power electronics based systems
in a systematic and rigorous manner. Our objectives are to put the reader
in the position to understand, analyze, model, design, and implement digital
feedback loops around power converters, from system-level transfer function
formulations to understand which coding tool may be used when working
with microcontroller (MCU or µC) platforms. In particular, the latter be-
longs to Texas Instruments™ C2000™ family, which is specifically designed
for real-time closed loop control such as power supplies, industrial drives,
and solar inverters applications. The Simulink® environment is able to au-
tomatically generate ANSI/ISO C/C++ code tailored for specific embedded
targets through a model-based workflow. Given the settings which enable a
background usage of the Code Composer™ Studio IDE, a Simulink® scheme
can be directly compiled and executed on C2000™ MCUs. Such automated
build and execution procedure speed up the control algorithms implementa-
tion, thus, the code generation of software interfaces and MCU peripherals
(e.g. ADC, digital I/O, PWM), which can be tested with execution profiling.
This makes the reader working in a rapid prototyping manner.
This book is oriented to graduate students of electrical and automation
and control engineering pursuing a curriculum in power electronics and drives.
Moreover, it aims to be a reference for engineers and researchers who seek to
expand on the expertize in design-oriented knowledge for the aforementioned
applications. It is assumed that the reader is well acquainted with funda-
mentals of electrical machines and power converters, along with associated
xvii
xviii Preface
Most of the projects shown in this book have been funded by the Department
of Mechanical Engineering of Politecnico di Milano, Italy, with the particular
contribution of its Laboratory of Electrical Drives and Power Electronics.
Special thanks goes to the university rector Prof. Ferrucio Resta and the
department director Prof. Marco Bocciolone for their support to this initiative.
We are grateful to our graduate students Marco Gerosa, Matteo Scandella,
Andrea Polastri, Matteo Sposito, and Luca Grittini for the precious work
in supporting the hardware development, the boards testing and the many
suggestions they made. We also thank all the Ph.D. students and researchers
who contributed to this book. In particular, Dr. Khaled ElShawarby and Dr.
Alberto Bolzoni, who were supporting the project from day zero.
The authors would like to specially thank Prof. Petros Karamanakos from
Tampere University, Finland, and Prof. Ralph Kennel from Technical Univer-
sity Munich, Germany, for their guidance, long discussions and availability to
share their high expertize in this field.
We are grateful to Nora Konopka and CRC Press LLC from Taylor and Fran-
cis Group for publishing this book. Special thanks goes to Prachi Mishra for
her guidance and support.
xix
Biographies
xxi
xxii Biographies
DOI: 10.1201/9781003196938-1 1
2 Advances in Firmware Design for Power Electronics Control Platforms
CPU
A/D
CONVERTER RAM
PROGRAM
CLOCK
MEMORY
MCU
1 From the customer’s point of view the “best” microcontroller is the one which matches
Since this book focuses on electrical power conversion case studies, from
now on the text refers to MCU platforms targeted to power electronics-based
applications. Even if this last statement reduces the candidate list, there still
are several suitable solutions available on the market which share a common
goal of being compact and versatile. Since the definition of a criterion to cat-
egorize each board would not be practical (i.e., there might be even deep
technology differences), it is recommended to follow a system-level approach
like the one presented here:
1. Consider all the components and peripherals that are necessary to
run all of the required features. If the board lacks any of them, it is
important to identify some supported expansions to include them.
2. Consider the supported programming languages and the level of
competence of the final user. Moreover, investigate if any automatic
code generation procedure is available as well as the quality of the
documentation at disposal for the adopted board. Indeed, commu-
nity and support are factors of great importance since they are the
primary resources when designing a project.
3. Evaluate costs versus adopted components for the considered spe-
cific application: is it worth paying for them?
• CPU and clock speed: these two values affect the overall performance of
the board. Namely, how fast it can perform computations. It should be noted
that clock speed comparisons between CPUs coming from different families
may not lead to meaningful considerations. Other factors, such as instruction
cycles, instruction sets, and pipeline depth, also affect MCU performances.
• RAM: the size of this memory affects the number of tasks that can be run
simultaneously. It also impacts how fast data can be processed, as swapping
it from RAM to nonvolatile storage incurs large performance overheads.
• Graphical processing unit (GPU): it allows development board to run
video output (e.g., VGA/HDMI). High-performance GPUs are needed while
processing video/images with the development board.
• Data memory: it affects the size of programs, operating systems, and gen-
erated/downloaded data that can be stored on development boards.
• General purpose input/output pins: these pins are used to connect
external components to the development board in use. Hence, more pins
typically means more possible simultaneous connections. These pins are
usually assigned specific functionalities by the manufacturer being compli-
ant with some standards, such as integrated circuit (I2C), serial peripheral
Selecting a Development Board 5
• Translation
Programs written in Binary code does not need any translation as this lan-
guage is a machine code already. Namely, the hardware is capable of un-
derstanding them without any translation. Instead, Assembly codes need
an Assembler to translate programs to their equivalent counterpart in Ma-
chine Code. High-level languages are always translated by compilers or in-
terpreters. Some of them required both compilers and interpreters to get the
Object/Binary file.
• Support
Low-level languages have less support than high-level ones. There may be
lower number of communities for low-level languages than for high-level ones.
The girl had been questioned, and the thing was now clear.
Walker explained it all on the way to Bartoldi’s in a taxicab. I had my
diamond in my pocket, and Walker had Bartoldi’s to exchange for the
forged draft. The old man was Vronsky, the most notorious forger in
the world. He had bribed this girl, the janitress of the Empire Bank
at Bar Harbor, to steal a book of blank drafts and some sheets of
stationery. It was easy to do; the book of blanks was lying on the
bookkeeper’s desk in the package as it had come from the printer,
and the stationery had never been locked up.
With the blanks bearing the secret water mark of the bank,
Vronsky was able to forge drafts on New York and place them,
establishing his identity by a letter from the bank officials on this
stationery, in which they said they were sending him the draft which
he intended to pay out, and giving its amount and number.
“It was a clever scheme,” Walker added. “The secret water mark
on the draft blanks would show that they were genuine—that’s what
convinced Bartoldi; and the forged letter would show the identity of
the man who undertook to place it. The forgery gave Vronsky no
trouble; the problem was how to get the blanks and letter paper.”
“And he got them with a diamond,” I said.
Walker’s drawl lengthened.
“Precisely as we got him.”
And so this adventure opened with a diamond and closed with the
arrest of one of the worst criminals in the world. What was it I wrote
in the opening paragraph of this case? Go back and read it.
CHAPTER VIII
The Expert Detective