Code zur Kapazitätsmessung des
verwendeten Akkus
Entwicklungsumgebung:
Arduino IDE Version 1.8.12 Verwendetes Bord: ATmeaga328P (old
Bootloader) Die Ausgabe des Mikrocontrollers kann auf einem
Seriellen Monitor ausgegeben werden; die Baudrate beträgt 115200.
Die Ausgegeben werte können einfach aus der Konsole als Dateinimport
in Excel eingelesen werden.
download Capacity_Tester.cpp
download Akkumessung.xlsx Code beginnt hier:
// Const
const int DATAPOINTS = 40; const double vFull = 4.2; const
double vEmpty = 3.0;
// Data double readvoltage; double
voltage[DATAPOINTS]; unsigned long time[DATAPOINTS]; int
samplecount = 0; double startvoltage;
// timemesurement
unsigned long starttime;
void setup() {
Serial.begin(115200); double delta = (vFull - vEmpty) /
(DATAPOINTS - 1); voltage[0] = vFull; voltage[DATAPOINTS-1] =
vEmpty; for (int i = 1; i < DATAPOINTS - 1; i++) {
voltage[i] = voltage[i - 1] - delta; }
Serial.println("messurement points:"); for (int i = 0; i <
DATAPOINTS; i++) { Serial.println(voltage[i]); }
startvoltage = double(analogRead(A0)) / 1024 * 5;
starttime =
millis(); }
void loop() { if (samplecount >=
DATAPOINTS) { Serial.println("End of messurement");
Serial.print("0 "); Serial.println(startvoltage); for (int i =
0; i < DATAPOINTS; i++) { Serial.print(time[i]);
Serial.print(";"); Serial.println(voltage[i]); } while
(true) {} }
readvoltage = double(analogRead(A0)) / 1024 *
5; if ((readvoltage <= voltage[samplecount]) && (samplecount <
DATAPOINTS)) { time[samplecount] = millis() - starttime;
Serial.print(time[samplecount]); Serial.print(";");
//Serial.print("0 "); Serial.println(voltage[samplecount]);
samplecount++; } delay(100);
//Serial.println(double(analogRead(A0)) / 1024 * 5); }
|