Sign in

username:

password:



Not a member?

Search basicx



Search tips

Subscribe to basicx



basicx by Keywords

Accelerometer | ADC | ADXL | Adxl20 | AVR | BasicStamp | BX-35 | BX28 | BX35 | COM3 | Compiler | Downloader | EEPROM | Electromagnet | GetADC | GP2D1 | GPS | I2C | IDE | Keypad | LCD | LCD+ | MIDI | Motors | Multitasking | Netmedia | Networking | PCB | PID | PlaySound | PWM | Relays | RTC | Servo | ShiftOut | SitePlayer | SPI | Stack | Timer | USB

Ads

Discussion Groups

Discussion Groups | BasicX | Re: Connecting eb500 to bx24 HELP

Discussion forum for the BasicX family of microcontroller chips.

Connecting eb500 to bx24 HELP - femme_pacita - Dec 2 17:45:20 2007

Hi, I read you know something about connecting the bx to the bluetooth
device. Coulyou please help me? I've been researchin for some days now
and I still don't know how to finish my proyect. Our deadline is
aproaching and I would really appreciate some help.

I know how to connect phisically the micocontroller to the eb500, but
I dont know how to make the bx24 order the eb500 to connect to another
bluetooth in a computer and to send data out by the eb500

Have any idea how the code would look like?? please???



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )


Re: Re: Connecting eb500 to bx24 HELP - Tom Becker - Dec 3 16:21:50 2007

> ... connect to a pc bluetooth?

One end needs to find the other, a process called pairing. You must
usually tell one of the radios to allow pairing, then direct the other
to find it. I would opt to have the PC find the EB500, but you can do
it the other way; that's up to you and convenience. You'll need to find
the appropriate commands in the EB500 manual and send those commands
from the BX-24, perhaps using a different BX-24 program (once done,
pairing usually sticks) unless the pairing needs to happen each time you
start the project up - like if the PC is not always the same one.

ACK is short for Acknowledged, NAK for Not Acknowledged. If you send a
valid command the EB500 it will send an ACK, otherwise a NAK. It's a
crude comm validation method.

Read that manual!
Tom



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Re: Connecting eb500 to bx24 HELP - Tom Becker - Dec 3 18:23:41 2007

Yup, your code compiled and ran fine. I added an OpenCom1 so the the
loop output would be easily visible in the IDE:

Option Explicit
Public Sub Main()
dim ibuffer as byte
dim obuffer as byte
dim q1 (1 to 160) as byte
dim q2 (1 to 160) as byte

Call DefineCom3(16, 17, bx1011_0111)
Call OpenQueue (q1, 160)
Call OpenQueue (q2, 160)
' Call OpenCom (3, 19200, q1, q2)
Call OpenCom (1, 19200, q1, q2)

Debug.print "bluetooth"
Do
Call PutQueueStr (q2, "funcion whatever")
Loop
End Sub

*** Opening file: C:\Program Files\BasicX\Project1.bxb
*** Downloading File
Writing internal EEPROM
Verifying internal EEPROM
Verify OK
Writing external EEPROM
Verifying external EEPROM
Verify OK
*** Finished Downloading
bluetooth
funcion whateverfuncion whateverfuncion whateverfuncion whateverfuncion
whateverfuncion whateverfuncion ...

I question only the size of the queues. You only have 401 bytes of RAM
to work with in the BX-24, you've allocated 320 for the queues alone,
and you also need some for other variables and stack. There is not much
left.

You only need as much queue as you need to buffer, i.e. if the source
sends in bursts of 10 bytes and you only take it from the queue in
single bytes, you need at least 10 bytes (plus nine bytes of overhead
for each queue), so that queue must be 19 bytes total or you might miss
some input data. Similarly, if you need to send a single variable of,
say, 20 bytes, you need at least a 29-byte output queue, but much more
is probably wasted RAM. Note that, if you put something to a queue that
is longer than the queue, the program will hang at that point, forever
waiting for sufficient space.



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Connecting eb500 to bx24 HELP - femme_pacita - Dec 3 23:09:24 2007


> BX-24 serial comm is easy. You must OpenQueues of sufficient lengths
> for input and output data and, if using COM3, Define it's parameters,
> then OpenCOMn. Data is sent with PutQueue and received with GetQueue.
> See the Basic-X manual and look at many examples in
>
http://tech.groups.yahoo.com/group/basicx/files/Datasheets-Appnotes-Examples-Dra\
> wings/Comm/
>
> Tom
>
Tom, thanks a lot. That was REALLY usefull. I understand how to define
and open com3 and to open the queues, can you please help me write the
code to make the eb500 find and connect to a pc bluetooth?

