December 03, 2024, 10:08:17 AM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


Using the uMP3 with the Prop-1

Started by JonnyMac, March 04, 2007, 01:09:43 PM

Previous topic - Next topic

JonnyMac

March 04, 2007, 01:09:43 PM Last Edit: January 26, 2008, 02:17:59 PM by JonnyMac
The uMP3 player from Rogue Robotics is a great way to add high-quality, stereo audio to your prop or display, and with just a little bit of effort and code (provided below), you can control it with the Prop-1.

The uMP3 player requires two control lines: TX (transmit to) and RX (receive from).  The Prop-1.TX pin (5) will connect to the uMP3.R pin; the Prop-1.RX pin (4) will connect to the uMP3.T pin.  The Prop-1 can provide 5v power to the uMP3 as well.  I typically build a custom cable.   As with other serial devices, the ULN2803 output driver chip will interfere with the uMP3 player and needs to be modified.  This is easy: simply pull the ULN2803 from its socket, remove pins 1 - 4 (corresponds to I/O P5 - P4) with diagonal cutters, and then reinstall the ULN2803.  Use the diagram below as a guide for removing the correct pins from the ULN2803 (the dotted line idicates the UN2003, the seven-channel version).



By removing pin 1 of the ULN2803 the P7 output is available for serial communications with EFX-TEK serial accessories like the DC-16 and RC-4.

To connect the Prop-1 to the uMP3 I built a custom cable using 0.025" female crimp pin sockets and shells.  These parts are available from www.jameco.com:

Part numbers edited: 26 JAN 2008


#100766   female crimp pin
#108812   2-pin shell
#157382   3-pin shell
#159266   crimper tool

Use #22-gauge stranded wire to make the cable. Here's a diagram of my cable:




black   Vss (ground)
red   Vdd (+5vdc)
white   transmit (to uMP3)
yellow   receive (from uMP3)

Note that you may need to reconfigure the uMP3 to work with the Prop-1's baud rate.  For this you'll need to connect your PC to the uMP3 and use a terminal to change the uMP3 settings, specifically the baud and response delay parameters.  Complete details on this process as well as loading new firmware into the uMP3 are explained in my Nuts & Volts column from December 2005; you can read that article online here:

http://www.parallax.com/dl/docs/cols/nv/vol6/col/nv128.pdf

I've found that the easiest way to connect to the uMP3 is with Parallax's USB2SER converter.  You can find it here:

http://www.parallax.com/detail.asp?product_id=28024

The program below is fairly full-featured as it will let you play from a list of files store in an EEPROM table.  To play a file you'll put the file number into a variable called "theMP3" and then call the Play_MP3 subroutine.  The subroutine will wait until the file is done before returning.  The program is constructed such that you can return to the main body without waiting for the song to finish, and then check on it later with the Check_Status subroutine.


' =========================================================================
'
'   File....... uMP3_Demo.BS1
'   Purpose....
'   Author..... Jon Williams, EFX-TEK
'   E-mail..... jwilliams@efx-tek.com
'   Started....
'   Updated....
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  Sio             = 7                     ' for DC-16, RC-4; no ULN
SYMBOL  Trigger         = PIN6                  ' setup = DN
SYMBOL  TX              = 5                     ' to UMP3.R; no ULN
SYMBOL  RX              = 4                     ' to UMP3.T; no ULN


' -----[ Constants ]-------------------------------------------------------

SYMBOL  Baud            = OT2400

SYMBOL  Yes             = 1
SYMBOL  No              = 0


' -----[ Variables ]-------------------------------------------------------

SYMBOL  char            = B2                    ' character value
SYMBOL  theMP3          = B3                    ' MP3 file pointer
SYMBOL  eePntr          = B4                    ' EEPROM memory pointer
SYMBOL  lottery         = W5                    ' random value


' -----[ Initialization ]--------------------------------------------------

Reset:
  PAUSE 2000                                    ' let uMP3 start

Prod_uMP3:
  SEROUT TX, Baud, (13)                         ' send CR
  SERIN  RX, Baud, char                         ' get response
  IF char <> ">" THEN Prod_uMP3                 ' wait for ">"


' -----[ Program Code ]----------------------------------------------------

Main:
  RANDOM lottery
  IF Trigger = No THEN Main

  theMP3 = lottery // 3                         ' make 0 - 2
  GOSUB Play_MP3                                ' play it

  PAUSE 5000
  GOTO Main


' -----[ Subroutines ]-----------------------------------------------------

' Put file # to play in "theMP3"
' -- "theMP3" will be modified by subroutine

Play_MP3:
  eePntr = 0                                    ' reset pointer
  IF theMP3 = 0 THEN Send_Cmd                   ' at position, play it

