Skip to content

Commit

Permalink
change battery handling when mower is in station and beginn the charg…
Browse files Browse the repository at this point in the history
…e sequenze
  • Loading branch information
netlars committed Aug 17, 2021
1 parent 8636e84 commit 77658f8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions code/ardumower/robot.cpp
Expand Up @@ -612,7 +612,7 @@ void Robot::readSensors(){

if (millis() >= nextTimeBattery){
// read battery
nextTimeBattery = millis() + 100;
nextTimeBattery = millis() + 500;
if ((abs(chgCurrent) > 0.04) && (chgVoltage > 5)){
// charging
batCapacity += (chgCurrent / 36.0);
Expand All @@ -633,9 +633,9 @@ void Robot::readSensors(){
#endif // **UZ**

// low-pass filter
double accel = 0.01;
double accel = 0.05;
//double accel = 1.0;
if (abs(batVoltage-batvolt)>5) batVoltage = batvolt; else batVoltage = (1.0-accel) * batVoltage + accel * batvolt;
if (abs(batVoltage-batvolt)>8) batVoltage = batvolt; else batVoltage = (1.0-accel) * batVoltage + accel * batvolt;
if (abs(chgVoltage-chgvolt)>5) chgVoltage = chgvolt; else chgVoltage = (1.0-accel) * chgVoltage + accel * chgvolt;
if (abs(chgCurrent-curramp)>0.5) chgCurrent = curramp; else chgCurrent = (1.0-accel) * chgCurrent + accel * curramp;
}
Expand Down Expand Up @@ -1324,6 +1324,7 @@ void Robot::setNextState(byte stateNew, byte dir){
//motorMowModulate = false;
}
if (stateNew == STATE_STATION){
nextTimeBattery = millis(); //read immediatly the battery
setMotorPWM(0,0,false);
setActuator(ACT_CHGRELAY, 0);
setDefaults();
Expand Down

0 comments on commit 77658f8

Please sign in to comment.