File tree 4 files changed +10
-11
lines changed
RoboHeartBalanceBotContol 4 files changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -209,9 +209,8 @@ bool RoboHeart::isCalibrated(int timeout_ms) {
209
209
}
210
210
delay (1 );
211
211
}
212
-
213
212
Serial.println (counter);
214
- return (counter < (timeout_ms / 4 ));
213
+ return (counter < (timeout_ms / 3 ));
215
214
}
216
215
217
216
float RoboHeart::getRotationX (){
Original file line number Diff line number Diff line change 18
18
#include " RoboHeartStepperMotor.h"
19
19
#include " pins_RoboHeart.h"
20
20
#include < math.h>
21
- #define TRESHOLD 0.2 // treshold in degrees/s
21
+ #define TRESHOLD 0.3 // treshold in degrees/s
22
22
23
23
#define MOTOR_A_CHANNEL1 0
24
24
#define MOTOR_A_CHANNEL2 1
@@ -74,8 +74,8 @@ class RoboHeart {
74
74
RoboHeartDRV8836* _turnMotor = NULL ;
75
75
RoboHeartDRV8836* _directionMotor = NULL ;
76
76
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 );
79
79
80
80
};
81
81
Original file line number Diff line number Diff line change @@ -71,8 +71,7 @@ void tick() {
71
71
// and later used to indicate stable vertical position
72
72
// of the Balancing Bot.
73
73
void processPinInterrupt () {
74
- offsetAngleDeg = processAngle (heart.getRotationX ());
75
- targetAngleDeg = offsetAngleDeg;
74
+ heart.resetGyro ();
76
75
errorSum = 0 ;
77
76
}
78
77
Original file line number Diff line number Diff line change @@ -173,8 +173,9 @@ void bleConnected() {
173
173
174
174
// handle -180 after crossing 180 Degrees
175
175
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 ;
178
179
}
179
180
return angle;
180
181
}
@@ -192,8 +193,8 @@ void tick() {
192
193
// and later used to indicate stable vertical position
193
194
// of the Balancing Bot.
194
195
void processPinInterrupt () {
195
- offsetAngleDeg = heart.getRotationX ();
196
- targetAngleDeg = offsetAngleDeg ;
196
+ heart.resetGyro ();
197
+ errorSum = 0 ;
197
198
}
198
199
199
200
InterfaceBLE ble = InterfaceBLE();
You can’t perform that action at this time.
0 commit comments