Raspberry Pi 3 & MathWorks Learn-to-Program Pack - Review

Table of contents

RoadTest: Raspberry Pi 3 & MathWorks Learn-to-Program Pack

Author: MARK2011

Creation date:

Evaluation Type: Workshop Tools

Did you receive all parts the manufacturer stated would be included in the package?: True

What other parts do you consider comparable to this product?: null

What were the biggest problems encountered?: Problem of incompatibility of the OS when installing MATHWORKS-RPi add-ons environment "Support Package for Raspberry Pi Hardware". Lack of program block for RPi 1-wire interface in "Support Package for Raspberry Pi Hardware". Minor issue with RPi window resolution when working remotely using VNC. And...the extremely huge range of MATHWORKS application possibilities - hard to choose most important issues to test... apologies it was a joke!

Detailed Review:

image

 

 

 

 

Introduction

 

When I received the e-mail approving me as the Raspberry Pi 3 & MathWorks tester, I felt the happiness and also sense of responsibility.

The subject is extremely deep and wide.

Both Raspberry board (and all relating stuff) as well as MATLAB/ SIMULINK environment are widely well known for years (despite the RPI is significantly younger, whatever!)

I admit, I know the raspberry from, let say, its early ages, I use it for around two years, nevertheless It's really hard to add something new as most of fields of RPi application, have been implemented, above concerns also the use of RPi together with MATHWORKS. On the other hand, there is still something new added and developed in the RPI realm.

MATLAB and obviously Simulink is another issue for me. I've been used different math supporting environments from my studying time (who remember "Derive" system for DOS?) . In one's time I enthustiately worked with MATHCAD but nowadays I prefer R (Cran system).

I know there are no comparison with SIMULINK in the matter of complex modeling, simulation and analysis. The scope of implementation is shocking and extremely huge.

With limited writer's abilities I will focus on simple explanation of my steps in this roadtest, I hope pictures and several videos would make my report more colorful and accessible.

 

 

Basic technical specifications

Honestly, I think that this part can be omitted as there are lot of information about both RPi and MATHWORKS.

Moreover Raspberry is, in my opinion, one of  the "flagship" devices of Element 14, detaily depicted and still commented in the forum.

Ok, lets put here most common information from raspberrypi.org  https://www.raspberrypi.org/products/raspberry-pi-3-model-b/

 

image

The Raspberry Pi 3 is the third-generation Raspberry Pi. It replaced the Raspberry Pi 2 Model B in February 2016.

  • Quad Core 1.2GHz Broadcom BCM2837 64bit CPU
  • 1GB RAM
  • BCM43438 wireless LAN and Bluetooth Low Energy (BLE) on board
  • 40-pin extended GPIO
  • 4 USB 2 ports
  • 4 Pole stereo output and composite video port
  • Full size HDMI
  • CSI camera port for connecting a Raspberry Pi camera
  • DSI display port for connecting a Raspberry Pi touchscreen display
  • Micro SD port for loading your operating system and storing data
  • Upgraded switched Micro USB power source up to 2.5A

 

All details related to the could be found hereimage

 

https://www.mathworks.com/products/matlab.html

The system consist of two main elements MATLAB and SIMULINK creating amazing tool for all project concerning mathematical modeling, analyses, simulations. From simple calculations, using very simple intuitive script language to complex problem solving with enhanced but still easy to operate graphic environment (GUI). According to the definition, MATLAB is a high-level language and interactive environment that solves numerical problems quickly.

 

Some basic words from MATHWORKS commercial site:

image

 

image

image

System can be used to capture and analyze sensor data by communicating with Raspberry platform (as well as i.e. Arduino).

It allow to take Simulink - block diagram environment for simulation and Model-Based Design. We can model, simulate and analyze the project then program the hardware using graphical block diagrams.

 

According to the advertisement it " Models for Every Project".

 

Unpacking

Can I repeat - from my previous test?...

"There is nothing better than opening the package with brand new, sophisticated electronic device (for me at least…)"

image

Our sweet raspberry came safely and well packed in the pleasant, colorful box.

One can complain, the box was oversized, but as I think the safety of the content is most important.

image

You can find basic instructions before opening the box

The set consist of

  • Raspberry Pi 3 board
  • 16GB MicroSD Card
  • MicroSD card to SD Card Adapter
  • Power Supply with universal AC system adapters
  • Convenient enclosure

image

image

The set of the AC supply adapters provides the compatibility with the every Energy System.

image

image

 

The MATLAB and Simulink Student Suite:

