You are on page 1of 2

USER STORY

Motorola Creates Electric Vehicle Battery Management


®
Controller with Real-Time Workshop Embedded Coder

Electric cars can travel moderate distances


on a single battery charge and maintain
average cruise speeds of 60 mph, making them
appealing options for inner-city commuters.
These battery-powered vehicles require a
sophisticated electronic control unit (ECU)
to regulate the flow of power from the batteries
to the motor.

The Motorola Automotive Group recently


developed and optimized software for a
The Motorola electronic control unit.
battery management controller using
model-based design and automatic code
turnaround times, so we decided to use
generation products from The MathWorks.
that approach here,” says Zeidan. “We select-
“We would almost certainly not have been ed the complete set of MathWorks products
able to meet our deadlines if we’d used paper to avoid piecing tools together and working
designs and hand coding instead of Simulink® from a disjointed process.”
THE CHALLENGE and Real-Time Workshop® Embedded Coder,”
The team used Simulink and Stateflow®
To develop battery manage- says Salam Zeidan, software manager
to model the control algorithms in floating
ment controller software at Motorola Automotive.
point and then converted the resulting
within a tight deadline
models into fixed point using the
THE CHALLENGE Fixed-Point Blockset.
Developing the controller was difficult
THE SOLUTION
because the interfaces among various system They encapsulated Stateflow and Simulink
Use integrated model-based
components were still fluid and would change. submodels within parent Simulink models
design and code generation
and created separate models based on
tools from The MathWorks The engineers had to manage the memory
functionality and execution rate. Using
to design, test, and manage resources for the HC12 microcontroller
Real-Time Workshop Embedded Coder, they
requirements for the without exceeding 8KB of RAM. They also
then generated C code for the HC12 embedded
controller had to ensure that all the code would fit into
target microcontroller directly from these
128KB of flash memory. The entire project
models. “The code generation process and
had to be completed within a tight time frame.
THE RESULTS the integration of the controller code with
■ Automatic generation the rest of the module code was very smooth
of efficient C code
THE SOLUTION because we had control over the way the code
Motorola Automotive had just completed a
■ Optimized memory was generated and over the early planning
production-intent ECU for a global body
resources of the interfaces,” says Zeidan.
seat controller on a model year 2002 vehicle
■ Ability to detect design
using MathWorks model-based design and They then performed software integration
flaws before generating code
code generation products. “We knew that tasks, such as interfacing the hardware I/O
model-based design is well suited for manag- layer’s handwritten code with the application
ing changes in requirements and fast layer’s automatically generated code.

508.647.7000 info@mathworks.com www.mathworks.com



We would almost

certainly not have been able to meet our

deadlines if we’d used paper designs

and hand coding instead of Simulink and


Real-Time Workshop Embedded Coder.
For the calibration phase, they applied an
improved data-fit function that automatically
selected the best tradeoff between the maxi-
Salam Zeidan, Motorola
mum tolerable error and the number of table
data points and marked the selected optimal
point on a graph. They then generated an
optimal data table from the graph.
THE RESULTS
“Using the Model-Based Calibration Toolbox ■ Automatic generation of efficient
and the Curve Fitting Toolbox allowed us to C code. “The automatic scaling capability
fit the models optimally and greatly reduced of Real-Time Workshop Embedded Coder
the memory needed for calibration parameters. saved us much effort by helping us to
This was critical for our memory-constrained systematically define the data types and
automotive ECU application,” says Zeidan. binary points of signals throughout the
fixed-point models. The fixed-point code
To validate the design against the customer’s
generation also uses an advanced expression-
requirements, the engineers associated the
folding approach and has capabilities
model components to the written requirements
that were not previously available to us,”
with the Requirements Management Interface.
says Zeidan.
“Internal reviews were then easy, and we could
■ Optimized memory resources. By
demonstrate to our customer that all the
explicitly defining global variables rather
requirements had been met,” Zeidan explains.
than using the default structure-based
APPLICATION AREAS
The source control interface in MATLAB® code, Motorola optimized memory
■ Automatic code generation
enabled them to use Rational ClearCase to resources. Real-Time Workshop
■ Automotive engineering
perform common project management activi- Embedded Coder generated compact
■ Algorithm development
ties directly from within the MATLAB and fixed-point code that fit within the existing
■ Modeling and simulation
Simulink environment. 128KB of flash and 8KB of RAM.
■ Ability to detect design flaws before
Motorola Automotive may implement system
PRODUCTS USED generating code. “Simulating the models
tests using other MathWorks products,
■ MATLAB early allowed us to perform most feature
including xPC Target and xPC TargetBox™,
■ Simulink tests in the simulation environment before
for future automation of system validation
■ Stateflow the embedded code was generated,” says
and software bench tests. xPC Target enables
■ Fixed-Point Blockset Zeidan. “If defects were discovered during
a Simulink and Stateflow model to be simu-
■ Real-Time Workshop system testing, we could quickly recreate
lated in real time on an external PC, enabling
Embedded Coder the conditions from the test bench using
hardware-in-the-loop testing of the actual
■ Model-Based log files as inputs to the Simulink models.”
ECU system against the model of the physical
Calibration Toolbox
system being controlled.
■ Curve Fitting Toolbox To learn more about the Motorola Automotive
■ Requirements Group, visit www.motorola.com
Management Interface

© 2003 by The MathWorks, Inc. MATLAB, Simulink, Stateflow, Handle Graphics, and Real-Time Workshop are registered trademarks, and TargetBox is a trademark of The MathWorks, Inc. 91101v 00 9/03
Other product or brand names are trademarks or registered trademarks of their respective holders.

You might also like