0

TrinketPro with Feather Music Maker
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

TrinketPro with Feather Music Maker

by Aharas on Fri Feb 08, 2019 3:39 pm

Is there any reasons that the Trinket Pro (3.3) cannot run the Feather Music Maker?

I have matched and mapped out the pinouts, but I am not getting any results.
I plan to dig deeper, but decided to ASK and maybe save some time.

Aaron

Aharas
 
Posts: 6
Joined: Mon Feb 04, 2019 6:40 pm

Re: TrinketPro with Feather Music Maker

by adafruit_support_carter on Fri Feb 08, 2019 5:55 pm

Should be possible, in theory.

adafruit_support_carter
 
Posts: 21061
Joined: Tue Nov 29, 2016 2:45 pm

Re: TrinketPro with Feather Music Maker

by Aharas on Fri Feb 08, 2019 9:12 pm

OK. That is what I thought. I'll dig in and keep ya'all posted..

Aharas
 
Posts: 6
Joined: Mon Feb 04, 2019 6:40 pm

Re: TrinketPro with Feather Music Maker

by Aharas on Mon Feb 11, 2019 6:51 pm

After digging into this ..
I had to change dreq pin and SPI pins to match the Pro trinket, then i had to pass SPI pins to the constructor.
Results:
- found the VS1053
- played the tone test
- found the SD card,
- displays the files in folder.
- Serial output indicates the file is playing /played . (There is no sound, only a click between songs)
- serial output does not appear as tho it is running in background

Things I have tried without success
- hooking up the Feather/MM to a 3.3 volt supply capable of 1000mA
- checked cables
- adjust volume
- pulling my hair
- not tried newer bigger SD card yet(currently older 4gig)

the only thing I hear is a click in the headphones when code starts 'playing' a file. But No sound/song

I have added some println statements showing what settings are

Serial monitor Output:

Processor = __AVR_ATmega328P__

Reset Control Pins for the ProTrinket
VS1053_CS = 6
VS1053_DCS = 10
CARDCS = 5
VS1053_DREQ = 3 - using pin 3 cause pin 9 is not int on ProTrinket

Reset SPI Pins for the ProTrinket - these are passed to constructor of the Adafruit_VS1053_FilePlayer class
MOSI = 11
MISO = 12
CLK = 13

Adafruit VS1053 Feather Test
VS1053 found
SD OK!
TRACK003.MP3 3251992
TRACK004.MP3 4266861
TRACK002.MP3 3436544
TRACK001.MP3 2396288

Set interrupt? Found the ATmega328 compatible - aka Protrinket

Using IRQ 1 - i un-commented line 79 in the library to see if it was attaching an interrupt at all.

Playing full track 001
Playing track 002
Code: Select all | TOGGLE FULL SIZE
// Specifically for use with the Adafruit Feather, the pins are pre-set here!

/*
 * We do not have a Feather, we will make this work with our trusty little ProTrinket.
 * Issues to address;
 *
 * 1) This code does originally does not indicate which pins are used for SPI connections MOSI, MISO and CLK.
 *    This info comes from the library based on the processor being used (feather, esp, etc)
 *    Looking at the pinouts for the ProTrinket, MOSI=11, MISO=12 and SCK=13. (my diagram has CLK as SCK
 *    we will add an if statement to check processor and assign appropriate pins
 *
 * 2) dreq anbd assigning
 *
 */

// include SPI, MP3 and SD libraries
#include <SPI.h>
#include <SD.h>
#include <Adafruit_VS1053.h>

// These are the pins used
#define VS1053_RESET   -1     // VS1053 reset pin (not used!)

/*
 * This section tests for different Feather boards and sets the Control pins accordingly.
 * Looking at the list we can see there is a lot of varation between boards.
 * We need to add a section to test for our device, OR, change default to suit our need.
 */
 //const String CPU_Type = "not found";         // USING TO TRY AND DETERMINE PROCESSOR KICKED BACK FROM pROtRINKET

// Feather ESP8266
#if defined(ESP8266)
  #define VS1053_CS      16     // VS1053 chip select pin (output)
  #define VS1053_DCS     15     // VS1053 Data/command select pin (output)
  #define CARDCS          2     // Card chip select pin
  #define VS1053_DREQ     0     // VS1053 Data request, ideally an Interrupt pin

