In this article, Brian Peek will demonstrate how to use Microsoft Robotics Studio to control the Lego Mindstorms NXT kit. A simple remote-controlled robot will be built and controlled using C#. Explore eLearning. An online eLearning program providing 100+ self-paced video lessons. Taking you from complete beginner to classroom-ready, each of the 15 courses lasts approximately 90 minutes (including build time and activities). Available language: US English. Explore eLearning. Curriculum Materials.

.IntroductionBefore I joined The MathWorks, I was an academic doing research on neural networks and neuroscience. MATLAB's utility in researchis a commonplace, but one thing that struck me was its utility in learning: its interpreted nature and visualization allowedme to play with ideas numerically and graphically. Today, I want to highlight one such teaching application, which is theuse of MATLAB with the LEGO Mindstorms robotics system. What is LEGO Mindstorms?The is a 'robotics system' composed of a few sensors, motors, and an embedded processor (the 'NXT brick'). What makes the systemmore than just an obscure hobbyist toy is its price (around $250, in the same ballpark as consumer electronics items) andthe decision by LEGO to create an.

Program

This allows third-party programs to send commands to the NXT over a Bluetooth wireless link, compile programs to be executedautonomously on the NXT, or replace the NXT firmware entirely with custom firmware and programs. In this post, I focus onthe Bluetooth wireless approach.But what does this have to do with teaching? Simply this: it is now easy and (relatively) inexpensive to connect lines ofcode on a computer screen to concrete actions in the world. A LEGO Mindstorms robot's actions - scooting around the room,bumping off the walls, playing sounds - can be controlled on the fly by a MATLAB program. This provides a powerful way tomotivate students to explore and master programming concepts. Step 1: Build an NXT RobotLet's see how to control the standard NXT example robot, the tribot.The tribot has two independently-powered wheels, a touch sensor in front to detect obstacles, and a sound sensor (so thatthe tribot can be started or stopped with a clap, for example).

.Instructor's Solutions Manual for Modern Control Systems. Dorf solution manual.

In addition, it has a pair of claws that are powered by athird motor. The NXT has four sensor ports ( Port1 – Port4) and three motor ports ( PortA – PortC). In a typical configuration. PortA is connected to the claw motor.

PortB and PortC are connected to the left and right wheel motors. Port1 and Port2 are connected to the touch and sound sensors.Step 2: Set Up the Bluetooth ConnectionNext I establish a Bluetooth connection between the LEGO NXT and the host computer. To do this, I need a Bluetooth adapter(preferably one ).

Once the adapter is installed and paired with the LEGO NXT, the communication channel shows up on the host computer asa virtual serial port (e.g., 'COM40'). Step 3: Set Up a Connection Between MATLAB and the TribotI use the capability to access a serial port. The wraps this communication channel into a high-level object-oriented interface.

A similar, though non-object-oriented, toolboxhas also been developed at RWTH Aachen University in Germany. See at the bottom of this postOnce the MATLAB toolbox is downloaded and installed, I first need to add the download directory to the MATLAB path, using.Now I can initiate a MATLAB connection to the tribot.

(You can try out the toolbox even if you do not have a LEGO robot byusing 'test' for the name of the serial port). Nxt = legoNXT( 'test');nxt is a MATLAB object and the input and output ports are objects also. LeftMotor = nxt.PortB;touchSensor = nxt.Port1;whos nxt leftMotor touchSensor Name Size Bytes Class AttributesleftMotor 1x1 1260 outputPortnxt 1x1 840 legoNXTtouchSensor 1x1 280 inputPortIssue commands by invoking the appropriate object methods. For example, let me to rotate the left wheel for 3 seconds at apower level of 30 (out of a maximum of 100). Start(leftMotor, 30);pause(3);stop(leftMotor);In order to read a sensor, I first need to tell the NXT what type of sensor is connected to the input port.

From then on,the sensor can be read with a simple method call:% configure nxt as a touch sensorset(nxt.Port1, 'type', 'touch');% get a sensor readingv = getdata(nxt.Port1);The NXT Bluetooth interface has other capabilities in addition to accessing motors and sensors. To access these capabilities,I need to get the 'low-level' NXT interface from the nxt object. Type lowlevelNXT nxti = get(nxt, 'NxtInterface');% Play a 1000 Hz tone for 300 millisecondsplayTone(nxti,1000,300);% execute a program already present on the NXTstartProgram(nxti, 'Demo.rxe');% get a full list of low-level commandshelp nxtInterface/ContentsFinally, close and clean up the interface. Delete(nxt);clear nxt Step 4: Create Tribot Programs in MATLAB!The capabilities I just showed provide the building blocks for students to explore a variety of programming concepts. A simpleassignment might be, 'wait until the sensor is pressed and released five times'. This assignment requires understanding ofboth looping and conditionals.

Here's one solution. Type checkSensor function checkSensor(nxt)% sensor values less than 50 = touch sensor is depressedcount = 0;previousValue = 100;while count = 50) && (currentValue.

Recent Articles