Forum Rule: Always post complete source code & details to reproduce any issue!
Page 9 of 9 FirstFirst ... 7 8 9
Results 201 to 207 of 207

Thread: Audio Recording / Logging to SD card --> microSoundRecorder

  1. #201
    Senior Member
    Join Date
    Jul 2014
    Posts
    3,150
    After Paul integrated SdFat-V2 I updated code to include directly TD SdFat.h (no -beta anymore)
    No need to download Bill's beta version.
    Best to remove SdFat-beta from local Arduino Libs and only use TD version

  2. #202
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    654
    Tim, Walter, thanks for the explanations, now I understand! I can confirm also, that the firmware compiles WITHOUT downloading the SdFat lib by Bill Greiman, thanks for your hints!

    I have one further question:

    * I built 12 new recorders, smaller and with a slightly modified layout, but still using the original T3.6 software and concept
    * I purchased 64Gbyte microSD cards
    * observation: when the software tries to activate the SD card after waking up to begin a new time window (sd.begin()), sometimes the Sd card refuses to work (this makes the software think there is no SD card inserted and it enters the never ending while loop with blinking pin 13 LED) --> it seems to me, the newly purchased SD cards are different in behaviour and need a higher power supply or a longer time before they respond . . . this is confirmed if I use older 64GByte SD cards, which work without problems [they are of exactly the same brand and type!]

    The corresponding code lines are in audio_logger_if.h

    Code:
      if (!sd.begin(SD_CONFIG))
      {
    //    sd.errorHalt("sd.begin failed");
        while(1)
        {
          // blink code suggests insertion of an SD card
                pinMode(13,OUTPUT);
                digitalWriteFast(13,HIGH);
                delay(200);
                digitalWriteFast(13,LOW);
                delay(200);
        }
      }
    I would like to cure this by letting the software make several trials in activating the SD card, but still indicate problems with not inserted SD cards by blinking with pin 13 LED.

    However, as I understand it, this statement makes it impossible to use pin 13 for I2S afterwards.

    Code:
    pinMode(13,OUTPUT);
    Can I revert this, so the code checks for SD card, blinks one second, and then checks again? Something like this:

    Code:
     while (!sd.begin(SD_CONFIG))
      {
          // blink code suggests insertion of an SD card
                pinMode(13,OUTPUT);
                digitalWriteFast(13,HIGH);
                delay(200);
                digitalWriteFast(13,LOW);
                delay(200);
                pinMode(13, ???); // here, I do not know how I can re-assign pin 13 for correct I2S use
    
        }

  3. #203
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    654
    one more thought:

    maybe the reason for the sporadic failure of SD card begin statement is the usage of the new/faster SD lib?

    Because the old SD cards were tested with the old software and the new SD cards with the new software!?

  4. #204
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    654
    Testing with the following modification at the moment (this is expected to do a restart of the Teensy every time the SD card cannot be initiated):

    Code:
    #define CPU_RESTART_ADDR (uint32_t *)0xE000ED0C
    #define CPU_RESTART_VAL 0x5FA0004
    #define CPU_RESTART (*CPU_RESTART_ADDR = CPU_RESTART_VAL);
    //____________________________ FS Interface implementation______________________
    void c_uSD::init()
    {
      delay(200);
      if (!sd.begin(SD_CONFIG))
      {
          delay(1000);
          CPU_RESTART;
      }
    
      // Set Time callback
      FsDateTime::callback = dateTime;
      //
      nbuf=0;
      state=0;
    }
    I will report back whether this cures the problem and allows to reliably start the acquisition, even when the SD card is sometimes not detected in the first attempt.

  5. #205
    Senior Member
    Join Date
    Jul 2014
    Posts
    3,150
    @DD4WH,
    If you wanted to use I2S and also use LED for messaging, You should use
    Code:
              CORE_PIN13_CONFIG = PORT_PCR_MUX(4);  // PTC5,  I2S0_RXD0
    after you are done with LEDing and move on to I2S

  6. #206
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    654
    perfect, thanks, exactly the info I was looking for! will try and report back and eventually place a PR after testing!

  7. #207
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    654
    First test result:
    * 7 recorders running for 4 days now
    * 1-12h and 13-24h
    * 15sec record, 15sec record, 30sec sleep
    * all equipped with the suspect 64GB microSD cards, which caused problems because they were not recognized after deep sleep and recorder went into infinite blink while loop

    Modification of the code in audio_logger_if.h (recorder blinks to indicate a missing SD card, but then trys again to mount the SD card, success of the mounting is saved into a file on the SD card)
    Code:
    void c_uSD::init()
    {
      delay(200);
      int SD_success = 0;
      char text[32];
      char SD_filename[24];
    
      while (!sd.begin(SD_CONFIG))
      {
         // configure pin 13 for LED      
         pinMode(13,OUTPUT);
         for(int idx = 0; idx < 8; idx++)
         {
             digitalWriteFast(13,HIGH);
             delay(200);
             digitalWriteFast(13,LOW);
             delay(200);
         }
         delay(5000);
         SD_success++;
         // reconfigure pin 13 for I2S
         CORE_PIN13_CONFIG = PORT_PCR_MUX(4);  // PTC5,  I2S0_RXD0
      }
    
      sprintf(SD_filename, "SD_s_%s.txt", acqParameters.name);
      file.open(SD_filename, O_CREAT|O_WRITE|O_APPEND);
        sprintf(text, "%04d_%02d_%02d,", year(), month(), day());  file.write((char*)text, strlen(text));
        sprintf(text, "%02d_%02d_%02d,", hour(), minute(), second());   file.write((char*)text, strlen(text));
        sprintf(text, "%10d\r\n", SD_success);          file.write((char*)text, strlen(text));
      file.close(); 
      
      // Set Time callback
      FsDateTime::callback = dateTime;
      //
      nbuf=0;
      state=0;
    }
    Test is still running, but after four days, at least one recorder had 3 occasions of unsuccessful mounting of the SD card after waking up from deep sleep and in the very next trial, the SD card was mounted successfully and the recordings continued as expected [until the next deep sleep 11 hours later]!

    Will continue the test until the recorders run out of battery and report the whole result.
    Last edited by DD4WH; 04-23-2021 at 05:23 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •