Logger Shield stopps logging

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
DJGERMANY
 
Posts: 6
Joined: Wed Nov 19, 2014 5:59 am

Logger Shield stopps logging

Post by DJGERMANY »

Hi,

I am logging S0 impulses -
The impulses are count and written to to card every ten minutes.
At 23:59 last entry will be written to the card and an new file will be created for the next day ( e.g. 20141116.CSV)
Problem is that the logger shield stops writing without any reasons during the day. (see attached files)
I have formatted the SD Card with sdformatter 4.0 as you told in the instructions and tried with different cards.


Hope you can help, even the program is written in german


Regards
DJ
20141115.CSV
File started at 18:20
(1.02 KiB) Downloaded 117 times
20141116.CSV
New File was created but stopped logging at 11:30
(1.98 KiB) Downloaded 116 times

Code: Select all

/*
Strom Impulese Logger Version 11.0 Final
S0 Log über 24 Stunden alle 10 Minuten 
Letzte Änderung am 12.10.2014
DJ Scharff 
 
 Programm zu Erfassung Impulsen eines S0 Stromzählers
 Der Impulsausgang vom Stromzähler muss an + 5 V Arduino PIN 2 und GND angeschlossen werden.
 Benutzung auf eigene Gefahr !!!    USE AT YOUR OWN RISK !!!
 Zähler = saia burgess ALD1D5F10   1000 Impulse = 1 kHh
 
 */

#include <Time.h>  
#include <Wire.h>  
#include <DS1307RTC.h>               // a basic DS1307 library that returns time as a time_t
#include <SD.h>

File myFile;

static boolean RunAction = true;     // für einmal zählen
const int S0B = 2;                   // Pin 2 für S0 Eingang
long Impulse = 0;                    // Zähler für Impuls
long Imps = 0;                       // Impulse summiert 

int Jahr = 1000;
int Monat = 12;
int Tag = 10;
int Stunde = 10;
int Minute = 10;
int Sekunde = 10;
static boolean pw = true;           // Prüfwert Tag 

char filename[8];


int x = 0; 
long Wartezeit = 0; 
long Warten = 0; 
long Karte = 0;

// Setup Teil des Programms 

void setup()  {
  pinMode(1, OUTPUT);               // Grüne LED
  pinMode(4, OUTPUT);               // Rote LED 
  pinMode(5, OUTPUT);               // Gelbe LED
  pinMode(S0B, INPUT);              //Pin 2 für den S0 Anschluß

  setSyncProvider(RTC.get);         // the function to get the time from the RTC

  pinMode(10, OUTPUT);              // Dieser Block ist wichtig hier wird geöffnet , geschrieben, geschlossen  

  if (!SD.begin(10)) {
    digitalWrite(1, HIGH);           // Grüne LED an
    digitalWrite(4, HIGH);           // Rote Led an 
    digitalWrite(5, HIGH);           // Gelbe LED  an
    return;
  }

  digitalWrite(1, LOW);           // Grüne LED aus
  digitalWrite(4, LOW);            // Rote LED aus
  digitalWrite(5, LOW);            // Gelbe LED aus



  // Warten bis 0 10 20 30 40 50 Minuten erreicht sind dann das Programm starten
  digitalWrite(5, HIGH);            // Gelbe LED dauerhaft an 
  while (minute() != 0 && minute() != 10 && minute() != 20 && minute() != 30 && minute() != 40 && minute() != 50 ){
  }
  digitalWrite(5, LOW);            // Gelbe LED aus 
  digitalWrite(1, HIGH);           // Grüne LED an 
}   








// ********************Hauptschleife************************* 
void loop(){


        Warten = minute();

        Warten = Warten + 10;       // + Dauer des Zählzyklus in Minuten (10) 
        Karte = Warten -1;

        if (Warten >= 60)
            Warten = Warten-60;

        if (Karte >= 60)
            Karte = Karte-60;  

          
              do {  // Zählschleife

                  if (digitalRead(S0B) == HIGH) {
                      digitalWrite(5, HIGH);   // Gelbe LED an wenn Impuls vom Zähler 

                       if(RunAction) {       // 1 Impuls einmal zählen 
                          Impulse = (Impulse + 1);
                          Imps = (Imps + 1);
                          RunAction = false;
                          }
                     }
                     else {
                             digitalWrite(5, LOW);     // Gelbe LED aus 
                             RunAction = true;
                     }

                      if (Karte == minute())
                         digitalWrite(4, HIGH);  // Eine Minute vor dem Schreiben rote LED an 

     
                       if (hour() == 23 && minute() == 59 && second() >= 59 && pw == true) {
                           pw = false;
                           druck();                         // Funktion Druck aufrufen 
                           Imps = 0; 
                           Warten = 10;                      // Testweise erfolgt dieser Eintrag um den nächsten Eintrag um 00:10 zu generieren 
                           Karte = 9;                        // Testweise erfolgt dieser Eintrag um den nächsten Eintrag um 00:10 zu generieren
                          }
   
                 }  
                 
             while (Warten != minute());  // Ende der Zählschleife

 
  // Daten auf SD Karte schreiben  
   pw = true; 
  druck();                  // Funktion Daten auf SD Karte schreiben aufrufen


}  // Hier Ende des Hauptschleife - Zurück auf Anfang  





// Funktion Druck 
// Daten werden auf SD Karte geschrieben 

