modify trip measurement

This commit is contained in:
interfisch 2023-06-18 02:09:41 +02:00
parent 8d180debf7
commit 150ce61f9f
2 changed files with 16 additions and 3 deletions

View File

@ -37,14 +37,13 @@ bool ESCSerialComm::update(unsigned long loopmillis) //returns true if something
#define TRIP_UPDATE_INTERVAL 100
if ( loopmillis > last_update_trip+TRIP_UPDATE_INTERVAL) {
unsigned long trip_update_interval_real=loopmillis-last_update_trip;
last_update_trip=loopmillis;
last_update_trip=loopmillis;
//double _meanRPM=(-Feedback.speedL_meas+Feedback.speedR_meas)/2.0;
double _meanRPM=(getFeedback_speedL_meas()+getFeedback_speedR_meas())/2.0;
meanSpeedms=_meanRPM*wheelcircumference/60.0; // Units: 1/min * m / 60s
trip+=abs(meanSpeedms)* ((trip_update_interval_real)/1000.0);
trip+=abs(meanSpeedms)* ((trip_update_interval_real)/1000.0);
//mah consumed
currentConsumed += (Motorparams.filtered_curL+Motorparams.filtered_curR)* (trip_update_interval_real/1000.0)/3600.0; //amp hours
}
@ -309,4 +308,11 @@ unsigned long ESCSerialComm::getFeedbackInterval() {
bool ESCSerialComm::getControllerConnected() {
return controller_connected;
}
float ESCSerialComm::getWheelspeed_L() {
return getFeedback_speedL_meas()*wheelcircumference/60.0; // Units: 1/min * m / 60s
}
float ESCSerialComm::getWheelspeed_R() {
return getFeedback_speedR_meas()*wheelcircumference/60.0; // Units: 1/min * m / 60s
}

View File

@ -109,6 +109,11 @@ class ESCSerialComm
void resetStatistics();
float getWheelspeed_L();
float getWheelspeed_R();
private:
long _millis_lastinput; //declare private variable
@ -161,6 +166,8 @@ class ESCSerialComm
float filterMedian(int16_t* values);
};
#endif