Forums > MaxMSP

bluetooth and serial object

July 19, 2006 | 7:46 am

Hi
I am trying to conect a bluetooth device to max using the serial object in windowsXP. It is a microphone connected to a microcontroller that anylize the values of the wave and send me the average data via bluetooth. the microphone is working well and using the hyperterminal i can access to the data without problem.
I have several problems when connecting to MAX.
1. The serial object only recognize COM1, COM2, COM3, and COM4. I can only connect to the bluetooth in COM2 and COM4 but when i try to connect the bluetooth via different number port MAX doesnt recognize them.

2. The second problem is. Using COM2 and COM4 i can get the data but somehow it istotally different to the data i get in the hyperterminal and also it is not responding at all to the sound wave captured by the mic. Using the mic with the hyperterminal i can see clearly the difference numbers when i talk or during silence but in max the data are always more or less the same.

I am just 2 weeks working with MAX and i have been reading the post in the forum but i can not find any possible solution, maybe i don see it. Can someone explain me how max interprete the data from the bluetooth? how to access diferent port numbers? and it is possible to access to the hyperterminal and get the data from there?
Where can i find more information about?

thanks a lot.
klara


July 19, 2006 | 8:05 am

I don’t have an appropriate Bluetooth device here to test with, but I
know that Bluetooth Serial works properly on the Mac OS. The serial
object that came with Max 4.5.7 exhibits some problems when
specifying COM ports, and definitely had problems with COM ports > 9.
You might try the version of the object on the Incremental Donwloads
page:

http://cycling74.com/twiki/bin/view/IncrementalDownloads

and see if you have better luck connecting.

As for your second point, the serial object in Max is limited to
unsigned char data – single bytes from 0-255. What kind of data is
your microphone sending? I’ve been told that Hyperterminal
automatically resolves larger data types. The Max serial object does
not. If you are using values > 255, you’ll need to manually parse
incoming values, and construct numbers of greater bit length. There
was a thread on this subject yesterday in the forums:

http://www.cycling74.com/forums/index.php?
t=msg&th=20921&start=0&rid=0&S=a4e26f6dc050b3a131a658a889178f2b

If you continue to have problems, let us know. If all of your
problems go away, let us know that too.

Thanks
jb

Am 19.07.2006 um 09:46 schrieb clara:

> I am trying to conect a bluetooth device to max using the serial
> object in windowsXP. It is a microphone connected to a
> microcontroller that anylize the values of the wave and send me the
> average data via bluetooth. the microphone is working well and
> using the hyperterminal i can access to the data without problem.
> I have several problems when connecting to MAX.
> 1. The serial object only recognize COM1, COM2, COM3, and COM4. I
> can only connect to the bluetooth in COM2 and COM4 but when i try
> to connect the bluetooth via different number port MAX doesnt
> recognize them.
>
> 2. The second problem is. Using COM2 and COM4 i can get the data
> but somehow it istotally different to the data i get in the
> hyperterminal and also it is not responding at all to the sound
> wave captured by the mic. Using the mic with the hyperterminal i
> can see clearly the difference numbers when i talk or during
> silence but in max the data are always more or less the same.
>
> I am just 2 weeks working with MAX and i have been reading the post
> in the forum but i can not find any possible solution, maybe i don
> see it. Can someone explain me how max interprete the data from the
> bluetooth? how to access diferent port numbers? and it is possible
> to access to the hyperterminal and get the data from there?
> Where can i find more information about?


July 19, 2006 | 9:49 am

OK, I did some research on this. The PICBASIC (and presumably others)
formatter doesn’t pack the bytes into high and low, in the case of
large decimals. It simply "spells" the number, which is why
Hyperterminal and the Parallax debugger are capable of "resolving"
WORDs. They are doing no such thing, but simply displaying ASCII
values. For instance, the number 256 is output as 3 bytes: 50, 53, 54.