Fast_Fwd:                                       ' move to selected title
  READ eePntr, char                             ' retrieve a character
  eePntr = eePntr + 1                           ' advance pointer
  IF char <> 0 THEN Fast_Fwd                    ' if not ., try again
    theMP3 = theMP3 - 1                         ' else, decrement file#
    IF theMP3 > 0 THEN Fast_Fwd                 ' if > 0, not at title yet

Send_Cmd:
  SEROUT TX, Baud, ("PC F /")                   ' start play command

Send_Name:                                      ' send file title
  READ eePntr, char
  eePntr = eePntr + 1
  IF char = 0 THEN Finish_Cmd
    SEROUT TX, Baud, (char)
    GOTO Send_Name

Finish_Cmd:
  SEROUT TX, Baud, (".MP3", 13)                 ' send extention + CR

Wait_For_Stop:                                  ' let song finish
  PAUSE 100
  GOSUB Get_Status
  IF char <> "S" THEN Wait_For_Stop
    RETURN

' -------------------------------------------------------------------------

Get_Status:
  SEROUT TX, Baud, ("PC Z", 13)                 ' request status
  SERIN  RX, Baud, char                         ' will be "S" or "P"
  RETURN


' -----[ EEPROM Data ]-----------------------------------------------------

' MP3 files are stored in root of SD card
' Table below needs only name, followed by a zero
' Keep names short to conserve EE space

MP3s:
  EEPROM ("Hello", 0)                           ' file #0
  EEPROM ("Wolf", 0)                            ' file #1
  EEPROM ("Scream", 0)                          ' file #2



Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

And if you're wondering how to do that same thing with a Prop-2, here's how (Note that I take advantage, where possible, of PBASIC 2.5 features):


' =========================================================================
'
'   File....... uMP3_Demo.BS2
'   Purpose....
'   Author..... Jon Williams, EFX-TEK
'   E-mail..... jwilliams@efx-tek.com
'   Started....
'   Updated....
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------


Sio             PIN     15                      ' for DC-16, RC-4; no ULN
TX              PIN     14                      ' to UMP3.R; no ULN
RX              PIN     13                      ' to UMP3.T; no ULN
Trigger         PIN     12                      ' setup = DN


' -----[ Constants ]-------------------------------------------------------

#SELECT $STAMP
  #CASE BS2, BS2E, BS2PE
    T2400       CON     396
    T4800       CON     188
    T9600       CON     84
    T19K2       CON     32
    T38K4       CON     6
  #CASE BS2SX, BS2P
    T2400       CON     1021
    T4800       CON     500
    T9600       CON     240
    T19K2       CON     110
    T38K4       CON     45
#ENDSELECT

Inverted        CON     $4000
Open            CON     $8000
EfxBaud         CON     Open | T38K4            ' for DC-16, RC-4
ump3Baud        CON     Open | T9600            ' for uMP3 player

Yes             CON     1
No              CON     0


' -----[ Variables ]-------------------------------------------------------

char            VAR     Byte                    ' character value
theMP3          VAR     Byte                    ' MP3 file pointer
eePntr          VAR     Word                    ' EEPROM memory pointer
pos             VAR     Word                    ' uMP3 file position
loopNum         VAR     Byte                    ' file loop # in cycle
lottery         VAR     Word                    ' random value


' -----[ Initialization ]--------------------------------------------------

Reset:
  PAUSE 2000                                    ' let uMP3 start

Prod_uMP3:
  DO
    SEROUT TX, ump3Baud, [CR]                   ' send CR
    SERIN  RX, ump3Baud, [char]                 ' get response
  LOOP UNTIL (char = ">")                       ' wait for ">"


' -----[ Program Code ]----------------------------------------------------

Main:
  RANDOM lottery
  IF (Trigger = No) THEN Main

  theMP3 = lottery // 3                         ' make 0 - 2
  GOSUB Play_MP3                                ' play it

  PAUSE 5000
  GOTO Main


' -----[ Subroutines ]-----------------------------------------------------

' Put file # to play in "theMP3"
' -- add DATA label entries to LOOKUP as required

Play_MP3:
  LOOKUP theMP3, [SFX0, SFX1, SFX2,
                  SFX3, SFX4, SFX5], eePntr     ' get base address

Send_Play_Cmd:
  SEROUT TX, ump3Baud, ["PC F /"]               ' start play command

Send_Name:                                      ' send file title
  DO
    READ eePntr, char
    eePntr = eePntr + 1
    IF char = 0 THEN EXIT
    SEROUT TX, ump3Baud, [char]
  LOOP

Finish_Cmd:
  SEROUT TX, ump3Baud, [".MP3", CR]             ' send extention + CR

Wait_For_Stop:                                  ' let song finish
  DO
    GOSUB Get_Status
  LOOP UNTIL (char = "S")
  RETURN

