There has been alot of discussion on the various Halloween forums about those little 16m mp3 players and how best to remotely activate them. One really good site shows how to use a Prop1 to both start and stop the player, as well as how to modify it for hook-up to the Prop1 terminals (site posted below). I'm not 100% sure of the where the wires should be attached to the Prop1 to best avoid a catastrophic failure of both the player, or worse yet, the board. Here's the site:
http://www.teambac.com/web_hall/MP3_player_hack.html
Since the battery holder has just one 1.5v cell there may be DC-to-DC circuitry in there to bump it up to 5v because that's what should be on the USB port. This suggests that you *might* be able to connect the MP3 player guts (sans battery holder) to the Prop-1/2 using a 3-pin cable that has been cut-off at one end. The B wire goes to ground, the R wire goes to +5 (on the USB connector), and the W wire goes to the pulled up side of the switch. To simulate a pressed button with the Prop-1 you would make the pin low, hold it for two seconds (I think the player needs that long to get going or stop), then the pin would be made an INPUT so that the pull-up could do its thing once again.
Note: Direct connection as suggested above could harm your Prop-1 if you're not careful, so do make sure you have good handle on electronics before proceeding. I found one of those players in my junk box and will see if I can get my suggestions to work.
According to some tests I had read at the Wolfstone homepage, this mp3 player uses the voltage that it "sees" to determine which mode it should be in, i.e. 5 volts=USB mode, 1.5v =player mode. Apparently, according to the person who ran the tests, this unit is very voltage sensitive, and will switch to USB mode if it gets anything more than the 1.5v. The only thing I've done with the unit so far is to attach the wires as recommended by the site I posted above. If you just touch the ends of the 2 wires together for about 2 seconds and release, the unit plays, do it again, and the player stops. Now I guess the question is, can the Prop1 be used to simply make that connection with those 2 wires, time it for 2 sec., release for play, and then repeat for stop?
Yes, just use the B (for ground) and W (signal wires). Before connecting you will and to connect a voltage meter across the wires you have on the MP3 player to determine which is ground and which is the button input.
Just as a point to consider, since touching the wires that are attached to the mp3 per the instructions listed on the TeamBourne page start and stop the player, would it be safer to have the Prop1 one trigger a relay switch to turn the player on and off ? Since the players seem to be voltage sensitive, and the wires just accomplish the same thing as pushing the button, it would seem to me that a relay would probably work. You'd know the current required by the relay for activation, and since there would be no other current running through the contacts the player was hooked to, there should'nt be a problem there. If this would work, what type of relay would you need and how would it be connected to the Prop1?
Yes, that would in fact be the best bet; use a 12v relay (they're cheap) and connect it between the V+ and OUTx terminals.
Last question on the matter and I'll consider it done! Would the Radio Shack relay listed below be considered a good choice or is there a better model that you would recommend for the application here?
http://www.radioshack.com/product/index.jsp?productId=2049722&cp=2032058.2032230.2032277&parentPage=family
That's pricey, but it will work. You might try All Electronics (http://www.allelectronics.com) or Jameco (http://www.jameco.com) for cheaper relays. All you want is a coil voltage of 12 vdc at about 3W or less (250 mA coil current). You don't need to worry about contact current because... there really isn't any!
I was testing my links and found this:
http://www.allelectronics.com/cgi-bin/item/RLY-461/500/12_VDC,_SPDT_RELAY_.html
You can buy eight of these for the price of that RadioShack unit -- and it would have been a shame to spend more on the relay than the MP3 player!
Has anyone written a BS-1 source code for this ? I can't seem to make it work properly.
According to the mp3-player instructions , the player needs 2 seconds to turn on , 1 brief push to start playing and 2 seconds to stop playing.
And this using a PIR sensor on pin7 and the mp3 player connected to P0.
The message on the player is about 50 seconds long.
Any input would be greatly appreciated.
Thanks
How are you connecting to the MP3 player from your Prop-1?
I'm making the board that Otaku ( over at the Hauntforum ) came up with.
http://halloweengallery.com/displayimage.php?pos=-3678
I'm planning on hooking it up to the GND-OUT0 output .
On that diagram you'll see a relay between the circuit and the MP3 player -- that's all you need. Connect a 12v relay between V+ (which is the common line) and OUT0. To simulate pressing a button you would do this:
HIGH 0
PAUSE 2000
LOW 0
That will "press" the button for exactly two seconds. If you connect a second relay to the fast-forward button you could actually have more than one file on the MP3 player and access them randomly as the Prop-1 can "press buttons" much faster and more precisely than humans can.
Oh I see.
So , to do the whole routine which is about 50 seconds long , it should look something like this :
HIGH 0
PAUSE 2000 ( to turn on player )
LOW 0
PAUSE 1000
HIGH 0
PAUSE 1000 (to start playback)
LOW 0
PAUSE 50000 ( to wait 50 seconds till the audio file is done playing )
HIGH 0
PAUSE 1000 ( to stop the playback )
LOW 0
Does that look right?
Thanks for the fast reply
It think it can be a bit shorter; I have one of those players and it will go from off to playing with the first 2-second press. I'm going to pop over to All Electroncis today and get some relays so I can do the hack myself. It think the code will work out to be something like this:
Main:
HIGH 0
PAUSE 2000
LOW 0
PAUSE 50000
HIGH 0
PAUSE 2000
LOW 0
END
Note that this is not very "professional" programming in my books. The toggling of the MP3 should be put into a subroutine and the control pin should be named with SYMBOL. Once I get the hardware working I'll write a full program that uses these (professional) techniques.
cool , thanks Jon. I will give it a go as soon as time is on my side and get the board done.
And since I don't know much about programming , your "unprofessional" explanation sounds pretty professional to me ;)
After I finish my book for Parallax (on programming the SX chip with SX/B) I will start on a book for us called "Prop Programming for Everybody" -- I'll take you to knowing nothing about Prop-1 programming to being a pro in very short order. There's no release date for that book yet, so please don't ask for one.
Quote from: JonnyMac on April 05, 2007, 12:18:30 PM
I'll take you to knowing nothing about Prop-1 programming to being a pro in very short order.
That sounds promising and looks like something some of us could use .
Thanks for the help and support , Jon.
OK, if I've got this straight, in order to start the mp3 through a 12v relay and run the 2min 30sec song I intend to use, the program (rough-n-dirty version) would look like this:
HIGH 0
PAUSE 2000
LOW 0
PAUSE 150000
HIGH 0
PAUSE 2000
LOW 0
END
and that would get it to start, play and stop. Now for the other routine I was intending to program ( "Blending Servo Motion"), would that be placed after the "END" command for the mp3, or placed in between the PAUSE 150000 and last HIGH 0. Sorry for the cross post, but for me, they are both tied together.
The limit of values in the Prop-1 (and Prop-2 for that matter) is 65535 (16-bits, a word), so the PAUSE 150000 line will not work as you intend. No worries, you can simply stack PAUSE routines:
PAUSE 60000
PAUSE 60000
PAUSE 30000
This is, though, a little blunt force and a more elegant programming solution is a delay subroutine that lets us specify the number of seconds to wait. The code looks like this on the Prop-1:
Delay_Secs:
IF secs = 0 THEN Delay_Secs_Exit
PAUSE 1000
secs = secs - 1
GOTO Delay_Secs
Delay_Secs_Exit
RETURN
You also have to define a variable called 'secs.' If this variable is a byte you can delay up to 255 seconds (four minutes, 15 seconds). If you use a word you can delay up to over 18 hours -- so abyte will probably do. To use the subroutine in your program you can do this:
secs = 150
GOSUB Delay_Secs
If you've got a program that requires lots of long delays then this is the best solution.
I got my mp3-player working . I added a relay in between the prop-1 and the mp3-player ( V+ and OUT0 ).
The prop is a Zoltar fortune teller . I have 14 fortunes on my mp3 player . The fortunes are the ones from the old Zoltan machine , so I need to record new ones for my prop.
Here's a link to the prop ( not standalone yet ).
http://s167.photobucket.com/albums/u145/cladinshadows2007/?action=view¤t=Zoltar65.jpg (http://s167.photobucket.com/albums/u145/cladinshadows2007/?action=view¤t=Zoltar65.jpg)
I used the pir code and the little code Jon wrote down and it works like a charm.
Now , the only thing I need to add is ; skipping audio files.
I'm gonna add another relay (V+ and OUT1 ) that will be connected to the mp3-player's "forward"button.
I'd like to skip 4 fortunes at a time . P.ex. fortune 1 will play , next time , fortune 5 will play , then message 9 ,....
That way that'll be a good mix.
How would you put that in code ?
This is what I have so far...
thank you in advance.
' =========================================================================
'
' File...... Zoltar
' Purpose... Talking Fortune Teller
' Author.... Clad In Shadows
' E-mail....
' Started... April 07 , 2007
' Updated...
'
' {$STAMP BS1}
' {$PBASIC 1.0}
'
' =========================================================================
' -----[ Program Description ]---------------------------------------------
' -----[ Revision History ]------------------------------------------------
' -----[ I/O Definitions ]-------------------------------------------------
SYMBOL PIR = PIN7 ' SETUP = DN
' -----[ Constants ]-------------------------------------------------------
SYMBOL IsOn = 1
SYMBOL IsOff = 0
' -----[ Variables ]-------------------------------------------------------
SYMBOL pirTimer = B2
' -----[ Initialization ]--------------------------------------------------
Reset:
' -----[ Program Code ]----------------------------------------------------
Main:
pirTimer = pirTimer + PIR * PIR
PAUSE 10
IF pirTimer < 2 THEN Main
HIGH 0
PAUSE 2000
LOW 0
PAUSE 52000
HIGH 0
PAUSE 2000
LOW 0
GOTO Main
END
' -----[ Subroutines ]-----------------------------------------------------
' -------------------------------------------------------------------------
' -------------------------------------------------------------------------
' -------------------------------------------------------------------------
' -------------------------------------------------------------------------
' -------------------------------------------------------------------------
' -----[ EEPROM Data ]-----------------------------------------------------
How many fortunes do you want to include? Also, I think your audio should have a few seconds of blank space after so that you have some "fudge factor" when dealing with them. There are ways to keep track of which files have played so that you can do something randomly, but not have any repeats until all is done. With the Prop-1 you can do this easily with eight files, with a bit more work you can do 16 (takes more code trickery).
In the meantime you should just experiment with the Forward button to get it working. I think a PAUSE 100 value will work fine -- guess I better go pick up some relays myself....
I currently have 14 fortunes from the old Zoltan machines ( for demo-ing) but I can live with 8 fortunes if that's less trouble.
I still need to record my own fortunes so it doesn't matter how many.
Since each of the fortunes are about 50 secs long , I added about 10 secs of blank space already and that for the reason you mentioned.
I will add the wires to the forward button probably tomorrow.
Thanks.
Added a second relay to the mp3 player .
The added wire is located on the bottom left switch-leg of the fwd button , same as the connection on the play button.
Now , the mp3 player plays a different fortune eveytime the sensor is activated.
I had to mess around with the PAUSE command and also changed the fortunes. Instead of having 10 secs of silence after the fortune , I changed it to 5 secs before and 5 secs after. The reason for that is because I have the player go to the next fortune at the end of the playing fortune . Otherwise it would start playing the next fortune right away.
So , a lot of PAUSE commands but it's working.
Thanks Jon for the help .
Once I recorded my new fortunes and have everything in place , I'll post some pics and videos online.
I might actually add another mp3-player to my Zoltar which will be operated through another sensor.
That mp3 player should run the opening line to draw the audience towards the machine.
I think it is possible to have two sensors running on 1 prop-1 controller , am I right?
Anyway ,the file as of now looks something like this :
' =========================================================================
'
' File...... Zoltar
' Purpose... Talking Fortune Teller
' Author.... Clad In Shadows
' E-mail.... Bluesjammer2004@aol.com
' Started... April 07 , 2007
' Updated... April 10 , 2007
'
' {$STAMP BS1}
' {$PBASIC 1.0}
'
' =========================================================================
' -----[ Program Description ]---------------------------------------------
' -----[ Revision History ]------------------------------------------------
' -----[ I/O Definitions ]-------------------------------------------------
SYMBOL PIR = PIN7 ' SETUP = DN
SYMBOL forward = 1 ' forward is connected to P1
' -----[ Constants ]-------------------------------------------------------
SYMBOL IsOn = 1
SYMBOL IsOff = 0
' -----[ Variables ]-------------------------------------------------------
SYMBOL pirTimer = B2
' -----[ Initialization ]--------------------------------------------------
Reset:
' -----[ Program Code ]----------------------------------------------------
Main:
pirTimer = pirTimer + PIR * PIR
PAUSE 10
IF pirTimer < 2 THEN Main
HIGH 0
PAUSE 2000
LOW 0
PAUSE 58000
HIGH 0
PAUSE 1000
LOW 0
HIGH forward ' turn forward on
PAUSE 200 ' hold for 1/5 second
LOW forward ' turn forward off
PAUSE 2000
HIGH 0
PAUSE 2000
LOW 0
GOTO Main
END
' -----[ Subroutines ]-----------------------------------------------------
' -------------------------------------------------------------------------
' -------------------------------------------------------------------------
' -------------------------------------------------------------------------
' -------------------------------------------------------------------------
' -------------------------------------------------------------------------
' -----[ EEPROM Data ]-----------------------------------------------------
Yes, you can have multiple sensors -- deal with them like this:
Main:
IF Trigger1 = IsOn THEN Show1
IF Trigger2 = IsOn THEN Show2
GOTO Main
I have updated a couple things on my MP3 hack page to include some of the suggestions from here. I haven't used audio in my past projects and these little players should be fun to add in.
http://www.teambac.com/web_hall/MP3_player_hack.html
I am looking forward for your book Jon on using SX/B for the SX chips. Past and future props that have needed control used the SX proto boards and I have been using really basic programming so far to control them.
Wes Bourn