From 7bd5f48f271e015f4e9a379e0f1cc332d22a80e1 Mon Sep 17 00:00:00 2001 From: Ola Palm Date: Sun, 25 Jun 2017 11:17:43 +0200 Subject: [PATCH] Fix for single coil setup for mower. --- Liam/BWFSensor.cpp | 2 +- Liam/Battery.cpp | 4 ++-- Liam/Battery.h | 8 ++++---- Liam/Controller.cpp | 20 +++++++++----------- Liam/Definition.h | 4 ++-- Liam/Liam.ino | 2 +- 6 files changed, 19 insertions(+), 21 deletions(-) diff --git a/Liam/BWFSensor.cpp b/Liam/BWFSensor.cpp index 88ad801..e6269f0 100644 --- a/Liam/BWFSensor.cpp +++ b/Liam/BWFSensor.cpp @@ -42,7 +42,7 @@ void BWFSENSOR::clearSignal() { bool BWFSENSOR::isInside() { - return (signal_status == INSIDE); + return (signal_status == INSIDE); } bool BWFSENSOR::isOutside() { diff --git a/Liam/Battery.cpp b/Liam/Battery.cpp index 3dd628c..d13f851 100644 --- a/Liam/Battery.cpp +++ b/Liam/Battery.cpp @@ -89,8 +89,8 @@ word BATTERY::readBatteryAndCalcValue(){ unsigned long newReading = analogRead(batSocpin); newReading = newReading * 488 * VOLTDIVATOR; newReading /= 10000; - return newReading; - //return word(newReading); + //return newReading; + return word(newReading); } bool BATTERY::isBeingCharged() { diff --git a/Liam/Battery.h b/Liam/Battery.h index 7ae4328..5fe8800 100644 --- a/Liam/Battery.h +++ b/Liam/Battery.h @@ -26,10 +26,10 @@ Placed under the GNU license #define LIION 2 //All voltage value need to be x100 to avoid decimals (12.54V = 1254) -#define LIIONFULL 1300 -#define LIIONEMPTY 1040 -#define NIMHFULL 1450 -#define NIMHEMPTY 1150 +#define LIIONFULL 1256 +#define LIIONEMPTY 1040 +#define NIMHFULL 1450 +#define NIMHEMPTY 1150 #define LEADACIDFULL 1330 #define LEADACIDEMPTY 1200 diff --git a/Liam/Controller.cpp b/Liam/Controller.cpp index e6ceadb..e06a299 100644 --- a/Liam/Controller.cpp +++ b/Liam/Controller.cpp @@ -65,9 +65,15 @@ int CONTROLLER::turnToReleaseRight(int angle) { sensor->select(0); if (sensor->isInside()) { - sensor->select(1); - if (sensor->isInside()) - return 0; // OK + // Only check sensor one if more than 1 sensor defined. + if(NUMBER_OF_SENSORS>1) + { + sensor->select(1); + if (sensor->isInside()) + return 0; // OK + } + else + return 0; // OK } if (wheelsAreOverloaded()) @@ -292,18 +298,10 @@ boolean CONTROLLER::hasBumped() { } boolean CONTROLLER::hasTilted() { - Serial.println(""); - Serial.println("NU är tiltvärdet :"); - Serial.println(compass->getTiltAngle(), DEC); - Serial.println(compass->getTiltAngle() > TILTANGLE); return (compass->getTiltAngle() > TILTANGLE); } boolean CONTROLLER::hasFlipped() { - Serial.println(""); - Serial.println("NU är Flippvärdet :"); - Serial.println(compass->getTiltAngle(), DEC); - Serial.println(compass->getTiltAngle() > FLIPANGLE); return (compass->getTiltAngle() > FLIPANGLE); } diff --git a/Liam/Definition.h b/Liam/Definition.h index dce24b2..0307178 100644 --- a/Liam/Definition.h +++ b/Liam/Definition.h @@ -65,10 +65,10 @@ const int MY_CUTTERMOTOR = 1; const int MY_BATTERY = 2; /* Number of BWF sensors can be 1-4 depending on shield */ -const int NUMBER_OF_SENSORS = 2; +const int NUMBER_OF_SENSORS = 1; /* BWF transmitter signals */ -#define INSIDE_BWF 85 +#define INSIDE_BWF 86 #define OUTSIDE_BWF 5 /* If you have a bumper connected to pin8, set it to true. Remember to cut the brake connection on your motor shield */ diff --git a/Liam/Liam.ino b/Liam/Liam.ino index 3b1df96..bd5a0e7 100644 --- a/Liam/Liam.ino +++ b/Liam/Liam.ino @@ -269,7 +269,7 @@ void loop() { state = DOCKING; break; } - + // Tries to turn, but if timeout then reverse and try again if ((err = Mower.turnToReleaseRight(30) > 0)) { Mower.runBackward(FULLSPEED);