Shop OBEX P1 Docs P2 Docs Learn Events
Audio Playback with the Basic Stamp — Parallax Forums

Audio Playback with the Basic Stamp

mattbstrongmattbstrong Posts: 21
edited 2012-10-21 02:42 in BASIC Stamp
I am looking for a way to play back audio using the BS2. I really like the waveshield but I have not been able to find any information about its compatibility with a BS2. Does anyone know if a BS2 can be used to control a waveshield (for the arduino)? If so, can you point me to some documentation?

If the waveshiled is not compatible with the BS2 what are some other options? I need to store about 3 dozen very short audio clips (a few seconds each) and play them back in any order I want.

Thanks.
«1

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-08-21 06:21
    The Rogue Robotics uMP3 can also be used with a Stamp as its controller.

    The Stamp will not work with the Wave Shield. The Wave Shield relies on the Arduino to do most of the work of reading the audio data off the SD card and presenting it to a DAC (digital to analog converter). The Stamp is neither fast enough nor has enough RAM memory to do this. The AP-16+ uses a Propeller to do the same kind of work as the Arduino and has a more powerful audio amplifier. The uMP3 uses a special purpose MP3/WAV player chip to do the work.
  • ercoerco Posts: 20,256
    edited 2012-08-21 10:02
    Here's a thread with links to some cheap MP3 boards, but AFAIK no one's gotten it working yet. I have both boards mentioned, but have not had time to test them yet and likely won't get to them for another month.

    http://forums.parallax.com/showthread.php?141091-10-Full-Control-MP3-Player&p=1119861
  • mattbstrongmattbstrong Posts: 21
    edited 2012-08-21 12:05
    Thanks for the suggestions. I ordered the SD Card MP3 Player Module w/ 6 Output Control from MDFly. I only need one out put but the cheaper single outpu modules were sold out. Still, at $22 shipped this is a great deal!

    Thanks for the help.
    Matt
  • ercoerco Posts: 20,256
    edited 2012-08-21 13:44
    Happy to help. When you get it going, please report back in that other thread with your findings, that will help others and probably me since you're likely to do it first!
  • mattbstrongmattbstrong Posts: 21
    edited 2012-09-05 20:47
    I am not having any luck making this work. Does anyone have some sample code they can post of how to control the MDFly MP3 Player board with a BS2?
  • Mike GreenMike Green Posts: 23,101
    edited 2012-09-05 22:07
    I've not heard of anyone using the MDFly MP3 player. Have you hooked it up using the information in the documentation provided at MDFly? What program are you using to control it? Please include a schematic of how you've hooked it up and a listing of your program and we'll try to help you.
  • mattbstrongmattbstrong Posts: 21
    edited 2012-09-05 22:47
    I have connected the MDFly MP3 Module (AU5106) to the BS2 in the follong way.

    MP3 BS2

    Pin 1 Vss
    Pin 2 Vdd
    Pin 3
    Pin 4
    Pin 5
    Pin 6 Pin14
    Pin 7 Pin15
    Pin 8 1K->Speaker->Vss
    Pin 9
    Pin 10
    Pin 11
    Pin 12
    Pin 13

    The datasheet provided by MDFly does not provide much help but it can be found here:

    http://mdfly.com/Download/Module/AU5106_spec.pdf

    I am not really sure where to start. I would love some help simply sending a comand to the module and then reading back the retrun code. If someone can help me get that far I think I can figure out how to make the rest work.

    I have been trying to use SEROUT and SERIN in the follwing way:

    Send a STOP command to the module:
    SEROUT 14,84,[$EF] 'STOP module

    I am not sure if I am using the correct baud rate or if I should even be using SEROUT. I have no idea how to use SERIN to read the return code.
  • mattbstrongmattbstrong Posts: 21
    edited 2012-09-05 23:18
    I was juat able to get the Green Play LED on the MDFly Module to turn green with the following command:

    TXMP3 PIN 14
    RXMP3 PIN 15
    PAUSE 3000 'Allow module to fire up
    SEROUT TXMP3,84,[$01] 'Play track 01

    But still no sound. I don't know if the volume is too low or if I have activated the correct output pin on the module. I cannot seam to get SERIN to work so that I can read things from the module like the current volume.
  • mattbstrongmattbstrong Posts: 21
    edited 2012-09-05 23:28
    OK. I am able to flash the play LED on the module on for 3 seconds and then off for 3 seconds three times in a row with the following code. It doens't work every time. I am not sure why it doesn;t work everytime if anyone has any ideas. Still no sound.

    TXMP3 PIN 14
    RXMP3 PIN 15
    PAUSE 3000 'Allow module to fire up
    start:
    DEBUG "PLAY 01.1",CR
    SEROUT TXMP3,84,[$01] 'Play track 01
    PAUSE 3000
    SEROUT TXMP3,84,[$EF] 'Stop play
    PAUSE 3000
    DEBUG "PLAY 01.2",CR
    SEROUT TXMP3,84,[$01] 'Play track 01
    PAUSE 3000
    SEROUT TXMP3,84,[$EF] 'Stop play
    PAUSE 3000
    DEBUG "PLAY 01.3",CR
    SEROUT TXMP3,84,[$01] 'Play track 01
    PAUSE 3000
    SEROUT TXMP3,84,[$EF] 'Stop play
    PAUSE 3000
  • mattbstrongmattbstrong Posts: 21
    edited 2012-09-06 00:31
    Well, I might be in trouble now. I think I switched the module to 115200 baud. Since the BS2 cannot go faster than 9600 is there anything I can do to switch the module back to 9600?
  • Mike GreenMike Green Posts: 23,101
    edited 2012-09-06 07:06
    The connections that you showed in Post #9 don't match the connections shown in the documentation you posted. That could explain why it doesn't work.

    If you did connect it properly somehow and changed the Baud to 115K, there's no way to change it back with a Stamp. The maximum transmit Baud for a BS2 is 9600. You'd have to get some kind of serial adapter for your PC like Parallax's USB2SER adapter and use the PC to send a "change Baud to 9600" command to the MP3 player at 115KBaud.

    Your MP3 player has a headphone output. You can't drive a speaker without some kind of amplifier. Try earphones. Also, the A_GND connection ("analog ground") has to be connected to ground, ideally close to the power supply to minimize pick up of digital noise. For testing and experimentation, this usually doesn't matter, just connect A_GND to the same place as GND.
  • mattbstrongmattbstrong Posts: 21
    edited 2012-09-06 08:33
    Thank you for the help so far. Electrical design is not my strength. In post 9 I numbered the pins backwards. This is how I have it hooked up now. The speaker is a little 0.25W speaker that I have used with the FREQOUT and BS2 before. Is this right? Also, if I was going to connect headphones do I connect them to Pins 11 and 9 or to one of the speaker pins?

    MP3 BS2

    Pin 13 Vss
    Pin 12 Vdd
    Pin 11
    Pin 10 Vss
    Pin 9
    Pin 8 Pin14
    Pin 7 Pin15
    Pin 6 1K->Speaker->Vss
    Pin 5
    Pin 4
    Pin 3
    Pin 2
    Pin 1

    My BOE has the same FTDI chip on it that is on the USB to SERIAL adapter you showed me. Is there a way to use the BOE to set the baud back to 9600? How do I hook up it up and what software do I use to send the command?
  • mattbstrongmattbstrong Posts: 21
    edited 2012-09-06 09:23
    OK. I switched the speaker to the head phone pin 11. I now get sound (very quite sound).

    I am now trying to use the BOE as a USB3SER adapter so that I can change the baud on the MP3 player bacck to 9600.

    I think I have the wiring figured out.

    TX on the MP3 ----> SERIN on the BOE
    RX on the MP3
    > SEROUT on the BOE

    Now I am trying to find some sort of Com Port Terminal.

    Is my wiring correct?
    What tool can I use to send the hex command to COM4 at 115200 Baud?
  • Mike GreenMike Green Posts: 23,101
    edited 2012-09-06 10:50
    It looks like all the digital pin connections and power connections are ok. I have no idea why you've connected the speaker to I/O pin 6. You need to connect a pair of earphones so the right one is connected to (R) and the left one is connected to (L) while the common lead or both other leads of the earphones is connected to A_GND (and Vss). This MP3 player is not designed for use with a speaker. It puts out maybe 3mW per channel while your speaker won't produce much sound at that at all.

    You can't use the BOE as a USB2SER adapter without some extra parts. Specifically, the BS2 uses inverted signals for its programming interface (Sin and Sout) while your MP3 player uses normal (non-inverted) signals. You'd need an inverter like part of a 74HC04. If you use the BOE's USB to serial interface, make sure to leave the BS2 module out of its socket so it doesn't interfere with the signals from the board's USB to serial interface.

    You'll probably have to write a program for your PC to send a command to your MP3 board. How to do that depends on what you're familiar with. You could use Visual Basic. I've used Chipmunk Basic for this sort of project since it will talk to serial ports. It was developed for the Mac, but now has Windows and Linux versions as well and it's free and trivial to install.
  • mattbstrongmattbstrong Posts: 21
    edited 2012-09-06 10:56
    Is there a commonly availble USB2Serial adapter I could use? I was hoping to finish this project to day and don't have time to wait for shipping from Parallax. I have an old desktop that has a serial prot on it. I wonder if I could use that? Any advice on how to hook it up?

    I found a COM Port terminal called "The Advanced Serial Port Terminal 6 by Eltima Software" that looks like it will let me send and receive HEX.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-09-06 11:19
    You could use a standard serial port, but, again, you'd need some external parts. A MAX232 will convert the serial port signals to something the MP3 player can use. There are plenty of examples of its use on the web. Here's one.

    There's also a quick and dirty serial adapter that uses a couple of transistors, resistors, and capacitors that you can get at a RadioShack. It's normally used for programming a Propeller, but would work for your MP3 board if you powered it from 5V instead of 3.3V as shown in this schematic. Leave out all of the stuff connected to the RESn pin of the Propeller up through the 0.01uF capacitor. It's not needed for your project. You do need the connection to DTR and the 10K resistor. Note that the pin marked Rx is the output from the adapter while the pin marked Tx is the input to the adapter.
  • mattbstrongmattbstrong Posts: 21
    edited 2012-09-06 11:43
    OK. I am off to Radio Shack. I will report back soon.
  • mattbstrongmattbstrong Posts: 21
    edited 2012-09-06 13:26
    I bought all the parts but I having trouble gettign it to work. When it works, will is show up as a COM port in my device manager on my PC?
  • mattbstrongmattbstrong Posts: 21
    edited 2012-09-06 14:02
    As much as I hate to admit it... I give up on the quick and simple. I ordered a USB2SER adapter and I will have to wait for it to arrive. I will let you know what comes of things.
  • mattbstrongmattbstrong Posts: 21
    edited 2012-09-06 14:11
    I just found my old Serial BOE. Can I use this to talk to my MP3 Player?
  • Mike GreenMike Green Posts: 23,101
    edited 2012-09-06 14:34
    1) The quick and dirty serial port adapter does two things ... It converts the voltages used for RS232 (-3 to -12V and +3 to +12V) to 0V/5V levels used by 5V digital logic like the Stamp and it inverts the sense of the signal in the process so negative voltages are 1 and positive voltages are 0. The serial port should already be recognized as either COM1 or COM2. Adding the adapter doesn't change any of that unlike what happens when you add a USB type adapter.

    2) The serial BOE won't help you much. The BOE's serial interface to the Stamp's SIN / SOUT programming pins is pretty minimal and doesn't do the voltage conversion or the inversion.

    3) You didn't say how much experience you have in terms of basic electronics. The serial port adapter circuit is pretty simple. If it doesn't work, you may have wired it incorrectly. It's easy to get the transistors wired incorrectly since some transistors have their pins in one order and others have them in a different order. They're often marked on the case, but sometimes the description on the packaging is the only place to find the pin-out
  • mattbstrongmattbstrong Posts: 21
    edited 2012-09-06 14:56
    I can find my way around a schematic but I am no EE. Maybe I'll just take a break from the project for a bit and come back to it. I tried wiring everything up on a breadboard but didn’t have any luck. Maybe I got the serial connector wrong. I bought a female 9 pin serial connector at RadioShack and wired it as follows. Is this right?

    Pin2 RX
    Pin3 TX
    Pin4 DTR
    Pin5 Vss

    I connected the DTR line to the RX line with a 10K resistor but left the 0.01 Cap off and everything that is down circuit from the cap the RES line.

    I connected the line labeled Rx(P31) to the TX line on the MP3 Player.
    I connected the line labeled TX(P30) to the RX line of the MP3 Player.
    I connected the line labeled Vss to the same Vss used by the MP3 Player.
  • mattbstrongmattbstrong Posts: 21
    edited 2012-09-06 15:03
    Maybe my old Serial BOE won't do the job but it could serve as common point of reference for us. What if I built the circuit on the BOE using the following Pinout?

    BOE
    Cicuit(left side)
    SOut
    Tx
    SIn
    Rx
    Vss
    Vss

    Circuit(right side)---MP3
    Rx(P31)
    Rx Pin8
    Tx(P30)
    Tx Pin7
    Vss
    Grnd
  • Mike GreenMike Green Posts: 23,101
    edited 2012-09-06 16:18
    Try swapping the RX and TX connections on the MP3 player. The pin 31 Rx and pin 30 Tx designations on the schematic are relative to the Propeller and probably for the MP3 player.

    Forget the serial BOE for now. The voltage regulator on it can be used and the breadboard area can be used. The rest is not really helpful for now
  • mattbstrongmattbstrong Posts: 21
    edited 2012-09-06 17:40
    Do I need to connect anything to DTR?
  • Mike GreenMike Green Posts: 23,101
    edited 2012-09-06 17:49
    Yes, DTR serves as a source of some negative voltage for the PC's serial port since neither the adapter nor the MP3 player can provide that.
  • mattbstrongmattbstrong Posts: 21
    edited 2012-09-06 18:27
    Still no luck. I don't know what I am doing wrong. The circuit is simple and I have tried it with every pin out for the 3904 and 3906 possible. I have also tried switching the tx and the rx lines.

    Any other thoughts?
  • mattbstrongmattbstrong Posts: 21
    edited 2012-09-06 18:50
    The Vss that is at the right side of the circuit... what pin on the MP3 do I connect that to? Ground?

    Is there a way to test the circuit without using the MP3 board to see if I have assembled it correctly?
  • Mike GreenMike Green Posts: 23,101
    edited 2012-09-06 20:40
    The Vss on the right side of the adapter schematic would be connected to the MP3 player ground. Remember that you also need a source of 5V. You could just connect the point marked 3.3V on the original schematic to Vdd on the MP3 player since that's the +5V connection to the MP3 player and they all have a common ground (as it should be).

    You could test the circuit with a voltmeter. Really the transmit side (to the MP3 player) is the only one that's crucial. The idle (resting) voltage of that should be +5V. If you transmit a stream of characters with mostly 0 bits in them, like a byte of all zero bits or even something like a space, the output voltage should drop to near 0V. A transmitted character has 10 bits, a start bit that's always 0, a stop bit that's always 1, and the 8 bits of the character. If you transmit all zero bits quickly so there's no idle time between characters, that's 9 out of 10 bits with zeros, so the average voltage should be somewhere near 5 x (10-9)/10 = 0.5V.
Sign In or Register to comment.