The student suite includes MATLAB, Simulink and 10 add-on products with Hardware Support Packages for Arduino, Raspberry Pi and more.

The 10 add-on products include toolboxes for control systems, data acquisition and instrument control, DSP system design, image processing, optimization, signal processing, statistics and machine learning, and symbolic math.

  • Model hierarchical subsystems with predefined library blocks
  • Simulate the dynamic behaviour of your system and view results as the simulation runs
  • View simulation results and debug the simulation
  • MATLAB and Simulink Student Suite includes MATLAB, Simulink, and 10 add-on products.
  • Simulink has built-in support for prototyping, testing, and running models Raspberry Pi.
  • MATLAB Mobile lets you access MATLAB from your mobile device.
  • Student software runs on Windows, Mac, and Linux.

Technical documentation overview

Well I didn't  find many special documents inside. Some safety issues - regarding to requirements and regulations. For me It's correct. All necessary information you can find on the net... before the parcel arrived, so you can be well prepared to use the brick when you open the box.

 

First switching on

Raspberry launch

It's simple and pleasant, nevertheless system downloading is time consuming depending on the net connection quality.

The simplest solution is to take the NOOBS system installation option, ready to use, delivered on the SD Card.

"Out Of the Box Software" NOOBS is user friendly and intuitive indeed!

NOOBS is an easy operating system installer which contains Raspbian. It also provides a selection of alternative operating systems which are then downloaded from the internet and installed.

On the other hand you can prepare the SD card individually, using SD card image burner (I tried  Etcher) It's more convenient if there is the problem with fast enough internet access etc.

 

For me, the good habit using RPi is starting the job with update/ upgrade commands:

sudo apt-get update

sudo apt-get dist-upgrade

I try to keep the system fresh!

It looks like here:

 

Another worth to remember and repeat systematically thing is SD card backup policy.

image

image

The process time depends on the quality of the used storage media.

 

 

Software review

At this place I must admit, that the bundle most attractive part for me is MATWORKS suite.

 

At the beginning of the roadtest I was afraid,  that I'm able to test only small part of this amazing environment.

Ending the report, making final corrections, I'm still sure, I know, that there are huge capabilities of this suite. I hope I will continue exploration of the matlab, sharing my discoveries and thoughts on the element14 platform.

 

My experiments with TRIAL

image

 

 

image

 

image

what's going on?...

image

image

You can extend the basic suite:

image

Several minor problems was easy to manage:

image

image

Is it quick?

Everything is relative, it depends on the connection quality ... and your patience...

image

I want to admit, at this point, that you don't  need to worry about interrupts or lose of internet connection during installation,

Despite of my fear, after the unsupposed break, installation continued from the last point, not the beginning!

 

My patience was rewarded

Voila:

image

In the purpose to enjoy best graphic capabilities, you should switch on Open GL in your system!

 

image

30 days of unlimited access to all MATHWORKS functionalities past quick. When the message about TRIAL period turn to 0:

image

I switched (associate) to my licenced package.

 

image

 

The process is quick and carefree!

 

image

I had the issue with licence files in C:\Program Files\MATLAB\R2017b\licenses. I had to delete the "licence" connected to the trial and everything work well!

 

Comparison of trial  and Student licences:

 

TRIALMATLAB and Simulink Student Suite
Trial PackageStudent - Individual
MATLABMATLAB
SimulinkSimulink
Communications System Toolbox------------------------------
Control System ToolboxControl System Toolbox
DSP System ToolboxDSP System Toolbox
Data Acquisition ToolboxData Acquisition Toolbox
Image Processing Toolbox
Instrument Control ToolboxInstrument Control Toolbox
Optimization Toolbox
Signal Processing ToolboxSignal Processing Toolbox
Simulink Control DesignSimulink Control Design
Stateflow-----------------------------------
System Identification Toolbox---------------------------------
Statistics and Machine Learning Toolbox
Symbolic Math Toolbox

 

 

Following, you can find some my complains regarding lose the   System Identification Toolbox image

 

 

Installation of Add-Ons

More challenging issue related to environment installation is installation of MATLAB and SIMULINK Support Package for Raspberry Pi Hardware

 

image

 

 

image

image

 

 

 

 

 

image

I forgot of SSH enabling - the results below:

image

image

image

 

image

      image

image

 

Basic, preliminary tests

Having the whole system prepared I enthusiastically wanted to test how it work together.

The simplest way to check the functionality of MATWORKS packages designed for Raspberry Pi is, according to the documentation execute of raspi command:

 

