Go Down

Topic: Arduino library for WTV020-SD-16P audio module (Read 119681 times) previous topic - next topic


kehkashan2

Kindly explain in English. I don't understand the language

HazardsMind

I finally got mine to work. All this time is was an incompatible memory card. The data sheet should give some examples of working cards to use, that way we know what to get, the first time.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

ScottG

I've got the Sparkfun breakout board for this audio module working intermittently. I'm using it in serial mode connected to an Arduino UNO with the Wtv020sd16p.h library from the original post in this thread.  The breakout board is powered from the 3.3 volts from my UNO.  I'm getting my sounds to play okay, but frequently I don't get any sounds.  If I remove power the UNO (which removes power from the breakout board), then re-apply, it works again.  I've tried adding a speaker.reset() before I try to play a sound.  I also tried increasing the delay() in Wtv020sd16p.cpp on line 37 from 300 to 750 and line 94 from 20 to 50 per a suggestion from a Sparkfun user in the breakout board comments, but neither helped.  Here's my sketch:

Code: [Select]

#include <Wtv020sd16p.h>

int resetPin = 8;  // The pin number of the reset pin.
int clockPin = 9;  // The pin number of the clock pin.
int dataPin = 10;   // The pin number of the data pin.
int busyPin = 11;   // The pin number of the busy pin.

bool playingSong;

// Create an instance of the Wtv020sd16p class.
Wtv020sd16p speaker(resetPin,clockPin,dataPin,busyPin);

void setup()
{
  Serial.begin(9600);
  speaker.reset(); // Initializes the speaker module
  playingSong = false;
  Serial.println("Finished setup");
}

void loop()
{

  if (playingSong == false)
  {
    Serial.println("Play sound");
    speaker.asyncPlayVoice(0);
    delay(200); 
    if(digitalRead(busyPin) == HIGH)
    {
      playingSong = true; // Set flag so command to play song doesn't run again
      Serial.println("Busy");
    }
    else
    {
      Serial.println("speaker not busy"); 
    }
  }
 
  if (digitalRead(busyPin) == LOW)  // when song is over, reset flag so it will play again
  {
    Serial.println("finished song, play again");
    playingSong = false;
  }
}


When I have the problem of no sound the sketch outputs this over and over, it's seems to loop a few times per second:
Play sound
Busy
finished song, play again
Play sound
speaker not busy
finished song, play again
Play sound
Busy
finished song, play again
Play sound
speaker not busy
finished song, play again
Play sound
Busy

marco_c

Hi the-rebel-agent,

Thanks for your library. Got my unit up and running in less that 30 minutes (most of it getting the wiring right!).

I had an old 64Mb(!) micro SD card that works fine and will probably be enough for what I want to do (voice for a robot).

Arduino libraries http://arduinocode.codeplex.com
Parola for Arduino http://parola.codeplex.com

edryan

Thank you for sharing this library!

I'm using the SparkFun breakout board as well, but I'm encountering some weird problems. Basically, I can get it to play back sounds, but when I try to play multiple files in a row, things don't work properly. Sometimes it will play the first file and then nothing for a couple of minutes, sometimes it will skip a file. Here's an example:

  while(true){
    wtv020sd16p.playVoice(1);
    delay(2000);
    digitalWrite(testLED, LOW);
    wtv020sd16p.playVoice(3);
    delay(2000);
    digitalWrite(testLED, HIGH);
  }

This behaves erratically. The LED flashes as expected, but the sound doesn't always play. Sometimes file 1 will play, sometimes nothing plays, and rarely file 3 plays. If I take it out of the loop, file 1 usually plays, but file 3 does not. I also tried it with asyncPlayVoice(), with the same results. If I take the delays out, the LED flickers and then stops while one of the files plays. Then it flickers some more and plays another file (usually it'll alternate, but sometimes it'll repeat).

Any ideas?

Arkestra

#126
Jun 30, 2013, 06:52 pm Last Edit: Jul 01, 2013, 03:48 pm by Arkestra Reason: 1
As with so many others on this thread, my problems have all come down to SD card issues.

Both a Sandisk and a Kingston 2GB failed to play any music at all - however a no-name 2GB card works fine. And by "works", I mean all songs play through fine as expected via 2-line control as done by this thread's library - so I must add my name to the chorus thanking the-rebel-agent!

And this behaviour was exactly the same on 2 WTV020-SD-16P modules (I got the second while trying to get the first to work, since I assumed Sandisk not working implied there might be a problem with my module).

All 3 SD cards look fine when used with a Mac SD card reader. However particularly in the case of the Sandisk, I wonder if the branded SD cards are genuine, particularly Sandisk which has a *huge* fakes problem?

My next steps
1) Run cards through F3 (http://oss.digirati.com.br/f3/, Mac version of h2testw) to see if anything emerges.
2) I have seen elsewhere (http://forum.arduino.cc/index.php?topic=115411.0) people suggesting trying slightly higher than 3.3v to the WTV, eg send in 3.6v - and that this can make previously failing cards work. I am getting a variable voltage regulator so I can try various levels and see if that helps with the 2 cards that are currently failing.
3) I've just got a job lot of old 1Gb and smaller SD cards and will see if any pattern emerges from that, in terms of what SD cards work and what don't.

If anyone could give an amazon UK (or other) supplier of cards that is guaranteed to work, that would be extremely useful!

Arkestra

1) Run cards through F3 (http://oss.digirati.com.br/f3/, Mac version of h2testw) to see if anything emerges.

All 3 SD cards showed full capacity and no errors on reading/writing. So nothing obvious there. The no-name SD card that works is slower than the other two - could it be possible that cards get too *fast* for the WTV020 somehow?

I will put results on this thread when I've got the regulator to test 3.5/3.6 driving voltage, and/or have tried a wider range of SD cards.

I would like to make a whole bunch of very small, very noisy things, and the WTV is the ideal module - if I can figure out a reliable source of working SD cards.

GoForSmoke

Faster card might drain more current but only if you run it faster.
Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

Arkestra

#129
Jul 02, 2013, 11:43 pm Last Edit: Jul 16, 2013, 11:00 pm by Arkestra Reason: 1
Having now tried a number of SD Cards at various voltages (3.3v, 3.40v, 3.48v, 3.57v):
Kingston 2Gb: 1 card, doesn't work at all
Transcend 2Gb: 1 card, doesn't work at all
Sandisk 2Gb: 3 cards, 1 works at 3.3v, 2 require 3.4v+
No-Name 2Gb: 1 card, works perfectly at 3.3v
No Name 128Mb: 8 cards, 7 work perfectly at 3.3v, 1 skips some plays at 3.3v, works at 3.4v+
Nokia 128Mb: 3 cards, 2 work perfectly at 3.3v, 1 skips some plays at 3.3v, works at 3.4v+

Conclusions (from my admittedly limited sample):
128Mb cards do better at 3.3v than 2Gb cards
Moving slightly above 3.3v seems to help with some cards (but is not a sure-fire cure)
Once you hit 3.4v, increasing further doesn't help with any more cards from the sample

Drilling down on one of the Sandisk 2Gb cards that needs more than 3.3v, it works at 3.38v or above, and not at 3.35v or below. So less than 0.1v is making the difference here.

HazardsMind

I have a Samsung 1Gb and it works fine. I bought a 5 pack on eBay, just in case the card stops working.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

neelarnab

Hi,
Recently I bought a  WTV020-SD-20SS module from http://emartee.com/product/41928/MP3%20SD%20Card%20Sound%20Module. But it is not behaving properly.When I gave command wtv020sd16p.asyncPlayVoice( 0) or  wtv020sd16p.asyncPlayVoice(2) it does not play any sound. Again if I give wtv020sd16p.asyncPlayVoice(1) or  wtv020sd16p.asyncPlayVoice(3) or wtv020sd16p.asyncPlayVoice(5) it play both 0002.ad4 and 0003. ad4 alternatively. I tried changing the mask HEX value (eg. unsiggned int mask = 0xFFFF) in the .cpp file it again behave differently.
Previously I was using WTV020-SD-16 p module from Sparkfun and it was working properly with the library.

What I feel is that , probably the timing or the mask value is not correct for WTV020-SD-20SS module. Can you help in resolving the issue?

-neel

jmknapp

Has anyone been able to get the volume command working properly with this device? According to the spec, commands 0xfff0 through 0xfff7 should set one of eight volume levels, but only mute (0xfff0) and full volume (0xfff7) work properly. Intermediate values cause the audio to become very choppy, randomly changing volume, like maybe the ADPCM can't sync up? This happens with this library (if I change, say, VOLUME_MIN from 0xfff0 to 0xfff3 and call mute()) as well as an interrupt-based one I'm working on.

I'm using 32Kb/s ADPCM files from the UsbRecorder utility.

Joe

HazardsMind

Quote
Has anyone been able to get the volume command working properly with this device? According to the spec, commands 0xfff0 through 0xfff7 should set one of eight volume levels, but only mute (0xfff0) and full volume (0xfff7) work properly. Intermediate values cause the audio to become very choppy, randomly changing volume, like maybe the ADPCM can't sync up? This happens with this library (if I change, say, VOLUME_MIN from 0xfff0 to 0xfff3 and call mute()) as well as an interrupt-based one I'm working on.

I'm using 32Kb/s ADPCM files from the UsbRecorder utility.

Joe


I modified the library to increase and decrease the volume, and it works great. I added three new functions to the library. Hope these help.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

jmknapp


I modified the library to increase and decrease the volume, and it works great. I added three new functions to the library. Hope these help.


Thanks. Didn't help unfortunately--I still get very choppy volume when trying to modify the volume. Here's scope trace of what's supposed to be a constant 440 Hz tone, after a call to volume(3):



Turns out that it only happens with 32 Kb/s ADPCM files (created by the UsbRecorder v1.3 tool). Setting the volume with 24 Kb/s or lower sampling rate files works fine, even though 32 KB/s file play fine at full volume. Weird. Anyway, the solution is to use 24 Kb/s max.

Go Up