Ford Motor Company and Pi Technology Develop Ford Focus Fuel Cell Vehicle Systems with Model-Based Design and Automatically Generated Production Code

"Building design models with Simulink and generating code from them with Simulink Coder for the production target gave us exceptional quality while maintaining the flexibility to prototype quickly."


To create three new electronic control units for an advanced hydrogen fuel cell vehicle


Use MathWorks tools for Model-Based Design to design, simulate, and automatically generate production code for the electronic control units


  • Multipurpose code generated
  • Executable specification leveraged
  • Portability ensured
Ford Focus fuel cell vehicle.

Drive systems for hybrid vehicles require precise control to maximize fuel efficiency and meet high safety standards. The Ford Focus fuel cell vehicle relies on more than a dozen electronic control units to control everything from temperature to the electric drive train that is powered by its hydrogen fuel cell.

A world leader in the development of electronic automotive systems, Pi Technology used MathWorks tools for Model-Based Design to design, simulate, prototype, and automatically generate production code for three of these control units, including the key supervisory controller of the vehicle. By applying automatic code generation for these applications with no hand-coded adjustments, Pi engineers accelerated development, avoided coding errors, and eliminated inconsistencies between the design specification and working code.


Because the project involved emerging fuel cell and hybrid technologies, Pi engineers faced two key challenges. First, the team would need to build three completely new controllers: the energy management module, the thermal system controller, and the vehicle system controller. Second, the team had to gracefully handle changes in system requirements, which were likely to evolve during the project.

To address these challenges, the team sought a design and development environment that would facilitate rapid design iterations by enabling them to automatically generate production code for safety-related automotive controllers.


Pi engineers used MathWorks tools for Model-Based Design to create executable specifications, run simulations, automatically generate code, and create real-time prototypes for each of the three electronic control units.

Leveraging existing Ford designs, the Pi team worked with Ford engineers to develop a common hardware platform that would support all three planned ECUs as well as future projects. Using Simulink, engineers created a custom set of blocks that provide input, output, communications, and diagnostic services for a Freescale MPC555-based ECU. This shared platform enables the team to keep all application-specific functionality for each control unit in higher-level Simulink models.

Working from Ford requirements and with Ford engineers, the team then used Simulink to create models for each ECU, which defined data interfaces between subsystems.

Following a style guide to ensure efficiency, clarity, testability, and consistency, Pi engineers used Simulink to implement decision logic and control algorithms that would interface with the hardware platform through custom Simulink blocks.

The group used Stateflow to implement the state-based and sophisticated combinatorial logic required by the ECUs.

Using Simulink, the engineers then simulated the systems to validate functionality. This included testing modules that would be inaccessible at the hardware level in production. These simulations also enabled the team to easily test input combinations that would be difficult to achieve in the application running on target hardware.

The team used Simulink Coder and Simulink Real-Time to create rapid prototypes of the systems, which enabled development and real-time testing to progress before the target hardware was available. Later, code was automatically generated for the application, compiled without modification, and deployed onto the production MPC555 target hardware.

Pi performed extensive simulation-based and hardware-in-the-loop testing on each system. When test engineers identified problems during testing, development engineers resolved the issues in the model before automatically generating new code for follow-up tests. Throughout development, the team completed numerous iterations to incorporate design changes using this approach.

Ford customers are currently evaluating the fleet of fuel cell vehicles. Automatically generating code is enabling Ford engineers to make further changes to the software at a Simulink model level for formal development and experimental prototypes.

Pi Technology subsequently applied automatic code generation to add crank angle-based processing and I/O suitable for running gasoline engines, as the OpenECU rapid prototyping product. This has been applied in diverse applications, including engine management, CAN gateways, and catalyst modeling and control.


  • Multipurpose code generated. MathWorks code-generation tools were used to target the same models for the rapid prototype and production target. By keeping the application models independent of the target hardware, the design team focuses on application development and pursues future enhancements, such as additional functionality and improved diagnostics.

  • Executable specification leveraged. The application models provide the team with an executable design specification that is always synchronized with the underlying code. Automatic code generation saved time, reduced costs, and eliminated the error-prone process of ensuring the models reflected the code without excluding functionality or including obsolete code.

  • Portability ensured. In addition to running the ECU models on Simulink Real-Time and code on Freescale hardware, the team could easily port the solutions to any target hardware by simply recreating the Simulink block library.