change from current to watts display and add to logging
This commit is contained in:
parent
4b5797d2f4
commit
298532b3d3
|
@ -101,6 +101,8 @@ float filtered_currentAll=0;
|
||||||
//Statistics values
|
//Statistics values
|
||||||
float max_filtered_currentAll;
|
float max_filtered_currentAll;
|
||||||
float min_filtered_currentAll;
|
float min_filtered_currentAll;
|
||||||
|
float max_filtered_wattAll;
|
||||||
|
float min_filtered_wattAll;
|
||||||
float max_meanSpeed;
|
float max_meanSpeed;
|
||||||
|
|
||||||
float minSpeedms; //speed in m/s of slowest wheel
|
float minSpeedms; //speed in m/s of slowest wheel
|
||||||
|
@ -108,6 +110,9 @@ double overallTrip; //m. trip with read distance from sd card
|
||||||
double trip; //m. trip distance since boot
|
double trip; //m. trip distance since boot
|
||||||
double currentConsumed;
|
double currentConsumed;
|
||||||
double overallCurrentConsumed;
|
double overallCurrentConsumed;
|
||||||
|
|
||||||
|
double watthoursConsumed;
|
||||||
|
double overallWatthoursConsumed;
|
||||||
float lastTripVoltage=0;
|
float lastTripVoltage=0;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -126,13 +126,16 @@ void display_drivingDisplay(ESCSerialComm& escFront, ESCSerialComm& escRear) {
|
||||||
static float averaged_filtered_currentAll;
|
static float averaged_filtered_currentAll;
|
||||||
#define CURRENT_FILTER 0.8
|
#define CURRENT_FILTER 0.8
|
||||||
averaged_filtered_currentAll=averaged_filtered_currentAll*CURRENT_FILTER+(1-CURRENT_FILTER)*filtered_currentAll; //filter over time
|
averaged_filtered_currentAll=averaged_filtered_currentAll*CURRENT_FILTER+(1-CURRENT_FILTER)*filtered_currentAll; //filter over time
|
||||||
dtostrf(averaged_filtered_currentAll,1,2,buf);
|
float averaged_filtered_wattAll=averaged_filtered_currentAll*(escFront.getFeedback_batVoltage()+escRear.getFeedback_batVoltage())/2.0;
|
||||||
|
//dtostrf(averaged_filtered_currentAll,1,2,buf);
|
||||||
|
dtostrf(averaged_filtered_wattAll,1,0,buf);
|
||||||
strbuf=buf;
|
strbuf=buf;
|
||||||
if (strbuf.length()<5) { //pad spaces on the left
|
if (strbuf.length()<5) { //pad spaces on the left
|
||||||
strbuf=" "+strbuf;
|
strbuf=" "+strbuf;
|
||||||
}
|
}
|
||||||
display.print(strbuf);
|
display.print(strbuf);
|
||||||
display.print("A");
|
//display.print("A");
|
||||||
|
display.print("W");
|
||||||
|
|
||||||
|
|
||||||
//## Trip / Current Consumed Display
|
//## Trip / Current Consumed Display
|
||||||
|
@ -146,6 +149,7 @@ void display_drivingDisplay(ESCSerialComm& escFront, ESCSerialComm& escRear) {
|
||||||
display.print("km/h");
|
display.print("km/h");
|
||||||
}else{
|
}else{
|
||||||
//## Current Consumed
|
//## Current Consumed
|
||||||
|
/*
|
||||||
dtostrf(min_filtered_currentAll,1,1,buf);
|
dtostrf(min_filtered_currentAll,1,1,buf);
|
||||||
display.print("min:");
|
display.print("min:");
|
||||||
display.print((String)buf);
|
display.print((String)buf);
|
||||||
|
@ -154,6 +158,16 @@ void display_drivingDisplay(ESCSerialComm& escFront, ESCSerialComm& escRear) {
|
||||||
dtostrf(max_filtered_currentAll,1,1,buf);
|
dtostrf(max_filtered_currentAll,1,1,buf);
|
||||||
display.print((String)buf);
|
display.print((String)buf);
|
||||||
display.print("A");
|
display.print("A");
|
||||||
|
*/
|
||||||
|
//## Watt Hours Consumed
|
||||||
|
dtostrf(min_filtered_wattAll,1,0,buf);
|
||||||
|
display.print("min:");
|
||||||
|
display.print((String)buf);
|
||||||
|
display.print("W max:");
|
||||||
|
|
||||||
|
dtostrf(max_filtered_wattAll,1,0,buf);
|
||||||
|
display.print((String)buf);
|
||||||
|
display.print("W");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,11 +189,13 @@ void display_debugDisplay(ESCSerialComm& escFront, ESCSerialComm& escRear) {
|
||||||
|
|
||||||
void display_standingDisplay(ESCSerialComm& escFront, ESCSerialComm& escRear) {
|
void display_standingDisplay(ESCSerialComm& escFront, ESCSerialComm& escRear) {
|
||||||
double _displaytrip=trip;
|
double _displaytrip=trip;
|
||||||
double _displaycurrent=currentConsumed;
|
//double _displaycurrent=currentConsumed;
|
||||||
|
double _displaywatthours=watthoursConsumed;
|
||||||
bool _displayOverall= ((millis()/3000)%2==0);
|
bool _displayOverall= ((millis()/3000)%2==0);
|
||||||
if (_displayOverall) { //alternate between this trip and overall trip
|
if (_displayOverall) { //alternate between this trip and overall trip
|
||||||
_displaytrip=overallTrip;
|
_displaytrip=overallTrip;
|
||||||
_displaycurrent=overallCurrentConsumed;
|
//_displaycurrent=overallCurrentConsumed;
|
||||||
|
_displaywatthours=overallWatthoursConsumed;
|
||||||
}
|
}
|
||||||
|
|
||||||
char buf[8];
|
char buf[8];
|
||||||
|
@ -203,15 +219,19 @@ void display_standingDisplay(ESCSerialComm& escFront, ESCSerialComm& escRear) {
|
||||||
dtostrf(_displaytrip,1,0,buf);
|
dtostrf(_displaytrip,1,0,buf);
|
||||||
display.print((String)buf);
|
display.print((String)buf);
|
||||||
display.print(" m ");
|
display.print(" m ");
|
||||||
dtostrf(_displaycurrent,1,2,buf);
|
//dtostrf(_displaycurrent,1,2,buf);
|
||||||
|
dtostrf(_displaywatthours,1,2,buf);
|
||||||
display.print((String)buf);
|
display.print((String)buf);
|
||||||
display.print(" Ah");
|
//display.print(" Ah");
|
||||||
|
display.print(" Wh");
|
||||||
display.println();
|
display.println();
|
||||||
|
|
||||||
display.print(F("Eff: "));
|
display.print(F("Eff: "));
|
||||||
dtostrf( _displaytrip/1000/_displaycurrent ,1,2,buf);
|
//dtostrf( _displaytrip/1000/_displaycurrent ,1,2,buf);
|
||||||
|
dtostrf( _displaytrip/1000/_displaywatthours ,1,2,buf);
|
||||||
display.print((String)buf);
|
display.print((String)buf);
|
||||||
display.print(" km/Ah");
|
//display.print(" km/Ah");
|
||||||
|
display.print(" km/Wh");
|
||||||
|
|
||||||
if (_displayOverall){
|
if (_displayOverall){
|
||||||
display.print(" sum");
|
display.print(" sum");
|
||||||
|
|
|
@ -26,7 +26,7 @@ bool initLogging() {
|
||||||
return false;
|
return false;
|
||||||
}else{
|
}else{
|
||||||
Serial.println("Card initialized.");
|
Serial.println("Card initialized.");
|
||||||
display.println(F("LOG=")); display.display();
|
display.print(F("LOG=")); display.display();
|
||||||
if (datalogging){
|
if (datalogging){
|
||||||
int filenumber=0;
|
int filenumber=0;
|
||||||
char buffer[6];
|
char buffer[6];
|
||||||
|
@ -40,7 +40,7 @@ bool initLogging() {
|
||||||
|
|
||||||
}
|
}
|
||||||
Serial.print(datalogging_filename); Serial.println(" is free");
|
Serial.print(datalogging_filename); Serial.println(" is free");
|
||||||
display.print(datalogging_filename); display.display();
|
display.print(datalogging_filename); display.println(); display.display();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -65,7 +65,7 @@ void loggingLoop(unsigned long loopmillis,ESCSerialComm& escFront, ESCSerialComm
|
||||||
dataFile.print("current_FrontL,current_FrontR,current_RearL,current_RearR,");
|
dataFile.print("current_FrontL,current_FrontR,current_RearL,current_RearR,");
|
||||||
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,trip,currentConsumed_Front,currentConsumed_Rear,currentConsumed,");
|
dataFile.print("currentAll,throttle,brake,speed,trip_Front,trip_Rear,trip,currentConsumed_Front,currentConsumed_Rear,currentConsumed,watthoursConsumed,");
|
||||||
dataFile.println("temp_ESCFront,temp_ESCRear,temp_Air,looptime_duration");
|
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;
|
||||||
|
@ -97,10 +97,11 @@ void loggingLoop(unsigned long loopmillis,ESCSerialComm& escFront, ESCSerialComm
|
||||||
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(currentConsumed,3); dataFile.print(",");
|
dataFile.print(currentConsumed,3); dataFile.print(",");
|
||||||
|
dataFile.print(watthoursConsumed,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); dataFile.print(",");
|
dataFile.print(looptime_duration); //dataFile.print(",");
|
||||||
looptime_duration=0; //reset
|
looptime_duration=0; //reset
|
||||||
|
|
||||||
dataFile.println("");
|
dataFile.println("");
|
||||||
|
@ -159,8 +160,9 @@ bool loadTripSD()
|
||||||
overallTrip=(line.substring(4)).toFloat();
|
overallTrip=(line.substring(4)).toFloat();
|
||||||
}else if (line.substring(0,4)=="occ="){
|
}else if (line.substring(0,4)=="occ="){
|
||||||
overallCurrentConsumed=(line.substring(4)).toFloat();
|
overallCurrentConsumed=(line.substring(4)).toFloat();
|
||||||
}
|
}else if (line.substring(0,4)=="owh="){
|
||||||
else if (line.substring(0,4)=="vlt="){
|
overallWatthoursConsumed=(line.substring(4)).toFloat();
|
||||||
|
}else if (line.substring(0,4)=="vlt="){
|
||||||
lastTripVoltage=(line.substring(4)).toFloat();
|
lastTripVoltage=(line.substring(4)).toFloat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,6 +171,8 @@ bool loadTripSD()
|
||||||
display.print(F("TripSD=")); display.println(overallTrip);
|
display.print(F("TripSD=")); display.println(overallTrip);
|
||||||
Serial.print("TripSD current:");
|
Serial.print("TripSD current:");
|
||||||
Serial.println(overallCurrentConsumed);
|
Serial.println(overallCurrentConsumed);
|
||||||
|
Serial.print("TripSD watthours:");
|
||||||
|
Serial.println(overallWatthoursConsumed);
|
||||||
display.print(F("Cur. SD=")); display.println(overallCurrentConsumed); display.display();
|
display.print(F("Cur. SD=")); display.println(overallCurrentConsumed); display.display();
|
||||||
Serial.print("TripSD voltage:");
|
Serial.print("TripSD voltage:");
|
||||||
Serial.println(lastTripVoltage);
|
Serial.println(lastTripVoltage);
|
||||||
|
@ -191,6 +195,8 @@ void writeTrip(unsigned long loopmillis,ESCSerialComm& escFront, ESCSerialComm&
|
||||||
myFile.println(overallTrip);
|
myFile.println(overallTrip);
|
||||||
myFile.print("occ=");
|
myFile.print("occ=");
|
||||||
myFile.println(overallCurrentConsumed);
|
myFile.println(overallCurrentConsumed);
|
||||||
|
myFile.print("owh=");
|
||||||
|
myFile.println(overallWatthoursConsumed);
|
||||||
myFile.print("vlt=");
|
myFile.print("vlt=");
|
||||||
float _voltage=(escFront.getFeedback_batVoltage()+escRear.getFeedback_batVoltage())/2.0;
|
float _voltage=(escFront.getFeedback_batVoltage()+escRear.getFeedback_batVoltage())/2.0;
|
||||||
myFile.println(_voltage,2);
|
myFile.println(_voltage,2);
|
||||||
|
@ -207,6 +213,8 @@ void resetTrip() {
|
||||||
myFile.println(0);
|
myFile.println(0);
|
||||||
myFile.print("occ=");
|
myFile.print("occ=");
|
||||||
myFile.println(0);
|
myFile.println(0);
|
||||||
|
myFile.print("owh=");
|
||||||
|
myFile.println(0);
|
||||||
myFile.print("vlt=");
|
myFile.print("vlt=");
|
||||||
myFile.println(0);
|
myFile.println(0);
|
||||||
myFile.flush();
|
myFile.flush();
|
||||||
|
|
|
@ -260,10 +260,14 @@ void loop() {
|
||||||
|
|
||||||
max_filtered_currentAll=max(max_filtered_currentAll,filtered_currentAll);
|
max_filtered_currentAll=max(max_filtered_currentAll,filtered_currentAll);
|
||||||
min_filtered_currentAll=min(min_filtered_currentAll,filtered_currentAll);
|
min_filtered_currentAll=min(min_filtered_currentAll,filtered_currentAll);
|
||||||
|
max_filtered_wattAll=max(max_filtered_wattAll,filtered_currentAll*(escFront.getFeedback_batVoltage()+escRear.getFeedback_batVoltage())/2.0);
|
||||||
|
min_filtered_wattAll=min(min_filtered_wattAll,filtered_currentAll*(escFront.getFeedback_batVoltage()+escRear.getFeedback_batVoltage())/2.0);
|
||||||
max_meanSpeed=max(max_meanSpeed,(escFront.getMeanSpeed()+escRear.getMeanSpeed())/2);
|
max_meanSpeed=max(max_meanSpeed,(escFront.getMeanSpeed()+escRear.getMeanSpeed())/2);
|
||||||
if (!armed) { //reset statistics if disarmed
|
if (!armed) { //reset statistics if disarmed
|
||||||
max_filtered_currentAll=0;
|
max_filtered_currentAll=0;
|
||||||
min_filtered_currentAll=0;
|
min_filtered_currentAll=0;
|
||||||
|
max_filtered_wattAll=0;
|
||||||
|
min_filtered_wattAll=0;
|
||||||
max_meanSpeed=0;
|
max_meanSpeed=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -281,9 +285,13 @@ void loop() {
|
||||||
overallTrip+=_tripincrease;
|
overallTrip+=_tripincrease;
|
||||||
|
|
||||||
float _currentIncrease=(escFront.getFiltered_curL()+escFront.getFiltered_curR()+escRear.getFiltered_curL()+escRear.getFiltered_curR())* ((loopmillis-last_statsupdate)/1000.0)/3600.0; //amp hours
|
float _currentIncrease=(escFront.getFiltered_curL()+escFront.getFiltered_curR()+escRear.getFiltered_curL()+escRear.getFiltered_curR())* ((loopmillis-last_statsupdate)/1000.0)/3600.0; //amp hours
|
||||||
|
float _watthoursIncrease=((escFront.getFiltered_curL()+escFront.getFiltered_curR())*escFront.getFeedback_batVoltage()+(escRear.getFiltered_curL()+escRear.getFiltered_curR())*escRear.getFeedback_batVoltage())* ((loopmillis-last_statsupdate)/1000.0)/3600.0; //amp hours
|
||||||
currentConsumed += _currentIncrease;
|
currentConsumed += _currentIncrease;
|
||||||
overallCurrentConsumed += _currentIncrease;
|
overallCurrentConsumed += _currentIncrease;
|
||||||
|
|
||||||
|
watthoursConsumed += _watthoursIncrease;
|
||||||
|
overallWatthoursConsumed += _watthoursIncrease;
|
||||||
|
|
||||||
last_statsupdate=loopmillis;
|
last_statsupdate=loopmillis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,7 +363,7 @@ void loop() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
looptime_duration=max(looptime_duration,loopmillis-millis());
|
looptime_duration=max(looptime_duration,millis()-loopmillis);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue