Weichai Power Develops ECU Software for High-Pressure Common-Rail Diesel Engine In-House

“Compared with our past experience with hand-coding, Model-Based Design enabled us to reduce labor costs by 30%, cut testing costs by 20%, and increase productivity by more than 30%. We completed ECU development ahead of schedule while establishing our in-house software development team.”


Build a production engine control and embedded software team, establish in-house development capability, and complete the first production program in 36 months


Use Model-Based Design to design, implement, and test control strategies and ECU software for a common-rail diesel engine while working with MathWorks consultants to develop the team’s software development skills and expertise


  • Development time cut by 40%
  • Integration testing time halved
  • 60% of design reused
A high-pressure common-rail diesel engine from Weichai Power.

Weichai Power is a global leader in heavy-duty engines. For many years, Weichai purchased engine control units (ECUs) and fuel systems for its diesel engines from suppliers. The company made a strategic plan to develop its own control strategy and ECU software for high-pressure common-rail diesel engines. The reasons for in-house development were to increase Weichai Power’s competitiveness and its ability to innovate by lowering costs, reusing core functionality, and enabling rapid development of engine control strategies based on customer requirements.

Weichai Power built a control strategy and embedded software team, and adopted Model-Based Design to develop the common-rail diesel ECU software.

“Model-Based Design—with its graphical design and automatic code generation—reduces software bugs, improves software maintainability and reuse, and reduces the difficulty of software development,” says Daming Li, director of the Electronic Controls Division at Weichai Power. “Model-Based Design enabled us to build a development team consisting of engine and control specialists within the shortest possible time and to dramatically reduce development costs.”


While Weichai Power regularly conducts engine control research and prototyping, the company had not previously developed embedded controls and software for a large-scale, production ECU.

Weichai Power sought a methodology and development tools that are widely used in the automotive industry. At the same time, they wanted to reduce the learning curve associated with introducing new tools. They needed to recruit engineers and train them to develop and test ECU software for production before China’s National Emission Standard IV took effect.


Weichai Power adopted Model-Based Design with MATLAB® and Simulink® to design and implement the common-rail diesel engine ECU software. They built a production control and software team, and trained new engineers in the tools. The company also worked with MathWorks Consulting to establish on-target rapid prototyping capability that would enable Weichai group companies and customers to collaborate.

Working from system requirements, Weichai Power engineers developed an engine controller model in Simulink and Stateflow®. They used Stateflow to model state transition logic for engine operating mode control, rail pressure control, and diagnostics routines.

During model development, they used the Model Advisor in Simulink to check compliance with modeling standards adapted from MathWorks Automotive Advisory Board (MAAB) guidelines.

Using Requirements Toolbox™ the team linked textual requirements to the model elements in Simulink that implemented the requirements to ensure traceability.

In Simulink, the team created a plant model of the vehicle, after-treatment systems, and engine, including fuel, torque, intake, and exhaust subsystems. To verify the control design, they ran closed-loop simulations of the control and plant models.

They created test vectors with Simulink Design Verifier™. Used with Simulink Coverage™ and Simulink Check™ these test vectors enabled the team to identify dead logic in their model and achieve complete model coverage.

Using Fixed-Point Designer™, the engineers converted the floating-point model to fixed point by recording minimum and maximum data values during simulation and applying Fixed-Point Designer recommendations for scaling fixed-point data types.

After comparing the floating-point and fixed-point model simulation results to verify the conversion, the team generated C code from the control model using Embedded Coder®.

Working in Simulink they performed software-in-the-loop tests on a PC and hardware-in-the-loop tests on an ETAS® PT-LABCAR simulator.

The team generated more than 340,000 effective lines of code for the production ECU with Embedded Coder. The generated code comprised 100% of the application software; 85% of the CAN application layer and diagnostic routines were also generated from models.

Working in MATLAB, the team developed vehicle drive cycle software, which they used for data analysis during testing of the initial production ECUs.

The common-rail diesel engine ECU is in production on heavy-duty trucks, construction machinery, and power generation equipment. Weichai Power plans to reuse the ECU design for light diesel engines.


  • Development time cut by 40%. “We completed development and verification of the ECU from scratch in 36 months—40% faster than we had planned,” says Li. “With Model-Based Design and support from MathWorks consultants, our engineer’s training time was reduced dramatically. In addition, using Embedded Coder to generate MISRA®-compliant code from our Simulink models considerably shortened the time required to implement quality software.”

  • Integration testing time halved. “Continuous testing via Simulink simulations throughout the development phase enabled us to detect 60–70% of bugs before integration testing,” Li says. “As a result, our integration testing time was reduced by about 50%.”

  • 60% of design reused. “We are currently developing an ECU for a compressed natural gas engine, and we have reused about 60% of the model from our initial project,” says Li. “This reuse has led to a 50% reduction in development time for the new ECU.”