Silicon ChipStamp-sized digital audio player - February 2020 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Subscriptions: PE Subscription
  4. Publisher's Letter
  5. Feature: The Fox Report by Barry Fox
  6. Feature: Techno Talk by Mark Nelson
  7. Feature: Net Work by Alan Winstanley
  8. Project: Audio DSP by Design by Phil Prosser , Words by Nicholas Vinen
  9. Project: Motion-Triggered 12V Switch by Nicholas Vinen
  10. Project: USB Keyboard and Mouse Adaptor for Micros by Tim Blythman
  11. Project: Stamp-sized digital audio player by Jim Rowe
  12. Project: Colour Maximite Computer
  13. Feature: Circuit Surgery by Ian Bell
  14. Feature: Practically Speaking by Mike Hibbett
  15. Feature: Using Stepper Motors by Paul Cooper
  16. Feature: Max’s Cool Beans by Max the Magnificent
  17. Feature: AUDIO OUT by Jake Rothman
  18. Feature: Make it with Micromite by Phil Boyce
  19. Feature: Electronic Building Blocks by Julian Edgar
  20. PCB Order Form
  21. Advertising Index

This is only a preview of the February 2020 issue of Practical Electronics.

You can view 0 of the 80 pages in the full issue.

Articles in this series:
  • Techno Talk (February 2020)
  • Techno Talk (February 2020)
  • Techno Talk (March 2020)
  • Techno Talk (March 2020)
  • (April 2020)
  • (April 2020)
  • Techno Talk (May 2020)
  • Techno Talk (May 2020)
  • Techno Talk (June 2020)
  • Techno Talk (June 2020)
  • Techno Talk (July 2020)
  • Techno Talk (July 2020)
  • Techno Talk (August 2020)
  • Techno Talk (August 2020)
  • Techno Talk (September 2020)
  • Techno Talk (September 2020)
  • Techno Talk (October 2020)
  • Techno Talk (October 2020)
  • (November 2020)
  • (November 2020)
  • Techno Talk (December 2020)
  • Techno Talk (December 2020)
  • Techno Talk (January 2021)
  • Techno Talk (January 2021)
  • Techno Talk (February 2021)
  • Techno Talk (February 2021)
  • Techno Talk (March 2021)
  • Techno Talk (March 2021)
  • Techno Talk (April 2021)
  • Techno Talk (April 2021)
  • Techno Talk (May 2021)
  • Techno Talk (May 2021)
  • Techno Talk (June 2021)
  • Techno Talk (June 2021)
  • Techno Talk (July 2021)
  • Techno Talk (July 2021)
  • Techno Talk (August 2021)
  • Techno Talk (August 2021)
  • Techno Talk (September 2021)
  • Techno Talk (September 2021)
  • Techno Talk (October 2021)
  • Techno Talk (October 2021)
  • Techno Talk (November 2021)
  • Techno Talk (November 2021)
  • Techno Talk (December 2021)
  • Techno Talk (December 2021)
  • Communing with nature (January 2022)
  • Communing with nature (January 2022)
  • Should we be worried? (February 2022)
  • Should we be worried? (February 2022)
  • How resilient is your lifeline? (March 2022)
  • How resilient is your lifeline? (March 2022)
  • Go eco, get ethical! (April 2022)
  • Go eco, get ethical! (April 2022)
  • From nano to bio (May 2022)
  • From nano to bio (May 2022)
  • Positivity follows the gloom (June 2022)
  • Positivity follows the gloom (June 2022)
  • Mixed menu (July 2022)
  • Mixed menu (July 2022)
  • Time for a total rethink? (August 2022)
  • Time for a total rethink? (August 2022)
  • What’s in a name? (September 2022)
  • What’s in a name? (September 2022)
  • Forget leaves on the line! (October 2022)
  • Forget leaves on the line! (October 2022)
  • Giant Boost for Batteries (December 2022)
  • Giant Boost for Batteries (December 2022)
  • Raudive Voices Revisited (January 2023)
  • Raudive Voices Revisited (January 2023)
  • A thousand words (February 2023)
  • A thousand words (February 2023)
  • It’s handover time (March 2023)
  • It’s handover time (March 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • Prophecy can be perplexing (May 2023)
  • Prophecy can be perplexing (May 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • How long until we’re all out of work? (August 2023)
  • How long until we’re all out of work? (August 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • Holy Spheres, Batman! (October 2023)
  • Holy Spheres, Batman! (October 2023)
  • Where’s my pneumatic car? (November 2023)
  • Where’s my pneumatic car? (November 2023)
  • Good grief! (December 2023)
  • Good grief! (December 2023)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (February 2024)
  • Cheeky chiplets (February 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk (July 2024)
  • Techno Talk (July 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk (November 2024)
  • Techno Talk (November 2024)
  • Techno Talk (December 2024)
  • Techno Talk (December 2024)
  • Techno Talk (January 2025)
  • Techno Talk (January 2025)
  • Techno Talk (February 2025)
  • Techno Talk (February 2025)
  • Techno Talk (March 2025)
  • Techno Talk (March 2025)
  • Techno Talk (April 2025)
  • Techno Talk (April 2025)
  • Techno Talk (May 2025)
  • Techno Talk (May 2025)
  • Techno Talk (June 2025)
  • Techno Talk (June 2025)
  • Techno Talk (July 2025)
  • Techno Talk (July 2025)
Using Cheap Asian Electronic Modules Part 21: by Jim Rowe Stamp-sized digital audio player The DFPlayer Mini is a low-cost digital audio player module. It’s available from popular Internet suppliers, including uk.banggood.com and Amazon. co.uk, as well as marketplaces like eBay and AliExpress, for a couple of pounds, including postage. Despite its size and price, it can do a lot! T he DFPlayer Mini is a very flexible module with a great many features. I was 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 surprisingly 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 YX520024SS 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 analogue DSP (digital signal processor), EPROM and Flash memory, a 24-bit stereo DAC (digitalto-analogue 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 CDquality WAV files on a 32GB card/drive, or about 23-days worth of 128kbit MP3 files – a lot! 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 HI-Fi, 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 4Ω loudspeaker load with 10% total harmonic distortion (THD+N), or 1.5W into an 8Ω load with 1% THD+N. 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 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. 38 Practical Electronics | February | 2020 Features and specifications n Just 21 × 21 × 12mm including microSD card socket and pin headers n Plays MP3, WMA and WAV audio files (4.3 filenames) n 24-bit stereo DAC n Built-in 2W mono bridge-mode amplifier n Plays files from microSD cards or USB Flash drives (up to 32GB) n Multiple control options, from just four pushbutton switches to full serial mode control from a microcontroller (eg, Arduino or Micromite) n Line-level stereo outputs which can also drive headphones n Six playback equalisation options: Normal (flat), Pop, Rock, Jazz, Classical and Bass n Programmable playback volume in 31 steps (0-30) n Runs from a 3.3-5.2V supply, drawing 25mA when idle or 200-250mA during playback. 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. show how it can be used to drive either stereo headphones or line-level outputs to an external stereo amplifier or HI-Fi 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 control arrangement of Fig.4 is a bit more tricky. To allow twenty pushbuttons to be connected using just two pins, each 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.3-5.2V DC) is fed to pin 1 (VCC) and pins 7/10 (GND). The total current requirement is around 25mA when idle, rising to around 200-250mA during playback. The module can be used as a self-contained audio player, controlled using just 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 and 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 Fig.3: the simplest method of controlling the DFPlayer Mini 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. Practical Electronics | February | 2020 39 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. 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.4: a more complex method for control involves 20 pushbuttons, each with a series resistor (except S10 and 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 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 1kΩ 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, for example, a USB socket, headphone socket or line outputs, 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 DFRobotDFPlayerMini-1.0.3.zip – it includes a set of example sketches and you will find a link to download it below. Fig.5: wiring diagram for the audio player module when connected to an Arduino. 40 Practical Electronics | February | 2020 Screenshot of the MMBasic example program running on a Micromite. 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 1kΩ 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 Mini 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 some Arduino library files. The program is called DFPlayerMini control program.bas and is available from the February 2020 page of the PE website. It’s designed to run on the LCD BackPack (see May 2017 and May 2018). 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! www.poscope.com/epe Handy links Module information and software: http://bit.ly/pe-feb20-dfp1 Software library and sketches: http://bit.ly/pe-feb20-dfp2 Documentation and Arduino library: http://bit.ly/pe-feb20-dfp3 Reproduced by arrangement with SILICON CHIP magazine 2020. www.siliconchip.com.au - USB - Ethernet - Web server - Modbus - CNC (Mach3/4) - IO - PWM - Encoders - LCD - Analog inputs - Compact PLC - up to 256 - up to 32 microsteps microsteps - 50 V / 6 A - 30 V / 2.5 A - USB configuration - Isolated PoScope Mega1+ PoScope Mega50 Fig.6: wiring diagram of the audio player module connected to a Micromite. Practical Electronics | February | 2020 - up to 50MS/s - resolution up to 12bit - Lowest power consumption - Smallest and lightest - 7 in 1: Oscilloscope, FFT, X/Y, Recorder, Logic Analyzer, Protocol decoder, Signal generator 41