20x2 to XBEE to SD-MP3 module problems

Randy5140

Member
Hello all!
I am trying to get an sd-mp3 card (midfly tdb380) to play specific sounds via two xbees

I have two boards each with picaxe 40x2's and xbee modules


Trans code:


Code:
'picaxe pinout
'B.7 = xbee transmit pin  (xbee pin2)
'B.6 = xbee rec pin          (xbee pin3)
'B.5 = xbee sleep pin       (xbee pin9)
'B.4 = sd-mp3 busy pin
'B.3 = sd-mp3 rec pin
'B.2 = sd-mp3 trans pin
'B.1 = out to AXE133Y 
'A.0 = switch 1  (norm high)
'A.1 = switch 2  (norm high)
'A.2 = switch 3  (norm high)







pause 2000					'TIME FOR SYSTEM TO BOOT


CHECKBUTTONS:
if pina.0 = 0 then			'BUTTON #1 PUSH
pause 1000					'DEBOUNCE FOR BUTTON
serout b.7, T4800,(#001,cr)  		'SENDS DATA THRU PIN B.7 TO XBEE
SEROUT B.1,N2400,(254,128,"$001")  	'SENDS TRANSMITTED DATA TO LCD FOR VERIFICATION THAT PROGRAM IS CONTINUEING   
high D.2					'TURNS ON LED TO VERIFY THAT BUTTON PUSH IS REGISTERED
pause 2000					'GIVES TIME TO LOOK AT LED TO VERIFY THAT BUTTON PUSH IS REGISTERED AND PROGRAM IS RUNNING
low D.2					'TURNS OFF LED INDICATOR


ELSEif pina.1 = 0 then			'BUTTON #2 PUSH
pause 1000					'DEBOUNCDE FOR BUTTON
serout b.7, T4800,(#002,cr)		'SENDS DATA THRU PIN B.7 TO XBEE
serout b.1,N2400,(254,128,"$002")	'SENDS TRANSMITTED DATA TO LCD FOR VERIFICATION THAT PROGRAM IS CONTINUEING 
high D.2					'TURNS ON LED TO VERIFY THAT BUTTON PUSH IS REGISTERED
pause 2000					'GIVES TIME TO LOOK AT LED TO VERIFY THAT BUTTON PUSH IS REGISTERED AND PROGRAM IS RUNNING
low D.2					'TURNS OFF LED INDICATOR


ELSEif pina.2 = 0 then			'BUTTON #3 PUSH
pause 1000					'DEBOUNCDE FOR BUTTON
serout b.7, T4800,(#003,cr)		'SENDS DATA THRU PIN B.7 TO XBEE
serout b.1,N4800,(254,128,"$003")	'SENDS TRANSMITTED DATA TO LCD FOR VERIFICATION THAT PROGRAM IS CONTINUEING 
high D.2					'TURNS ON LED TO VERIFY THAT BUTTON PUSH IS REGISTERED
pause 2000					'GIVES TIME TO LOOK AT LED TO VERIFY THAT BUTTON PUSH IS REGISTERED AND PROGRAM IS RUNNING
low D.2					'TURNS OFF LED INDICATOR

end if

goto CHECKBUTTONS







receive code:


Code:
'the data is recieved thru the xbee connected to pin B.6 of the 40x2
'I am trying,, and I guess its working to put the data received thru pin B.6 (serin B.6) into the veriable b34
'then I an trying to have b34 (the data received) sent to the sd-mp3 module thru pin B.3
'the lcd thru the 40x2 pin b.1 is only for reference that the correct data is being sent out and if nothing shows on the 
'lcd screen it indicates the program is stalling somewhere on or before the "serout B.1,N2400,(254,128,#b34) code  line


'picaxe pinout
'B.7 = xbee transmit pin    (xbee pin2)
'B.6 = xbee rec pin            (xbee pin3)
'B.5 = xbee sleep pin         (xbee pin9)
'B.4 = sd-mp3 busy pin
'B.3 = sd-mp3 rec pin
'B.2 = sd-mp3 trans pin
'B.1 = out to AXE133Y 
'A.0 = switch 1  (norm high)
'A.1 = switch 2  (norm high)
'A.2 = switch 3  (norm high)


'receive code
	high B.6					'SETS B.6 (RECEIVE PIN FROM XBEE) HIGH SO THAT INCOMEING DATA IS READY TO BE RECEIVED
	high B.3					'SETS B.3 (OUTPUT PIN TO SD-MP3 MODULE) HIGH SO THAT PICAXE IS READY TO SEND DATA  TO MP3 MODULE

	serout B.3,T4800,($EF)			'STOPS SD-MP3 MODULE
playsong:
	serout b.1,n2400,(254,1)		'CLEARS LCD MONITOR 
	serin B.6,N4800,b34			'RECEIVES DATA FROM XBEE AND PUTS IT IN b34
	serout B.1,n2400,(254,128,#b34)	'SENDS RECEIVED DATA FROM XBEE TO LCD TO VERIFY DATA IS BEING RECEIVED
	serout B.3,T4800,(b34)			'SEBDS b34 (RECEIVED DATA) TO SD-MP3 MODULE
	goto playsong

The xbee modules have been programed at 4800 baud

I also have an axe210 board with xbee inserted, that during testing is connected to the pc with an axe027 download cable to try and monitor what's going on.

I also have a sparfun xbee comport/programing board with xbee inserted programed at 4800 for monitoring what's going on.

I program board #1 with the transmit code
I program board #2 with the receive code

when I push button #1 on the transmit board:
1. all 4 xbees flash the send/receive led
2. the receive board is evidently receiving the data thru the 40x2 as the busy light on the sd-mp3 module comes on
3. the terminal on the programing editor shows the data coming thru the xbee mounted on the axe210 ( 1,2 or 3 according to which button is pushed)
4. the terminal on the pc (the one in the xctu program) shows the data being received (1,2 or 3 according which button is pushed)

I am thinking either the correct data is not being loaded into b34 or something in my use of # or $ is wrong.

I have read over the long posting on the tendra sd-mp3 module but somewhere I have gotten something wrong,,

can someone please look over my code and tell me where I messed up?

I spent the whole day yesterday trying different things, sometimes it will play a sound,, but it is never the correct one.

the sd card has been formatted and I used drive sort to check and order the files, even though there are currently only three I am working with.

Thanks in advance
Randy
 
Last edited:

1968neil

Senior Member
you need to use the $ and not the # in front of any number that is sent to the mp3 module as you suspect.
ie: serout pin baud ($001) must be in hex or it wont work as you expect.

Regards
Neil
 

Randy5140

Member
Neil,

The ($001) works fine hardwired,, directly from the picaxe to the sd-mp3 module.

I still cannot get the sd-mp3 module to work from one chip(board) to the other via the xbee.

I spent most of the day trying different things, sometimes it will play, but never has it played the expected song.


I guess I really don't understand what is being sent via the xbee. or something,,,,,

Saturday I spent most of the day building new boards. I used two perf boards each with an 18m2, sd-mp3 (midfly),audio amp module and an xbee.

using these boards.

my transmit code (last used/testing) serout B.7,T4800,($004)

The receive code serin C.6,T4800,b0 trying to get the $004 into b0
Then on the receive board, serout C.2,($b0) sent to the mp3 module.

I have the ax210 plugged into the picaxe programing cable and the terminal in the programing editor on screen. it shows information being received by the xbee, but it appears to be garbage,, (baud rate is set to match the xbee module.)


Any ideas on what I am doing wrong?


Randy
 

hippy

Ex-Staff (retired)
The receive code serin C.6,T4800,b0 trying to get the $004 into b0
Then on the receive board, serout C.2,($b0) sent to the mp3 module.
$B0 is a hexadecimal constant, not a variable. If b0 contains $04 then simply send b0 -

serout pin, baud, (b0)
 

Randy5140

Member
Hippy,


OK,,

this is what I am trying to do:


Thru a button push, I send serout B.7,T4800,($004) to the xbee transmit from Board 1


On board 2 the xbee receives the information and sends it to the picaxe at: serin C.6,T4800,bo ( I am guessing the received information via the xbee will then be put into b0)

then on board 2 the picaxe sends the information to the sd-midi module via: serout C.2,T4800,(b0,cr)
 

hippy

Ex-Staff (retired)
on board 2 the picaxe sends the information to the sd-midi module via: serout C.2,T4800,(b0,cr)
You do not need to send the CR to the module.

Start simple -

high C.2
Pause 1000
serout C.2,T4800,( $01 ) ' Play song 001
Pause 5000
serout C.2,T4800,( $EF ) ' Stop playing
end

Does that play the first song for 5 seconds then stop ?

If so then this should do the same -

b0 = $01
high C.2
Pause 1000
serout C.2,T4800,( b0 ) ' Play song
Pause 5000
serout C.2,T4800,( $EF ) ' Stop playing
end

Now alter the $01 to $02, $03 and check that plays song 002, song 003 etc.

Get everything working reliably before adding an XBee into the mix.
 

hippy

Ex-Staff (retired)
Good news. Now get the two PICAXE talking to each other through the Xbee's ...

Transmitter:
Do
SerOut B.7,T4800,(b0)
Pause 1000
b0 = b0 + 1
Loop

Receiver:
#Terminal 4800
Do
SerIn B.6, T4800, b0
SerTxd( #b0, " " )
Loop

Once the receiver code is downloaded, does that launch the terminal windows and show incrementing numbers ?
 

Randy5140

Member
Hippy,
didn't work,, looked at code and I have C.6 as serin from the xbee,, changed code to C.6

it works,, programed board 1 as transmit and board 2 as receive,, let the count run to 255 and then it started over at 0

programed board 1 as receive and board 2 as transmit, let the counter run to 255 and then it started over at 0

I made a change to the code to add a switch trigger to start the count. worked perfectly

no changes to the board,,
 

hippy

Ex-Staff (retired)
EXcellent. So we have PICAXE->XBee->XBee-PICAXE working and PICAXE->MP3 working. Change the transmitting PICAXE to use -

SerOut B.7,T4800,("CMD",b0)

And receiver to use -

SerIn C.6, T4800, ("CMD"), b0

And check it all still works. Then you can modify the transmitter to send the data you ultimately need to send via XBee then modify the receiver to pass that data to the MP3 player ...

SerIn C.6, T4800, ("CMD"), b0
SerOut B.7, T4800, (b0)

And finally you can add the LCD handling code.
 

Randy5140

Member
Hippy,,,

At work again,,

will check it again tonight, but I think this will solve my problem,, I just couldn't figure out how to get the "cmd" into b0.

I will let you know how it works out.

Thanks for everything so far! :)
 

Randy5140

Member
Hippy,

question,, where,, SerOut B.7,T4800,("CMD",b0)

is, CMD supposed to be "CMD" or the song number like $01 ?


and

where,, SerIn C.6, T4800, ("CMD"), b0

is, "CMD" supposed to be "CMD" or the song number like $01 ?
 

hippy

Ex-Staff (retired)
"CMD" can be any sequence of letters, digits or characters. It is used to qualify the data sent so the receiver knows the data is as expected and only used to synchronise data from transmitter to receiver; it has no relevance to what is later sent to the MP3 player.
 

Randy5140

Member
Hippy,


got it I think,, will understand more when I can experiment tonight.

how late to you monitor this stuff,, there is about 5 hours difference between us.

its about 2:50 here so I am guessing its about 7:50 there,,, right?
 

Randy5140

Member
Hippy,


Hey copied and pasted the code into the transmit and receive code from yesterday:

Transmitter:
Do
SerOut B.7,T4800,("CMD",b0)
Pause 1000
b0 = b0 + 1
Loop





Receiver:
#Terminal 4800
Do
SerIn C.6,T4800,("CMD"),b0
SerTxd( #b0, " " )
Loop


I get nothing on the terminal
 

Randy5140

Member
Hippy,.

Here is what I am getting:

if I program this:

Transmitter:
Do
SerOut B.7,T4800,(b0)
Pause 1000
b0 = b0 + 1
Loop


Receiver:
#Terminal 4800
Do
SerIn C.6, T4800, b0
SerTxd( #b0, " " )
Loop


The results in the terminal are:

1,2,3,4,5,6,7,8 thru 255 then starts over at 0

The results are the same with, bd1 Trans and bd2 rcv or, bd2 Trans. and bd1 Rcv.

if I program this:

Transmitter:
Do
SerOut B.7,T4800,("CMD",b0)
Pause 1000
b0 = b0 + 1
Loop


Receiver:
#Terminal 4800
Do
SerIn C.6, T4800, ("CMD"), b0
SerTxd( #b0, " " )
Loop

The Results In The Terminal Are:
blank terminal

The results are the same with, bd1 Trans and bd2 rcv or, bd2 Trans. and bd1 Rcv


***************************************************************************************************

Playing around trying different stuff:

If I program this:


Transmitter:
Do
SerOut B.7,T4800,("CMD",b0)
Pause 1000
b0 = b0 + 1
Loop

Receiver:
#Terminal 4800
Do
SerIn C.6, T4800, b0
SerTxd( #b0, " " )
Loop

The Results In The Terminal Are:

67,67,67,67 continuous

I let it run over 255 counts.

The results are the same with, bd1 Trans and bd2 rcv or, bd2 Trans. and bd1 Rcv
*****************************************************************************************************
 

hippy

Ex-Staff (retired)
The ASCII value of "C" ( first character of "CMD" ) is 67 so it appears the "C" at least is getting through. It is probably that the received data is arriving too fast for the SERIN to keep up.

Using SETFREQ and adjusting the baud rate constant to reflect that change might solve that but the simplest solution is to remove the "CMD" for now in both transmitter and receiver. We know that works so build upon what does work.
 

Randy5140

Member
Hippy,,


that makes some since as,, off and on,,, I was also monitoring the xbees via an axe110 and when the download cable was plugged into it, the terminal would read "cmd" then a symbol,, the symbol would change with each new "cmd" received.

would resetting the xbees to a lower baud rate make a difference?
 

Randy5140

Member
Hippy,,


another thought,, would proximity of the xbee's to each other make a difference?

I have been testing with them within a foot or so of each other.

I remember when we used 72mhz on our radio control airplanes if we got the antenna too close the the model the servos would glitch around.

I know I am up on 2.4ghz,, but,,,,,,,,
 

hippy

Ex-Staff (retired)
Dropping the baud rate would probably help; that gives the SERIN more time in the stop bit of each byte for the incoming data to be stored and for it to move on to receiving the next.

Being too close can be an issue but if you are receiving data it would seem it is okay.
 

Randy5140

Member
Hippy,,

OK,, got something out of it!

I first tried changing the frequency to setfreq m8
didn't help.

then,

Using the XCTU software, I reprogramed the xbees to 2400 baud.

I also changed the packetization timeout from 3 to 6.

then changed the picaxe program as below:

Transmitter:
Do
SerOut B.7,T2400,("CMD",b0)
Pause 1000
b0 = b0 + 1
Loop


Receiver:
#Terminal 2400
Do
SerIn C.6, T2400, ("CMD"), b0
SerTxd( #b0, " " )
Loop

Didn't get anything to show on the terminal, just for the heck of it,, I changed the baud setting on the terminal back to 4800 and it started printing out numbers!

1,2,3 etc. thru 255 then started over

is that what I am supposed to see?

Or should CMD1, CMD2,CMD3,CMD4 etc. be expected?

I am asking because with the cable connected to the axe110, I see CMD then a symbol, the symbol changes each time CMD displays.

I am also wondering why I had to change the terminal to 4800 to get anything to show???
 

Hemi345

Senior Member
I changed the baud setting on the terminal back to 4800 and it started printing out numbers!

1,2,3 etc. thru 255 then started over

is that what I am supposed to see?

Or should CMD1, CMD2,CMD3,CMD4 etc. be expected?
No, you should just be seeing the numbers. "CMD" is the qualifier....like a secret handshake.
 

Randy5140

Member
First I want to say thanks to everyone here,, especially Hippy, Neil and Hemi345!
This is a great place to LEARN!!
I like the way things are put forth,
steps
get one level working thru testing and getting to understand what is being done in the coding.
then go to the next level and learn that!
Much better than someone just throwing some working code on the forum and then letting someone copy and paste it,,
Nothing learned from that!

So,,, Thanks again all!!





GOOD NEWS!!! :)

OK,, pulled almost an all-nighter last night on this thing,,

and finally got it working,, don't know how, but it works with my setup.

The program:

Transmitter:

if PINC.7 = 0 THEN
b0 = $001
SerOut B.7, T2400,(b0)

HIGH B.3
PAUSE 1000
LOW B.3
SEROUT C.2,T4800,($01,CR)



ELSEif PINC.0 = 0 THEN
b0 = $005
SerOut B.7, T2400,(b0)
Pause 1000
HIGH B.3
PAUSE 1000
LOW B.3


ELSEif PINC.1 = 0 THEN
b0 = $003
SerOut B.7, T2400,(b0)
Pause 1000
HIGH B.3
PAUSE 1000
LOW B.3
ENDIF
GOTO TRANSMITTER







#Terminal 4800
HIGH C.6
Receiver:

SerIn C.6,T2400,b0
SEROUT C.2,T4800,(b0)
HIGH B.3
SerTxd(#b0)
LOW B.3
GOTO RECEIVER



I tried leaving the "CMD" handshaking in, but with it in on the terminal I would get numbers showing up like 243, then next transmission,245 then 247,,

seemed to jump over even numbers. ????

also,, using $01 didn't work,, had to use $001.

I have only tested this with numbers up to 006,,

by using three digits,, what do I do when I reach 10?
 

hippy

Ex-Staff (retired)
also,, using $01 didn't work,, had to use $001.
No matter how many leading zeroes you type the compiler will see it as the same number, put the exact same value into the PICAXE chip to be sent. Not working will be because of something other than how many leading zeroes there are.

Using Txxxx baud rates you should set the pin being used for serial output HIGH at the beginning of the program or the first data byte sent may become corrupted or be missed. Adding a "CMD" or other qualifier for the XBee to XBee comms ensures the receiver does not get any corrupt data which it may then pass on to the MP3 player.

Your receiver "HIGH C.6" before using "SERIN C.6" is not correct; it sets the input pin as an output and may damage the XBee connected to that pin. It should be "HIGH C.2".
 

Randy5140

Member
Hippy,,

Thanks,,,,noted,,


On Receive,,
will change High C.6 to High C.2

On Transmit,,

will add High B.7


Will let you all know how it works tonight! :)
 
Top