add gametrak stats to log

This commit is contained in:
interfisch 2023-06-17 22:02:12 +02:00
parent de1757d7af
commit 91e79369f0
1 changed files with 23 additions and 15 deletions

View File

@ -104,7 +104,8 @@ float filter_stop_set_steer=0.06; //safety stop
#define GT_LENGTH_MAXLENGTH 2000 //maximum length in [mm]. maximum string length is around 2m80
#define GT_LENGTH_ADC_MAXDIFF 127 //maximum adc value difference between A and B poti. Used to detect scratching poti. during length calibration was 57
int raw_length_maxdiff=0;
int raw_length_maxdiff=0; //maximum value seen since boot/reset
int raw_length_diff=0; //maximum value since last log write
//TODO: implement error for poti maxdiff
uint16_t gt_length=0; //0=rolled up, 1unit = 1mm
/* calibration 20220410
@ -369,7 +370,8 @@ void loop() {
int raw_length_a=analogRead(PIN_GAMETRAK_LENGTH_A);
int raw_length_b=analogRead(PIN_GAMETRAK_LENGTH_B);
raw_length_maxdiff=max(raw_length_maxdiff,abs(raw_length_a-raw_length_b));
raw_length_maxdiff=max(raw_length_maxdiff,abs(raw_length_a-raw_length_b)); //overall max
raw_length_diff=max(raw_length_diff,abs(raw_length_a-raw_length_b)); //max since last log write
int raw_length=(raw_length_a+raw_length_b)/2;
@ -683,22 +685,28 @@ void loop() {
dataFile.print("current_L,current_R,");
dataFile.print("rpm_L,rpm_R,");
dataFile.print("temp,vbat,");
dataFile.println("trip,currentConsumed,motorenabled,disarmedByDelay");
dataFile.println("trip,currentConsumed,motorenabled,gt_length,raw_length_diff,gt_horizontal,gt_vertical,disarmedByDelay");
dataFile.print("#TIMESTAMP:"); dataFile.println(now());
logging_headerWritten=true;
}
dataFile.print(String(loopmillis)); dataFile.print(";");
dataFile.print(esc.getCmdL()); dataFile.print(";");
dataFile.print(esc.getCmdR()); dataFile.print(";");
dataFile.print(esc.getFiltered_curL(),3); dataFile.print(";");
dataFile.print(esc.getFiltered_curR(),3); dataFile.print(";");
dataFile.print(esc.getFeedback_speedL_meas()); dataFile.print(";");
dataFile.print(esc.getFeedback_speedR_meas()); dataFile.print(";");
dataFile.print(esc.getFeedback_boardTemp()); dataFile.print(";");
dataFile.print(esc.getFeedback_batVoltage()); dataFile.print(";");
dataFile.print(esc.getTrip()); dataFile.print(";");
dataFile.print(esc.getCurrentConsumed(),3); dataFile.print(";");
dataFile.print(motorenabled); dataFile.print(";");
dataFile.print(String(loopmillis)); dataFile.print(",");
dataFile.print(esc.getCmdL()); dataFile.print(",");
dataFile.print(esc.getCmdR()); dataFile.print(",");
dataFile.print(esc.getFiltered_curL(),3); dataFile.print(",");
dataFile.print(esc.getFiltered_curR(),3); dataFile.print(",");
dataFile.print(esc.getFeedback_speedL_meas()); dataFile.print(",");
dataFile.print(esc.getFeedback_speedR_meas()); dataFile.print(",");
dataFile.print(esc.getFeedback_boardTemp()); dataFile.print(",");
dataFile.print(esc.getFeedback_batVoltage()); dataFile.print(",");
dataFile.print(esc.getTrip()); dataFile.print(",");
dataFile.print(esc.getCurrentConsumed(),3); dataFile.print(",");
dataFile.print(motorenabled); dataFile.print(",");
dataFile.print(gt_length,0); dataFile.print(",");
dataFile.print(raw_length_diff,0); dataFile.print(",");
raw_length_diff=0; //reset
dataFile.print(gt_horizontal,0); dataFile.print(",");
dataFile.print(gt_vertical,0); dataFile.print(",");
dataFile.print(debug_count_disarmedbecauseofnrfdelay);
dataFile.println("");
dataFile.close();