Rolling out some Raspberry Pi and Arduino maker projects at Fab Fest

September 09, 2015

Rolling out some Raspberry Pi and Arduino maker projects at Fab Fest

MathWorks recently participated in Fab11, a week-long event in Boston that brought together Fab Lab managers from different parts of the world. During...

MathWorks recently participated in Fab11, a week-long event in Boston that brought together Fab Lab managers from different parts of the world. During Fab11, the public could participate in Fab Fest, which brought together all types of innovators, and they were provided hands-on education and entertaining experiences.

Events such as Fab Fest provide a great opportunity to demonstrate to makers some relevant low-cost hardware-related projects that have worked in maker spaces, and which can be performed on their own. I’ll recount some of the projects that were showcased at Fab Fest.

Raspberry Pi speaks

Converting text to speech is not new. Features such as screen readers, speaking robots, and interactive phone apps have been available for quite some time. The technology behind converting text to speech, called speech synthesis, was prevalent even before the famous vocoder.

Different types of speech synthesizers are available to make the voice sound natural and intelligible. Synthesizer eSpeak uses the formant synthesis method that makes the voice more robotic than natural. Watch this video that takes you through the steps to get your Raspberry Pi to speak. In the video, the block that wraps the calls to eSpeak library is shown in Figure 1. This block will make your Raspberry Pi read out the textual input provided. For Fab Fest, the block was customized to enable the robot to speak in a female voice.

Figure 1: This block is part of the Simulink support package for Raspberry Pi.

Simulink provides two options when communicating with low-cost hardware boards – normal and external mode. Both modes use automatic code generation to generate an “executable” that runs on the hardware. Normal mode lets you use the hardware independent of Simulink, whereas external mode enables debugging and tuning capabilities from the Simulink environment. External mode is used in this project, as we want to modify the inputs to the code that’s running on Pi from Simulink. We wanted to do the following:

  1. Include a virtual on/off switch to determine when the Raspberry Pi speaks.
  2. Change the text while the code is still running on Pi.
  3. Provide the ability to switch between a male and female robotic voice.

Figure 2: Here is a snapshot from the video that instructs users how to make a Raspberry Pi speak in five simple steps. (Click to enlarge)

Wave your hand and play an instrument

A great interactive project for kids that was demonstrated at Fab Fest involved using Simulink to program an Arduino. Users could simply wave a hand on top of a distance measurement sensor to play Theremin-like music. The distance sensor measurements are filtered in the Arduino MEGA using a low-pass filter. These measurements are then converted into a frequency value at which the buzzer operates to create Theremin-like music.

External mode was used in this project to:

  1. Tune and design the low-pass filter parameters while the code was still running on the Arduino.
  2. Illustrate the performance of the low pass filter acting on the analog signals.
  3. Demonstrate the buzzer’s frequency of oscillation for different distance measurements.

Figure 3: This image demonstrates Theremin-like frequencies of the buzzer (top), the corresponding distance measurements from the hand to the sensor (middle), and the low-pass filter in action (bottom). (Click to enlarge)

Mobile robots

Mobile robots are always fun maker projects. Simulink’s normal mode is used to generate code that’s deployed onto the projects Shy Pet and Zumo Line Follower. As the name suggests, Shy Pet is a robot that avoids all obstacles/human beings and hides away from them; the Zumo Line Follower follows a track using sensors.

The decision-making process of the Shy Pet can be visualized using the flow diagram shown in Figure 4. The “brain” (the Arduino Due, in this case) has incoming information from the “eyes” (an IR sensor) and “whiskers” (the tactile sensors), which detect the obstacles. In the case of tactile sensors, a complete set of scenarios in which the robot can encounter obstacles are considered (either one or both whiskers). The IR sensor/eye information was used to see if an obstacle was within a random threshold value to make decisions.

Figure 4: Shown is the bot converted into a Shy Pet using the “brain” algorithm. (Click to enlarge)

In the case of Line Follower robots, two unique control algorithms were implemented on two different robots running on the track. A PID and bang-bang controller was tested on a simulated version of the Zumo bot to receive the desired performance. These designs were implemented on the actual robots using Simulink’s automatic code generation support for Arduino, which eliminates the need to design a controller and handwrite code for the Arduino.

Figure 5: Pololu’s Zumo bot running code generated by Simulink during Fab Fest.

A video shows how to program Simulink with Arduino for the Shy Pet, and documentation on the Line Following Robot is also available.

Engineers and makers at the event were most intrigued with the following aspects of making: the ability to learn different disciplines of engineering, such as controls (Zumo Line Follower), signal processing (IR Theremin), state machines (Shy Pet), and the ability to program different low-cost hardware. For more maker-related projects using Arduino, LEGO, and Raspberry Pi with MATLAB and/or Simulink, visit the MakerZone.

Madhu Govindarajan is a Partner Manager at MathWorks. He focuses on helping the maker community effectively use MathWorks software to connect with different low-cost hardware boards. He holds two masters degrees in mechanical engineering, one specialized in vehicle dynamics and the other in controls and artificial intelligent systems. He found his calling as a maker when he modified a radio controlled toy car into an autonomous car.

Madhu Govindarajan, MathWorks
Open Source