// Feather ESP32
#elif defined(ESP32)
  #define VS1053_CS      32     // VS1053 chip select pin (output)
  #define VS1053_DCS     33     // VS1053 Data/command select pin (output)
  #define CARDCS         14     // Card chip select pin
  #define VS1053_DREQ    15     // VS1053 Data request, ideally an Interrupt pin

// Feather Teensy3
#elif defined(TEENSYDUINO)
  #define VS1053_CS       3     // VS1053 chip select pin (output)
  #define VS1053_DCS     10     // VS1053 Data/command select pin (output)
  #define CARDCS          8     // Card chip select pin
  #define VS1053_DREQ     4     // VS1053 Data request, ideally an Interrupt pin

// WICED feather
#elif defined(ARDUINO_STM32_FEATHER)
  #define VS1053_CS       PC7     // VS1053 chip select pin (output)
  #define VS1053_DCS      PB4     // VS1053 Data/command select pin (output)
  #define CARDCS          PC5     // Card chip select pin
  #define VS1053_DREQ     PA15    // VS1053 Data request, ideally an Interrupt pin

#elif defined(ARDUINO_NRF52832_FEATHER )
  #define VS1053_CS       30     // VS1053 chip select pin (output)
  #define VS1053_DCS      11     // VS1053 Data/command select pin (output)
  #define CARDCS          27     // Card chip select pin
  #define VS1053_DREQ     31     // VS1053 Data request, ideally an Interrupt pin

#elif defined(__AVR_ATmega328P__)
  // Test to determine if this is a "ProTrinket" although lots of boards return this as it only tests processor.!
  // in need of some fancier test to determine exact board to ensure campatability
  // For now we will set the variables below to match out ProTrinket pinouts
  const String CPU_Type = "__AVR_ATmega328P__";
  #define VS1053_CS       6     // VS1053 chip select pin (output)
  #define VS1053_DCS      10     // VS1053 Data/command select pin (output)
  #define CARDCS          5     // Card chip select pin
  #define VS1053_DREQ     3     // VS1053 Data request, ideally an Interrupt pin

// Feather M4, M0, 328, nRF52840 or 32u4
#else
  #define VS1053_CS       6     // VS1053 chip select pin (output)
  #define VS1053_DCS     10     // VS1053 Data/command select pin (output)
  #define CARDCS          5     // Card chip select pin                               // ah-
  // DREQ should be an Int pin *if possible* (not possible on 32u4)
  #define VS1053_DREQ     9     // VS1053 Data request, ideally an Interrupt pin      // ah- pin 9 on Protrinket is NOT an Interupt, but pin 3 is ! Test
 
 
#endif

/*
 * Notes on the declaration of musicPlayer object (type Adafruit_VS1053_FilePlayer)
 * The declaration of the object only passes the Control Pins not the SPI pins.
 * This was my first real suspicion that I would need to look at the library
 * Open the Adafruit_VS1053.h (header) file, and you will notice;
 *  line 37 - start of test for processor to set the register size.
 *  line 58 - if else defaults our processor to ____ 8 bit? no change needed
 *  line 66 - Explicitly defines VS1053_FILEPLAYER_PIN_INT = 5.
 *  line 165- Shows us that the class Adafruit_VS1053_FilePlayer is inherited from Adafruit_VS1053
 *  line 167- Shows that the class can be declared multiple ways (Overloaded). this means we can pass
 *            our SPI pin numbers inside a different declaration of Adafruit_VS1053_FilePlayer in our code below.
 */
// Adafruit_VS1053_FilePlayer musicPlayer = Adafruit_VS1053_FilePlayer(VS1053_RESET, VS1053_CS, VS1053_DCS, VS1053_DREQ, CARDCS);   // ah- out with the old

