Model-Based Development (MBD) offers a way to design embedded systems by using visual models instead of traditional coding. Model-based development tools generate production-ready code, reducing manual errors and compliance issues. This guide will walk you through the basics of Model-Based Development, its advantages, challenges, risks and a tutorial for developing embedded systems from start to finish.

Table of Content

What are the Challenges in Classic Development Approach?

Senior Developer

What are the Benefits of Adopt Model-Based Development?

Benefits

  1. Faster Development: Model-based development toolkits allow you to simulate both the model and the generated C code, helping to identify issues early and reduce late-stage fixes.
  2. Improved Quality: Early defect detection leads to fewer errors and higher product quality.
  3. Better Collaboration: Common visual models enhance team communication.
  4. Automatic Code Generation: Model-based development tools generate production-ready code, reducing manual errors and compliance issues.

What’s the Catch?

The most commonly-used model-based development tool is MATLAB Simulink, and it costs a fortunate. And if you’d like to add additional toolboxes e.g., Signal Processing Toolbox, this may incur even additional costs.

This makes it unsuitable for startups and freelancers with limited budgets.

What Happens to the Legacy Code?

Legacy Code

When transitioning to model-based development, you don’t need to discard your existing code:

Are Developers Going to Lose their Jobs to Model-Based Development?

It’s an enhancement, not a replacement. Model-based design enhances, not replaces, engineering expertise in software design. Software engineers focus on modeling architecture, coding platform software, and system integration, rather than manually writing code for everything.

Step-by-Step Guide: Model-Based Development in MATLAB for Embedded Systems:

Step-by-Step Guide

1. Build the Model in Simulink

Use the Simulink Editor to build your models.

Simulink Editor

block libraries

Generator block

Scope block

block parametersblock parameters

2. Simulate the System

Simulate the System

run the simulation

3. Refine the Model

Based on simulation results, tweak the model and block parameters until desired performance is achieved.

4. Prepare for Code Generation

Select your target hardware and configure code generation settings for C/C++ code.

Go to the Apps tab in Simulink and select Embedded Coder.

Specify the part of your model you want to generate code for.

Specify the part of model

Choose between C or C++.

Choose between C or C++.

Select the processor you’re targeting:

Select the processor you're targeting

Indicate your priorities (e.g., performance):

Indicate your priorities

After answering the questions, click Generate Code

5. Generate and Deploy Code

The generated code can be deployed directly to your microcontroller:

Generate and Deploy Code

6. Test on Real Hardware

Test the generated code on hardware in real-world conditions. Make adjustments in the model until desired performance is achieved:

Test the generated code

Additional Considerations:

Real-World Examples of Model-Based Design

Iveco’s Shift Range Inhibitor System

Shift Range Inhibitor System

Iveco developed a shift range inhibitor system using Model-Based Design in Simulink. They created and tested a detailed model, automatically generating structured text code. This approach helped them with timely delivery and high-quality performance.

Ather Energy’s Intelligent Electric Scooter

Intelligent Electric Scooter

Ather Energy utilized Model-Based Design to build their Ather 450 electric scooter. By simulating various scenarios in a detailed plant model, they optimized design choices and validated control algorithms.

Ponsse’s Wood Harvester Control

Wood Harvester Control

Ponsse enhanced their Scorpion wood harvester’s control system with Model-Based Design. They generated real-time code from a control model, which streamlined debugging and integration, resulting in faster development and better quality.

Challenges and Risks in Model-Based Design

Conclusion

Model-Based Design (MBD) transforms development by using models throughout design, implementation, and testing.  Model-based design enables automatic code generation, simulations, and other capabilities, leading to fewer errors, and faster time to market. While model-based design offers major benefits, challenges like workflow integration and initial learning must be managed. Using model-based design effectively can lead to more efficient, higher-quality products.

Key references:

INCOSE: https://www.incose.org/

Subscribe Our Newsletter