User Stories

Wärtsilä Accelerates Engine Control Development Using Production Code Generation


Develop embedded controls for large diesel and gas engines that lower emissions and increase performance and reliability


Use MathWorks tools for Model-Based Design to design, test, and automatically generate embedded code for innovative controller software


  • Reusable models
  • 20% faster code
  • 200–300% increase in productivity

"Modern control features are notoriously problematic to develop and often involve extensive engine testing. Simulink and Embedded Coder let us design and optimize the features early in our process, saving a large amount of costly engine tests."

Johan Pensar, Wärtsilä
Wärtsilä engine.

Energy production and marine propulsion, the main market segments for large diesel and gas engines, are facing environmental and commercial challenges to design cleaner and more efficient engines. As the world's first manufacturer to use common rail electronic fuel injection on large, oil-fired diesel engines, Wärtsilä is at the forefront of embedded system innovation. Key to this innovation is their engine control software, developed by teams of control strategists, software engineers, and hardware designers to reduce emissions, increase performance, and ensure reliability.

As their engine software grew in size and complexity, however, Wärtsilä’s manual C-code approach prevented their engineering teams from developing clear specifications and communicating effectively. Using MathWorks tools for Model-Based Design, Wärtsilä adopted a more natural paradigm using modeling and simulation.

"Symbolic programming with executable specifications and automatic code generation is necessary for developing sophisticated embedded software for our engine controls," explains Ari Saikkonen, Wärtsilä automation expert. "Simulink and Embedded Coder are our core tools for applying Model-Based Design and have been successfully applied in our production programs."


Advanced control strategies are growing in their use for all engine systems, especially for emerging technology areas. Distributed power generation environments, which isolate the customer's plant from problems with the grid, now rely heavily on software to increase power quality and reliability. Engine systems based on natural gas are also growing in popularity and fully depend on electronics to control engine performance.

Wärtsilä needed a proven embedded software development process to design these new strategies, maintain high system reliability, and satisfy time-to-market needs. To employ this new process, they required symbolic design tools that provided executable diagrams and automatic code generation. These tools also needed to work within their formal development processes, which included rigorous verification and validation.

"C-based development had become extremely difficult and required far too many engine tests," says Saikkonen. "We needed an integrated dynamic simulation for testing the application against a detailed software model to such a high degree of accuracy that when the application is first run on a real engine there are very few issues."


After evaluating several options, Wärtsilä chose Simulink® to design and simulate their system models and Embedded Coder® to automatically generate production code from the models. This approach enabled them to transition easily from design to implementation and to verify and validate models in early development stages, meeting aggressive release schedules and reducing development costs by performing fewer live engine tests.

"MathWorks products supported the design through implementation phases and covered a significant part of the testing stage," explains Tom Kaas, Wärtsilä automation expert. "MathWorks tools provide a complete control systems development package―not just a point solution."

Wärtsilä engineers used MathWorks tools for Model-Based Design to structure and represent complex functions and algorithms using hierarchical block diagrams and state machines. They detailed and refined the diagrams to include software design information, such as data types, function partitioning, and sample time information.

Engineers used Simulink to model control law functions such as PID controls, fuel limiters, and feed-forward control. Stateflow helped them design logic-driven state machines such as mode transitions. Using Simulink and Stateflow, Wärtsilä created a complete component library as the implementation base for a wide range of applications, such as a speed/load controller. Using model components, engineers quickly assemble and manage large applications.

With this base of blocks and models, Wärtsilä easily and methodically evolves subsequent development projects and no longer creates new applications from scratch. Using a spiral development approach, engineers first identify business requirements and continue maintaining the application long after the initial production release. By basing this process on MathWorks tools for Model-Based Design, iterations are easier to execute because the design is clearer and matches the implementation.

"The results with Simulink and Embedded Coder are impressive," says Kaas. "We have seen significant improvements in all aspects of our software development metrics: quality, efficiency, and engineering time."

Wärtsilä’s speed/load controller is now in commercial use. They are now in active development of several new production software applications based on MathWorks tools.


  • Reusable models. "We satisfied all our goals during the first project and have established a solid baseline of reusable models for future projects," says Kaas.

  • 20% faster code. "The automatically generated code was better than hand code for RAM, ROM, and execution speed," notes Saikkonen. "We estimate a reduction in code size up to 30% and a reduction in CPU execution time of nearly 20%."

  • 200–300% increase in productivity. "The higher abstraction, improved structure, and automatic production code provided by Simulink and Embedded Coder has made us an estimated 2–3 times more productive," Saikkonen says.