Simulink Offers Easy, Graphical Programming for Raspberry Pi & Arduino

Every hardware hobbyist has experienced that painful moment when you smell smoke and discover that it’s coming from your hardware project. It’s a rite of passage. Wouldn’t it be nice if you could test your hardware before burning it? At the Open Hardware Summit, held in Boston recently, I saw that MathWorks’ Simulink offers an appealing alternative that allows you to debug your model (embedded software) before deploying it onto hardware.

Simulink Offers Easy, Graphical Programming for Raspberry Pi & ArduinoA Simulink-powered robot caught my eye at the summit. Like a good pet, this robot tracked a green ball moving around on the demo floor. The robot is interesting from a hardware perspective because it uses both a Raspberry Pi and an Arduino Mega2560 communicating over the UART serial port interface. But more interesting is the amount of time spent on writing C code. It’s negligible!

If you are a hardware hobbyist like I am, you probably enjoy designing and building systems rather than wrestling with code issues. Simulink makes this possible with its graphical modeling environment and automatic code generation capabilities. From an educator’s perspective, Simulink offers a way to ease the learning curve for programming languages. Also, portability of your design to another hardware platform becomes easier than having to move your C-code to another development environment. I watched the program get worked on at summit — it looked so easy.

However, let’s dig a little deeper into the demo to understand how this is possible. Here’s a snapshot of the Simulink model deployed on the Raspberry Pi. This block diagram matches the mental model of a hardware hobbyist way more than C code does:

Simulink Offers Easy, Graphical Programming for Raspberry Pi & Arduino SchematicRaspberry Pi connects to a webcam and acts as the vision system for this robot. The image-processing algorithm for detecting a green ball is implemented using a built-in block from Simulink. The Pi also computes steering and driving commands for the Arduino based on the ball location in its field of vision. These commands are then communicated over the serial interface. This division of work makes sense, since the Pi is an order of magnitude faster in terms of processing speed as compared to an Arduino Mega. By simulating this model with real-time camera input, you can visualize, debug, and test the computer vision algorithm before you decide to deploy it on the Pi. Once you are confident about the design, you can generate code from this model with the click of a button to deploy it on the Pi.


For more detail: Simulink Offers Easy, Graphical Programming for Raspberry Pi & Arduino

© 2015 Powered By Engineering Projects Team, Raspberry Pi Projects

Scroll to top