Skip to content

Commit e455a06

Browse files
Balance bot
Calibration Balance bot example
1 parent 5c8a44a commit e455a06

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

RoboHeart.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,8 @@ bool RoboHeart::isCalibrated(int timeout_ms) {
209209
}
210210
delay(1);
211211
}
212-
213212
Serial.println(counter);
214-
return (counter < (timeout_ms / 4));
213+
return (counter < (timeout_ms / 3));
215214
}
216215

217216
float RoboHeart::getRotationX(){

RoboHeart.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "RoboHeartStepperMotor.h"
1919
#include "pins_RoboHeart.h"
2020
#include <math.h>
21-
#define TRESHOLD 0.2 //treshold in degrees/s
21+
#define TRESHOLD 0.3 //treshold in degrees/s
2222

2323
#define MOTOR_A_CHANNEL1 0
2424
#define MOTOR_A_CHANNEL2 1
@@ -74,8 +74,8 @@ class RoboHeart {
7474
RoboHeartDRV8836* _turnMotor = NULL;
7575
RoboHeartDRV8836* _directionMotor = NULL;
7676

77-
void calculateDiff(int timeout_ms = 500);
78-
bool isCalibrated(int timeout_ms = 500);
77+
void calculateDiff(int timeout_ms = 250);
78+
bool isCalibrated(int timeout_ms = 250);
7979

8080
};
8181

examples/RoboHeartBalanceBot/RoboHeartBalanceBot.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ void tick() {
7171
// and later used to indicate stable vertical position
7272
// of the Balancing Bot.
7373
void processPinInterrupt() {
74-
offsetAngleDeg = processAngle(heart.getRotationX());
75-
targetAngleDeg = offsetAngleDeg;
74+
heart.resetGyro();
7675
errorSum = 0;
7776
}
7877

examples/RoboHeartBalanceBotContol/RoboHeartBalanceBotContol.ino

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,9 @@ void bleConnected() {
173173

174174
// handle -180 after crossing 180 Degrees
175175
float processAngle(float angle) {
176-
if (angle < -90) {
177-
return angle = 360 + angle;
176+
// handle -180 after crossing 180
177+
if (angle > 180) {
178+
return angle - 360;
178179
}
179180
return angle;
180181
}
@@ -192,8 +193,8 @@ void tick() {
192193
// and later used to indicate stable vertical position
193194
// of the Balancing Bot.
194195
void processPinInterrupt() {
195-
offsetAngleDeg = heart.getRotationX();
196-
targetAngleDeg = offsetAngleDeg;
196+
heart.resetGyro();
197+
errorSum = 0;
197198
}
198199

199200
InterfaceBLE ble = InterfaceBLE();

0 commit comments

Comments
 (0)