HarzSR:
@zhomeslice - Found out the culprit. Sensor is dead. New sensor is working fine. I tried your code and found this result.I2C Scanner
Scanning...
I2C device found at address 0x68 !
doneWhen i tried running the MPU6050 general program or from I2C and got the results for YRP. I have also tried your new Code and got the results too. Am so much happy now. I have screen shots of both the programs.
First screen shot (Values.jpg) for the program that i initially had
Second screen shot (New values.jpg) for the program that you gave latest - MPU6050_Latest_CodeNext what should i do Sir zhomeslice. Please guide me from here. I would like to learn from you.
My Favorite part Getting the bot to ballance
For starters you will have a lot of testing and retesting to do. The bot you saw the YouTube Video I posted (How to Balance Robot PID totorial in under 2 minutes! ) that will get you a good start and possibly a bot that balances right away.
First lets calibrate our MPU6050
you will get 6 numbers
add them to the mpu6050 file
// supply your own gyro offsets here, scaled for min sensitivity use MPU6050_calibration.ino
// -4232 -706 1729 173 -94 37
// XA YA ZA XG YG ZG
int MPUOffsets[6] = { -4232, -706, 1729, 173, -94, 37};
Put then in the appropriate location in the BalancingBotBasic.ino file
You will need to modify the motor controls also
Modify These Function to work with your motor control
void FullBreaking () {
HBridgeLockA(false);
HBridgeLockB(false);
SetPWMA(255);
SetPWMB(255);
}
void SetPWMA(int Speed) {
analogWrite(PWM_A, Speed);
}
void SetPWMB(int Speed) {
analogWrite(PWM_B, Speed);
}
/* My HBridge configuration =
I have 2 1/2 H-Bridge chips per motor each chip has one High/Low side select input and an enable input.
The enable input of both 1/2 inputs are tied together and connected to pin 6 for Hbridge A and pin 3 for Hbridge B with PWM enabled
The following code focuses only on the High/Low side select
So by default when the enable input (PWM) is HIGH The Low side of my HBridge is on.
Now I can enable the High side by connecting 5v to the Select pin (HBgA1HighEn pin 8,HBgA2HighEn pin 7 & HBgB1HighEn pin 4,HBgB2HighEn pin 5).
so for costing all I need to do is set PWM low.
and for full breaking I need to set all High/Low selects to the Low side and enable the H-Bridge (analogWrite(PWM_A, 255);)
Forward motion I put one side high and the other low reverse that and the motor turns in reverse.
Simple :)
*/
void HBridgeLockA(bool HighSide) {
digitalWrite(HBgA1HighEn, HighSide);
digitalWrite(HBgA2HighEn, HighSide);
}
void HBridgeLockB(bool HighSide) {
digitalWrite(HBgB1HighEn, HighSide);
digitalWrite(HBgB2HighEn, HighSide);
}
void HBridgeGoA(bool Reverse) {
digitalWrite(HBgA1HighEn, Reverse);
digitalWrite(HBgA2HighEn, !Reverse);
}
void HBridgeGoB(bool Reverse) {
digitalWrite(HBgB1HighEn, Reverse);
digitalWrite(HBgB2HighEn, !Reverse);
}
BalancingBotBasic.ino (16.1 KB)
MPU6050_calibration.ino (7.64 KB)