void druck()                 
{

  Jahr = year();
  Monat = month();
  Tag = day();
  Stunde = hour();
  Minute = minute();
  Sekunde = second();

  sprintf(filename, "%04d%02d%02d.csv", Jahr, Monat, Tag);

  myFile = SD.open(filename , FILE_WRITE);
  myFile.print(Jahr);
  myFile.print("-");
  if (Monat < 10) 
    myFile.print('0');
  myFile.print(Monat);
  myFile.print("-");
  if (Tag < 10) 
    myFile.print('0');
  myFile.print(Tag);
  myFile.print(";");
  if (Stunde < 10) 
    myFile.print('0');
  myFile.print(Stunde);
  myFile.print(":");
  if (Minute < 10) 
    myFile.print('0');
  myFile.print(Minute);
  myFile.print(":");
  if (Sekunde < 10) 
    myFile.print('0');
  myFile.print(Sekunde);
  myFile.print(";");
  myFile.print(Impulse);
  myFile.print(";");
  myFile.print(Imps);
  myFile.println(); 

  myFile.close();

  Impulse = 0;

  digitalWrite(4, LOW); // Rote LED aus 
   
}




User avatar
adafruit_support_bill
 
Posts: 88092
Joined: Sat Feb 07, 2009 10:11 am

Re: Logger Shield stopps logging

Post by adafruit_support_bill »

I don't see anything in the code that would cause it to stop recording. How are you powering the system? What did you do get get it to produce the second file?

User avatar
DJGERMANY
 
Posts: 6
Joined: Wed Nov 19, 2014 5:59 am

Re: Logger Shield stopps logging

Post by DJGERMANY »

Powering at the Moment via USB but same problem occured when connected direcly via 9 Volt

Hope I understand your question,

The second file is produced
by this

Jahr = year();
Monat = month();
Tag = day();
Stunde = hour();
Minute = minute();
Sekunde = second();

sprintf(filename, "%04d%02d%02d.csv", Jahr, Monat, Tag);


The last entry is at 23:59:59 and the first entry is at 10 Minutes after midnight so the filename changes and a new file will be created automaticly.
as wie see in the two files this worked perfect.

I also do not see an piece of code which stopp the writingt to the sd card and the red led which is switched on one Minute before writing to the card (just to warn you not to pull the card) is switched off at the end of void(druck) (printing) after writing to the card.
Here everthing seems to be normal, even the wrintig ends at 11:20 in file 20141116.CSV the led goes on an out.

And there are no blank lines in the file so writing to the sd stopped completly

Could these be a hardware problem?

I will try to restart the system , maybe it the wrintig stopps after the same time.
I will also use a 9 V 1,0 A Power supply this time

User avatar
adafruit_support_bill
 
Posts: 88092
Joined: Sat Feb 07, 2009 10:11 am

Re: Logger Shield stopps logging

Post by adafruit_support_bill »

Does the led continue to go on and off after the writing has stopped?

One possibility is a communication problem with the RTC. The Arduino wire library can hang sometimes if there is a bad connection to one of the devices on the bus. In this case, the program would stop completely and there would be no LED activity at all.

User avatar
DJGERMANY
 
Posts: 6
Joined: Wed Nov 19, 2014 5:59 am

Re: Logger Shield stopps logging

Post by DJGERMANY »

Yes , definitly the red LED keeps going on and off, even the writing to the sd has stopped - so you have no possibility to see that there is an error as long as the sd card is in the logger shield.

there is also a yellow (gelb) Led which goes on every time a S0 Impuls is counted

User avatar
adafruit_support_bill
 
Posts: 88092
Joined: Sat Feb 07, 2009 10:11 am

Re: Logger Shield stopps logging

Post by adafruit_support_bill »

Interesting. Since the red led is turned on before calling druck() and is turned off inside druck(), you must be calling druck() on schedule.
There is no conditional code inside druck() and the LED is turned off at the very end, so the only explanation that makes sense to me would be some communication problem with the SD card.

If you post photos of the front and back of the shield, we can check for any assembly issues. Also, if you have another SD card, try using that to see if you have better results.

User avatar
DJGERMANY
 
Posts: 6
Joined: Wed Nov 19, 2014 5:59 am

Re: Logger Shield stopps logging

Post by DJGERMANY »

Ok, I will check this tomorrow and I will take photos of the shield - I just started the arduino and I will wait until tomorrow after 12:00 am to see if the writing error comes up again. I checked an older file and here it stopped writing at 11:40 am

User avatar
DJGERMANY
 
Posts: 6
Joined: Wed Nov 19, 2014 5:59 am

Re: Logger Shield stopps logging

Post by DJGERMANY »

Hello again,

as much as I can say after testing some more days is :

a) it seems to be that I have to use a 9V 1 A powersupply

b) one major problem might be that you can not pull the card and push it back (for reading with a laptop) - I do not know if this is documented
but should be - cause normally you think that you can do this with an sd-card. Maybe it needs some more code to reactivate the card after the exchange.

User avatar
adafruit_support_bill
 
Posts: 88092
Joined: Sat Feb 07, 2009 10:11 am

Re: Logger Shield stopps logging

Post by adafruit_support_bill »

a) it seems to be that I have to use a 9V 1 A powersupply
The SD card does need more current to write. (The exact amount depends on the card).
b) one major problem might be that you can not pull the card and push it back (for reading with a laptop)
Unless you attempt to access the card during the time it is removed, it should not be a problem. If you are not actively reading or writing to the card, the SD library would not be aware that the card is missing.

User avatar
DJGERMANY
 
Posts: 6
Joined: Wed Nov 19, 2014 5:59 am

Re: Logger Shield stopps logging

Post by DJGERMANY »

Thats make sense, when I pull the card and push it back the Program rans as normal but did not write to the card anymore after that time - not even in the existing file it also does not create a new file after midnight.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”