This exercise is intended to help students to understand how to communicate with the LEGO MINDSTORMS EV3 brick using MATLAB.
- Download the LEGO MINDSTORMS Education EV3 software from the Lego Education webpage. Install the software on your computer and read the manual.
- Download the LEGO MINDSTORMS EV3 hardware support from MATLAB from the manufacturer’s webpage. Install the hardware support on your computer and read the manual.
- Build a USB, Bluetooth, or Wifi connection between your computer and the EV3 brick.
- Display text ‘Hello, World!’ on the display of the EV3 brick.
- Play tone with frequency 800 Hz and duration of 500 ms.
- Change the color of the status light of the EV3 brick to a flashing orange color.
Solution
- You need the LEGO MINDSTORMS Education EV3 Core Set (~400 USD), the LEGO MINDSTORMS Education EV3 Expansion Set (~100 USD), a Mac running macOS or a PC running Windows. Furthermore, you need a WiFi USB Adapter compatible with the EV3 brick, such as the EDIMAX EW-7811UN Wireless USB Adapter, 150 Mbit/s, IEEE802.11b/g/n.
- During the experiments we will need MATLAB together with the Signal Processing Toolbox, the Statistics and Machine Learning Toolbox, the Image Processing Toolbox and the Computer Vision Toolbox.
- Next you need to download the LEGO MINDSTORMS EV3 software, which includes teacher resources, a documentation tool, building instructions and tutorials. Check the Tools menu -> Update Firmware if there is a new version of the firmware for the EV3 brick. We will not use the software and the LEGO programming language during the experiments but it helps to update the firmware and to find problems when trying to establish the USB, WiFi and Bluetooth connection.
- For the MATLAB/Lego Mindstorms experiment you need the MATLAB hardware support “legomindstormsev3io” and the LEGO EV3 software. The MATLAB Support Package for USB Webcams will be used during some of the other experiments. We will also use the iPhone and iPad Sensor Support from MATLAB and the Android Sensor Support from MATLAB.
- The USB connection is the easiest to make. Communication with your PC running MATLAB is stable and fast. With the WiFi connection, we have the advantage that no cable is necessary. However, it is found that transmission errors occur frequently, which can lead to malfunctions. Furthermore, even though the Brick Info suggests that there is a connection and the EV3 brick has an IP address, there is no communication between the PC and the brick. Use the command terminal command PING to find out whether there is a connection between the PC and brick, e.g. “ping 10.0.1.3” if you are using a closed WiFi network with the router’s IP address 10.0.1.1, the PC has 10.0.1.2 and the EV3 brick has 10.0.1.3. The Bluetooth connection is not recommended, since MATLAB hardware support can only read a single sensor.
- Use the MATLAB script attached to this post to solve tasks 4–6.
MATLAB script to run the experiment
Download the MATLAB script.