Thread Subject: Matlab with bluetooth serial adapter

Subject: Matlab with bluetooth serial adapter

From: Nimita Wadhwa

Date: 12 Aug, 2009 16:30:21

Message: 1 of 5

HI,

I have to give commands via matlab to my robot, which I have connected via a bluetooth serial adapter. I have Matlab version R2007b. My bluetooth serial adapter is this: http://www.rovingnetworks.com/firefly.php

I am using baudrate of 38400. The bluetooth COM ports are COM4 for outgoing and COM5 for incoming.

The problem is that I am unable to use fopen on the ports in order to connect them to Matlab. I am doing this -

>> sPort = serial('COM4','BaudRate',38400)

   Serial Port Object : Serial-COM4

   Communication Settings
      Port: COM4
      BaudRate: 38400
      Terminator: 'LF'

   Communication State
      Status: closed
      RecordStatus: off

   Read/Write State
      TransferStatus: idle
      BytesAvailable: 0
      ValuesReceived: 0
      ValuesSent: 0
 
>> fopen(sPort)
??? Error using ==> serial.fopen at 71
Cannot connect to the COM4 port. Possible reasons are another
application is connected to the port or the port does not exist.


I either get this error, or sometimes --

??? Error using ==> serial.fopen at 71
Port: COM4 is not available. Available ports: COM1, COM4, COM5.
Use INSTRFIND to determine if other instrument objects are connected to the requested device.

So, it says COM4 is not available and then lists it under available ports. I know for a fact that COM4 is not connected to anything and is availabe.

If I don't have bluetooth at COM4, it won't give me any troubles. If I am using a serial cable at COM1 or something too, it won't give any errors

So what can I do to make it connect to this bluetooth COM port?

Subject: Matlab with bluetooth serial adapter

From: Nimita Wadhwa

Date: 12 Aug, 2009 23:49:05

Message: 2 of 5

Also, when the port is "incoming" for bluetooth - it connects fine then too. Like I don't have troubles opening COM5.

"Nimita Wadhwa" <nimitawadhwa@gmail.com> wrote in message <h5uqmt$71r$1@fred.mathworks.com>...
> HI,
>
> I have to give commands via matlab to my robot, which I have connected via a bluetooth serial adapter. I have Matlab version R2007b. My bluetooth serial adapter is this: http://www.rovingnetworks.com/firefly.php
>
> I am using baudrate of 38400. The bluetooth COM ports are COM4 for outgoing and COM5 for incoming.
>
> The problem is that I am unable to use fopen on the ports in order to connect them to Matlab. I am doing this -
>
> >> sPort = serial('COM4','BaudRate',38400)
>
> Serial Port Object : Serial-COM4
>
> Communication Settings
> Port: COM4
> BaudRate: 38400
> Terminator: 'LF'
>
> Communication State
> Status: closed
> RecordStatus: off
>
> Read/Write State
> TransferStatus: idle
> BytesAvailable: 0
> ValuesReceived: 0
> ValuesSent: 0
>
> >> fopen(sPort)
> ??? Error using ==> serial.fopen at 71
> Cannot connect to the COM4 port. Possible reasons are another
> application is connected to the port or the port does not exist.
>
>
> I either get this error, or sometimes --
>
> ??? Error using ==> serial.fopen at 71
> Port: COM4 is not available. Available ports: COM1, COM4, COM5.
> Use INSTRFIND to determine if other instrument objects are connected to the requested device.
>
> So, it says COM4 is not available and then lists it under available ports. I know for a fact that COM4 is not connected to anything and is availabe.
>
> If I don't have bluetooth at COM4, it won't give me any troubles. If I am using a serial cable at COM1 or something too, it won't give any errors
>
> So what can I do to make it connect to this bluetooth COM port?

Subject: Matlab with bluetooth serial adapter

From: Trent Jarvi

Date: 13 Aug, 2009 22:54:42

Message: 3 of 5


