Open LepiDelfin opened 1 year ago
Hello, I am sorry that you are having difficulty. It has been a long time since I have played with this library. So I literally dusted off the parts and did a fresh install of Arduino IDE 2.0.4 and pulled the current SdFAT 2.2.0 and the VS1053 for SdFAT 1.3.0 and I did not experience the problems you described. Rather it worked for me, right out of the box.
I suspect your observation is due to a version of compiler. Note I think the real problem is below. I read the following link https://forum.arduino.cc/t/warning-iso-c-forbids-converting-a-string-constant-to-char/634147/8 I did change line 292 to the following
char patch053fn[] = "patches.053";
if(VSLoadUserCode("patches.053")) return 6;
and for me it worked just the same. Give it a try. but notice the forum indicated that it was a warning. and to ignore it. The fact that you are able to run it and get to a prompt and attempt to play the file indicates that that may not be your real issue.
To wrap up the above issue, I have seen instances in the past where a gcc compiler already installed on the system finds its way via path to be what the IDE or other will use to compile. And when that happens all bets are off, as to what that compiler will enforce or not.
About the ERROR CODE 2. Have you looked at https://mpflaga.github.io/Arduino_Library-vs1053_for_SdFat Specifically https://mpflaga.github.io/Arduino_Library-vs1053_for_SdFat/#Error_Codes It states ERROR CODE 2 is filename not found. Note you are not getting a NO SdCARD found or something like that. So it found the SdCard.
Have you issued the 'd' directory print command. Does it find the track001.mp3 file? It may be that you need sample files. I would also recommend placing the *.053 plugin files onto the SdCard. The code will update the VS1053 with them.
Thank you for your reply. I know this project is quite old and so I am even more grateful for your continued support.
I am using the same versions of IDE and libraries as you. Is it possible that you don't get the warning because under "File -> Preferences -> Compiler warnings" you have it set to "none"? Even if i substitute the code you provided on line 292 in vs1053_SdFat.cpp I still get the same warning. And in the Serial Monitor I still get: Error code: 6 when trying to start MP3 player Warning: patch file not found, skipping.
Do you also get this warning? Is the patch file even necessary for the VS1053 to function? It just seems like to big of a coincidence that the function I am getting a warning for is also the one returning an error in the Serial Monitor. The error prints because the function VSLoadUserCode(char* fileName) called in line 292 returns 2. If i look at the definition of this function on line 328, I can see that the function returns 2 in line 339. This is because track.open(fileName, O_READ) returns 0. But I can't find where this function is defined. I think the return in 339 ends the function before the patch file can update the VS1053.
However, the wording in the last paragraph of your reply suggests that that patch files are not a must and that Error code 6 should also be ignored.
It might be worthwhile to mention I have SD Schip Select connected to pin 9 and made sure that it is also set as 9 in vs1053_SdFat_config. But I don't think this is an issue because as you said it appears to have found the SD card.
So, for now I will ignore the Error 6 and the compiler warning and try to tackle the: Error code: 2 when trying to play track. If I run the SdFat library example program QuickStart it prints the following:
Card successfully initialized. Card size: 15942 MB (MB = 1,000,000 bytes) Volume is FAT32, Cluster size (bytes): 32768 Files found (date time size name): 2023-03-18 21:32 3558641 track001.mp3 2023-03-18 21:33 4424444 track002.mp3 2023-03-18 21:33 2524819 track003.mp3 2023-03-18 21:34 8020269 track004.mp3 2018-02-09 05:38 16766 patchesd.053 2018-02-09 05:38 16378 patchesf.053 2018-02-09 05:38 8626 patchesl.053 2018-02-09 05:38 1642 pcm.053 2018-02-09 05:38 2746 pshift.053 2018-02-09 05:38 56 rtmidi.053 2018-02-09 05:38 210 admxleft.053 2018-02-09 05:38 222 admxmono.053 2018-02-09 05:38 210 admxrght.053 2018-02-09 05:38 234 admxster.053 2018-02-09 05:38 234 admxswap.053 2018-02-09 05:38 4186 eq5.053 2018-02-09 05:38 17096 patchefl.053 2018-02-09 05:38 6350 patches.053
So the SD card is definitely readable and i think the files are named correctly. When I open the SD card in windows it only says for instance track001, without the file extension. I have read on the internet that that it how you are supposed to name them, without the extension in the name.
However if i type the command "d" i just prints:
Received command: d Files found (name date time size): Time since last command: 18.11 Enter s,1-9,+,-,>,<,f,F,d,i,p,t,S,b,m,e,r,R,g,k,O,o,D,V,B,C,T,E,M:,h : Received command:
Time since last command: 0.10 Enter s,1-9,+,-,>,<,f,F,d,i,p,t,S,b,m,e,r,R,g,k,O,o,D,V,B,C,T,E,M:,h :
I have reviewed the part of code that i think covers the d command but have no idea why it doesn't work.
If i try the Fileplayer example i first get the error: fatal error: vs1053.h: No such file or directory. If I change vs1053.h for vs1053_SdFat.h I then get a whole hoard of errors.
I know this is a really long reply, I just want to note my observations as thoroughly as I can. Thank you for your help.
Yes, I have my preferences to see all the compile and upload messages. No, I do not see that error. Yes, the patches are optional. for the basic functions. There may be some bugs in the VS1053. However, you are not even getting there. In the past my go to suggestion is to load the SdFAT QuickStart as you have. All of the times I remember, the people are not seeing even that. Which would be a SdCard issue. But here you see what is expected. There is an initializer for "SdFile vs1053::track;" So that track.open and the other methods are inherited from SdFAT's SdFile class Please make sure the VS INIT pin is not connected to anything else. Likely that is good for you and the case here.
There appears to me to be two critical observations. 1) The compile error. While it seems like a warning and should be a don't care. It is too coincidental. 2) When you use code that uses both the SdFAT and the VS1053 it does not see the SdCard contents. Have you tried the playing the MIDI beep. command. To see if the VS1053 is working. On its own. This lends me back to the interrupt or other wires/resources that are shared.
Also have you tried the Adafruit VS1053. I recall it used to work just fine. As it used the stock SdCard library. But may have needed its INT pin changed from its default.
On Tue, Mar 21, 2023 at 2:55 PM LepiDelfin @.***> wrote:
Thank you for your reply. I know this project is quite old and so I am even more grateful for your continued support.
I am using the same versions of IDE and libraries as you. Is it possible that you don't get the warning because under "File -> Preferences -> Compiler warnings" you have it set to "none"? Even if i substitute the code you provided on line 292 in vs1053_SdFat.cpp I still get the same warning. And in the Serial Monitor I still get: Error code: 6 when trying to start MP3 player Warning: patch file not found, skipping.
Do you also get this warning? Is the patch file even necessary for the VS1053 to function? It just seems like to big of a coincidence that the function I am getting a warning for is also the one returning an error in the Serial Monitor. The error prints because the function VSLoadUserCode(char* fileName) called in line 292 returns 2. If i look at the definition of this function on line 328, I can see that the function returns 2 in line 339. This is because track.open(fileName, O_READ) returns 0. But I can't find where this function is defined. I think the return in 339 ends the function before the patch file can update the VS1053.
However, the wording in the last paragraph of your reply suggests that that patch files are not a must and that Error code 6 should also be ignored.
It might be worthwhile to mention I have SD Schip Select connected to pin 9 and made sure that it is also set as 9 in vs1053_SdFat_config. But I don't think this is an issue because as you said it appears to have found the SD card.
So, for now I will ignore the Error 6 and the compiler warning and try to tackle the: Error code: 2 when trying to play track. If I run the SdFat library example program QuickStart it prints the following:
Card successfully initialized. Card size: 15942 MB (MB = 1,000,000 bytes) Volume is FAT32, Cluster size (bytes): 32768 Files found (date time size name): 2023-03-18 21:32 3558641 track001.mp3 2023-03-18 21:33 4424444 track002.mp3 2023-03-18 21:33 2524819 track003.mp3 2023-03-18 21:34 8020269 track004.mp3 2018-02-09 05:38 16766 patchesd.053 2018-02-09 05:38 16378 patchesf.053 2018-02-09 05:38 8626 patchesl.053 2018-02-09 05:38 1642 pcm.053 2018-02-09 05:38 2746 pshift.053 2018-02-09 05:38 56 rtmidi.053 2018-02-09 05:38 210 admxleft.053 2018-02-09 05:38 222 admxmono.053 2018-02-09 05:38 210 admxrght.053 2018-02-09 05:38 234 admxster.053 2018-02-09 05:38 234 admxswap.053 2018-02-09 05:38 4186 eq5.053 2018-02-09 05:38 17096 patchefl.053 2018-02-09 05:38 6350 patches.053
So the SD card is definitely readable and i think the files are named correctly. When I open the SD card in windows it only says for instance track001, without the file extension. I have read on the internet that that it how you are supposed to name them, without the extension in the name.
However if i type the command "d" i just prints:
Received command: d Files found (name date time size): Time since last command: 18.11 Enter s,1-9,+,-,>,<,f,F,d,i,p,t,S,b,m,e,r,R,g,k,O,o,D,V,B,C,T,E,M:,h : Received command:
Time since last command: 0.10 Enter s,1-9,+,-,>,<,f,F,d,i,p,t,S,b,m,e,r,R,g,k,O,o,D,V,B,C,T,E,M:,h :
I have reviewed the part of code that i think covers the d command but have no idea why it doesn't work.
If i try the Fileplayer example i first get the error: fatal error: vs1053.h: No such file or directory. If I change vs1053.h for vs1053_SdFat.h I then get a whole hoard of errors.
I know this is a really long reply, I just want to note my observations as thoroughly as I can. Thank you for your help.
— Reply to this email directly, view it on GitHub https://github.com/mpflaga/Arduino_Library-vs1053_for_SdFat/issues/18#issuecomment-1478426655, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAO26IUQFR6XMPYMUBLEHULW5H2QFANCNFSM6AAAAAAWAPVUIY . You are receiving this because you commented.Message ID: @.***>
--
Michael P. Flaga, @.***
I will try using the Adafruit VS1053. The "Play a MIDI File Beep" plays a beep.
But I think there might be something behind this VS INT pin. I am assuming you are talking about the MP3_DREQINT pin. By default it is set to 0. On the internet it says that the interrupt pins on the mega are : "2, 3, 18, 19, 20, 21 (pins 20 & 21 are not available to use for interrupts while they are used for I2C communication)". So I am hoping that this is the problem. My problem is that on the mp3 shield I am using (https://www.elecrow.com/wiki/index.php?title=VS1053_MP3_Shield) I don't know which pin is supposed to be the MP3_DREQINT. Currently i have the MP3_DREQ pin on my Arduino set to 2 and and have it connected to the DREQ pin on the shield. But I don't know what to connect the DREQINT pin to (which pin on the shield it is). Or does my shield not have a DREQINT pin? Can it work without one? I am honestly just getting more and more confused.
See this documentation https://mpflaga.github.io/Arduino_Library-vs1053_for_SdFat/vs1053___sd_fat__config_8h.html#a4c60fb7c286789d19f9ed13a19891653 It describes that you can turn off the interruptions, in the config file.
So that the demo will poll the DREQ with line https://github.com/mpflaga/Arduino_Library-vs1053_for_SdFat/blob/master/examples/demo/demo.ino#L31
On Thu, Mar 23, 2023 at 10:30 AM LepiDelfin @.***> wrote:
I will try using the Adafruit VS1053. The "Play a MIDI File Beep" plays a beep.
But I think there might be something behind this VS INT pin. I am assuming you are talking about the MP3_DREQINT pin. By default it is set to 0. On the internet it says that the interrupt pins on the mega are : "2, 3, 18, 19, 20, 21 (pins 20 & 21 are not available to use for interrupts while they are used for I2C communication)". So I am hoping that this is the problem. My problem is that on the mp3 shield I am using (https://www.elecrow.com/wiki/index.php?title=VS1053_MP3_Shield) I don't know which pin is supposed to be the MP3_DREQINT. Currently i have the MP3_DREQ pin on my Arduino set to 2 and and have it connected to the DREQ pin on the shield. But I don't know what to connect the DREQINT pin to (which pin on the shield it is). Or does my shield not have a DREQINT pin? Can it work without one? I am honestly just getting more and more confused.
— Reply to this email directly, view it on GitHub https://github.com/mpflaga/Arduino_Library-vs1053_for_SdFat/issues/18#issuecomment-1481301869, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAO26IWL3LOEFTSKKIYGI53W5RM7BANCNFSM6AAAAAAWAPVUIY . You are receiving this because you commented.Message ID: @.***>
--
Michael P. Flaga, @.***
I didn't have any luck with turning off the interrupts. I did fiddle around with the Adafruit VS1053. i had similar issues. Basically either the SD card work or the VS1053 works, I can't get them both to work. I have figured out it has to do with the reset pin. If i have the reset pin connected the VS1053 is found, but SD.begin() returns 0 (which means it failed). But if I disconnect the reset pin then the VS1053 isn't found, but SD.begin() return 1 (it works). If I have the reset pin connected and before the SD.begin() put digitalWrite(the reset pin, LOW) it also works. Do you have any idea why the reset pin would prevent the SD card from functioning? Does this mean I have a faulty board?
FYI, I notice your link above to elecrow.com is a geeetech.com VS1053 shield. by coincidence I am using here that exact same shield. I have worn out my original SparkFun shield. And this one work's fine. That said - I do recall some 3rd party shields did require some jumper settings and or config.h settings. However, I do not find any such mods to my shield and as mentioned above I just did a clean install and setup of Arduino and this Library, and it worked right out of the box.
I wonder if your issue is more a specific issue with the shield. One of the 6,7,8,9 pins are not making good contact or if there is a short. I once ran across a UNO board that's ATmega328P had no pull-ups working. Which really messed up things, in a very confusing way. This would mess with the VS and Sd's chip selects and reset, etc...
At this point, I would be putting in more debug prints and/or testing out individual features and pins. Here is a link to a video I did long ago, showing how to change a PIN. And thus, the vs1053_SdFat_config.h would need to be correspondingly updated.
Along with keeping in mind the compile issues you are seeing. And or if you are seeing them with the Adafruit version of the library. Note, if I remember correctly, the Adafruit VS1053 demo, does not use any IRQ's.
There may be some others who had this problem. You may want to look through http://www.billporter.info/2012/01/28/sparkfun-mp3-shield-arduino-library/comment-page-1/#comments. There were a lot of support requests back in 2012.
Being a long time ago, it is foggy. I do seem to remember once having a shield that worked in the Sd and VS1053 independently but not together. And it was down to a worn-out Socket to pin connect between the shield and board. I always order + 1 spare for everything, just because of these gremlins. It looks like several manufacturers have copied this exact board.
Sorry I do not have a magic answer for you.
Thank you for all your help. I noticed something weird. If I connect just my MOSI, MISO, SCK, SD CS and 5V pins, the SD library example program QuickStart works perfectly. But if I connect the GND pin in doesn't work. Is this normal? Do the SPI wires carry ground or how can it work? This whole time I didn't even think that this is weird. Could this indicate a problem with my shield or does the same thing happen for you?
Also the "d" command randomly started working and lists my directory. But now if I press "f" or "2" it just says: Received command: f and nothing else. If I put the patches file on the SD i just get: F_CPU = 16000000 Free RAM = 7051 Should be a base line of 1028, on ATmega328 when using INTx and nothing else. If I delete the patches file it works. Very interesting .
Ground is necessary. If connecting ground creates issues. Then there is something wrong somewhere. Such as a second ground somewhere else that should not be.
Above you showed a link showing a shield. I am assuming that shield is directly connected to an Uno and that Uno has a USB to the PC. Where the Shield has the SdCard inserted, and a Headphone connected to the SPK connector. The Shield has only two ground pins between the MP3 shield and the UNO. These should be making connection between them.
Any other connections can be suspected of a second ground causing a ground loop. Even the SPK could be a ground loop if it is going to an Amplifier.
Otherwise, there may be a damaged part on the shield.
Missing ground will cause intermittent results. Often a circuit may fake ground but only for a brief moment. Which may explain your observation that 'd' randomly works. 'f' or '2' will need larger valid data chunks to make music. So small data, between long gaps of time will work, before the data stream gets corrupted.
When debugging, strip down all non-essential parts and try only the basics.
On some of shields I have inserted and removed them soo many times their pins and or headers get worn out. The fork in the header gets stretched. So, the pins go down through the center of the header, microscopically missing the header. Hence with some small pliers bend the pins a bit, to give them the smallest of waggles.
Very interesting. I'm actually using and Arduino mega and I'm connecting the shield with jumper cables. I'm using earphones, so the only connections the shield has to any possible ground are as as stated before: "MOSI, MISO, SCK, SD CS and 5V". With these pins QuickStart works, not needing a ground wire. I just ran QuickStart again, and after running it, one by one removed the cables. If I want the LEDs on the shield to light up all I need to do is connect the 5V and then connect the Arduino's SCK pin (52) to any of the shield's SPI pins. These two jumper cables alone will light the LEDs. So the LEDs can definetly be grounded by any one of the shield's SPI pins. The same two LED's light up if I connect the shield only with 5V and ground. This only works after I type in the chip select pin into the Serial Monitor. It seems very weird. Must be a faulty shield right? Or does your shield do the same?
I am led to believe there are local issues with the cabling or components.
I just tested a similar setup as shown in the photo and it worked as expected. I was able to show the directory and play an MP3 file.
I suspect you already know this. See THIS LINK FOR MEGA SPI Jumpers for the cabling shown in the above photo.
Hmmm - Do you know the two GNDs on the geetech shield are not tied together? I just checked with my meter. In fact, the GND by the "Aref" is not tied to the circuitry on the shield. But only to the pin going to the Arduino Host, which in turn should be GND. At least this is the case with my shield.
At this point I can only assume you do not have the shield on top of the Mega, but rather aside and cabled. When problem solving always work yourself backwards to the simplest proven. Here I have shown a picture and setup that is proven to work. If that fails, then go back to just an UNO.
Hello, I am new to programing micro-controllers and decided to do a project with audio. I've bought a VS1053 MP3 Shield and have spent at least 8 hours today trying to get it to work. My current problem is that while compiling the example program "demo" I get the following warning:
C:\Users\kastr\Documents\Arduino\libraries\VS1053_for_use_with_SdFat\src\vs1053_SdFat.cpp: In member function 'uint8_t vs1053::vs_init()': C:\Users\kastr\Documents\Arduino\libraries\VS1053_for_use_with_SdFat\src\vs1053_SdFat.cpp:292:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] if(VSLoadUserCode("patches.053")) return 6; ^
I assume this warning is the reason that in the serial monitor I get the error:
Error code: 6 when trying to start MP3 player Warning: patch file not found, skipping.
It does still print all the given commands, but if i try to play a file by typing a number i get:
Error code: 2 when trying to play track
I am using an Arduino mega. I have routed the wires correctly and changed the CS pin in vs1053_SdFat_config. I have tried everything I found on the internet. I can't think of a reason why the demo program would not compile properly. I have had little luck trying to understand the code behind the library, it's too complex.
If anyone has any insight into my problem, i would greatly appreciate it.