Simulink on Raspberry Pi

Introduction

Want to combine the easy programming of MATLAB Simulink and the widely adopted hardware platform of Raspberry Pi? You can!

Many engineers love programming in MATLAB Simulink due to its support and ease of use. The Raspberry Pi, which had its first commercial release back in 2012 has become a very popular platform for prototyping. So how do we combine these two great tools?

MATLAB Already Supports the Raspberry Pi Platform!

How Do I Code The Raspberry Pi?

The toolbox allows you to write code that will run standalone (without your PC attached) on the Raspberry Pi.

Is It Free?

There is no additional cost as long as you have the MATLAB, Simulink, and Coder licences!

What are some benefits of using MATLAB on the Raspberry Pi?

MATLAB Toolboxes

MATLAB has an enormous range of toolboxes that can be quickly integrated into a project.

Simple Workflow

Easily port simulations done in MATLAB to run on the Raspberry Pi.

Camera Support

Connect a camera to the Raspberry Pi and take advantage of the vision toolboxes.

Supported Algorithms

Easily start integrating more complex algorithms like Machine Learning, Artificial Intelligence, and Model Predictive Control.

MATLAB Online

Program and collaborate over the web rather without any downloads or installations.

MATLAB/Simulink Usage

Installation on Raspberry Pi

MATLAB supports a wide range of Raspberry Pi boards. Because the FlexSeries products use a Raspberry Pi CM3+ (A small form factor Raspberry Pi 3B+) it is automatically included as part of that support.

Model 1B+/2B/3B/3B+/4B/ZeroW

For the many supported Raspberry Pi models MATLAB has a great guide for installation

MATLAB's Installation Guide
Model FlexCase/FlexBench

Our team has a guide walkthrough based on the MATLAB version.

Simulink on MPU guide

MATLAB Benefits

Significant benefit comes from being able to now interface the outside world with the Raspberry Pi. With MATLAB, you can now control:

  • Vision Systems – USB Webcams and other cameras for vision processing

  • Input Control – Reading sensors over I2C, SPI, etc.
  • Output Control – Controlling outputs like pulse width modulation and general purpose outputs
  • Linux Control – Interacting with Linux through the system shell

  • Online and Interactive – You can set up two-way communication and control your Raspberry Pi over the internet with MATLAB Online

High Reliability Considerations

From our previous post, high reliability can be thought of as:

Confidence that your system will run as desired the same way all the time. The device can self detect if something is wrong, quickly fix itself and resume. For automotive systems, this can mean update cycles every few milliseconds and the system automatically resetting within that cycle if anything goes wrong.

Because the MATLAB script runs on top of Linux, real-time behaviour cannot be guaranteed . However, i f you are running MATLAB/Simulink on the FlexCase, there a few additional benefits.

  • Improved Reliability – Combining the Raspberry Pi with an ASIL co-processor can be used to add safety checks.

  • Hardened Input/Outputs – The Raspberry Pi can take advantage of the FlexCase’s high voltage and current capacity.
  • Additional Protocols – Use the Raspberry Pi to control I/O, CAN, IoT, and EtherCAT .

Conclusions

The Raspberry Pi can be a great hardware platform to run standalone MATLAB/Simulink code on. This benefit is especially true when a few sensors or actuators are needed as part of the design.

Have any questions or comments? Contact us.

Full content in Audesse

Post source

Audesse

Audesse

Embedded Control & Industry Services