Guy on Simulink

Simulink & Model-Based Design

Running Simulink models on LEGO MINDSTORMS NXT

As you probably already know, MATLAB R2012a is now available for download!

One of my favorite feature in this release is the built-in support for running models on low-cost target hardware, including LEGO® MINDSTORMS® NXT and BeagleBoard. To give you an idea of this feature, here is a discussion I had with my friend Ashish Uthama.

Background

Ashish and I started as Application Support Engineers at MathWorks on the same day. While I was focusing on Simulink, he quickly transferred into the Image Processing Toolbox team. Consequently, he never really had opportunities to use Simulink.

As part of my job, I am currently developing what we call Model-Based Design Labs. In these internal training labs, we use LEGO® MINDSTORMS® NXT to give participants a Model-Based Design experience. Ashish just signed up for the next set of labs I will teach next month.

Part 1 - Setup

Ashish: Hey Guy, I am really excited about the Model-Based Design Lab!. I just bought a LEGO® MINDSTORMS® NXT kit. Here is a YouTube video of what I did last weekend.

Guy: WHAT!!! You did not use Simulink to program the NXT???

Ashish: I was planning to, eventually. Isn’t there a whole lot of setup steps? Like downloading drivers, compilers, blocks and the associated configuration? I’ll get to it when I have more time to spare.

Guy: It used to be that way. But we have made the process a whole lot simpler with R2012a. Now it's literally a couple of clicks to install it. Once you have MATLAB and Simulink installed, go to the Tools menu and you should see an option to Install/Update Support Package.

Installing the NXT support package

In R2012a, we offer support packages for two targets: Beagle Board and LEGO® MINDSTORMS® NXT. Select the one you need and Simulink will install everything needed.

Selecting a target

Ashish: That's it? And I only need MATLAB and Simulink installed? No Simulink Coder?

Guy: Absolutely, and in fact, it also works with the Student Version of MATLAB and Simulink.

A few hours later...

Part 2 - Results

Ashish: With just a basic introduction to Simulink I received 4 years back when I started with tech support at MathWorks, it only took me a couple of minutes to install the required software and an hour or so to get my first bot programmed! Here is a video of what it does:

Guy: Nice... and what does your model look like?

Ashish: As you can see below, I used the Color Sensor and configured it as a light sensor. I analyzed the data realized I could program it to follow the edge of the line. The algorithm is simple, white means turn left and black means turn right.

Line Tarcking Model

Guy: Not bad for a first try. I’ll show you how to improve that in the Model-Based Design Lab.

Ashish: Considering it's actually running a compiled program on the hardware, this is really impressive. I am excited about the power of Simulink!

Guy: I really think this built-in support for running models on low-cost target hardware is a great tool to learn many engineering concepts.

Now it's your turn!

Do you think it could be useful for you to learn or teach engineering concepts and Model-Based Design?

For more information, consult the documentation for more details on how to run models on target hardware.

Leave a comment here.

|
  • print

댓글

댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.