MATLAB Answers

0

Problem with running code on Lego Mindstorms NXT 2.0 in Simulink via Bluetooth

Asked by Ramtin Kermani on 24 Aug 2012

Hello Everyone,

I am trying to run a test code on a Lego Mindstorms NXT 2.0 using Simulink and Matlab Support package for Lego Mindstorm NXT 2.0 via Bluetooth.

I have installed the Support package using the "targetinstaller" on Matlab R2012a and I follow the instructions line by line, but it doesn't work and I receive the following error message:

The call to realtime_make_rtw_hook, during the entry hook generated the following error: Connecting to LEGO MINDSTORMS NXT failed. Check that: 1. LEGO MINDSTORMS NXT is powered on. 2. USB connection to the LEGO MINDSTORMS NXT is working. 3. LEGO MINDSTORMS NXT is not running an application.

The build process will terminate as a result.

I am following these instructions for setting up the Bluetooth connection: http://www.mathworks.com/help/toolbox/simulink/ug/bs9ked3-1.html

and this one to run the model on target: http://www.mathworks.com/help/toolbox/simulink/ug/bs9kd9y-1.html

This is What I did: - Created and ran models using Lego's LabVIEW-like application using USB And Bluetooth --> Success

- Installed Simulink Support package using target installer --> Success

- Created a simple Simulink model and ran it on the Lego using USB --> Success

- Tried to run the same Simulink model on the Lego using Bluetooth, and when I choose ( Tools -> Run on target Hardware -> Run ) --> Fail!

Note:

- I am using a Bluetooth Dongle attached to my computer

- I am running Matlab R2012a and Lego Mindstorms NXT 2.0

- I have updated NXT firmware when installing the Support package

- Bluetooth on NXT is turned on and paired with my Computer and I have 2 virtual COM ports

** I have tried everything: Re-Pairing my Bluetooth Device, Reconnecting, turning it on and off, restarting windows! Nothing worked! Any suggestions? Has anyone had the same problem with the Bluetooth in Simulink?

Thank you, Ramtin

  1 Comment

Hi Ramit! Were you able to solve the issue. I am facing the same issue with my connection too I am using MATLAB 2012b and NXT2. I tried connecting through USB instead of bluetooth to run the code in Simulink.

The error which comes is

The call to realtime_make_rtw_hook, during the after_make hook generated the following error: Could not find the COM port for the Bluetooth connection with the NXT brick 'NXT'. Use 'Add a device' in the Windows Control Panel to create a Bluetooth connection with your NXT brick. The build process will terminate as a result.

Could not find the COM port for the Bluetooth connection with the NXT brick 'NXT'. Use 'Add a device' in the Windows Control Panel to create a Bluetooth connection with your NXT brick.

Is it necessary to establish a bluetooth connection to use external mode?

Sign in to comment.

1 Answer

Answer by Stephen R. on 27 Aug 2012

Hi Ramtin. Did you select 'Enable External mode' in the Simulink configuration parameters before running via Bluetooth? This checkbox must be selected to enable Bluetooth communication between the LEGO and Simulink. Also, did you double-check the possible connection problems highlighted in the error message, specifically, did you verify that the LEGO brick was powered on, that you were still connected via USB (to download the model) and that no other application was still running on the LEGO? HTH. -Stephen

  0 Comments

Sign in to comment.


Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today