By the way, I didn't understood the "and ACKs or NAKs the command"
part. Sorry, kindda new at this.



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Re: Connecting eb500 to bx24 HELP - Tom Becker - Dec 4 1:49:38 2007

> ... when I tell the bluetooth in the pc to detect the other one, it
only finds a COM5...

That's probably correct. COM5 is the _PC_ COM5, a logical port assigned
to _its_ Bluetooth device. COM5, on the PC, is the port you must use to
talk to the remote radio. Try running a terminal program on the PC and
look at COM5.



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Connecting eb500 to bx24 HELP - Tom Becker - Dec 4 17:43:32 2007

Now I'm puzzled. Is your intent to have the PC play a note that
corresponds to a distance determined by the BX-24? Or have the BX-24
drive a MIDI hardware channel, connected to a synth that plays the
note? If the latter you must use COM1 and some additional hardware
(conventional MIDI is a current loop) to be MIDI-compatible.

If that's so, the MIDI output (at ~31kbs) must be on COM1 since COM3
can't operate above 19200, and you'll need to convert that COM1 data
to current loop. Here, you open COM3 and you send MIDI output to COM3
at 9600. That won't work unless the PC (tied to BX-24 COM3 via
Bluetooth) passes the MIDI along to a synth or equivalent.

If your intent is to play the note on the PC via Bluetooth, you don't
need 31kbs; you can use any speed, I think, to get the MIDI data to
the PC and then pass that along to a true MIDI hardware output like
those available on many sound boards, or a software synth. The latter
will require some PC programming, perhaps a VB application that takes
serial Bluetooth data and controls a software synth via DirectX, I
believe.

The register.ubrr = 14 line can only affect the hardware UART on COM1.
It will have no effect on COM3, which is a software UART.

> 'open serial port on COM1:
> Call DefineCom3(16, 17, bx1011_0111)
> call openCom(3, 9600, inputBuffer, outputBuffer)
>
> 'set baud rate to 30.270:
> register.ubrr = 14



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Connecting eb500 to bx24 HELP - femme_pacita - Dec 4 18:23:03 2007

That's exactly what I want, my bx sending out MIDI, but I don't know
how to translate the data recieved into sound or how to send it into
the MIDI board

I managed to send text and visualize it with HyperTerminal, but
nothing more.



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Connecting eb500 to bx24 HELP - Tom Becker - Dec 5 0:51:44 2007

> ... I want my bx sending out MIDI, but I don't know how to translate
the data received into sound or how to send it into the MIDI board...

If the goal is to generate sound you can look into the BX-24 PlaySound
procedure to drive a speaker with the BX-24 directly, but I have no
experience with it. Perhaps someone else here can help.

If the exercise is to use MIDI, you have two choices: convert COM1 to
a MIDI current-loop interface and connect it to a synth with a 5-pin
MIDI cable, or write a VisualBasic or other PC language program to
receive the MIDI data via Bluetooth and control a synthesizer
connected to the PC. If that's the task, you'll need to switch hats
now and become a PC programmer.

Tom



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Connecting eb500 to bx24 HELP - femme_pacita - Dec 5 6:11:10 2007

Ok, I added my program to the code. This s it

dim outputBuffer(1 to 10) as byte '1-byte output buffer
dim inputBuffer(1 to 13) as byte '1-byte input buffer
'declare an array of 12 byte variables

dim pitch (0 to 11) as byte

'declare other vriables
dim note as byte
dim ADCvar as integer
dim ADCvar1 as integer
dim midiCmd as byte
dim velocity as byte

Sub Main()
'the 12 elements of the array called pitch are the 12 notes of a scale:
pitch(0)= 60 ' middle C
pitch(1)= 36
pitch(2)=37
pitch(3)=38
pitch(4)=64
pitch(5)=65
pitch(6)=66
pitch(7)=67
pitch(8)=68
pitch(9)=69
pitch(10)=70
pitch(11)=71
'open serial queques:
call OpenQueue(inputBuffer,13)
call OpenQueue(outputBuffer,10)

'open serial port on COM1:
Call DefineCom3(16, 17, bx1011_0111)
call openCom(3, 9600, inputBuffer, outputBuffer)

'set baud rate to 30.270:
register.ubrr = 14
do
call putpin(25, 0)

'my distance ranger gave a range from 0 to 1024
ADCVar=getADC (13)
ADCVar1=getADC (15)
'convert to range from 0 to 11:
'note = cByte(ADCVar \ 98)
if ADCvar=0 then
if ADCvar1=0 then