So, your Max code to resolve a DEC formatted number in PICBASIC (e.g.
DEBUG DEC myVar or SEROUT 16, 16468, [DEC myVar]) would resemble the
following:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 85 62 214 196617 bondo 4;
#P newex 289 116 64 196617 fromsymbol;
#P newex 221 116 64 196617 fromsymbol;
#P newex 153 116 64 196617 fromsymbol;
#P newex 85 116 64 196617 fromsymbol;
#P number 85 249 60 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 153 191 27 196617 +;
#P newex 221 165 27 196617 +;
#P number 289 36 35 9 48 57 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 289 90 40 196617 itoa;
#P number 221 36 35 9 48 57 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 221 142 32 196617 * 10;
#P newex 221 90 40 196617 itoa;
#P number 153 36 35 9 48 57 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 153 142 38 196617 * 100;
#P newex 153 90 40 196617 itoa;
#P newex 85 217 27 196617 +;
#P newex 85 142 44 196617 * 1000;
#P newex 85 90 40 196617 itoa;
#P number 85 36 35 9 48 57 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P connect 19 0 1 0;
#P connect 19 1 4 0;
#P connect 19 2 7 0;
#P connect 19 3 10 0;
#P connect 0 0 19 0;
#P connect 6 0 19 1;
#P connect 9 0 19 2;
#P connect 11 0 19 3;
#P fasten 18 0 12 1 294 161 243 161;
#P connect 17 0 8 0;
#P connect 16 0 5 0;
#P connect 4 0 16 0;
#P connect 7 0 17 0;
#P connect 10 0 18 0;
#P connect 15 0 2 0;
#P connect 1 0 15 0;
#P connect 3 0 14 0;
#P fasten 13 0 3 1 158 212 107 212;
#P fasten 12 0 13 1 226 186 175 186;
#P connect 5 0 13 0;
#P connect 8 0 12 0;
#P connect 2 0 3 0;
#P window clipboard copycount 20;

Whereas the Max patch to resolve the high and low bytes of a WORD
variable (256 = 1, 0; 257 = 1, 1; etc.) (e.g. SEROUT 16, 16468,
[myVar.HIGHBYTE, myVar.LOWBYTE]) would look like this:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 85 62 47 196617 bondo 2;
#P number 85 160 60 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 122 36 35 9 0 255 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 85 128 27 196617 +;
#P newex 85 92 29 196617 < < 8;
#P number 85 36 35 9 0 255 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P fasten 5 1 2 1 127 120 107 120;
#P connect 5 0 1 0;
#P connect 1 0 2 0;
#P connect 3 0 5 1;
#P connect 0 0 5 0;
#P connect 2 0 4 0;
#P window clipboard copycount 6;

In both cases, you would need to come up with a way to separate
values, so that you know when the next number begins. So, you might
reserve an ascii character as a spacer. To what extent you have
control over this on your device, I have no way of knowing, but
presumably, this is something you can do, if it’s not already being
done.

As for your COM1-4 problem. I think this problem is likely limited to
HyperTerminal, and has nothing to do with Max. A quick look at the
HyperTerminal Knowledgebase online shows that that software _is_
limited to COM ports 1-4, and that this is a known limitation of it
(so that you’ll buy their HyperACCESS product). You should try the
new version of serial, in any case, since it’s more reliable than the
4.5.7 release version.

jb

Am 19.07.2006 um 10:05 schrieb Jeremy Bernstein:

> As for your second point, the serial object in Max is limited to
> unsigned char data – single bytes from 0-255. What kind of data is
> your microphone sending? I’ve been told that Hyperterminal
> automatically resolves larger data types. The Max serial object
> does not. If you are using values > 255, you’ll need to manually
> parse incoming values, and construct numbers of greater bit length.
> There was a thread on this subject yesterday in the forums:


July 19, 2006 | 11:09 am

thanks very much for your reply
i am still trying to understand your suggestions (i am very very new at this) but about the COM1-4 problem, i have tried the new version of serial and now i can access almost all port numbers, including >9 but. If i send the print message to the serial object i get information of only COM1 COM3 COM4 and COM9 available but if in the serial object i specifie the port name i can easily get the data.
about understanding the data problem it will take me some time…
thanks
klara


July 19, 2006 | 11:37 am

The "print" message only prints ports with things connected to them.
What port is your interface connected to? Or, better, what are you
expecting to see when you send "print"?

Am 19.07.2006 um 13:09 schrieb clara:

> thanks very much for your reply
> i am still trying to understand your suggestions (i am very very
> new at this) but about the COM1-4 problem, i have tried the new
> version of serial and now i can access almost all port numbers,
> including >9 but. If i send the print message to the serial object
> i get information of only COM1 COM3 COM4 and COM9 available but if
> in the serial object i specifie the port name i can easily get the
> data.
> about understanding the data problem it will take me some time…


July 20, 2006 | 9:31 am

hello
my real problem is (or what i think it is..)
i am sending ASCII data via bluetooth
when i receive them in MAX the data are totally
different. so…what kind of data am i receiving?
what kind of operation should i do to convert them?
For example using the hyperterminal i can see this data:

-120 silenc
-122 silence
-120
-119
-120
-90 i am talking to the mic
-87 i am talking to the mic
-120
-122
-120
-119
-120

but using the serial object in max
i got

