Skip to main content

I want to add sound to my crossing gates. I have the approach from Stan (previously posted in the "IR or Optical Sensors" forum), but had some questions with regard to his post. Stan suggested that I move that discussion to a new forum, so here we are.

I purchased an MP3 player on ebay and audio amplifier card from same. In Stan's post, he shows a capacitor adder to both the player and the amp. The pictures do not provide enough detail for me to determine where the cap's should be added. If I had bought the same player & amp that Stan used, I could make a pretty good guess. I will repost the pic's of my player, and per Stan's request, I will post the ebay location of the amp I bought along with a pic.

The reason for the cap additions  was never mentioned, but someone suggested it might be to improve sound quality???

Stan also suggested that I put an MP3 file on the player and see if it auto plays. I did that and it does not. I believe everything on these players is display-driven. However, Stan has never been stumped before--so we will see.

Ken

Attachments

Images (6)
  • MP3 Player-1
  • MP3 Player-2
  • MP3 Player-3
  • MP3 Player-4
  • Audio Ampl-1
  • Audio Ampl-2
Original Post

Replies sorted oldest to newest

Thanks Bruk, but if you go to their website, it is a mess. I don't trust any company that overwrites the key elements of their product descriptions.

Also, they don't talk about a unit for o-scale (which is what I want). With Stan's design, I have to have an SD Card, but if all I want to play is the bell ringing of a crossing gate, I can create an MP3 file of that sound, put it on the card, and when the player is activated by a gate sensor, the sound will play continuously (not for a max. of 5 min.), until the sensor is de-activated. It's a little more work, but I believe provides more flexibility (plus I like to fiddle with new designs).

Thanks again for the input.

Ken

ken's trains posted:

Thanks Bruk, but if you go to their website, it is a mess. I don't trust any company that overwrites the key elements of their product descriptions.

Also, they don't talk about a unit for o-scale (which is what I want). With Stan's design, I have to have an SD Card, but if all I want to play is the bell ringing of a crossing gate, I can create an MP3 file of that sound, put it on the card, and when the player is activated by a gate sensor, the sound will play continuously (not for a max. of 5 min.), until the sensor is de-activated. It's a little more work, but I believe provides more flexibility (plus I like to fiddle with new designs).

Thanks again for the input.

Ken

I understand. Tim is the owner of the company. He is a really cool and knowledgeable gentlemen. I work with him all the time. He can be over descriptive sometimes because he's passionate about what he does. He makes me custom sound boards and lighting boards for projects for all scales. (he is also local to me) We stock his lighting products at our store.

Also you can change the speakers out for larger applications.

Last edited by Bruk

In your application, what provides power to the player/amp?  And what voltages are available?

For the player, the added 5 cent capacitor was attached to the + and - pads of the battery (which was removed).   A battery provides a relatively steady voltage so without the battery there, the capacitor a similar smoothing function which aids with audio quality.

For the amplifier, the added 5 cent capacitor is added as shown int he photo; it appears you have the identical board.  The function here is a bit more nuanced.  In this case it affects the startup time of the amplifier which helps to demote the initial pop/click you frequently hear when turning on an audio amplifier.  It additionally assists with audio quality.

It's a nuisance if your player does not start playing when you turn it on.  So what exactly happens and how do you get it to start playing?  Does the display come up with a scroll-able list of all the .MP3 files stored on the SD card?  Then even if only 1 choice, it makes you select it for it to start?

I'm sure we can eventually figure something out to get your $1.79 player to work, but is procuring the 99 cent player I used an option you'd consider?

For example, in addition to the automatically-start "feature" that I think is handy, another sleuthing task is to determine if the player module can directly accept 5V in "play" mode if one has removed the ~3.8V Lithium battery (see comment below).  Some MP3 players let you transfer your MP3 files into the microSD card via the USB cable while the USB is charging the battery.  Others let you stream MP3 files over USB.  And so on.  I've not found datasheets for the magic chips used in these low-cost player to understand the voltage limitations or modes of operation.

Separately, as a general comment about these $1-2 MP3 players.  Some listings on eBay have a warning about NOT overcharging the battery - such as don't leave it plugged in to the USB 5V port for more than some number of hours or something like that:

battery warning

I have indeed had these tiny rechargeable Lithium batteries bulge and fail in my messing around with these modules.  Note that these devices have very simplistic battery-charging circuits unlike the sophisticated chargers in smartphones or whatever that know when to stop pushing power into the cells.  In any event, I recommend simply removing the battery for DIY track-side sound accessories when using these modules.  There is a separate discussion about rolling-stock sound and if/how a battery might be applicable but that's for another day.

Attachments

Images (1)
  • battery warning
Last edited by stan2004

Hi Guys,

Bruk I'm sure their great products, but if you go to the web page you linked, you will see that it's a page of product descriptions where most of the text is overwritten with other text and is mostly unreadable. So I cannot get a good description of his products.

Stan I thought the amps were the same, but I did want to understand the reason for the caps--so thank you for that. I also tried to look up the chip on the player (had to take a pic with cell phone to read no.), with no result. I only loaded a single file on the player and when it turns on, it comes up in the "Music Mode". If you select 'ff right' you get to the "Set Mode" where you can select 'language' , 'contrast', 'light', or 'return'. If you press the "M" button in the Music Mode, you get a list of songs and must select one to play by pressing the 'play/pause' button (center button).

With the description of the player you used, I was able to find them on ebay and have ordered some. I don't know why they didn't come up in my initial search for players before. If the display version is not doable, that's ok, I will just wait a month till the one you used arrives.

As always, thanks much.

Ken

Sorry, forgot question about power. At this time, friend has printed a crossing gate with a servo motor and controlled by an Arduino. We are using the side-by-side led emitter-sensor combo for crossing detection which triggers the Arduino. The plan for sound was to have the Arduiino also trigger a channel of an 8-ch relay I have several of. That would provide 5 VDC to the player and amp.

Ken

If you go with the 99 cent MP3 player and separate amplifier, I dug up photos from earlier threads but collected here with additional comments to summarize one way to do it.

ogr stereo sound hack

Not necessarily for crossing gates, but since the MP3 player is STEREO, you can play two completely independent sounds.  So for a track-side layout sounds that run all the time, just add a 2nd speaker and store sound #1 on the left-channel and sound #2 on the right-channel.

ogr mp3 player backside

Above shows the guts of the MP3 player.  The battery is disconnected and unused.  The volume controls are not used; as per the discussion, this player will automatically start playing whatever MP3 file/song/sound is stored on the microSD memory car when power is initially applied.

insanely priced mp3 sound accessory

Above shows the general concept of a MP3 player + audio amplifier + speaker.  The battery is not used in your application.  Again, these are re-cycled photos.  The point here is to put the speaker in a chamber which greatly improves audio performance.  Note that the IC amplifier chip (PAM8403) can drive a 4 ohm, 8 ohm, or whatever ohm speaker you have lying around.

ogr mp3 player wiring

Above shows the 1uF capacitor (polarized so mind the + and -) installed in place of the Lithium battery.  The player's ON/OFF slide switch is placed in the ON position.  5V DC is applied as shown.  These are the same connection points as the +5V and GROUND connections on the mini-USB but the cable is somewhat bulky and by the time you cut, splice, strip, etc. the cable, it's probably easier (and certainly more compact) to just wire in +5V and ground as shown.  Ground is soldered to the mini-USB connector tab as shown.

The two audio outputs (if you are even using both), are as shown.  It is very important to note that the audio common is not used when the MP3 player is mated to the amplifier module.  

ogr mp3 amp wiring

Above is audio amplifier module.  Capacitor is added as shown; note polarity.  Again, note that the audio common (the pad between the two audio inputs) is NOT used when mated with the MP3 player.

power and audio connections if not using cables

Above shows you do not need to use the 3.5mm earbud connector between the MP3 player and the audio amp.  You can save substantial space by dispensing with the 3.5mm plug and simply tacking a wire to one (or both if needed) audio outputs as shown.  Again, you do not use the common audio output connection.

------------------

Separately, if you want manual volume control you can get what amounts to the same PAM8403 IC amplifier electronics except with potentiometer.  Here's how you'd attach the capacitor on the eBay module which is also about $1 shipped.  As noted earlier, the capacitor is optional.  For a layout accessory sound that is continuously running, I don't think it matters or that you'd even notice the one time pop/click when you power up your layout for an operating session.

capacitor on amp with volume control

pam8403 amp with volume

The other connections to the MP3 player, speaker(s), 5V DC are the same.

pam8403 amp with volume knob

I figure you would only set the volume once for a crossing gate and never change it.  So the fixed volume module works fine with any one-time volume setting done by simply modifying the MP3 file itself within a sound-editor (Audacity or whatever).

Attachments

Images (9)
  • insanely priced mp3 sound accessory
  • ogr mp3 amp wiring
  • ogr mp3 player backside
  • ogr mp3 player wiring
  • ogr stereo sound hack
  • pam8403 amp with volume knob
  • capacitor on amp with volume control
  • power and audio connections if not using cables
  • pam8403 amp with volume
Last edited by stan2004
ken's trains posted:

...The plan for sound was to have the Arduiino also trigger a channel of an 8-ch relay I have several of. That would provide 5 VDC to the player and amp.

Understood.

OK.  So the described configuration above will directly take the 5V switched-DC from your relay module and "automatically" start playing the crossing gate MP3 file.  Very simple.

But as you patiently wait for your MP3 players to transit the Pacific, note that another way to manage power is to keep the audio amplifier module continuously powered with 5V DC (since your Arduino module is presumably always powered).  Then when you need crossing-gate audio, you simply power-up JUST the MP3 player module which draws a very small current relative to the audio amp module.  The point being you can use the modest output drive capability of an Arduino to switch power to JUST the MP3 player electronics.  This way you don't need to use the relay module with its 10 Amps (!) of switching capability.  Of course if you're already using the 8-channel relay module "nearby" then so be it.  If this is something you'd like to pursue, it may cost 10 cents or so in parts (e.g., a transistor or whatever) but if space is an issue or you just like to tinker with stuff, I will elaborate.

ken's trains posted:

...At this time, friend has printed a crossing gate with a servo motor and controlled by an Arduino. We are using the side-by-side led emitter-sensor combo for crossing detection which triggers the Arduino.

When you get it all together, can you post a photo of what your friend printed.  With all the 3-D printing activity, I figure at some point someone will want a track-side enclosure to house the LED-sensor combo for a DIY IR occupancy detector (MTH ITAD or Lionel 153IR).  The off-the-shelf versions run $30-40 or so whereas the underlying electronics is less than $5 if going the DIY route.  I've figured a stumbling block has been a suitable enclosure to mount/disguise the LED-sensor combo...but if you've come up with a share-able (printable) solution, I'd be interested in seeing it.

Last edited by stan2004