image

Unfortunately I encountered serious problem with building the MATLAB I/O system on RPi

image

 

I was trying this:

image

image

...but still unsuccesfully...

 

Well, I lose several days looking for the answer.

The solution was easy and came from another Roadtester - THANK YOU AGAIN!

image

Just replacement of the two files and several commands, the system is working!

 

Now, using simple code I checked if I can operate RPi using MATLAB

On the following video I present the use of basic raspi function application.

The Matlab lets me control of the LED 0 on the RPi.

 

 

In the SIMULINK, there are intuitive solutions to communicate and control the RPi unit.

Using command blocks from libraries I could build any project.

image

image

I started with the simplest one, described here:

"Getting Started with Simulink Support Package for Raspberry Pi Hardware"

https://www.mathworks.com/help/supportpkg/raspberrypi/examples/getting-started-with-raspberry-pi-hardware.html?s_tid=src…

 

Details are presented on the following video

 

 

My first project

To be honest, the project is not main but very popular, used  as the first example of temperature measurement and application of 1-wire protocol in Raspberry.

The sensor is well known Dallas 18B20.

image

Using the simple breadboard layout I found in the net: "Raspberry Pi: Measure, Record, Explore."

 

Znalezione obrazy dla zapytania rpi3 ds18b20

The humble temperature measuring plant looks like here:

image

After initialization of the 1wire port, the temperature can be read using one command:

 

image

In the video below, you can see the results:

Here I want to complain a little. Maybe I looked for it in the libraries inattentively, but I didn't find 1wire library for RPi in the Simulink.

There are lot of materials and examples for arduino but regarding RPi I found nothing.

Honestly mentioned previously problem with raspi and lack of simple access from Simulink to 1wire in RPi spoiled my plan and the most important test failed.

 

Data Import and Export

Having RPi set as temperature logger, with the set of temperature readouts, I wanted to check possibilities of MATLAB in simple data import and visualization.

Following images show my steps in this example:

image

image

image

 

 

 

image

 

 

image

In the following video, you can see, how I imported and presented the data - temperature readouts

 

Use of the examples from MATHWORKS:

Usage of most examples is simple as you need only write one command in the MATHCAD to initiate the demo.

Bouncing Ball

My first example - exercise of use of the Simulink, taken from the huge examples library on Mathworks site was

Simulation of a Bouncing Ball

The principle is elementary as follow:

 

image

And the model also relatively simple:

image

image

Without any problems I reach following results:

changes of position and speed of the ball are easily presented on the chart:

 

image

 

Thermal Model of a House

The next example was more complex. It was interested for me, as the subject is very close to my projects related to energy efficiency in HVAC installations.

Here we have:

https://de.mathworks.com/examples/simulink/mw/simulink_product-sldemo_househeat-thermal-model-of-a-house?s_tid=examples_p2_Topic

According to the description, This example shows how to use Simulink to create the thermal model of a house.

This system models the outdoor environment, the thermal characteristics of the house, and the house heating system.

The most interesting issue is possibility to present supposed energy consumption and its cost.

 

 

image

image

 

image

The next, even more interested example, I tried to see and test:

The model is a house heating system that includes a heater (plant), thermostat (controller), and room (environment).

https://www.mathworks.com/help/simulink/examples/thermal-model-of-a-house.html

doesn't work unfortunately!

Execution of Ssc_house_heating_system  gives the error in my case.

 

Automation is my realm and probably most vintage automation engineer (or at least me) is keen on PID regulation principles.

Therefore I decided to test some

PID examples

I found very interesting examples of use simulink for modeling and  control

The Control Tutorials for MATLAB and Simulink (CTMS) is located here:

http://ctms.engin.umich.edu/CTMS/index.php?example=Introduction&section=SystemModeling

Examples are simple but I quickly learned how to use SIMULINK building automation process models.

 

Mass-Spring-Damper System

image

The free-body diagram for this system is shown below. The spring force is proportional to the displacement of the mass,

and the viscous damping force is proportional to the velocity of the mass,

Both forces oppose the motion of the mass and are, therefore, shown in the negative -direction. Note also that

corresponds to the position of the mass when the spring is unstretched.

image

Below, you can see results of my tests:

 

 

image

Above chart shows behaviour of the body when the external force as well as spring force acts.

The modeling of proportional controller seems to be perfect.

PID

My attempts to model and tune the PID regulator are shown below

 

image

Thanks to the CTMS, I found the automatic PID tuning functionality of Simulink