'sent a note on message, channel 1, velocity 64:
midiCmd = &H90
velocity = &H64
call putQueue(OutputBuffer, midiCmd, 1)
call putQueue(OutputBuffer, pitch(3), 1) 'pitch[note]
call putQueue(OutputBuffer, velocity, 1)
call delay(0.25)
midiCmd = &H80
velocity = 0
call putQueue(OutputBuffer, midiCmd, 1)
call putQueue(OutputBuffer, pitch(3), 1) 'pitch[note]
call putQueue(OutputBuffer, velocity, 1)
call delay(0.03)
end if
end if
if ADCvar=0 then
if ADCvar<>10 then
'sent a note on message, channel 1, velocity 64:
midiCmd = &H90
velocity = &H64
call putQueue(OutputBuffer, midiCmd, 1)
call putQueue(OutputBuffer, pitch(1), 1) 'pitch[note]
call putQueue(OutputBuffer, velocity, 1)
call delay(0.03)
midiCmd = &H80
velocity = 0
call putQueue(OutputBuffer, midiCmd, 1)
call putQueue(OutputBuffer, pitch(1), 1) 'pitch[note]
call putQueue(OutputBuffer, velocity, 1)
call delay(0.03)
end if
end if

if ADCvar1=0 then

'sent a note on message, channel 1, velocity 64:
midiCmd = &H90
velocity = &H64
call putQueue(OutputBuffer, midiCmd, 1)
call putQueue(OutputBuffer, pitch(2), 1) 'pitch[note]
call putQueue(OutputBuffer, velocity, 1)
call delay(0.03)
midiCmd = &H80
velocity = 0
call putQueue(OutputBuffer, midiCmd, 1)
call putQueue(OutputBuffer, pitch(2), 1) 'pitch[note]
call putQueue(OutputBuffer, velocity, 1)
call delay(0.03)
end if

Debug.print "bluetooth"

Call PutQueueStr (OutputBuffer, "funcion whatever")

Loop
End Sub
But when I tell the bluetooth in the pc to detect the other ne, it
only finds a COM5, no way to make it look for COM3.
So the pc detects it when I power it, but I can't make it send data out.



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Re: Connecting eb500 to bx24 HELP - Tom Becker - Dec 5 8:54:32 2007

> ... You're right about that.

Right about what? I think I asked which of three possibilities you're
trying to do.

> ... the other one receives the midi through the bluetooth and sends
the audio out to a midi board.