Stan, thank you so much for the details. I will get to it when the correct players arrive. At this time, my friend is refining his crossing gate design (I will post pics when complete), and then he will start on a design for the LED-sensor module enclosure and I will post that. The turntable is coming along pretty good also (but it's been a much bigger project).

Ken

ken's trains posted:

Hi Guys,

Bruk I'm sure their great products, but if you go to the web page you linked, you will see that it's a page of product descriptions where most of the text is overwritten with other text and is mostly unreadable. So I cannot get a good description of his products.

 

It's the browser you are using. I get the same thing with Chrome, but it works fine when using Edge. The website does have some interesting products, definitely worthy of consideration.

Having said that, I like Stan's projects as well. He has posted some great things here on the forum and is always very helpful to anyone in need.

Hi Stan,

The new MP3 players arrived early. I hooked them up per your instructions and every thing works as you said except the 1uf cap does not eliminate the pop when my player starts up. Will a larger value cap help??

As to posting pics, my friend is on vacation, and we need to come up with the optimum height for the sensors (depends on different rolling stock configurations so as to always get a reflection--even with a built-in delay) before he designs an enclosure. He does have a completed crossing gate, and I will post pics and a vid when he returns.

Ken

As for the sound, no matter what you find I believe you'll have to edit it to make it a 10 minute (or whatever) long file.  While these MP3 players will repeat a single stored MP3 song, there's a small gap.  So what I do for repetitive sounds that might need to go on for minutes is to use a sound editor like Audacity and cut-and-paste a chunk of sound over and over until I build up a 10 minute song.  Of course this still takes only a trivial amount of memory easily fitting into any microSD card.

Point being, if you're going to edit anyway it doesn't matter that it's an MP3 file to begin with - kind of sideways thinking on my part but that's my opinion.  The first Google result from "railroad crossing bell sound" was this video which sounds pretty good to me.  There's probably a converter programs to convert youtube audio to MP3 - what I know how to do is capture the sound within a sound editor, find convenient splice points, cut-and-paste to make the 10 minute file, then "save-as" MP3.  Kind of old-school but that's what works for me...

Last edited by stan2004

Judging from the .1" spacing of the connectors on the WAV Trigger, this is WAY too large for any rolling stock, so it's limited to stuff like under the layout, looks to be around 3" x 3".  It also seems to be massive overkill for this application!  This looks like a neat product, but I suspect it's more complex than most folks are willing to go for a simple sound application.

Attachments

Images (1)
  • mceclip0

Stan,

I have been playing with the MP3 player, amp module, and speaker. I have it working fine (other than the startup pop). However, now comes the problem. As you had recommended, I am powering the amp/speaker with the 5VDC supply direct. I wrote a short Arduino program to turn an output pin high for 5 sec. and then low for 5 sec. I tried connecting the MP3 player directly to the output pin and got nothing. I looked at the spec.s for the Arduino and at one site it says 20ma max. at 5V VCC. I measured the MP3 current when powered at 5V direct and it varied between 21 and 19ma--seemed like it should have worked a little; but nothing. So, plan 2. I connected one of my 3904 transistors with the player connected to the 5VDC supply and grounded through the transistor. Used a resistor splitter for the base with 10K to ground and 1K to the base and each end of the resistors connected to the Arduino output pin. The speaker is noisy when the transistor is off and plays poorly when it's on. I measured the voltage drop across the player when powered and it's only 3.8V. I checked the spec.s on the 3904 and it says it can sink 170ma max. With 5VDC direct to the player it works fine. I don't understand what is going on. I know there is a voltage drop across the transistor, but it I measured it and it's very low (maybe 100mv). Do I need to lower the base resistor (currently 1K) to more fully turn on the transistor?

Ken

MP3 Player001

Attachments

Images (1)
  • MP3 Player001
ken's trains posted:
... I measured the voltage drop across the player when powered and it's only 3.8V. I checked the spec.s on the 3904 and it says it can sink 170ma max. With 5VDC direct to the player it works fine. I don't understand what is going on. I know there is a voltage drop across the transistor, but it I measured it and it's very low (maybe 100mv).

Just to clarify.  If starting from 5V and there's 100mV drop across the transistor how can there only be 3.8V across the player?  I'd think there'd be 4.9V?

Anyway, I suspect the noise is because you're switching the DC- or ground of the MP3 player (rather than the DC+) side.  From the amplifier's perspective, it interprets the incoming signal referenced to its DC-.  Any difference between the DC- of the MP3 player and the amplifier will be interpreted as audio.  Yes, you are in the saturation region but saturation is not a binary on/off condition.  Consider that if you're drawing 20 mA, that 100mV drop means the transistor effectively looks like a 5 ohm resistor (R = V / I = 0.1 / 0.02) which is horrible when compared to a 5 cent electro-mechanical switch.  OK, it's an apples-orange comparison but the point is any variation in current in the MP3 player will shift the DC- voltage via this 5 ohm resistor.

So I suppose you could lower the 1K but I don't think you'll get much bang for the buck since you're already in saturation while you can drive it harder into saturation at 100mV I'm not sure there's much more to gain.  You could use a better transistor such as a 10 cent switching N-channel FET which would have an effective "on" resistance of under 0.1 Ohms...but I don't think you have these just lying around.

But my opinion is to try switching the DC+ to the MP3 player.  For example, do you have a PNP 2N3906 lying around (the complementary part to the NPN 2N3904).  It would be the same configuration as the NPN circuit except switching DC+ when the Arduino pin is "low". 

Now as to why the Arduino output pin does nothing when driving the MP3 directly.   Seems I had a recent discussion with someone who was messing with converting between 3V and 5V signals in an Arduino environment.  Just want to confirm you have "genuine" 5V Arduino outputs.  Anyway, I don't know exactly which module you have but usually best to go the source datasheet such as the ATMEGA32 microcontroller chip which would show an output capability (with 5V chip supply):

atmega32a 5v source

So this suggests an output of about 4.5V when loaded by 20mA as you measured.   But if you removed the battery and only have a 1uF capacitor on the MP3 player, the ability to handle current peaks is restricted.  That is, while 20mA is the average current, I can easily see current peaks of maybe double that when, for example, the MP3 module initially starts up or when it goes to the SD card to fetch the next block of MP3 data (or whatever).  So a surge current or startup current of, say, 40mA would drop the Arduino output voltage to just under 4V which might starve the MP3 player from doing anything.  Not sure what's happening but that's one explanation.  You could try increasing the 1uF capacitor to, say, 100uF or whatever value you have lying around.  This might even help with the 2N3904 low-side switch problem (noise from a shifty ground).

As to the pop.  I think you were messing with increasing the capacitor on the amplifier.  But if the amplifier is continuously powered, changing that capacitor will not help when you turn power on/off to the MP3 player.  The pop is coming from the jolt in voltage from the player.  If you powered the two simultaneously, then the pop from the MP3 player would be masked by the amplifier which delays its amplification proportional to the capacitor.  I apologize if I misled you on the effect of increasing that capacitor if you are separately powering the MP3 player and the amplifier.

Actually, as I write the above, I wonder if you could solve two problems by simultaneously powering the player and the amplifier.  I realize you'd need a beefier transistor but any DC- noise would be common between the two devices and ought to be rejected.  And in this case, the startup pop rejection of the amplifier would mask any startup pop from the MP3 player.  I realize you probably didn't go this route if you only have a low-current 2N3904 NPN in your stash.  If this was why you only switched power to the ~20 mA player and don't have a 500mA or 1A transistor, I can try this for you.  Let me know.

 

Attachments

Images (1)
  • atmega32a 5v source

Stan, as usual, you are the best. As to why I measured such small drop across the 3904 and only 3.8V across the player, I am also at a loss. I can check again, but am pretty sure that's what I saw.  I only have a digital VOM to do the measuring, so maybe I'm not seeing the full picture. My mechanical genius friend has some FETs, but I don't know if P or N, and I can try one if he has a P. I do have some 3906s and will try your suggestion as to switching DC+. If this winds up still noisy, I may just use one of many relays I have and switch the player & amp on/off together.

Also, sorry about the lousy 'schematic' from last post, but it was late.

Ken

Stan, a little more info. As per your suggestion, I used a 3906 and got a somewhat different result. The player played ok during it's cycle, but was still very noisy.  I then played around with the player ground connection. When connected to my breadboard ground, noisy; when connected directly to an Arduino ground pin much less noisy;, and when connected to the power supply ground very little noise.

Now for the problem I can't explain. During the non-play cycle (5 sec.), the speaker clicks loudly at about a 1 Hz rate. I changed my simple program to power the Arduino and only have the output turn the transistor off--no speaker 1 Hz pops. As soon as I cycle the transistor on/off with the 5 sec. delays, the pops are back during the off cycle. I just measured the Arduino output pin state (connected to the transistor base thru the 500 ohm resistor) and it is ~ 0.17V when LOW and ~3.99V when HIGH. I don't have a scope so that's the best I can do. The only other thing I can try is to power the player/amp via a relay and use the Arduino to control the relay. If the relay chatters, I will know the problem is with the Arduino. I've included a couple pics of my 'kluge', & the Sparkfun Arudino I am using.

Attachments

Images (3)
  • 20171109_213620
  • 20171109_213630
  • 20171109_213646
ken's trains posted:

Now for the problem I can't explain. During the non-play cycle (5 sec.), the speaker clicks loudly at about a 1 Hz rate. I changed my simple program to power the Arduino and only have the output turn the transistor off--no speaker 1 Hz pops. As soon as I cycle the transistor on/off with the 5 sec. delays, the pops are back during the off cycle. I just measured the Arduino output pin state (connected to the transistor base thru the 500 ohm resistor) and it is ~ 0.17V when LOW and ~3.99V when HIGH.

Well, if your PNP switch circuit is symmetrical (i.e., 5.0V DC on the emitter), then in the OFF cycle you are apply a forward voltage (i.e., base-emitter) of 1V into the PNP via the 1K base resistor!  This is, say, about 1/2 mA of base current which the 2N3906 will amplify and "weakly" attempt to power up the MP3 electronics.  I suspect the MP3 electronics is trying to start up but the PNP is not providing enough current and the circuit shuts down, then tries again after 1 sec causing the hiccups that couple over to the amplifier.

As to why you have 4.0V (rather than 5.0V) on an output pin when driven HIGH is the question. I tried to zoom in on your pics but couldn't quite make out which exact pins you are using.  Here's one scenario which could explain the 4V.  Suppose you left the 10K tied to ground rather that moving it to 5V when going from NPN to PNP.  Additionally suppose you are using an output pin that is operating as a so-called open-collector (OC) output.  These outputs can only "drive" current when LOW.  When HIGH the pin essentially floats so that that 10K to ground would provide about 1/2 mA of base current which is coincidentally what you measured.  This inability of an OC to drive current when HIGH would explain why it did absolutely nothing when trying to power the MP3 player directly from the output pin.  Well, that's one scenario anyway.

I guess if you have a 5V relay module lying around that is one way to make a better electrical switch with an "on" resistance less than 0.1 Ohms or whatever!  I think a FET would also work if powering the player and amplifier simultaneously.  As you point out, those eBay relay modules can be driven directly from an Arduino output pin because the relay module has a transistor buffer driving the relay coil which requires only a few mA of trigger current. 

Thanks Stan. Just for giggles, when I have a chance, I will get a TO-120 from my buddy (he does not have a TO-125) and see how that works.

And again, he has put the gate designs aside while he is printing a bridge for the redesigned turntable that uses a lazy susan and slipring combo with a 22" disc we cut out using a router mounted on a swing arm. When he gets back to gates and comes up with a housing for the cross-track and one=side track sensors, I will post.

That module can indeed reduce wiring.  BTW, posts with direct eBay links can be deleted/modified by OGR moderator per terms of use.  I post the image of the listing which should be enough info to find it; other guys post the eBay listing number though that goes stale after a few months.  In any event, $1.31 with free-shipping from Asia.

gpd2856 module with unmarked audio amp

Here are some observations which may or may not be relevant in the context of a crossing-gate application.

1. The speaker will pop on initial application of power.  I'm fairly confident that you can add a capacitor to demote this effect.

gpd2856 module unmarked audio amp

The module has an un-marked audio chip.  I have an idea of what it is - or at least enough to suggest the capacitor modification as shown (across C6).  The separate audio amp module (available with or without volume control knob) uses the PAM8403 IC audio amp which is well documented in terms of providing detailed info on how a capacitor affects the pop, noise, etc.

2. The module has a mono audio-amp.  So somewhere on the board the Left and Right channels of the stereo MP3 sound are combined.  The separate PAM8403 audio-amp module has a stereo amplifier - 2 audio inputs, 2 amplified audio outputs.  As discussed earlier, if you have two locations where you want layout sounds, they can be completely independent.  Or if you can dream up an application to take advantage of the stereo to create some fun effects - like a train passing left-to-right and/or right-to-left with Doppler effect proportional to speed, or plane flying overhead, etc.  This would require a stereo or 2 independent audio amplifiers (and 2 speakers).

3. If using a separate audio-amp, there are PAM8403 versions with a manual rotary-knob volume control.  My notes show this module will always start up at max volume.  I believe you will be driving your setup with an Arduino.  So I suppose you could use the Arduino to adjust the volume by using some digital outputs to emulate the push-button Volume+ and Volume- buttons.  Note that these highly integrated widgets tend to multi-plex the switch connections with other functions so it's not just a matter of writing a HIGH or LOW to a pin connected to a switch to effect CLOSE or OPEN.  I didn't consider the Arduino button interface but it might require using an OC/OD (Open Collector, Open Drain) output pin or even adding an electronic equivalent of a relay (i.e., an analog-switch chip).

4. I did not study this module enough to confirm if you can directly apply 5V DC as the power source.  Presumably the BAT+ and BAT- connections are for a standard 3.7V Lithium rechargeable which seems to be the assumed power source for these tiny MP3 players.  OTOH, as this module has screw-terminal connector for the speaker, it was clearly intended for DIY applications. Also, I did not check to see if some kind of charging capability is built-in.

5. I noticed this module has a longer start-up time (from application of power to sound coming out).  I don't have any numbers written down but it was noticeable enough that I remember it.  In general I've noticed for these MP3 players that the larger the memory card, the larger the start-up time.  Additionally, the time it takes after finishing one .mp3 sound and starting the next one (or repeating a single .MP3) seems proportional to the size of the memory card.  I've not studied this in any depth as I typically use a 64MB or 128MB cards with one .MP3 file on it.

Again, many/most of these comments may not apply to your crossing-gate application...

 

Attachments

Images (2)
  • gpd2856 module with unmarked audio amp
  • gpd2856 module unmarked audio amp
Last edited by stan2004

Stan, again your info is greatly appreciated. I have powered the module with the USB port and located the 5V + & - terminals that I could solder to. Also, I have applied 5V to the BAT + & - terminal on the board and nothing smoked---yet--and it worked same as with USB power. And yes, it seems to take slightly longer to play, and also, the volume always comes on too loud, even after I lower it with button, power off, and power on. Result is volume always too loud. I was considering putting a (5W) resistor in parallel with the speaker to see if I could reduce volume that way.

By the way, I have given up on powering the audio directly with the Arduino. I am going to trigger a relay with the Arduino output to power the audio.

If the volume will be fixed, why not use the audio-editor and drop the volume that way.  To be sure, you give up signal-to-noise (SNR) ratio dB for dB...but for a crossing-gate clanging sound I really don't think you can tell - IMO of course.

Or to lower volume, put a resistor in SERIES with the speaker (not in parallel).  That amplifier chip is effectively a voltage-output device so a parallel resistor will simply consume more current with the same voltage (volume) applied to the speaker.  If done in series, an 8 Ohm resistor added to an 8 Ohm speaker doubles the resistance load so cuts the current in half.  The max voltage out of the amplifier is 5V.  So you can do the math to see the Wattage (Watts = V x I) requirement of any resistor.  Note that the average power dissipated by the added resistor will be much less - maybe 25% depending on type of sound - than what you calculate for the whatever speaker impedance you are using - you shouldn't need a 5 Watt resistor.

 

Last edited by stan2004

Audio-editor (e.g., Audacity) is whatever PC/laptop software program you used to edit, splice, modify, and save the .MP3 sound file.  So should be as simple as opening the .MP3, select the entire waveform, decrease by 6dB or whatever, re-save.

Series resistor is probably faster.  If 8 ohm speaker, adding 8 ohm resistor drops power 6dB.  Not as efficient as half your electrical power is wasted as heat in the series resistor but as this is not a battery application it should not be a big deal.

As mentioned earlier, with these highly integrated digital chips (as used on the MP3 module), it may not be as simple as applying a long pulse to the volume button(s).  As alluded to in my previous post, these chips tend to share pins between multiple function including changing a pin from being an input to an output hundreds of times per second.  This is done to reduce the pin-count and footprint of the IC.  In other words, the VOL+ and VOL- control lines may be used for other functions so directly driving from the Arduino may conflict with chip operation unless you only drive the pins during the magical intervals when those pins are acting as VOL+ and VOL-.  Again, I don't know if this specific MP3 player module uses this so-called "pin multiplexing".  But note that the magic MP3 chips has only 16-pins on it...and it is talking to the SD card, can talk USB to a PC over the micro-USB connector, is blinking a LED, is possibly performing some kind of battery charging, generating stereo audio, listening to 4 buttons, etc.. you have to wonder how it can do this with "only" 16-pins!

Last edited by stan2004

Hi Stan and anyone else interested. To answer your question, I did not solve the pop problem.

However, I just wanted to show you what all your help and a lot of C programming reading accomplished. I made an HO scale test bed (my railroad is o-scale) and connected 2 'cross-track' sensor pairs and one 'side-by-side' sensor pair to an Arduino. I made a simulated crossing gate operated with a servo motor and connected that along with the MP3 player/amp module/speaker combo also to the Arduino. I wrote (and re-, re-, wrote) a C program to control all. It finally all works. I have enclosed 2 pics of the setup (what a mess of wiring--will try to simplify), and a video of the operation.

Sorry, it turns out that I cannot upload the video. It is 180MB and I get an error when trying to upload as an attachment.

Add Reply

Post
×
×
×
×
Link copied to your clipboard.
×
×