' -------------------------------------------------------------------------

' Gets status from uMP3
' -- "P" = playing, "D" = paused, "S" = stopped
' -- also gets file position and loop number of play cycle

Get_Status:
  SEROUT TX, ump3Baud, ["PC Z", CR]
  SERIN  RX, ump3Baud, [char, DEC pos, DEC loopNum]
  RETURN


' -----[ EEPROM Data ]-----------------------------------------------------

' MP3 files are stored in root of SD card
' Table below needs only name, followed by a zero
' Keep names short to conserve EE space

SFX0            DATA    "Hello", 0
SFX1            DATA    "Wolf", 0
SFX2            DATA    "Scream", 0
SFX3            DATA    "Chuckie", 0
SFX4            DATA    "Exorcist", 0
SFX5            DATA    "Lightning", 0
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

Prop-1 version redux.

As you can see, the BS2 has the ability to resolve DATA label addresses at compile time.  The BS1 can't do this, but I can, so I decided to update the first program using manual address resolution to see if it saved any space.  It does.  This means you can add more file names to the program which is more valuable to a prop than searching through a list of names looking for zeros (that also takes time).

To add another file to this version of the program you would need to to two things:

1. Add the EEPROM statement at the end -- don't forget the trailing zero.
2. Update the LOOKUP statement at the beginning of the Play_MP3 subroutine to include the new address.

You can count the characters manually, which I do, but then I also confirm by using the Memory Map view set to ASCII mode.  I've highlighted the starting characters of each file.  Remember that the Memory Map uses hexadecimal mode, so $000 [row] + $B [column]= $B [address] --> 11 (starting location for "Scream").




' =========================================================================
'
'   File....... uMP3_Demo-v2.BS1
'   Purpose....
'   Author..... Jon Williams, EFX-TEK
'   E-mail..... jwilliams@efx-tek.com
'   Started....
'   Updated....
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  Sio             = 7                     ' for DC-16, RC-4; no ULN
SYMBOL  Trigger         = PIN6                  ' setup = DN
SYMBOL  TX              = 5                     ' to UMP3.R; no ULN
SYMBOL  RX              = 4                     ' to UMP3.T; no ULN


' -----[ Constants ]-------------------------------------------------------

SYMBOL  Baud            = OT2400

SYMBOL  Yes             = 1
SYMBOL  No              = 0


' -----[ Variables ]-------------------------------------------------------

SYMBOL  char            = B2                    ' character value
SYMBOL  theMP3          = B3                    ' MP3 file pointer
SYMBOL  eePntr          = B4                    ' EEPROM memory pointer
SYMBOL  lottery         = W5                    ' random value


' -----[ Initialization ]--------------------------------------------------

Reset:
  PAUSE 2000                                    ' let uMP3 start

Prod_uMP3:
  SEROUT TX, Baud, (13)                         ' send CR
  SERIN  RX, Baud, char                         ' get response
  IF char <> ">" THEN Prod_uMP3                 ' wait for ">"


' -----[ Program Code ]----------------------------------------------------

Main:
  RANDOM lottery
  IF Trigger = No THEN Main

  theMP3 = lottery // 3                         ' make 0 - 2
  GOSUB Play_MP3                                ' play it

  PAUSE 5000
  GOTO Main


' -----[ Subroutines ]-----------------------------------------------------

' Put file # to play in "theMP3"
' -- add starting location(s) of file names manually

Play_MP3:
  LOOKUP theMP3, (0, 6, 11), eePntr

Send_Cmd:
  SEROUT TX, Baud, ("PC F /")                   ' start play command

Send_Name:                                      ' send file title
  READ eePntr, char
  eePntr = eePntr + 1
  IF char = 0 THEN Finish_Cmd
    SEROUT TX, Baud, (char)
    GOTO Send_Name

Finish_Cmd:
  SEROUT TX, Baud, (".MP3", 13)                 ' send extention + CR

Wait_For_Stop:                                  ' let song finish
  GOSUB Get_Status
  IF char <> "S" THEN Wait_For_Stop
    RETURN

' -------------------------------------------------------------------------

Get_Status:
  SEROUT TX, Baud, ("PC Z", 13)                 ' request status
  SERIN  RX, Baud, char                         ' will be "S" or "P"
  RETURN


' -----[ EEPROM Data ]-----------------------------------------------------

' MP3 files are stored in root of SD card
' Table below needs only name, followed by a zero
' Keep names short to conserve EE space

MP3s:
  EEPROM ("Hello", 0)                           ' file #0, eePntr = 0
  EEPROM ("Wolf", 0)                            ' file #1, eePntr = 6
  EEPROM ("Scream", 0)                          ' file #2, eePntr = 11
Jon McPhalen
EFX-TEK Hollywood Office

avgjoefriday

