Hallo Leute,
ich habe mit meinem Adafruit DataLogging shield ein ähnliches Problem wie Lukas. Bei mir hört die Messung nach 100000 Millisekunden auf, sowohl im seriellen Monitor als auch auf der SD-Karte, wenn ich eine 2GB FAT16 SD-Karte eingesetzt habe. Bei meiner 4GB FAT32 passiert es manchmal, dass die Karte neu initialisiert wird und die Zeit wieder bei 0 anfängt. Ich hatte im Forum gelesen, dass die Zeit weiterläuft und erst nach 49 Tagen von 0 anfängt.
Hat einer eine Idee?
Viele Grüße Thomas
/*
SD card dataloggerThis example shows how to log data from three analog sensors
to an SD card using the SD library.The circuit:
- SD card attached to SPI bus as follows:
** UNO: MOSI - pin 11, MISO - pin 12, CLK - pin 13, CS - pin 4 (CS pin can be changed)
and pin #10 (SS) must be an output
** Mega: MOSI - pin 51, MISO - pin 50, CLK - pin 52, CS - pin 4 (CS pin can be changed)
and pin #52 (SS) must be an output
** Leonardo: Connect to hardware SPI via the ICSP header
Pin 4 used here for consistency with other Arduino examplescreated 24 Nov 2010
modified 9 Apr 2012 by Tom Igoe
weiterverarbeitet am 24 Nov 2012 von Thomas BuhrmannThis example code is in the public domain.
*/
#include <SD.h>
unsigned long time; //Die Zeit wird in Millisekunden gezählt bis zum nächsten Reset
// On the Ethernet Shield, CS is pin 4. Note that even if it's not
// used as the CS pin, the hardware CS pin (10 on most Arduino boards,
// 53 on the Mega) must be left as an output or the SD library
// functions will not work.
const int chipSelect = 10;File dataFile;
int potpin8 = 8; //analoger Eingang 8 wird als ganze Zahl definiert
int potpin9 = 9; //analoger Eingang 9 wird als ganze Zahl definiert
int var8; // Variable var8 wird als ganze Zahl definiert
int var9; // Variable var9 wird als ganze Zahl definiertvoid setup()
{pinMode(22,INPUT); //Digitaler Eingang 22 "An" -> SD-Karte wird beschrieben (zum Wechseln)
pinMode(23,INPUT); //Digitaler Eingang 23 "An" -> Kontroller liest die Daten einif (digitalRead(23)==HIGH){
Serial.begin(19200); // Open serial communications and wait for port to open:
// while (!Serial) {
//; // wait for serial port to connect. Needed for Leonardo only
}Serial.print("Initializing SD card...");
// make sure that the default chip select pin is set to
// output, even if you don't use it:
pinMode(SS, OUTPUT);// see if the card is present and can be initialized:
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
// don't do anything more:
while (1) ;
}
Serial.println("card initialized.");// Open up the file we're going to log to!
dataFile = SD.open("datalog.txt", FILE_WRITE);
if (! dataFile) {
Serial.println("error opening datalog.txt");
// Wait forever since we cant write data
while (1) ;
}
}void loop()
{
// make a string for assembling the data to log:
String dataString = "";// read three sensors and append to the string:
var8 = analogRead(potpin8); //liest die Werte vom linken Schuh ein und schreibt sie der Variablen var8 zu
var9 = analogRead(potpin9); //liest die Werte vom rechten Schuh ein und schreibt sie der Variablen var9 zu
dataString += "Millisekunde: "; //schreibt den Text Millisekunde
time = millis(); // liest die Zeit
dataString += String(time); // schreibt den Wert in Millisekunden
dataString += " Links: "; // schreibt den Text Links
dataString += String(var8); // schreibt den Wert, den er in Zeile 78 ausgelesen hat
dataString += " Rechts: "; // schreibt den Text Rechts
dataString += String(var9); // schreibt den Wert, den er in Zeile 79 ausgelesen hatdataFile.println(dataString); // bereitet die Zeile für das schreiben auf die SD-Karte vor
// print to the serial port too:
Serial.println(dataString); //Wiedergabebefehl für den seriellen Monitor auf em PC// The following line will 'save' the file to the SD card after every
// line of data - this will use more power and slow down how much data
// you can read but it's safer!
// If you want to speed up the system, remove the call to flush() and it
// will save the file only every 512 bytes - every time a sector on the
// SD card is filled with data.if (digitalRead(22)==HIGH){
dataFile.flush(); //schreibt die Zeile auf die SD-Karte
}
delay(50); //Zeitverzögerung zwischen zwei Messungen, tatsächlich 76 ms
}