Author Topic: Oak with the WT588D audio module  (Read 11128 times)

postuma

  • Jr. Member
  • **
  • Posts: 64
Oak with the WT588D audio module
« on: May 16, 2016, 06:25:46 pm »
working on a project to play designated sound files (WAV format only) via the Digistump Oak. Found the Waytronic WT588D module on eBay for a couple of bucks, which outputs files or playlists to either a 0.5W external speaker via PWM, or to amplification via DAC. It's pretty versatile, and output quality is good.

The version I'm using has 8 Mbit of flash, is smaller than the Oak, but does require an external programmer:



Note that other versions are available: a USB version that does not require the external programmer, costs about a dollar more, and had 32 Mbit flash. Downside: it's larger.

There's some tricks involved in programming this module, so I've detailed the process on my blog: http://www.ars-informatica.ca/eclectic/programming-the-wt588d-sound-module-part-1/

I'm using it in one-line serial mode, only using two of the Oak's lines out: VCC to supply it, and a single pin for control. You may wish to dedicate another pin in to pick up the BUSY signal, or one to RESET.





and the code:

Code: [Select]
/*
Very basic example, WT588D Audio Module in one-line serial mode, controlled by the Digistump Oak
It cycles continuously through 5 sound files, defined by the AudioSequenceID, referred to as an Equation in the VoiceChip software

Neither the RESET or BUSY pins are required for this example, though can of course be used
*/

#define WT588D_DATA   6

byte AudioSequenceID = 0;
byte i;


void setup() {
  pinMode(WT588D_DATA, OUTPUT);
  setVolume(7);                           //set volume level from 0 to 7
}


void loop() {
  WT588DCommand(AudioSequenceID);
  AudioSequenceID++;
  if (AudioSequenceID == 5) AudioSequenceID = 0;
  delay(1500);                            //pause between audio play commands
}


void WT588DCommand(byte WTbyte) {
  digitalWrite(WT588D_DATA, 0);           //pull DATA low to wake up chip, 2-10 msec
  delay(5);

  for( i = 0; i < 8; i++)  {              //read each bit of the AudioSequenceID, and write to data pin
    if (bitRead(WTbyte, i)) {
      digitalWrite(WT588D_DATA, 1);       //then write to data pin
      delayMicroseconds(400);             //2:1 high/low indicates high
      digitalWrite(WT588D_DATA, 0);
      delayMicroseconds(200);
    }
    else {
      digitalWrite(WT588D_DATA, 1);
      delayMicroseconds(200);             //and 1:2 high/low indicates low
      digitalWrite(WT588D_DATA, 0);
      delayMicroseconds(400);
    }
  }
  digitalWrite(WT588D_DATA, 1);
}


void setVolume(byte i) {                  //takes a value of 0-7 for volume control
  WT588DCommand(i+224);         
}

postuma

  • Jr. Member
  • **
  • Posts: 64
Re: Oak with the WT588D audio module
« Reply #1 on: May 18, 2016, 05:11:12 pm »
small update: code update to add routines to increase and decrease volume, loop through audio files or playlists, and stop audio.

Code: [Select]
/*
Very basic example, WT588D Audio Module in one-line serial mode, controlled by the Digistump Oak
It cycles continuously through 5 sound files, defined by the AudioSequenceID, referred to as an Equation in the VoiceChip software

Neither the RESET or BUSY pins are required for this example, though can of course be used
*/

#define WT588D_DATA   6

byte AudioSequenceID = 0;
byte volume = 7;                         //set volume level from 0 to 7
byte i;


void setup() {
  pinMode(WT588D_DATA, OUTPUT);
  setVolume(volume);
}


void loop() {
  WT588DCommand(AudioSequenceID);
  AudioSequenceID++;
  if (AudioSequenceID == 5) AudioSequenceID = 0;
  delay(1500);                            //pause between audio play commands
}


void WT588DCommand(byte WTbyte) {
  digitalWrite(WT588D_DATA, 0);           //pull DATA low to wake up chip, 2-10 msec
  delay(5);

  for( i = 0; i < 8; i++)  {              //read each bit of the AudioSequenceID, and write to data pin
    if (bitRead(WTbyte, i)) {
      digitalWrite(WT588D_DATA, 1);       //then write to data pin
      delayMicroseconds(400);             //2:1 high/low indicates high
      digitalWrite(WT588D_DATA, 0);
      delayMicroseconds(200);
    }
    else {
      digitalWrite(WT588D_DATA, 1);
      delayMicroseconds(200);             //and 1:2 high/low indicates low
      digitalWrite(WT588D_DATA, 0);
      delayMicroseconds(400);
    }
  }
  digitalWrite(WT588D_DATA, 1);
}


void setVolume(byte b) {                  //takes a value of 0-7 for volume control
  volume = b;
  WT588DCommand(b+224);         
}

void incVolume() {
  if (!volume >= 7) WT588DCommand(++volume);
}

void decrVolume() {
  if (!volume) WT588DCommand(--volume);
}

void loopAudio() {
  WT588DCommand(242);
}

void stopAudio() {
  WT588DCommand(254);
}

postuma

  • Jr. Member
  • **
  • Posts: 64
Re: Oak with the WT588D audio module
« Reply #2 on: May 26, 2016, 06:23:46 pm »
Whoops. The loopAudio and stopAudio functions above do not work in one-line serial mode.

Other advantages with three-line serial mode, versus one-line mode:
  • Three-line serial mode operates with a 40 microsec to 2 msec clock cycle; much faster than one-line. The Waytronic documentation does not state explicitly, but various examples suggest that 600 microseconds is the minimum time required per data bit, and a signalling rate of 600-2000 microseconds is cited on their web site.
  • One can switch out of three line mode temporarily to use these pins as standard I/O – though I don’t see at this time how you’d use such functionality.
  • Finally, one-line mode draws a minimum 5 mA current even when not playing, it does not go into sleep mode. Three-line serial mode draws 10 uA in sleep mode.
Rather than reproduce the schematics, wiring diagram, etc. here - a link to my web site article http://www.ars-informatica.ca/eclectic/programming-the-wt588d-sound-module-part-3-three-line-serial-mode/