fix wrong consumed current. increase current filter
This commit is contained in:
parent
c9c2cce97a
commit
fc8ce7d2f3
|
@ -151,8 +151,8 @@ SerialFeedback NewFeedbackFront;
|
||||||
SerialFeedback FeedbackRear;
|
SerialFeedback FeedbackRear;
|
||||||
SerialFeedback NewFeedbackRear;
|
SerialFeedback NewFeedbackRear;
|
||||||
|
|
||||||
#define CURRENT_FILTER_SIZE 40 //latency is about CURRENT_FILTER_SIZE/2*MEASURE_INTERVAL (measure interval is defined by hoverboard controller)
|
#define CURRENT_FILTER_SIZE 60 //latency is about CURRENT_FILTER_SIZE/2*MEASURE_INTERVAL (measure interval is defined by hoverboard controller)
|
||||||
#define CURRENT_MEANVALUECOUNT 10 //0<= meanvaluecount < CURRENT_FILTER_SIZE/2. how many values will be used from sorted weight array from the center region. abour double this values reading are used
|
#define CURRENT_MEANVALUECOUNT 20 //0<= meanvaluecount < CURRENT_FILTER_SIZE/2. how many values will be used from sorted weight array from the center region. abour double this values reading are used
|
||||||
typedef struct{
|
typedef struct{
|
||||||
int16_t curL_DC[CURRENT_FILTER_SIZE] = {0}; //current will be inverted for this so positive value means consumed current
|
int16_t curL_DC[CURRENT_FILTER_SIZE] = {0}; //current will be inverted for this so positive value means consumed current
|
||||||
int16_t curR_DC[CURRENT_FILTER_SIZE] = {0};
|
int16_t curR_DC[CURRENT_FILTER_SIZE] = {0};
|
||||||
|
@ -328,7 +328,7 @@ void loop() {
|
||||||
trip+=abs(meanSpeedms)* (SENDPERIOD/1000.0);
|
trip+=abs(meanSpeedms)* (SENDPERIOD/1000.0);
|
||||||
|
|
||||||
//mah consumed
|
//mah consumed
|
||||||
currentConsumed += filtered_currentAll* (SENDPERIOD/1000.0)/3600.0; //amp hours
|
currentConsumed += (motorparamsFront.filtered_curL+motorparamsFront.filtered_curR+motorparamsRear.filtered_curL+motorparamsRear.filtered_curR)* (SENDPERIOD/1000.0)/3600.0; //amp hours
|
||||||
}
|
}
|
||||||
|
|
||||||
//If needed write log to serial port
|
//If needed write log to serial port
|
||||||
|
@ -384,7 +384,7 @@ void writeLog(HardwareSerial &SerialRef, unsigned long time, MotorParameter &mpf
|
||||||
SerialRef.print(mprear.cmdL); SerialRef.print(",");
|
SerialRef.print(mprear.cmdL); SerialRef.print(",");
|
||||||
SerialRef.print(mprear.cmdR); SerialRef.print(",");
|
SerialRef.print(mprear.cmdR); SerialRef.print(",");
|
||||||
|
|
||||||
SerialRef.print(mpfront.filtered_curL,3); SerialRef.print(","); //invert. positive current is drive current
|
SerialRef.print(mpfront.filtered_curL,3); SerialRef.print(",");
|
||||||
SerialRef.print(mpfront.filtered_curR,3); SerialRef.print(",");
|
SerialRef.print(mpfront.filtered_curR,3); SerialRef.print(",");
|
||||||
SerialRef.print(mprear.filtered_curL,3); SerialRef.print(",");
|
SerialRef.print(mprear.filtered_curL,3); SerialRef.print(",");
|
||||||
SerialRef.print(mprear.filtered_curR,3); SerialRef.print(",");
|
SerialRef.print(mprear.filtered_curR,3); SerialRef.print(",");
|
||||||
|
@ -399,7 +399,7 @@ void writeLog(HardwareSerial &SerialRef, unsigned long time, MotorParameter &mpf
|
||||||
SerialRef.print(fbfront.batVoltage/100.0); SerialRef.print(","); //in V
|
SerialRef.print(fbfront.batVoltage/100.0); SerialRef.print(","); //in V
|
||||||
SerialRef.print(fbrear.batVoltage/100.0); SerialRef.print(","); //in V
|
SerialRef.print(fbrear.batVoltage/100.0); SerialRef.print(","); //in V
|
||||||
|
|
||||||
SerialRef.print(currentAll,3); SerialRef.print(","); //invert. positive current is drive current
|
SerialRef.print(currentAll,3); SerialRef.print(",");
|
||||||
SerialRef.print(throttle); SerialRef.print(",");
|
SerialRef.print(throttle); SerialRef.print(",");
|
||||||
SerialRef.print(brake); SerialRef.print(",");
|
SerialRef.print(brake); SerialRef.print(",");
|
||||||
SerialRef.print(meanSpeedms); SerialRef.print(","); // m/s
|
SerialRef.print(meanSpeedms); SerialRef.print(","); // m/s
|
||||||
|
|
Loading…
Reference in New Issue