This is only a preview of the December 2018 issue of Silicon Chip. You can view 37 of the 104 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Items relevant to "An incredibly sensitive Magnetometer to build":
Items relevant to "Amazing light display from our LED Christmas tree...":
Articles in this series:
Items relevant to "A Useless Box":
Items relevant to "El cheapo modules, part 21: stamp-sized audio player":
Items relevant to "Low voltage DC Motor and Pump Controller (Part 2)":
Purchase a printed copy of this issue for $10.00. |
Using Cheap Asian Electronic Modules Part 21: by Jim Rowe
A stamp sized
digital audio player
The DFPlayer Mini is a low-cost digital audio player module. It's
available from popular internet suppliers, including Banggood, as well
as from marketplaces like eBay and AliExpress, for as low as a few
dollars, including postage. Despite its size and price, it can do a lot!
This is a very flexible module with
a great many features. I was very impressed after trying the module out
for myself.
One of the best things about it is
that it plays several different audio
file formats, including MP3, WMA
and WAV, in mono or stereo, and it can
read those files off either a microSD
card or USB flash drive with a capacity up to 32GB in either case. But it
has a lot of other features, so let's take
a look at the hardware involved and
how to drive it.
What's inside the module
Circuit diagrams for the DFPlayer
Mini module are hard to find but an
examination of the module reveals that
it's based on two ICs: a YX5200-24SS
(IC1) which does most of the work
and a smaller 8002 audio amplifier
chip (IC2).
While data sheets for both devices
are available, the sheet for the YX5200-
24SS is almost entirely in Chinese. But
I was able to glean enough info to draw
the module's internal block diagram,
shown in Fig.1.
The YX-5200 chip is the module's
brains. Inside it, there's a 16-bit MCU
(micrcontroller), an analog DSP (digital signal processor), EPROM and flash
memory, a 24-bit stereo DAC (digitalto-analog converter), a serial UART
for communication with an external
MCU and ports to communicate with
a microSD card or a USB thumb drive.
All this in a compact 24-pin SSOP
(SMD) package – it's virtually a complete digital audio system on a chip!
The YX-5200 chip can play back
MP3, WMA and WAV files at sampling rates of 8kHz, 11.025kHz, 12kHz,
16kHz, 22.05kHz, 24kHz, 32kHz,
44.1kHz or 48kHz.
It can handle files on either microSD (“TransFlash” or TF) cards or
USB thumb drives with capacities up
to 32GB, formatted with a FAT16 or
FAT32 file system.
You can store up to 45 hours of
CD-quality WAV files on a 32GB
card/drive, or about 23 days worth of
128kbit MP3 files.
The 24-bit stereo DAC in the YX5200 is claimed to provide a dynamic
range of 90dB, with a signal-to-noise
ratio (SNR) of 85dB. That isn't exactly
hifi but it isn't too bad either.
The built-in MCU and DSP combine
to provide features like audio gain adjustment over 31 levels and the ability to select one of six playback tonal
equalisation settings.
You can also select the playback
mode (normal/repeat/folder repeat/
single repeat/random) and the playback source (USB drive, microSD card
or a couple of other options).
It also provides a BUSY logic output signal which is at logic low level
(<800mV) when playing a file, rising
to logic high (~3.5V) when playback
stops.
Turning to IC2, its operation is
quite straightforward. Housed in an
8-pin SOIC package, it's basically just
a low-power audio amplifier with a
few extras.
Running from 5V, it can deliver
up to 2W into a 4W loudspeaker load
with 10% total harmonic distortion
(THD+N), or 1.5W into an 8W load
with 1% THD+N.
Views of the top (left) and bottom of
the DFPlayer Mini module with a
microSD card inserted. It is shown at
close to double life size for clarity.
74
Silicon Chip
Australia’s electronics magazine
siliconchip.com.au
Features & Specifications
R Just 21 x 21 x 12mm including microSD card socket and pin headers
R Plays MP3, WMA and WAV audio files (4.3 filenames)
R 24-bit stereo DAC
R Built-in 2W mono bridge-mode amplifier
R Plays files from microSD cards or USB flash drives (up to 32GB)
R Multiple control options, from as few as four pushbutton switches
to full serial mode control from a microcontroller such as an Arduino
or Micromite
R Line-level stereo outputs which can also drive headphones
R Six playback equalisation options: Normal (flat), Pop, Rock, Jazz,
Classical and Bass
R Programmable playback volume in 31 steps (0-30)
R Runs from a 3.3-5.2V supply, drawing 25mA when idle or 200250mA during playback
It provides a push-pull (bridged)
output and no output coupling capacitors, snubber network or bootstrap capacitors are needed. It's also
unity-gain stable, has an externally
programmable gain and includes circuitry to suppress clicks and plops
during power on/off.
As you can see from Fig.1, the DFPlayer Mini module makes good use
of the many features provided by
both ICs.
As well as providing all of the main
control inputs needed by IC1, it also
features a microSD card socket on the
top of the module connected directly
to IC1. The latter's BUSY signal output
is brought out to a pin and also drives
LED1, a tiny blue SMD LED.
The left and right channel outputs from the YX5200's DAC are also
brought out for use in driving either
headphones or an external amplifier,
in addition to being mixed together
and fed into IC2 to drive a speaker
directly.
No socket is provided for plugging
in a USB thumb drive – just a couple
of pins identified as USB- and USB+.
I couldn't find any information on the
use of these pins anywhere in the commonly available data sheets for the DFPlayer Mini module but I guessed that
these could be connected to the D- and
D+ signal lines of a USB socket, and as
you will see later, I was right.
Fig.1: block diagram of the DFPlayer
Mini audio player module.
The total current requirement is
around 25mA when idle, rising to
around 200-250mA during playback.
The module can be used as a selfcontained audio player controlled
merely using four SPST pushbutton
switches, connected as shown in Fig.3.
Alternatively, a much larger array of
20 pushbuttons can be connected as
shown in Fig.4.
Otherwise, its operation can be controlled entirely from an Arduino, a Micromite or many other kinds of microcontroller, using the UART serial port
lines at pins 2 (RX) and 3 (TX), along
with the BUSY signal from pin 16. This
configuration is shown in Figs.5 & 6.
The rest of the connections are to
make use of the module's extra features.
For example, you can use it to play
files from a USB thumb drive by connecting up a Type A USB socket as
shown at the top right of Fig.2, with
pin 1 connected to the +5V supply,
pins 2 and 3 to pins 15 (USB-) and 14
(USB+) of the module, and pin 4 to the
module ground (pins 7 or 10).
The dashed connections to pins 4
(DAC_R) and 5 (DAC_L) of the module show how it can be used to drive
either stereo headphones or line-level
outputs to an external stereo amplifier
or hifi system.
Returning now to Fig.3, which
shows the simple four-pushbutton
control scheme, S1 and S2 have dual
functions in this mode. A short press
is used to move to the previous track
(S1) or the next track (S2), while a
longer press either decreases (S1) or
increases (S2) the volume. S3 and S4
each have only single functions, to
start playing the first track (S3), or the
fifth track (S4).
The more complex pushbutton con-
Putting it to use
Fig.2 shows how to wire up the
DFPlayer Mini module. The speaker
(if used) connects directly between
the SPK_1 and SPK_2 pins (6 and 8)
while the module's power supply (3.35.2V DC) is fed to pin 1 (Vcc) and pins
7/10 (GND).
siliconchip.com.au
Fig.2: This shows how to connect the audio player module for playback to a
speaker, headphones or other audio devices via the level outputs.
Australia’s electronics magazine
December 2018 75
Press S1: previous track
Hold S1: increase volume
Press S2: next track
Hold S2: decrease volume
Press S3: play first track
Press S4: play fifth track
Fig.3: the simplest method of controlling the DFPlayer module is by using four
pushbutton switches. Track 5 is equivalent to 005.mp3 (four characters at most
for a filename, three for the extension); folders are named 01 to 99.
trol arrangement of Fig.4 is a bit more
tricky. To allow twenty pushbuttons
to be connected using just two pins,
each of the ten pushbuttons in a given
“bank” has a different resistor value
connected in series.
The chip then measures the current
sunk from pin 12 or 13 when a button is pressed and depending on what
range it is in, it knows which button
was pressed.
In this mode, most of the extra
switches (S7 - S20) are simply used to
allow direct selection of tracks to play.
Switches S5 and S6 basically duplicate the actions of S1 and S2 in Fig.3,
while the first four switches (S1 - S4)
allow control over the playback mode
(single track/continuous), playback
source (USB/SD/SPI/SLEEP), enable
loop all mode and provide the pause/
play function.
Controlling it with a micro
Hooking the DFPlayer Mini up to a
microcontroller is simple, thanks to the
module's built-in UART serial port. You
just need to connect the module's RX
input (pin 2) to the serial TX output of
the micro and connect the module's TX
output (pin 3) to the serial RX input of
the micro. The GND of the module (pin
7 and/or 10) also needs to be connected
to the micro's ground network.
The module's UART is pre-programmed to communicate at 9600
baud, with the basic 8N1 protocol. It's
also a good idea to link the module's
BUSY output (pin 16) to a digital input on the micro so that the control
program can tell whether the module
is playing a file or has stopped.
Arduino specifics
Fig.5 shows the connections for controlling the module from an Arduino.
It's powered from the Arduino's 5V
supply, which is fed to its Vcc pin (pin
1). For serial communications, we're
using Arduino digital I/O pins 10 and
11, which are driven by the SoftwareSerial library code.
The D11 digital output is connected to the RX pin on the module via
a 1kW series resistor. That's because
the module inputs can handle a 3.3V
signal while the Arduino pins have a
5V swing.
The resistor limits the current into
the module's RX pin to a reasonable
level (less than 2mA) when D11 is
driven high. The only other connection needed is between pin 16 of the
module (BUSY) and D3 of the Arduino, for the reasons described above.
For clarity, Fig.5 does not show a
USB socket, headphone socket, line
outputs etc, which were shown in
Fig.2. But these can certainly be included if you need those functions.
There are many different libraries
and sketches on the internet which
show how to drive the DFPlayer Mini
from an Arduino, although some are a
bit flakey and/or hard to understand.
But one of the best is from the manufacturers themselves, DFRobot and
is called “DFRobotDFPlayerMini1.0.3.zip”. It includes a set of exam-
Fig.4: a more complex method for control involves 20
pushbuttons, each with a series resistor (except S10 &
S20). S7-20 just allows playback of tracks 1-14 directly
(holding the switch will cause it to repeat indefinitely),
while the rest of the switches are for playback
functionality with S5/6 identical to S1/2 in Fig,3.
Switch functions:
S1 – single track/continuous playback
S2 – change playback source (USB/SD/SPI/sleep [none])
S3 – loops the current track
S4 – pause/play
76
Silicon Chip
Australia’s electronics magazine
siliconchip.com.au
Fig.5: wiring diagram for
the audio player module
when connected
to an Arduino.
ple sketches and you will find a link
to download it below.
Driving it from a Micromite
If you're one of the many Micromite enthusiasts, Fig.6 shows the basic connections needed to control the
DFPlayer Mini module from a Micromite Backpack.
The arrangement is very similar to
that for the Arduino. The module's
RX (2) and TX (3) pins are connected to pins 9 and 10 of the Micromite
respectively, again with a 1kW series
resistor in series with the line to the
module's RX pin.
Pins 9 and 10 of the Micromite are
the TX and RX pins for the Micromite's
COM2 serial port. The remaining connection is from the BUSY pin (16) of
the module to pin 24 of the Micromite, again to provide a playing/not
playing signal. And again, for clarity,
Fig.6 leaves out any extra connections
you may wish to make to the DFPlayer module, like those shown in Fig.2.
I couldn't find any pre-existing Micromite programs to control a DFPlayer Mini, so I wrote one myself,
after studying the YX5200-24SS data
sheet and also some of the Arduino
library files. The program is called
“DFPlayerMini control program.bas”
and it's available from the Silicon
Chip website.
It's designed to run on the LCD BackPack (see February 2016 [siliconchip.
com.au/Article/9812] and May 2017
[siliconchip.com.au/Article/10652]
issues);
As you can see from the screen grab
of the LCD touchscreen, the program
gives you a set of six touch buttons
labelled PLAY, PAUSE, PREV, NEXT,
VOLUME (down) and VOLUME (up).
Touching any of these buttons makes
the Micromite send a command to
the module to achieve the desired response, similarly to how the hardware
switches shown in Fig.3 work.
Now this MMBasic program is pretty
simple but it should give you a good
starting place for writing more elaborate programs yourself. With the technical information on the DFPlayer
Mini module in this article, you should
be able to get the module performing
all kinds of impressive tricks!
Handy links
Module information and software:
siliconchip.com.au/link/aald
Software library and sketches:
siliconchip.com.au/link/aale
Documentation and Arduino library:
siliconchip.com.au/link/aalf
SC
Above: screenshot of the MMBasic example program running on a Micromite.
Fig.6 (right): wiring diagram of the audio player module connected to a Micromite.
siliconchip.com.au
Australia’s electronics magazine
December 2018 77
|