Adafruit_VS1053_FilePlayer musicPlayer = Adafruit_VS1053_FilePlayer(11,12,13,VS1053_RESET, VS1053_CS, VS1053_DCS, VS1053_DREQ, CARDCS);
void setup() {
  Serial.begin(115200);

  // if you're using Bluefruit or LoRa/RFM Feather, disable the radio module
  //pinMode(8, INPUT_PULLUP);

  // Wait for serial port to be opened, remove this line for 'standalone' operation
  while (!Serial) { delay(1); }
  delay(500);
 
  Serial.print("\n Processor = ");
  Serial.println(CPU_Type);
  Serial.println("\nReset Control Pins for the ProTrinket");
  Serial.print(" VS1053_CS = ");
  Serial.println(VS1053_CS);
  Serial.print(" VS1053_DCS = ");
  Serial.println(VS1053_DCS);
  Serial.print(" CARDCS = ");
  Serial.println(CARDCS);
  Serial.print(" VS1053_DREQ = ");
  Serial.println(VS1053_DREQ);
   
  Serial.println("\nReset SPI Pins for the ProTrinket");
  Serial.println(" MOSI = 11");
  Serial.println(" MISO = 12");
  Serial.println(" CLK = 13");
 
  Serial.println("\nAdafruit VS1053 Feather Test");
 
  if (! musicPlayer.begin()) { // initialise the music player
     Serial.println(F("Couldn't find VS1053, do you have the right pins defined?"));
     while (1);
  }

  Serial.println(F("VS1053 found"));
 
  musicPlayer.sineTest(0x44, 500);    // Make a tone to indicate VS1053 is working
 
  if (!SD.begin(CARDCS)) {
    Serial.println(F("SD failed, or not present"));
    while (1);  // don't do anything more
  }
  Serial.println("SD OK!");
 
  // list files
  printDirectory(SD.open("/"), 0);
 
  // Set volume for left, right channels. lower numbers == louder volume!
  musicPlayer.setVolume(2,2);

  /*
   * We are using a ProTrinket so we will fail this test and go to the else statement
   * where we pass the interrupt number to use to the player.
   * We will add an ifelse to cover our "ProTrinket" akak
   */
#if defined(__AVR_ATmega32U4__)
  // Timer interrupts are not suggested, better to use DREQ interrupt!
  // but we don't have them on the 32u4 feather...
  musicPlayer.useInterrupt(VS1053_FILEPLAYER_TIMER0_INT); // timer int

// added this
#elif defined(__AVR_ATmega328P__)
  Serial.println(F("\nSet interrupt? Found the ATmega328 compatible - aka Protrinket"));
  Serial.println(F("pass 5 to useInterrupt method, library should attachInterrupt to value returned from digitalPinToInterrupt(dreq )"));
  musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT);  // DREQ int is set to pin 3 instead of default pin 9. Pin 3 on ProTrinket is an interrupt.
 
#else
  // If DREQ is on an interrupt pin we can do background
  // audio playing
  musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT);  // Cant use this for Trinket, variable is pre-defined in library as #5.
#endif
 
  // Play a file in the background, REQUIRES interrupts!
  Serial.println(F("\nPlaying full track 001"));
  musicPlayer.playFullFile("track001.mp3");

  Serial.println(F("Playing track 002"));
  musicPlayer.startPlayingFile("/track002.mp3");
}

void loop()
{
  Serial.print(".");
  // File is playing in the background
  if (musicPlayer.stopped()) {
    Serial.println("Done playing music");
    while (1) {
      delay(10);  // we're done! do nothing...
    }
  }
  if (Serial.available()) {
    char c = Serial.read();
   
    // if we get an 's' on the serial console, stop!
    if (c == 's') {
      musicPlayer.stopPlaying();
    }
   
    // if we get an 'p' on the serial console, pause/unpause!
    if (c == 'p') {
      if (! musicPlayer.paused()) {
        Serial.println("Paused");
        musicPlayer.pausePlaying(true);
      } else {
        Serial.println("Resumed");
        musicPlayer.pausePlaying(false);
      }
    }
  }
  delay(100);
}



/// File listing helper
void printDirectory(File dir, int numTabs) {
   while(true) {
     
     File entry =  dir.openNextFile();
     if (! entry) {
       // no more files
       //Serial.println("**nomorefiles**");
       break;
     }
     for (uint8_t i=0; i<numTabs; i++) {
       Serial.print('\t');
     }
     Serial.print(entry.name());
     if (entry.isDirectory()) {
       Serial.println("/");
       printDirectory(entry, numTabs+1);
     } else {
       // files have sizes, directories do not
       Serial.print("\t\t");
       Serial.println(entry.size(), DEC);
     }
     entry.close();
   }
}


