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!
- 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
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