DFPlayer Build

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

DFPlayer Build

Post by JLeith »

He All
My DFPlayer just arrived this morning and I'm excited to learn more on the DFPlayer Mini

I believe the Model is DFR0299 from the paper work. Can't see any markings on the player.

I have 2 designs I'm going to try.
1. Resistor value and connect to AdKey_2
2. The RX /TX with RS232 programming

The Resistor version 1 is using a 8 relay interface and sending Port A = 0B11111110 commands Logic 0 to activate the relays.

Option 2 (RS232) I do recall working with RS232 back in Flowcode 5 but I lost all the files on the PC Crash. So I don't have examples to look over.

Knowledge:
I know the DFplayer runs on 3V VCC and Grd
Speaker 4ohm connects to SPK_1 & Spk_2
......End of my Knowledge

Questions at this time....
1. What size of Micro SD card do I use ?
2. Need refresher course on the building blocks for RS232.

Here is my possible design.

John
Attachments
DFPlayer & PIC and relay.png
(191.81 KiB) Downloaded 5334 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: DFPlayer Build

Post by medelec35 »

Hi John,
DFPlayer can work from about 3.2 to 5V.
The Resistor goes from MCU TX to DFPlayer RX
All makes of SD cards i have tried seem to work I'm currently using 16G Scandisk
There are two ways of placing the files on the SD card.
1 which is the best way:
Make a folder called MP3 on the root of sd card.
place all the audio files within MP3 folder with the file name is the format of 0001_Name.mp3, 0002 Name.mp3 etc
The track number only will be specified within the commands. The names are ignored.
2 you can pace them directly on the root but the first song will not necessarily be 0001 but the order in which the files was save to card.
so if 0003 was first then 0001 second, then the first track would indeed be 0003.
Martin

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: DFPlayer Build

Post by JLeith »

I pickup up a SD card 32GB.
I have wired the DFPlayer.
I will now work on the MP3 Sounds

For the RS232 commands ?

John

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: DFPlayer Build

Post by JLeith »

Revised drawing for the 1K on the PIC (TX) to the DF RX

John
Attachments
DFPlayer & PIC and relay.png
(192.22 KiB) Downloaded 5324 times

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: DFPlayer Build

Post by JLeith »

I have added 2 MP3 Files to the MP3 Folder
MP3.png
(3.99 KiB) Downloaded 5323 times
John

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: DFPlayer Build

Post by medelec35 »

Hi John,
Attached are mp3 files for testing that will count from one to ten and back down again.
It's using command 0x12.
For some silly reason that is the main command for playing a track number, but was left off the data sheet.
What you can see on the datasheet is 0x03.
that is Play FAT file number.
So if using number 4, it will not necessarily play track named 0004, but will play the fourth MP3 that was added to the sd card.
The file name will be ignored
The volume is set low at 3, but you should see a volume calculation box that will allow you to change the volume.
You will of course need to change target device and clock speed to suit.
Attachments
DFPlayer Count up down 16F1937.fcfx
(22.61 KiB) Downloaded 331 times
One to Ten.zip
(92.74 KiB) Downloaded 313 times
Martin

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: DFPlayer Build

Post by JLeith »

Thank you Martin

Only 1 noticed difference is the RS232 on your Count down

Your is listed as UART. I looked but can't see a UART communication. I do see in properties it Type RS232
UART.png
(5.71 KiB) Downloaded 5293 times
I will do some study on the programs.

Back soon
John

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: DFPlayer Build

Post by medelec35 »

Hi John,
They are both referring to the same component.
UART = 5V version of RS232
So the RS232 component is used.
I used flowcode V8 at its just great!
If does not work with V6 then I will post a V6 working version.
I'm guessing it should work?
It's interesting controlling the Dfplayer via Bluetooth.
I could select a track number via my mobile and it would play the correct track.
just like a MP3 player
Martin

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: DFPlayer Build

Post by medelec35 »

Hi John,
If you can't get DFPlayer to work, there is a way of ruling in or out communications from UART (RS232)
Just Connect a flying lead to IO_2.
Each time you briefly connnect the other end to ground, A track should play (FAT order only).
By holding the lead on ground will increase volume.
So if it does play a track ok, then issue is of course with comms from MCU.
If not, suspect card, player or file not correct format.
Martin

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: DFPlayer Build

Post by JLeith »

Hi Martin
I was able to get the IO_2 pulse to ground to play my MP3 1 then play MP3 2.

Not able to play the files via the PIC.

I'm not 100% sure how to interface my Train detection 1 - Play MP3 - 1
Then Train detection 2 - Play MP3 - 2.... And others to come

I have attached my Version 1 Flowcode.
I took the DFplayer files from your 'Count Down" hope I got the ones I needed.
Maybe I could send some info to my LCD to follow the actions ?

In my current design I detect Port B0 then active the Macro - Train Detected.
Not sure how to send the DFplayer to play a file

I placed notes in the main to follow.

John
Attachments
Christmas_dfPlayer VER1.fcfx
(44.26 KiB) Downloaded 276 times
PIC to DF.png
(4.39 KiB) Downloaded 5273 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: DFPlayer Build

Post by medelec35 »

Hi John
To make a track 3 play for example:

Code: Select all