-49
-50
-49
-13
-10
-49
-50
-49
-55
-41
-13
-10

no matter if i am talking or not.
it is extrange because 13 10 appear always in the same order at
regular intervals.

i am sorry but i can not explain me better. my knowledge on this is very limited but i am trying to understand. In theory i could work with the data that max give me but somehow it seems that something extrange happens because there are not changes when i talk to the mic and some changes (13 10) always appear even in silence.

About the port problem it is solved, i can connect now to different ports and understand better how it works.

any help you could give me is marvelous.
thanks
klara


July 20, 2006 | 9:44 am

Spelling this as ASCII:

121rn1217)rn

No idea what that (55, 41) is there for – are you sure you didn’t
mistype? However, the rest makes sense – 13,10 is rn – a line
break, which is being inserted between values.

Here’s another patch that you can use to "unspell" the data coming
from your device. However, you need to find some documentation about
the format of data coming through, in order to correctly parse it. I
assume that your Bluetooth device came with some sort of manual with
a description of the serial specification.

jb

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 169 311 32 196617 print;
#P message 148 60 67 196617 49 48 50 52;
#P newex 112 198 64 196617 fromsymbol;
#P newex 112 169 40 196617 itoa;
#P number 112 311 50 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 89 89 211 196617 t b l l b;
#P message 290 229 33 196617 set 0;
#P newex 112 283 40 196617 accum;
#P newex 112 143 27 196617 t i b;
#P newex 112 120 25 196617 iter;
#P newex 112 229 51 196617 *;
#P newex 185 197 97 196617 expr pow(10\,$i1);
#P newex 215 145 27 196617 – 1;
#N counter 1 1 0;
#X flags 0 0;
#P newobj 185 169 71 196617 counter 1 1 0;
#P message 89 60 52 196617 50 53 54;
#P newex 215 120 34 196617 zl len;
#P connect 8 0 11 0;
#P fasten 8 0 15 0 117 307 174 307;
#P connect 0 0 3 0;
#P connect 3 0 2 2;
#P connect 2 0 4 0;
#P connect 6 0 7 0;
#P fasten 7 1 2 0 134 163 190 163;
#P fasten 9 0 8 0 295 274 117 274;
#P connect 10 3 9 0;
#P fasten 10 2 0 0 228 113 220 113;
#P fasten 10 1 6 0 161 113 117 113;
#P fasten 10 0 8 0 94 276 117 276;
#P connect 1 0 10 0;
#P fasten 4 0 5 1 190 224 158 224;
#P connect 7 0 12 0;
#P connect 12 0 13 0;
#P connect 13 0 5 0;
#P connect 5 0 8 1;
#P connect 14 0 10 0;
#P window clipboard copycount 16;

Am 20.07.2006 um 11:31 schrieb clara:

> -49
> -50
> -49
> -13
> -10
> -49
> -50
> -49
> -55
> -41
> -13
> -10


July 24, 2006 | 7:23 am

Dear Jeremy
i think i did solve my problem or at least now i understand better what was going on.
My bluetooth device is handmade. It is connected to a microcontroller that was sending decimal data. The problem is that it seems that Max serial object is expecting to receive characters and convert them to integer. am i right? Even if i was sending already integers, max understood this data as characters and transform again to integers so the resultant data was different to what i was sending. After try some solutions and make some test with the spell you send it to me, the easiest way we have found is to programme the microcontroller to send characters. By this way, i am sending characters and max transform it to integers that corresponds with what i was expecting to get. In the hyperterminal i get something like

nroptrmqqnrmnqprprompqlpnqrprnpnoporqsropnqrprnonpronqoq
rmqppqpsnmprprnpsrqqnoqprompnoqorponqrsloposlpoprlnootqnpronqpqqrnnpomonroqrlqpq
pprpronpqomqorprroromqpmrmnpormooprrlqqqrnpnpspnpomprsrmqqlooqpqnrnnoorpsrpqpnqp
rprnkprnpoorpqpnpnnpqqrprnpponpornpopsnnonornnponoprpqnlqoqrornoolpomqooqprrooop
snnoronpnrqsonnnrrnrnnnoonqprnpoonpprrprnnpqqpqrlppnponsqtpmnpqrpsnnomoporprrnpp

but max understand this as

107
108
106
107
108
106
110
112
102

that in fact are the values that i need (values of the wave captured by the microphone)
I dont know if this is the better solution but for the moment it is working and as my knowledge of max is still very poor…i am very happy . Let see what problems i will find later. This is always like a puzzle for me.

thank you very much for your kind help.
klara


Viewing 8 posts - 1 through 8 (of 8 total)