"Nimita Wadhwa" <nimitawadhwa@gmail.com> wrote in message
news:h5vkdh$g1s$1@fred.mathworks.com...
> Also, when the port is "incoming" for bluetooth - it connects fine then
> too. Like I don't have troubles opening COM5.
>
> "Nimita Wadhwa" <nimitawadhwa@gmail.com> wrote in message
> <h5uqmt$71r$1@fred.mathworks.com>...
>> HI,
>>
>> I have to give commands via matlab to my robot, which I have connected
>> via a bluetooth serial adapter. I have Matlab version R2007b. My
>> bluetooth serial adapter is this:
>> http://www.rovingnetworks.com/firefly.php
>>
>> I am using baudrate of 38400. The bluetooth COM ports are COM4 for
>> outgoing and COM5 for incoming.
>>
>> The problem is that I am unable to use fopen on the ports in order to
>> connect them to Matlab. I am doing this -
>>
>> >> sPort = serial('COM4','BaudRate',38400)
>>
>> Serial Port Object : Serial-COM4
>>
>> Communication Settings
>> Port: COM4
>> BaudRate: 38400
>> Terminator: 'LF'
>>
>> Communication State
>> Status: closed
>> RecordStatus: off
>>
>> Read/Write State
>> TransferStatus: idle
>> BytesAvailable: 0
>> ValuesReceived: 0
>> ValuesSent: 0
>>
>> >> fopen(sPort)
>> ??? Error using ==> serial.fopen at 71
>> Cannot connect to the COM4 port. Possible reasons are another
>> application is connected to the port or the port does not exist.
>>
>>
>> I either get this error, or sometimes --
>>
>> ??? Error using ==> serial.fopen at 71
>> Port: COM4 is not available. Available ports: COM1, COM4, COM5.
>> Use INSTRFIND to determine if other instrument objects are connected to
>> the requested device.
>>
>> So, it says COM4 is not available and then lists it under available
>> ports. I know for a fact that COM4 is not connected to anything and is
>> availabe.
>>
>> If I don't have bluetooth at COM4, it won't give me any troubles. If I am
>> using a serial cable at COM1 or something too, it won't give any errors
>>
>> So what can I do to make it connect to this bluetooth COM port?

This suggests that the driver does not fully support the windows serial API.
The different COM ports for incoming and outgoing communication are probably
going to be problematic. One bluetooth device that has worked with MATLAB
Serial is the one that is designed for the Lego Mindstorm product.

Subject: Matlab with bluetooth serial adapter

From: Nimita Wadhwa

Date: 14 Aug, 2009 22:05:20

Message: 4 of 5

Thanks for your reply.

But what exactly do you mean by driver doesn't fully support "windows serial API"?

Is there some driver I could install to make this work? You're talking about Matlab drivers right? Is there another version that would work?

Also, when its just a serial cable, COM1, I don't have troubles opening it and when I try to transfer bytes, it does say that bytes are being transfered - although my robot does nothing - so I was thinking I have to double check my code on the robot side..
But with bluetooth it doesn't even OPEN the port.

so if the problem was with windows serial API, even the COM1, should not open right?

Thanks.

Subject: Matlab with bluetooth serial adapter

From: Hossain

Date: 20 Oct, 2009 02:56:03

Message: 5 of 5

Hey Wadha,

Try using "advanced com port redirector" and redirect ur bluetooth serial outgoing port to a virtual port.

Unfortunately matlab doesn't support all bluetooth ports, See this http://www.mathworks.com/support/solutions/en/data/1-ZWNF9/index.html

So in my case com port redirection worked fine.


"Nimita Wadhwa" <nimitawadhwa@gmail.com> wrote in message <h5uqmt$71r$1@fred.mathworks.com>...
> HI,
>
> I have to give commands via matlab to my robot, which I have connected via a bluetooth serial adapter. I have Matlab version R2007b. My bluetooth serial adapter is this: http://www.rovingnetworks.com/firefly.php
>
> I am using baudrate of 38400. The bluetooth COM ports are COM4 for outgoing and COM5 for incoming.
>
> The problem is that I am unable to use fopen on the ports in order to connect them to Matlab. I am doing this -
>
> >> sPort = serial('COM4','BaudRate',38400)
>
> Serial Port Object : Serial-COM4
>
> Communication Settings
> Port: COM4
> BaudRate: 38400
> Terminator: 'LF'
>
> Communication State
> Status: closed
> RecordStatus: off
>
> Read/Write State
> TransferStatus: idle
> BytesAvailable: 0
> ValuesReceived: 0
> ValuesSent: 0
>
> >> fopen(sPort)
> ??? Error using ==> serial.fopen at 71
> Cannot connect to the COM4 port. Possible reasons are another
> application is connected to the port or the port does not exist.
>
>
> I either get this error, or sometimes --
>
> ??? Error using ==> serial.fopen at 71
> Port: COM4 is not available. Available ports: COM1, COM4, COM5.
> Use INSTRFIND to determine if other instrument objects are connected to the requested device.
>
> So, it says COM4 is not available and then lists it under available ports. I know for a fact that COM4 is not connected to anything and is availabe.
>
> If I don't have bluetooth at COM4, it won't give me any troubles. If I am using a serial cable at COM1 or something too, it won't give any errors
>
> So what can I do to make it connect to this bluetooth COM port?

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
com Mihir Shah 9 Mar, 2011 12:23:01
port Nimita Wadhwa 12 Aug, 2009 12:34:21
com Nimita Wadhwa 12 Aug, 2009 12:34:21
bluetooth Nimita Wadhwa 12 Aug, 2009 12:34:21
rssFeed for this Thread

Contact us at files@mathworks.com