Commands = 0x12
CommandFeedback = 0
Parameter1HighByte = 0 //Track number HB
Parameter2LowByte = 3 //Track number LB
You may find it easer if using decimal instead of hex.

If you want to play a track number less then 255 then keep Parameter1HighByte at 0
Parameter2LowByte = track number to play & command 0x12 is just the command to play a specified track number that's within MP3 folder

The problem is you have got Parameter2LowByte after // which means it's ignored.
So within your flwochart, if you need to play track 2 you need to make sure:

Code: Select all

Commands = 0x12
CommandFeedback = 0
Parameter1HighByte = 0 //Track number HB
Parameter2LowByte = 2 //Track number 2
is accessed.
Martin

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: DFPlayer Build

Post by JLeith »

Hi Martin
Not getting the RS232 to work ?
Checked my wiring and all checks out.

I used the relay connection worked on Adkey_1

Is there a test to confirm RS232 I could do ?

John
Attachments
Setting not working.png
(7.52 KiB) Downloaded 5256 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: DFPlayer Build

Post by medelec35 »

Hi John,
JLeith wrote:Is there a test to confirm RS232 I could do ?
The best way is with a TTL compatible USB to RS232 converter. (could also be known as USB to UART)
I mentioned it here as they do come in very useful for diagnostics.
Just make sure you pick one that's the correct voltage as you can get 3V3 and 5V versions

Have you made sure that the DFP VCC is directly connected to MCU VCC?
Can you post your latest flowchart.
The flowchart I posted should have worked as test, then you could easily adapt it to suit your needs.
Martin

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: DFPlayer Build

Post by JLeith »

Cold morning here today
For the TTL cable the connection to the DFplayer is just 2 wires (TX/RX)
For the power to the DFplayer.

I didn't load you example your chip was 16F1937 (40pin) mine was 16F1938 (28 Pin)

Here is my Flowcode

In the Sendbyte I noticed code to dp Version and File size.
Is that not a question to the DF. Could we collect the Version number from the DF and post on LCD ?

John
Attachments
Christmas_dfPlayer VER1.fcfx
(44.7 KiB) Downloaded 193 times
Power.png
(5.22 KiB) Downloaded 5237 times

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: DFPlayer Build

Post by JLeith »

I have converted to 12V power supply rather then a battery.

Martin I'm converting your program to the RS232 and pic161938 and will load and see what happens

John

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: DFPlayer Build

Post by medelec35 »

Hi John,
You also don't connect it up like the way you did.
You must never have data pins going to a higher voltage than the supply.
If the data pins are going to 5V via MCU (although there is a resistor in series) but the device VCC is connected to 3V then that's not the way.
You could end up damaging the DFPlayer.
Don't forget the DFPlayer can go up to 5V.
So, as I stated earlier, connect the DFPlayer VCC and MCU VCC together!
Also at this stage you only need one wire connected(TX of MCU to RX of player).
The other connection(TX of player to RX of MCU) is not required.
Martin

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: DFPlayer Build

Post by JLeith »

Hi Martin
I did what you indicated for the VCC
I connected the DFPlayer to the 5V supply of the PIC.

No changes in my program. I converted your Count Program.
The count program runs in Flowcode but not on the PIC.
I have the count set to display on the LCD.
The PIC LCD displays
1. Hello 2 then nothing
2. Flowcode
A. Hello 2
B. Hello
C Hello 1---10

I also order and received a new DFplayer from a Canadian company (Digi Key) Ordered last night and it arrived this morning at 10am.

No difference in the action
I have the SD card loaded with your 1-10 count.
When I do the Grd Flash on the (IO1) pin of the DFplayer I can go thru sound off 10 - 1.

I have sent the Count flowcode maybe you can see why the PIC won't run.
I did change the Count program to Internal OSC.

John
Attachments
DFPlayer Count up down 16F1938.fcfx
(20.32 KiB) Downloaded 225 times

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: DFPlayer Build

Post by JLeith »

Question
Can we send a msg to put the DFplayer in a busy state that will turn on the led on the DFplayer.

The Led comes on when the OI1 is activated.

John

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: DFPlayer Build

Post by medelec35 »

Hi John,
Whenever you create a new project, ALWAYS connect an LED via a resistor with Loop: LED on, 1sec, LED off, sec.
You must make sure the LED is flashing at the correct rate.
If with your project RS232 is not at the correct baud rate because osc at running at wrong speed, then project will not work!

Looking at your flowchart you have clock speed set to19660800, Yet you also have the internal osc enabled.
I'm not surprised it's not working.
You need to remember that the clock speed is for delays and vital timing of components like UART LCD etc.
It does not control the harware clock speed, it's

Code: Select all

OSCCON=0xXX
which does.
OK lets use an internal osc of 16MHz.
You will need to set the osc to internal then look at the datasheet for your device and add a C code with correct

Code: Select all

OSCCON
;value.
That must be very first code accessed!
To do that look at this post.
Martin

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: DFPlayer Build

Post by JLeith »

Hello Martin

Thank you for your help.
Thank you.png
(54.42 KiB) Downloaded 5207 times
John

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: DFPlayer Build

Post by medelec35 »

Hi John,
Glad its working now.
Thanks for the update.
Martin

Post Reply