Any help on this would be appreciated.
A

Aharas
 
Posts: 6
Joined: Mon Feb 04, 2019 6:40 pm

Re: TrinketPro with Feather Music Maker

by Aharas on Sun Feb 17, 2019 9:56 pm

Update: Unfortunately I am still not hearing any of the mp3s.

I have tried 3 SD cards (quick and slow format) and 10 songs of varying length.
The songs do appear to play because I hear it click when next song starts. and,
the song 'playing' appears to be the correct amount of time before advancing.

So, my Trinket Pro interacts with the Music Maker and all checks are good. I attach to interrupt #1 on pin 3 and the test tone works! The files 'play' for correct time but no audio except a click between songs.

What else can I try?

Aharas
 
Posts: 6
Joined: Mon Feb 04, 2019 6:40 pm

Re: TrinketPro with Feather Music Maker

by Aharas on Wed Feb 20, 2019 1:47 pm

I had purchased 4 Music Maker Featherwings. So I soldered up a second one and found I have the exact same issues.

The only thing I have not tried is a brand new unformatted SD card. But, I can see no reason why this device is not working.

Could one of the Adafruit gurus please take some time and flex their brain on this puzzle? I have been working on this for over a week now and I am not seeing any progress.
Thanks

Aharas
 
Posts: 6
Joined: Mon Feb 04, 2019 6:40 pm

Re: TrinketPro with Feather Music Maker

by adafruit_support_carter on Wed Feb 20, 2019 3:14 pm

Any reason why you are not using a Feather?

adafruit_support_carter
 
Posts: 21061
Joined: Tue Nov 29, 2016 2:45 pm

Re: TrinketPro with Feather Music Maker

by Aharas on Thu Feb 21, 2019 1:52 pm

... because money does not grow on trees! And I happen to have some Pro Trinkets, and they are stocked in my local electronics shop along with a few other adafruit products. I am also familiar with the Pro Trinket, and in this case I have a project that I wanted to re-do and kick up a notch from a hacked sound device to something more cool/flexible. Space is a consideration, but it is really the money and accessibility. Could you send me a freebie? Is that enough of a reason?

But more to the point, you said "Should be possible, in theory", so maybe we can try to determine if in fact it is possible. It would be a feather in everyone's hat if we can.

So, it "appears" the files are playing, but not in background. When this happens what kind of issues could cause this?

Aharas
 
Posts: 6
Joined: Mon Feb 04, 2019 6:40 pm

Re: TrinketPro with Feather Music Maker

by adafruit_support_carter on Thu Feb 21, 2019 3:49 pm

The TrinketPro uses an ATmega328, which is the same processor used on an Arduino UNO.

The Music Maker FeatherWing uses the VS1053 chip, which is the same one used on the Music Maker Shield.

The Music Maker Shield works on the UNO:
https://learn.adafruit.com/adafruit-mus ... bis-player

So you should be able to use the information in that guide, along with the pin out information available for the Trinket Pro
https://learn.adafruit.com/introducing- ... et/pinouts
and the Music Maker FeatherWing
https://learn.adafruit.com/adafruit-mus ... ng/pinouts
to try and piece the two together.


And just so you know, the VS1053 is available in a breakout version:
https://www.adafruit.com/product/1381
which might be easier to use with non-Feather form factors.

adafruit_support_carter
 
Posts: 21061
Joined: Tue Nov 29, 2016 2:45 pm

Re: TrinketPro with Feather Music Maker

by XRAD on Fri Feb 22, 2019 6:56 pm

Have you uploaded/tried the simple arduino example 'test'? I had a problem with MM playing certain files off the SD if they were saved after being named 001.MP3 vs saved as just 001 or 002 etc....I use audacity to create all my sound files(it's great and it's free)

define the pins as needed for the T-pro, some pins do better than others for certain tasks...

If I remember correctly, you have to use FTDI to serial monitor and debug the trinket pro. Maybe I am wrong. But, if you do find a few extra $'s, you will love moving up to the feather M0 express. So many more pins and easy debug....I stuck with my old trusty Trinkets and just recently moved up to Trinket M0.