You can't send audio to a MIDI board, at least not in the conventional
sense (you can load audio _samples_ to be played as a note by a sampler
via MIDI but I doubt that's what you need to do).

I still don't understand what your goal is. If you _must_ be wireless
and you don't want to or can't program the PC to collect MIDI data from
Bluetooth and operate a PC sound board synth, software synth or external
synth with that data (it is not audio yet, just a string of commands
that a synthesizer will convert to audio), you'll need to receive the
Bluetooth and convert it to MIDI , then sound, another way.

Another Bluetooth radio, and another BX-24 with its COM1 (at ~31250)
tied to the current-loop MIDI interface of a synth will do it, too. One
of the EB500 commands will tell you the Bluetooth MACs of available
radios to pair with; the PC adapter can do the same. You might also
find the MAC printed on a label on or in the EB500 or its box.

Thursday? That's tomorrow where I am. Build a time machine first so
you can give yourself another week; you're late.

Tom



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Connecting eb500 to bx24 HELP - femme_pacita - Dec 5 11:24:40 2007

Ok. The thing is I have 2 bx, 2 eb500 and midi boards. The proyect is
to capture certain sensors, so when one of them is activated, we send
a midi note out. Diferent sensors activated means different notes. And
this must be wireless.
So, I have the first bx connected to the sensors and the eb500; then I
have the second bx connected to the second eb500 and to the MIDI out.

My question is: do I send the sensors data by bluetooth or do I send
the MIDI by it? You told me that COM3 doesn't send midi, so should I
change the com or it would be easier to send the sensors data out so
that the second bx is the one that transform it to midi?



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Connecting eb500 to bx24 HELP - femme_pacita - Dec 5 12:39:28 2007

Could the Com1ToAdc and DACtoCom1 functions be usefull in this case?



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Connecting eb500 to bx24 HELP - Tom Becker - Dec 5 13:19:09 2007

> ... My question is: do I send the sensors data by bluetooth or do I
send the MIDI by it?

I suspect you can do either, that's a design decision that you need to
make. I would send the raw data wirelessly and convert to MIDI at the
other end. Like you suggest next:

> You told me that COM3 doesn't send midi, so should I
> change the com or it would be easier to send the sensors data out so
> that the second bx is the one that transform it to midi?

BX-24 COM3 can't send MIDI because it can't make the MIDI rate, only
BX-24 COM1 can get close.

What MIDI board? I think that's the first mention of it. Let's see a
link.



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Re: Connecting eb500 to bx24 HELP - Tom Becker - Dec 5 15:09:56 2007

> ...COM1ToADC...

No.
Tom



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Connecting eb500 to bx24 HELP - femme_pacita - Dec 6 1:25:41 2007

You're right about that. So I'm thinking about buying another eb500
and connect it to another bx. That way I can split my sensors-midi
code, so one bx captures data and trasnform it into midi, while the
other one recieves the midi through the bluetooth and sends the audio
out to a midi board.

My main problem here is that I don't know how to connect the two
bluetooth without the "friendly" pc interface.
I know that I should find out the eb500 adress, but I really have no
idea how to do that. Can you help me with it please?? Deadline
Thursday. Thanks a lot!!



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Connecting eb500 to bx24 HELP - femme_pacita - Dec 6 8:59:09 2007


> Ups, sorry, somehow I thought both bluetooth had to be COM3.
> Now my problem is that I don't know how to recieve the MIDI that my bx
> is sending out. Should I connect another BX to the PC? How can I do
> that so incoming data can be trasfered to the MIDI box? Or is there
> some program that can read the data that I'm sending in the pc itself,
> so I can trasfer it to some audio program?
>
> By the way, thanks SO MUCH for your help. I'm hanging on a cliff here.
>
> --- In b...@yahoogroups.com, Tom Becker wrote:
> >
> > > ... when I tell the bluetooth in the pc to detect the other
one, it
> > only finds a COM5...
> >
> > That's probably correct. COM5 is the _PC_ COM5, a logical port
> assigned
> > to _its_ Bluetooth device. COM5, on the PC, is the port you must
> use to
> > talk to the remote radio. Try running a terminal program on the
PC and
> > look at COM5.
>



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Connecting eb500 to bx24 HELP - femme_pacita - Dec 6 16:42:34 2007

Sorry for that- As you must suspect, I have slept 8 hours in the last
4 days, and now we finally succeded. And really, I couldn't have done
it without your help and advise.

We used a code called s2midi that detects midi input from the serial,
so we could send data via bluetooth. The rest is history.

Thanks a lot

Maria

--- In b...@yahoogroups.com, "Tom Becker" wrote:
>
> I guess it must be Thursday. I suspect, unless he has, indeed, built
> the time machine and we'll hear from him again last week, he's on his
> way home for the holidays, I'll bet.
>
> Who would like a no-reward job teaching strangers who take, take some
> more, and some more, then vaporize, leaving not a hint if you were
> helpful or foolishly wasteful of your time? You'll need to provide
> your own tools, supplies and workspace, but the perks are, uh, uh,
> well, there are no perks.
> Tom
>



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Connecting eb500 to bx24 HELP - femme_pacita - Dec 6 17:57:40 2007

This code worked perfect with S2Midi program. I sent data with a eb500
connected to the BX and was read by the Hyper Terminal. I don't have
the MIDI code in here, but here it is for connecng eb500 and Hyper
Terminal in a pc.
Public Sub Main()
dim ibuffer as byte
dim obuffer as byte
dim q1 (1 to 160) as byte
dim q2 (1 to 160) as byte

Call DefineCom3(16, 17, bx0000_1000)
Call OpenQueue (q1, 160)
Call OpenQueue (q2, 160)
Call OpenCom (3, 9600, q1, q2)

Do
Call PutQueueStr (q2, "funcion whatever")
call delay (0.2)
Loop
End Sub



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Connecting eb500 to bx24 HELP - Tom Becker - Dec 6 18:34:54 2007

I guess it must be Thursday. I suspect, unless he has, indeed, built
the time machine and we'll hear from him again last week, he's on his
way home for the holidays, I'll bet.

Who would like a no-reward job teaching strangers who take, take some
more, and some more, then vaporize, leaving not a hint if you were
helpful or foolishly wasteful of your time? You'll need to provide
your own tools, supplies and workspace, but the perks are, uh, uh,
well, there are no perks.
Tom



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Connecting eb500 to bx24 HELP - Tom Becker - Dec 8 5:39:51 2007

--- In b...@yahoogroups.com, "femme_pacita" wrote:
> Maria

Well, he's a she! There was a hint, I guess, but no matter. Maria, I
still somehow have little idea of what you did, but I'm glad to hear
that it sufficed.
Tom



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )