Adding sound to my train controller

Enhanced mid-range devices. PIC12F1xxx and PIC16F1xxx

Adding sound to my train controller

Postby grandpa jay » Tue Jun 07, 2016 1:28 pm

Gentlemen
I am adding a MP3 module DFPlayer Mini SKU:DFR0299 to my train controller. I now have it working with a little static. I had to set the pin 12 high in the initialization and have the program pull it low for 100ms.

Would it be better to add a pullup resistor to pin 12? Any suggestions on reducing the noise from the small speaker?

I am new to this form and not sure about adding files.

Jay
Attachments
TCwS.c
(9.82 KiB) Downloaded 422 times
TCwSoundsch.jpg
TCwSoundsch.jpg (30.29 KiB) Viewed 6796 times
grandpa jay
 
Posts: 22
Joined: Wed Sep 24, 2014 9:10 pm

Re: Adding sound to my train controller

Postby Ian.M » Tue Jun 07, 2016 6:41 pm

I though the Microchip forum had mangled the schematic, but it looks like it got mangled your end. Please repost it as a GIF or PNG (both lossless image formats) with enough resolution for component designator and value text to be readable.

I suspect the noise is due to interference from your digital circuits. We'll probably also need to see photos of both side of the board so we can check the wiring layout. Worst case, it may well need its own regulator, and may even need the control signals isolated.
Ian.M
Verified identity
 
Posts: 95
Joined: Wed May 28, 2014 12:47 am
PIC experience: Professional 1+ years with MCHP products

Re: Adding sound to my train controller

Postby grandpa jay » Tue Jun 07, 2016 7:46 pm

Ian
This is exported from eagle. The eagle schematic file is not allowed.
Jay
Attachments
TCwS.png
TCwS.png (36.69 KiB) Viewed 6788 times
grandpa jay
 
Posts: 22
Joined: Wed Sep 24, 2014 9:10 pm

Re: Adding sound to my train controller

Postby grandpa jay » Tue Jun 07, 2016 7:50 pm

Ian
The H-bridge is not installed on the PCB or the two relays.
Jay
grandpa jay
 
Posts: 22
Joined: Wed Sep 24, 2014 9:10 pm

Re: Adding sound to my train controller

Postby grandpa jay » Thu Jun 09, 2016 2:04 pm

Gentlemen
This is the PCB that I am using.
Jay
Attachments
TCwSound.png
TCwSound.png (108.6 KiB) Viewed 6776 times
grandpa jay
 
Posts: 22
Joined: Wed Sep 24, 2014 9:10 pm

Re: Adding sound to my train controller

Postby drh » Thu Jun 09, 2016 2:57 pm

There should be a 0.1uF capacitor at the Vdd-Vss pins of the PIC. Also, your speaker traces are running next to the L293 which will be generating large current spikes, also known as noise.
User avatar
drh
Verified identity
 
Posts: 61
Joined: Tue May 27, 2014 3:31 pm
Location: Hemet, Calif.
PIC experience: Professional 5+ years with MCHP products

Re: Adding sound to my train controller

Postby grandpa jay » Thu Jun 09, 2016 4:46 pm

drh
Thank you for the reply. I will add the 0.1uF cap to the back of the PCB. The L293 is not installed at this time so the noise is not from there. I do not have a scope but the noise is very uniform.
Jay
grandpa jay
 
Posts: 22
Joined: Wed Sep 24, 2014 9:10 pm

Re: Adding sound to my train controller

Postby Roche » Fri Jun 10, 2016 9:32 am

Maybe try a few things - a largish capacitor across the supply to the MP3 player - maybe 220uF right on the pins of the connector.
Also, the 100ms trigger pulse - do you send a single pulse, or does it get re-triggered multiple times - you could try manually triggering, by lifting the pic pin, or turning it into an input...
Roche
 
Posts: 72
Joined: Fri Jul 11, 2014 12:35 pm
PIC experience: Professional 5+ years with MCHP products

Re: Adding sound to my train controller

Postby grandpa jay » Fri Jun 10, 2016 1:36 pm

Roche
Thank you, I will try the 220uF cap. The 100mx trigger is a single pulse, if I make it longer the module is setup to repeat the sound file.
Jay
grandpa jay
 
Posts: 22
Joined: Wed Sep 24, 2014 9:10 pm

Re: Adding sound to my train controller

Postby drh » Fri Jun 10, 2016 3:19 pm

Is the noise always there or just when you "play" a selection? Noise could actually be on the MP3 file. (Not too likely)

The module may be picking up noise generated by the PIC. If you remove the PIC and manually trigger it is the noise still there?

You really need to use an O'scope to check for noise on the Vcc line. It would make it a lot easier to identify the source of
the noise if we could "see" it.

It may just be a crappy PCB layout. Don't ask me how I know. :oops:
User avatar
drh
Verified identity
 
Posts: 61
Joined: Tue May 27, 2014 3:31 pm
Location: Hemet, Calif.
PIC experience: Professional 5+ years with MCHP products

Next

Return to 14-Bit Core (enhanced)

Who is online

Users browsing this forum: No registered users and 1 guest