Code: Select all | TOGGLE FULL SIZE
/***************************************************
  This is an example for the Adafruit VS1053 Codec Breakout

  Designed specifically to work with the Adafruit VS1053 Codec Breakout
  ----> https://www.adafruit.com/products/1381

  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries. 
  BSD license, all text above must be included in any redistribution
 ****************************************************/

// include SPI, MP3 and SD libraries
#include <SPI.h>
#include <Adafruit_VS1053.h>
#include <SD.h>

// define the pins used
//#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
// Connect CLK, MISO and MOSI to hardware SPI pins.
// See http://arduino.cc/en/Reference/SPI "Connections"

// These are the pins used for the breakout example
#define BREAKOUT_RESET  9      // VS1053 reset pin (output)
#define BREAKOUT_CS     10     // VS1053 chip select pin (output)
#define BREAKOUT_DCS    8      // VS1053 Data/command select pin (output)
// These are the pins used for the music maker shield
#define SHIELD_CS     7      // VS1053 chip select pin (output)
#define SHIELD_DCS    6      // VS1053 Data/command select pin (output)

// These are common pins between breakout and shield
#define CARDCS 4     // Card chip select pin
// DREQ should be an Int pin, see http://arduino.cc/en/Reference/attachInterrupt
#define DREQ 3       // VS1053 Data request, ideally an Interrupt pin

Adafruit_VS1053_FilePlayer musicPlayer =
  // create breakout-example object!
  Adafruit_VS1053_FilePlayer(BREAKOUT_RESET, BREAKOUT_CS, BREAKOUT_DCS, DREQ, CARDCS);
  // create shield-example object!
  //Adafruit_VS1053_FilePlayer(SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);
 
void setup() {
  Serial.begin(9600);
  Serial.println("Adafruit VS1053 Simple Test");

  if (! musicPlayer.begin()) { // initialise the music player
     Serial.println(F("Couldn't find VS1053, do you have the right pins defined?"));
     while (1);
  }
  Serial.println(F("VS1053 found"));
 
  SD.begin(CARDCS);    // initialise the SD card
 
  // Set volume for left, right channels. lower numbers == louder volume!
  musicPlayer.setVolume(20,20);

  // Timer interrupts are not suggested, better to use DREQ interrupt!
  //musicPlayer.useInterrupt(VS1053_FILEPLAYER_TIMER0_INT); // timer int

  // If DREQ is on an interrupt pin (on uno, #2 or #3) we can do background
  // audio playing
  musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT);  // DREQ int
 
  // Play one file, don't return until complete
  Serial.println(F("Playing track 001"));
  musicPlayer.playFullFile("track001.mp3");
  // Play another file in the background, REQUIRES interrupts!
  Serial.println(F("Playing track 002"));
  musicPlayer.startPlayingFile("track002.mp3");
}

void loop() {
  // File is playing in the background
  if (musicPlayer.stopped()) {
    Serial.println("Done playing music");
    while (1);
  }
  if (Serial.available()) {
    char c = Serial.read();
   
    // if we get an 's' on the serial console, stop!
    if (c == 's') {
      musicPlayer.stopPlaying();
    }
   
    // if we get an 'p' on the serial console, pause/unpause!
    if (c == 'p') {
      if (! musicPlayer.paused()) {
        Serial.println("Paused");
        musicPlayer.pausePlaying(true);
      } else {
        Serial.println("Resumed");
        musicPlayer.pausePlaying(false);
      }
    }
  }

  delay(100);
}

XRAD
 
Posts: 644
Joined: Sat Nov 19, 2016 3:28 pm

Re: TrinketPro with Feather Music Maker

by Cygnii on Fri Mar 08, 2019 10:14 am

Hello,

i have a big project coming up: Lucio from Overwatch!
I've watched John Park's video's and read the step -by- step a couple of times but since i'm also going to add lights in the whole costume and leave out the trigger sound effects, would the Pro Trinket and Featherwing Music Maker be enough? Or is that not the best way to go?




Linde

Cygnii
 
Posts: 1
Joined: Fri Mar 08, 2019 9:59 am

Please be positive and constructive with your questions and comments.