-
Notifications
You must be signed in to change notification settings - Fork 0
/
chronoAmperometry.ino
65 lines (56 loc) · 2.06 KB
/
chronoAmperometry.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// chronoAmperometry tab / WheeStat5_4 sketch in publicEnergiaSketches folder
// chronoamperometry and two step chronoamperometry experiments
// both working as of May 20, 2014
void chronAmp() {
// Serial.print(rdTime);
//Serial.print(",");
//Serial.println(readTime);
////////// ////////////////////////////////////////////////
PWMWrite(signal_pin,pwmRes,dInit,pwmClock); // set signal voltage to 512 + 1/2 Vinit
///// from Ben's old stuff ////
int Iread = 0;
long inTime = 0;
// readTime = readTime*1000; // micros durring read
// fnlV_time = fnlV_time*1000;
// long time1 = micros();
long time2; // = time1;
// readTime = 50000;
delay(delay1*1000);
long time1 = millis();
///////// Step and read ////////////////////////////////////////////////
PWMWrite(signal_pin,pwmRes,dFnl,pwmClock);
while(inTime <= readTime){
// while(time2 <= time1+readTime){
Iread = 0;
// time2 = micros();
// inTime = (time2-time1)/1000; //inTime is in ms, time1 and time2 are micros
time2 = millis();
inTime = time2-time1; //inTime is in ms, time1 and time2 are micros
// Serial.print("4 ,"); // not working here
Serial.print(inTime);
Serial.print(","); // working here
// Serial.println(Iread2,4); // holdover from Ben's old stuff
// time2 = micros();
// Serial.print("1 ,");
readCurrent(true);
Serial.print(iMin);
Serial.print(",");
Serial.println(iMax);// Serial.println("");
// Serial.println("");
}
if(mode == chronoAmp2) {
PWMWrite(signal_pin,pwmRes,dInit,pwmClock); // step back to initial voltage
while(inTime <= readTime*2){
Iread = 0;
time2 = millis();
inTime = time2-time1; //inTime is in ms, time1 and time2 are micros
Serial.print(inTime);
Serial.print(","); // working here
readCurrent(true);
Serial.print(iMin);
Serial.print(",");
Serial.println(iMax);// Serial.println("");
}
}
openCircuit(); // go to open circuit
}