change logging format to comma, add looptime duration to log

This commit is contained in:
interfisch 2023-06-17 22:28:08 +02:00
parent a00c1d2cba
commit 6c69e4c895
3 changed files with 34 additions and 29 deletions

View File

@ -48,6 +48,7 @@ int16_t throttle_pos=0;
int16_t brake_pos=0; int16_t brake_pos=0;
unsigned long loopmillis; unsigned long loopmillis;
unsigned long looptime_duration;
#define ADSREADPERIOD 3 //set slightly higher as actual read time to avoid unnecessary register query #define ADSREADPERIOD 3 //set slightly higher as actual read time to avoid unnecessary register query

View File

@ -66,38 +66,40 @@ void loggingLoop(unsigned long loopmillis,ESCSerialComm& escFront, ESCSerialComm
dataFile.print("rpm_FrontL,rpm_FrontR,rpm_RearL,rpm_RearR,"); dataFile.print("rpm_FrontL,rpm_FrontR,rpm_RearL,rpm_RearR,");
dataFile.print("temp_Front,temp_Rear,vbat_Front,vbat_Rear,"); dataFile.print("temp_Front,temp_Rear,vbat_Front,vbat_Rear,");
dataFile.print("currentAll,throttle,brake,speed,trip_Front,trip_Rear,currentConsumed_Front,currentConsumed_Rear,"); dataFile.print("currentAll,throttle,brake,speed,trip_Front,trip_Rear,currentConsumed_Front,currentConsumed_Rear,");
dataFile.println("temp_ESCFront,temp_ESCRear,temp_Air"); dataFile.println("temp_ESCFront,temp_ESCRear,temp_Air,looptime_duration");
dataFile.print("#TIMESTAMP:"); dataFile.println(now()); dataFile.print("#TIMESTAMP:"); dataFile.println(now());
logging_headerWritten=true; logging_headerWritten=true;
} }
dataFile.print(loopmillis/1000.0,3); dataFile.print(";"); dataFile.print(loopmillis/1000.0,3); dataFile.print(",");
dataFile.print(escFront.getCmdL()); dataFile.print(";"); dataFile.print(escFront.getCmdL()); dataFile.print(",");
dataFile.print(escFront.getCmdR()); dataFile.print(";"); dataFile.print(escFront.getCmdR()); dataFile.print(",");
dataFile.print(escRear.getCmdL()); dataFile.print(";"); dataFile.print(escRear.getCmdL()); dataFile.print(",");
dataFile.print(escRear.getCmdR()); dataFile.print(";"); dataFile.print(escRear.getCmdR()); dataFile.print(",");
dataFile.print(escFront.getFiltered_curL(),3); dataFile.print(";"); dataFile.print(escFront.getFiltered_curL(),3); dataFile.print(",");
dataFile.print(escFront.getFiltered_curR(),3); dataFile.print(";"); dataFile.print(escFront.getFiltered_curR(),3); dataFile.print(",");
dataFile.print(escRear.getFiltered_curL(),3); dataFile.print(";"); dataFile.print(escRear.getFiltered_curL(),3); dataFile.print(",");
dataFile.print(escRear.getFiltered_curR(),3); dataFile.print(";"); dataFile.print(escRear.getFiltered_curR(),3); dataFile.print(",");
dataFile.print(escFront.getFeedback_speedL_meas()); dataFile.print(";"); //+ //Todo: check if speed for R wheels needs to be negated dataFile.print(escFront.getFeedback_speedL_meas()); dataFile.print(","); //+ //Todo: check if speed for R wheels needs to be negated
dataFile.print(escFront.getFeedback_speedR_meas()); dataFile.print(";"); //- dataFile.print(escFront.getFeedback_speedR_meas()); dataFile.print(","); //-
dataFile.print(escRear.getFeedback_speedL_meas()); dataFile.print(";"); //+ dataFile.print(escRear.getFeedback_speedL_meas()); dataFile.print(","); //+
dataFile.print(escRear.getFeedback_speedR_meas()); dataFile.print(";"); //- dataFile.print(escRear.getFeedback_speedR_meas()); dataFile.print(","); //-
dataFile.print(escFront.getFeedback_boardTemp()); dataFile.print(";"); dataFile.print(escFront.getFeedback_boardTemp()); dataFile.print(",");
dataFile.print(escRear.getFeedback_boardTemp()); dataFile.print(";"); dataFile.print(escRear.getFeedback_boardTemp()); dataFile.print(",");
dataFile.print(escFront.getFeedback_batVoltage()); dataFile.print(";"); dataFile.print(escFront.getFeedback_batVoltage()); dataFile.print(",");
dataFile.print(escRear.getFeedback_batVoltage()); dataFile.print(";"); dataFile.print(escRear.getFeedback_batVoltage()); dataFile.print(",");
dataFile.print(filtered_currentAll,3); dataFile.print(";"); dataFile.print(filtered_currentAll,3); dataFile.print(",");
dataFile.print(throttle_pos); dataFile.print(";"); dataFile.print(throttle_pos); dataFile.print(",");
dataFile.print(brake_pos); dataFile.print(";"); dataFile.print(brake_pos); dataFile.print(",");
dataFile.print((escFront.getMeanSpeed()+escRear.getMeanSpeed())/2.0); dataFile.print(";"); dataFile.print((escFront.getMeanSpeed()+escRear.getMeanSpeed())/2.0); dataFile.print(",");
dataFile.print(escFront.getTrip()); dataFile.print(";"); dataFile.print(escFront.getTrip()); dataFile.print(",");
dataFile.print(escRear.getTrip()); dataFile.print(";"); dataFile.print(escRear.getTrip()); dataFile.print(",");
dataFile.print(escFront.getCurrentConsumed(),3); dataFile.print(";"); dataFile.print(escFront.getCurrentConsumed(),3); dataFile.print(",");
dataFile.print(escRear.getCurrentConsumed(),3); dataFile.print(";"); dataFile.print(escRear.getCurrentConsumed(),3); dataFile.print(",");
dataFile.print(temp_ESCFront,2); dataFile.print(";"); dataFile.print(temp_ESCFront,2); dataFile.print(",");
dataFile.print(temp_ESCRear,2); dataFile.print(";"); dataFile.print(temp_ESCRear,2); dataFile.print(",");
dataFile.print(temp_Air,2); dataFile.print(";"); dataFile.print(temp_Air,2); dataFile.print(",");
dataFile.print(looptime_duration,0); dataFile.print(",");
dataFile.println(""); dataFile.println("");
dataFile.close(); dataFile.close();
} }

View File

@ -312,6 +312,8 @@ void loop() {
} }
looptime_duration=max(looptime_duration,loopmillis-millis());
} }