📬❄️📦Adafruit Holiday Shipping Deadlines 2019: Please place all UPS 3 Day orders by 11am ET Friday December 13 📬❄️📦
0

VS1053 - Trouble getting examples to work
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

VS1053 - Trouble getting examples to work

by brocktane on Tue Jun 18, 2013 8:27 pm

I went through some mild trouble getting the VS1053 breakout working with the examples, and now that I've got it working, I want to help others avoid the perils of hardware debugging.

I got the Adafruit VS1053 Arduino code from Github (download the and extract the zip file from https://github.com/adafruit/Adafruit_VS1053_Library), and put it in the Arduino libraries folder. (I do have the latest version of Arduino.) When I went to run Arduino, it clogged up and acted very angry >( ...This was because the library code wasn't compiling. I was working in Windows 7.

PROBLEM: I'm working in Windows 7 and Adfruit_VS1053_Library is not compiling!

FIX: There is a missing include guard in the header file Adafruit_VS1053.h. You should add:
[#ifndef Adafruit_1053_h
#define Adafruit_1053_h

... // includes and rest of header file...

#endif /* Adafruit_1053_h */]

This fixed the problem for me on Windows 7.
NOTE: Later I tried compiling the library on Mac OSX Lion (also with latest version of Arduino) and it worked without the include guard. Don't know how, but I put it in after anyway. In any case, I also want to remind users to get the latest version of Arduino: http://arduino.cc/en/main/software

Next I wanted to start using the examples. I open up the gpio_test.ino sketch. But the pin name references in the code are different from the pin name references on the board, which are usually different from the pin name references in the datasheet (http://www.adafruit.com/datasheets/vs1053.pdf).

PROBLEM: I want to use the gpio_test sketch, but I don't know exactly how to connect the pins.

(partial) SOLUTION: Some of them are straight forward, but some I'm still iffy on. Lines go "name in code = name on board = pin in gpio_test = name in datasheet"

CS = CS = 10 = XCS
DCS = XDCS = 8 = ?
DREQ = DREQ = 3 = ?
CARDCS = SDCS = 4 = ?
RESET = RST = 9 = ?
MOSI = MOSI = 11 = ?
MISO = MISO = 12 = ?
CLK = SCLK = 13 = ?

In addition--just to be absolutely clear--I have attached VCC to Arduino Uno 3.3V and GND to Arduino ground.

NOTE: CLK, MISO, MOSI are commented out in current commit of code (18 June 2013) and appear to not be used--I will address this next. I am pretty sure on the datasheet pins I filled in.

NOTE: Attach at least one of the AGND pins to ground--it is the analog reference ground. I believe it is broken out so you can attach it to lower noise ground if you want to. I don't know why there are two of them...*maybe Adafruit engineer could answer this? :)

Okay! Run the sketch and...
[VS1053 GPIO test
VS1053 not found]
...pops up on the Serial Monitor.

PROBLEM: Getting VS1053 GPIO test/VS1053 not found with gpio_test sketch

FIX: After browsing the library code, I spotted something that made me think I should try uncommenting
[// #define CLK 13 // SPI Clock, shared with SD card
// #define MISO 12 // Input data, from VS1053/SD card
// #define MOSI 11 // Output data, to VS1053/SD card]

I did this and it worked.

NOTE: I did not uncomment
[// Alternately, use 'soft SPI'. Requires Adafruit's flexible SD library
// Adafruit_VS1053_FilePlayer musicPlayer = Adafruit_VS1053_FilePlayer(MOSI, MISO, CLK, RESET, CS, DCS, DREQ, CARDCS);]
Only the pin defines.


I will post more info as I run through the different sketches. Hopefully this helps someone!

brocktane
 
Posts: 4
Joined: Mon Apr 22, 2013 12:07 am

Re: VS1053 - Trouble getting examples to work

by adafruit_support_bill on Wed Jun 19, 2013 6:55 am

Thanks for posting this. I'm sure many will find it helpful :)

We hope to have a tutorial on this board soon. We'll try to address the issues you have found.

adafruit_support_bill
 
Posts: 75285
Joined: Sat Feb 07, 2009 10:11 am

Re: VS1053 - Trouble getting examples to work

by brocktane on Sat Jun 22, 2013 11:39 pm

So I'm trying to use a plugin I got off the VSLI website--its the spectrum analyzer plugin. I want to use the library's loadPlugin function, but it hasn't worked so far. The first part of the problem is that the SD card doesn't recognize the .plg file. For the OggVorbis recording example, you use some form of disk image. Do I need to do that? Do you know if/how I can convert the .plg to that disk image format?

brocktane
 
Posts: 4
Joined: Mon Apr 22, 2013 12:07 am

Re: VS1053 - Trouble getting examples to work

by adafruit on Mon Jun 24, 2013 10:28 am

Our library is not currently tested with plugins - we just have it working with MP3 decoding and Ogg encoding. We may try to get plugins working, but there's no ETA

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

Re: VS1053 - Trouble getting examples to work

by brocktane on Wed Jun 26, 2013 6:07 pm

Wait! I think I have something working!!!! :)

Let me walk through what I learned--for anyone else trying to do something similar.

The VS10XX series audio codecs from VLSI have DSP processor cores, and can therefor be programmed to do tasks in addition to the VS10XX's built-in functionality (for example, the OggVorbis recording sketch included in the Adafruit VS1053 library loads a patch that allows OggVorbis recording, which is not a built-in functionality of the VS1053). If you go to VLSI's website, you will find that they actually have very decent support for using their VS10XX series chips with micro-controllers. If you go to the software page (http://www.vlsi.fi/en/support/software.html) you will find several links of interest: a link to VSIDE--a Windows programming IDE etc. for making VS10XX plugins/patches/apps; a link to VS10XX Applications, Patches, and Plugins; and a link to Microcontroller examples.

Notice the words...Application, Patch, Plugin.
** A lot of confusion stems from this peculiar classification scheme of VS10XX programs as Applications vs. Patches vs. Plugins.** It is not immediately apparent what classification a particular program should fall under. For example, the OggVorbis encoder program is found under the Applications link. Things like equalizers can be sound under be found under both Applications and Plugins. On the other hand, the Patches link generally contains things like bug fixes or upgrades. What these classifications really refer to is how the program interacts with the chip. In general, applications become the main functions of the chip, while plugins can act as additional functionality on top of what the chip already does, and patches fix functionality that is faulty or missing. For example, a user might load a ADPCM encoder application, in which the chip's main function becomes encoding to PCM. Then they might load a patch to fix something with the PCM encoding. Then they might add a volume monitoring plugin that allows them to monitor the volume of the PCM encoded signal. (NOTE: Adafruit's library has a function called applyPatch, which is basically a direct implementation of VLSI's suggested algorithm for communicating programs like plugins and applications, which I will discuss more below. This algorithm functions as a general program upload procedure, not just for patches.)

So far I have been dealing with the spectrum analyzer plugin for VS1053, found under Software > Plugins > Spectrum Analyzer Plugin. The zip file contains the spectrum analyzer doc pdf and a folder called /code. Inside code, you can find files ending in '.c', '.plg', and '.cmd'. The prefixes to these files are the version of the VS10XX chip they are meant for. We are interested in the VS1053 plugin, or the file spectrumAnalyzer1053b.plg. The '.c', '.cmd', and '.plg' versions of the program all contain basically the same information--that is, how to upload the program to the VS1053--but in different formats. The '.cmd' file separates the program upload procedure into specific commands line by line. The '.c' file separates out the registers SPI should write to and the data it should write. The 'plg', which we will use, contains RLE (run length encoded) compressed programs that the VS1053 can run. The basic format of the file is [register address] [how much data to write] [data], with each data block being two bytes. The RLE part comes in when the MSB (i.e. 0x8000) of [how much data to write] is on. You can see how this is handled in the code. Page 7 of the spectrum analyzer doc (http://www.vlsi.fi/fileadmin/software/V ... alyzer.pdf) has an example of the commonly used microcontroller algorithm for communicating the data in this '.plg' file.

If you open up the 'spectrumAnalyzer1053b.plg' file and take a look--you'll see they include this pseudo-code for uploading the program in the file. We want the array of unsigned 16-bit integers called plugin--this is what we will write to the VS1053. I had written my own procedure to upload the code based on the VLSI suggested microcontroller algorithm, but I recently figured out that the Adafruit library has a function that does the same exact thing--it's called applyPatch (which I noted earlier). **However, I still cannot get the Adafruit library applyPatch function to work. I don't know why because our functions do the exact same thing. My function is (almost direct copy from VSLI doc):

[
void LoadPlugin(const uint16_t* plugin, uint16_t plugin_size)
{
int i = 0;
while (i<plugin_size)
{
uint16_t addr, n, val;
addr = plugin[i++];
n = plugin[i++];
if (n & 0x8000U)
{ /* RLE run, replicate n samples */
n &= 0x7FFF;
val = plugin[i++];
while (n--)
{
musicPlayer.sciWrite(addr, val);
}
}
else
{ /* Copy run, copy n samples */
while (n--)
{
val = plugin[i++];
musicPlayer.sciWrite(addr, val);
}
}
}
}
]

So here are the steps for uploading a program to the VS1053 from an Arduino (NOTE: I've only tested for the admonEQ spectrum analyzer plugin, but it should work for other patches/apps/plugins as well).

1) Find the RLE compressed hex code that describes the program and its upload procedure. This should be in a file called 'xxxxvs1053.plg', or something like that. Inside the file will be a const unsigned short plugin[PLUGIN_SIZE].

2) Copy the plugin array into your Arduino sketch. (It takes up a lot of room and can be annoying. I would like to eventually read the program from an SD card, but I haven't yet figured out how save the 'plg' bytecode as bytes and not ascii representation.)
NOTE: the spectrum analyzer plugin comes with an array size set at 970 unsigned shorts. Arduino doesn't like number that aren't divisible by four I guess, so I suggest changing its actual size to 1024, just to be safe. 970 was making my program glitchy.

3) Initialize an Adafruit musicPlayer like in the player examples etc..

4) Use the LoadPlugin function (above) in your sketch.

Doing this the plugin should load correctly. I have also tried the same thing with the VS1053's ADPCM recording application.


NOTE: I still haven't figured out how to deal with it, but I think the Serial interferes with the SD card SPI. I'll have to keep looking into it..

-Brian

brocktane
 
Posts: 4
Joined: Mon Apr 22, 2013 12:07 am

Re: VS1053 - Trouble getting examples to work

by adafruit_support_bill on Thu Jun 27, 2013 6:12 am

Thanks again for posting your findings and results on this. :D
We'll try to make sure this is covered in the Tutorial.

adafruit_support_bill
 
Posts: 75285
Joined: Sat Feb 07, 2009 10:11 am

Re: VS1053 - Trouble getting examples to work

by Aristote on Tue Jul 09, 2013 7:19 pm

Hello,
Great job brocktane ! Your post helped me a bit.
I got the "player_simple" example code working fine and now I would like to try to record. Therefore I'm gonna test the "reccord_ogg" example code. But I'm not quite confident on the microphone wiring...
The comments in the example code referes to the Connection diagram page 13 of the Vs1053 datasheet. Unfortunally, on this diagram, it seems that a bunch of very small capacitors (and some resistors) are needed to connect the microphone to the pins MIC+ and MIC-. I don't really have those kinds of capacitors and I would like to know which components are really essentials to make it running.
I also guessed that none of them are on the board since there is no commons components between the microphone and the line in.

Thanks in advance for your help and advices.
(Sorry for my english, I'm french...)
Aristote
 
Posts: 1
Joined: Tue Jul 09, 2013 7:00 pm

Re: VS1053 - Trouble getting examples to work

by Sam_CC on Mon Jul 15, 2013 7:57 am

Hi guys,

Ive got the examples up and running no problems but am having some issues trying to load a plugin as described above. I have pasted the plugin into my code however it causes the program to crash, it won't start at all. It seems the plugin cant be bigger than about 320 as thats all the memory available. Are you able to explain a little more how you managed it?
Sam_CC
 
Posts: 1
Joined: Thu Nov 15, 2012 10:24 am

Re: VS1053 - Trouble getting examples to work

by kscharf on Thu Jul 25, 2013 9:47 am

I don't think the AGND on the breakout board should go to the analog ground on the arduino, they are NOT at the same potential (the AGND on the vs1053 is biased above digital ground and is meant ONLY for driving headphones!) You could connect the two by a 100nf capacitor though.

Also the breakout board looks like it runs on 5v not 3.3, although there IS a 3.3 volt connection there, I thought that was the output of the 3.3v regulator on the breakout board. Since Adafruit has not (yet) posted schematics I'm not sure if you can drive the board with 3.3 volts and bypass the internal 5 to 3.3 volt regulator. Unless you were using a 3.3v powered arduino, I don't see any good reason to power the breakout board from 3.3volts, nor any reason to tie the arduino 3.3 volt regulator to the one on the board, can you say ground loop!

kscharf
 
Posts: 249
Joined: Wed Sep 10, 2008 10:29 am

Re: VS1053 - Trouble getting examples to work

by kscharf on Wed Aug 14, 2013 6:11 pm

I was confusing AGND with GBUF. Normally the headphones use the GBUF terminal as the return. I'm not sure which would be better, for the differental input to use AGND or GBUF, it depends on if the amplifier cares about the DC offset. For line out the AGND is correct!

kscharf
 
Posts: 249
Joined: Wed Sep 10, 2008 10:29 am

Re: VS1053 - Trouble getting examples to work

by paulvissers2005 on Fri Oct 25, 2013 6:17 pm

I had troubles too, when Arduino failed to pick up the program where it left, after having sent a command to VS1053.

I discovered that you shall not send a new “play” command to AdafruitVS1053 if it is still playing. Arduino may never return to its executable.

In case of pushbuttons commands, it is therfor important to detect the (up- / downgoing) flank of the switch, otherwise Arduino may send several Play-commands to Adafruit and that is a failure.

In VS1053-interrupt mode ( player_interrupts ) this is what I found usefull now:


void loop()
{
knopje22status = digitalRead(22);
knopje24status = digitalRead(24);
knopje26status = digitalRead(26);
knopje28status = digitalRead(28);
knopje30status = digitalRead(30);
knopje32status = digitalRead(32);
knopje34status = digitalRead(34);
knopje36status = digitalRead(36);

if (knopje22status == LOW && (knopje22status != vorigestatus22) && (!musicPlayer.playingMusic)) musicPlayer.startPlayingFile("track001.mp3");
if (knopje24status == LOW && (knopje24status != vorigestatus24) && (!musicPlayer.playingMusic)) musicPlayer.startPlayingFile("track002.mp3");
if (knopje26status == LOW && (knopje26status != vorigestatus26) && (!musicPlayer.playingMusic)) musicPlayer.startPlayingFile("track003.mp3");
if (knopje28status == LOW && (knopje28status != vorigestatus28) && (!musicPlayer.playingMusic)) musicPlayer.startPlayingFile("track005.mp3");
if (knopje30status == LOW && (knopje30status != vorigestatus30) && (!musicPlayer.playingMusic)) musicPlayer.startPlayingFile("track006.mp3");
if (knopje32status == LOW && (knopje32status != vorigestatus32) && (!musicPlayer.playingMusic)) musicPlayer.startPlayingFile("track007.mp3");
if (knopje34status == LOW && (knopje34status != vorigestatus34) && (!musicPlayer.playingMusic)) musicPlayer.startPlayingFile("track009.mp3");
if (knopje36status == LOW && (knopje36status != vorigestatus36) && (!musicPlayer.playingMusic)) musicPlayer.startPlayingFile("track010.mp3");
if (musicPlayer.playingMusic) Serial.println("Playing music right now. ");
vorigestatus22 = knopje22status;
vorigestatus24 = knopje24status;
vorigestatus26 = knopje26status;
vorigestatus28 = knopje28status;
vorigestatus30 = knopje30status;
vorigestatus32 = knopje32status;
vorigestatus34 = knopje34status;
vorigestatus36 = knopje36status;
}


Note that my Mega uses in pins 22 etc for the input buttons. And the dutch word “knopje” means button, "vorige"= previous.
-PAUL-
paulvissers2005
 
Posts: 5
Joined: Thu Sep 26, 2013 5:15 pm

Re: VS1053 - Trouble getting examples to work

by cecy.herrera on Tue Nov 19, 2013 12:04 am

Hello everyone,
I purchased the VS1053 recently and I'm also having trouble getting the examples to work. I've only tried player_simple and player_interrupts and none have worked. I'm working with the Arduino UNO board, a SanDisk 2GB MicroSD card. My OS is Windows 8. I've used the simple examples of the Arduino board and it seems to be working perfectly with those basic examples. I've done the addition to the library that was mentioned in the first post of this discussion but no luck getting it to work.

So far the only "sound" I get is a little pop when the code is uploaded or whenever I reset the board and the headphones are "buzzing" as if waiting for a song to be read and played... I think it might be an issue of the SD card not being read at all... what do you think? Have any of you had this problem? How did you fix it? Any help will be greatly appreciated.
cecy.herrera
 
Posts: 1
Joined: Mon Nov 18, 2013 11:55 pm

Re: VS1053 - Trouble getting examples to work

by adafruit_support_bill on Tue Nov 19, 2013 6:58 am

Post photos showing your soldering and all your connections to the Arduino. Also, check the Serial Monitor output while you are running the sample code. If there are any SD card reading errors, they will be printed there.

adafruit_support_bill
 
Posts: 75285
Joined: Sat Feb 07, 2009 10:11 am

Re: VS1053 - Trouble getting examples to work

by ramin-shami on Tue Dec 10, 2013 4:33 pm

cecy.herrera wrote:Hello everyone,
I purchased the VS1053 recently and I'm also having trouble getting the examples to work. I've only tried player_simple and player_interrupts and none have worked. I'm working with the Arduino UNO board, a SanDisk 2GB MicroSD card. My OS is Windows 8. I've used the simple examples of the Arduino board and it seems to be working perfectly with those basic examples. I've done the addition to the library that was mentioned in the first post of this discussion but no luck getting it to work.

So far the only "sound" I get is a little pop when the code is uploaded or whenever I reset the board and the headphones are "buzzing" as if waiting for a song to be read and played... I think it might be an issue of the SD card not being read at all... what do you think? Have any of you had this problem? How did you fix it? Any help will be greatly appreciated.


Hi I have this EXACT same problem, but running on Mac. I can play various test sounds (musicPlayer.sineTest(0x45, 200); // Make a tone to indicate VS1053 is working) successfully, but still no music from the SD card. I am getting the same popping sound when the code is uploaded as well. Any luck with different file formats? Does anyone have a solution for this issue?

Thanks.
ramin-shami
 
Posts: 6
Joined: Tue Dec 10, 2013 4:30 pm

Re: VS1053 - Trouble getting examples to work

by adafruit_support_bill on Tue Dec 10, 2013 5:01 pm

Hi I have this EXACT same problem

Same advice then: Post photos showing your soldering and all your connections to the Arduino. Also, check the Serial Monitor output while you are running the sample code. If there are any SD card reading errors, they will be printed there.

adafruit_support_bill
 
Posts: 75285
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.