image

It works great as you can see

 

image

I attached the video from my tests of the PID experiments  in yhe Simulink

 

 

Licence limitation problem

Trying to retrieve some coding ideas from my youth

I looked to the project examples archive looking for runde-kutta solutions for 4thorder

As I remember form my student time nice implementation of these are the pendulum modeling issues.

I found quite nice:

https://www.mathworks.com/help/ident/examples/classical-pendulum-some-algorithm-related-issues.html?s_tid=srchtitle

image

image

image

 

image

It was working fine on the TRIAL version - where all packages were available.

Unfortunately after switch into licenced, student version, the example can’t be used.

image

 

image

 

To use 'iddata', the following product must be licensed, installed, and enabled:  System Identification Toolbox 

Lack of the licence for System Identification Toolbox is the problem here.

 

Never mind, another pendulum model:

Modeling a Foucault Pendulum

works fine with the Student Edition

 

image

image

You can watch it on the following video:

 

Matlab online

https://matlab.mathworks.com/

I must praise that very useful solution is online matlab version.

It's perfect solution which made me free, independent from the access to my computer.

Cloud based solutions are popular and Mathworks used it perfectly.

example below:

 

image

image

 

 

 

VNC in the Raspberry

Probably it's very old and frequently repeated notice but I will still glorify the simplicity of use of remote control of RPi using VNC.

It helps very much if the brick is located in "strange" place or it is used in extraordinary project.

image

image

My tests were conducted having RPi on laptop's screen.

The only issue is resolution. If RPi starts without the monitor, the default settings make the screen difficult to tune-up as well as minimum resolution is... big too much.

Sometimes RPi windows oversize main window, which make troubles.

 

ThingSpeak

- is the perfect tool to upload data e.g. from RPi sensors. The engine belongs to Mathworks, which make it perfectly compatible with our subject.

image

According to the definition, Thingspeak is an IoT platform that enables collecting, store, analyze, visualize,

and act on data from sensors or actuators from devices as Raspberry, Arduino etc.

Unfortunately, I neglected Thingspeak capabilities during my roadtest

but this part will be continued in my following projects with RPi & Simulink.

 

Comparison of Raspberry versions

The first Raspberry Pi - 1 Model B was released in February 2012, Model A was simpler and cheaper.

Raspberry Pi 1 Model B+ was released In 2014,

Raspberry Pi 2 which extended RAM was released in February 2015, It could be up to 14 times faster than a Raspberry Pi 1 Model B+

Raspberry Pi 3 Model B was released in February 2016     is told to be 10 times the performance of a Raspberry Pi 1

simple comparison is presented in the following table

image

Conclusions

My experiments and tests show, how powerful and interesting is the set: Matlab+Simulink & Raspberry Pi.

This roadtest is only the beginning of my adventure with that amazing program suite and charming device.

I feel, that probably I've lost too much time experimenting with MATLAB and Rpi separately, adding unsupposed problem with the integration,

I didn't have enough time to finish my test related to temperature control using Rpi as PID controller, all governed using Simulink.

This task will be conducted and I hope to report the results on this forum soon.

 

pros

I must confirm, that according to the advertisement, Mathwork products capabilities fulfill advanced requirements for analyzing data, developing algorithms or creating models.

It is intuitive, supported by excellent help as well as worldwide Matlab/ Simulink environment enthusiasts associated on many forums.

RPi is also very convenient, thanks to its versatility. Same as above, myriads  of forums, examples and advices will not allow you to feel lost when encounter hardware or software issue.

 

cons

Incompatibility of system version, when installing MATLAB and SIMULINK Support Package for Raspberry Pi Hardware,

resulting errors when building the MATLAB I/O server on RPi,

resolution problem when using RPi remotely with VNC,

lack of 1wire library for RPi in the Simulink.

Talking about Matlab, i admit, the price is, let say, delicate and relative issue. I don't know the pricing policy in different countries but I'm afraid for many students, or even universities,the suite is unavailable because of the costs. I hope I'm wrong.

 

Bibliography

MathWorks papers                    The MathWorks, Inc.                                                     www.mathworks.com

Raspberry papers, manuals      Raspberry Pi                                                                 www.raspberrypi.org

CTMS tutorials                          Control Tutorials for MATLAB and Simulink (CTMS)      ctms.engin.umich.edu/CTMS

 

Thank you again for selecting me as the roadtester and give me the opportunity to deal with these extraordinary and amazing tools.

Marek

Anonymous