Hi Jon,

I am considering trying out a uMP3 after this post. Thanks for the details!
I hopped over to Jameco's website and it seems some of the part numbers have changed since this post.

I think these are correct, but was hoping someone could confirm.

http://www.jameco.com/Jameco/catalogs/c281/P103.pdf
Jameco #100766, Mfg # JS-1105-T-R, Female Crimp Pin
Jameco #100812, Mfg # JS-1108-02-R, 2-pin shell
Jameco #157383, Mfg # JS-1108-3-R, 3-pin shell

http://www.jameco.com/Jameco/catalogs/c281/P188.pdf
Jameco #159266, Mfg # HT-213-R, D-Sub Pin Crimping Tool

Thanks!

Scott

JonnyMac

Thanks for the heads-up, Scott; I've updated the part numbers in the original post.
Jon McPhalen
EFX-TEK Hollywood Office

avgjoefriday

Jon,

The uMP3 appears to have two ground pins now in its header row.  Based upon the N&V column and the posts above, I am guessing the ground in your picture goes to the input power ground pin.  Can the uMP3's TTL serial ground pin remain unused?

Layout here:
http://www.roguerobotics.com/files/ump3/documentation/UMP3-110-A1-102.pdf

Thanks
Scott


JonnyMac

If you're connecting the uMP3 to the Prop-1, Prop-2, or Prop-SX with the cable assembly I describe above, you only need one -- ground on the uMP3 is common.  If you're using a separate power supply, then you'll want to use ground near the RX and TX pins to connect to the controller, and the other ground will go to the external supply.
Jon McPhalen
EFX-TEK Hollywood Office

tds234

 For anyone considering these devices I want to stress how important it is to set the response timeout when using these with a prop controller like a Prop-1. Once again, Jon comes through. I was struggling with a uMP3  for quite a while and getting very little assistance from the OEM but looking through the column that Jon wrote I find the 'ST R" command that happens to be undocumented by the original company in the documentation that I was able to download from them. Once this was set to 'ST R 5' everything started to work swimmingly. And these devices, although a tad expense, rock if you want very complex sound systems under complete serial control. I don't mean to take ANYTHING away from the AP-8 (I have a few of those and like them very well) but having the ability to play MP3's opens up a bunch more possibilities than either the AP-8 or the Cowlacious boards (again I have many of both of those two and I like them for more limited sound effects situations). The sound quality is a high as the MP3 you make and you can spend time editing your sound to get it exactly the way you want without having to worry about re-recording.

davisgraveyard

OK, I have the uMP3 and I made your custom cable with all the correct parts from Jameco.   I am trying to connect it to Hyperterminal to see what version of the Firmware I have.   I am using the cable connected to a Prop-2 to give the uMP3 power.  I am using my USB to serial connector that I use for Prop-1 programming and connecting it to the uMP3.   But I am not seeing the ">" character show up?  I can hit enter and I see the activity light flash on the uMP3.   I have the port set to 9600 N-8-1 and flow control is set to none.  The USB device is coming up as COM5 and it works fine when I use the pBASIC IDE.   

I want to send the ST R 5  command to get it configured so I can program the Prop-2 to play a sound.   

Any suggestions?

Jeff

JonnyMac

I don't think I understand how you're connecting to the uMP3.  I always use a Parallax USB2SER as it provides the USB to TTL serial conversion and has separate RX and TX pins (you need that for the uMP3). 
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

I am using the USB Serial Adaptor with the BS1 Serial Adaptor attached so I can connect it to the uMP3. 

A picture is worth a 1000 words.


JonnyMac

The BS1 Serial Adapter will not work -- it doesn't use the same polarity as standard serial signals.
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

SO I could just build a 9pin-din with 2 wires coming off the correct pins to connect it to the uMP3?


davisgraveyard

The USB2SER from Parallax is $32.95.   Seems kinda expensive for just talking to the uMP3 which only cost me $99.    THe USB to Serial Adaptor from you guys is only $14.95.  Seems like that gets me close and I already have one.   What do you suggest?


JonnyMac

April 06, 2008, 12:40:58 AM #14 Last Edit: April 06, 2008, 01:15:35 PM by JonnyMac
The Parallax USB2SER is not the only adapter available, it's just the only one I've used.  If you can find a cheaper adapter that goes from serial (or USB) to TTL serial in True mode (the BS1 serial adapter doesn't, and the USB to Serial adapter does not give you TTL levels) then that will work. 

I don't mean to sound insensitive, but this problem was not created by Parallax or EFX-TEK -- it is Rogue that made a device that requires a PC for setup yet is not easy to connect to a PC....

You could always try to send the new setup commands with a Prop-2, but you wouldn't be able to get the feedback easily.
Jon McPhalen
EFX-TEK Hollywood Office