Go Down

Topic: self balancing robot - schematic (Read 831 times) previous topic - next topic


Jan 14, 2015, 07:36 am Last Edit: Jan 14, 2015, 07:50 am by sudheesh19
hi friends,
i am working on a project - self balancing robot using mpu 6050. details i gathered from http://www.instructables.com/id/2-Wheel-Self-Balancing-Robot-by-using-Arduino-and-/
having sorce code also. from that code i got some idea for wiring the robo. but still missing few connections.
few lines i mentioned in red - here i have some doubts in connection.
can anyone help me with the schematic?
main source code:

         #include <Wire.h>
         #include "I2Cdev.h"
         #include "MPU6050_6Axis_MotionApps20.h"
         #define LED 13
         #define PWM_L 10
         #define PWM_R 11
         #define DIR_L1 6
         #define DIR_L2 12
         #define DIR_R1 8
         #define DIR_R2 9
         #define SPD_INT_L 3//1
          #define SPD_PUL_L 4

         #define SPD_INT_R 7
         #define SPD_PUL_R 5
         #define MPU_INT 2//0
         #define K_AGL_AD A0
          #define K_AGL_DOT_AD A1
          #define K_POS_AD A2
          #define K_POS_DOT_AD A3

         MPU6050 mpu;            // AD0 low = 0x68
         // MPU control/status vars
         bool dmpReady = false;  // set true if DMP init was successful
         uint8_t mpuIntStatus;   // holds actual interrupt status byte from MPU
         uint8_t devStatus;      // return status after each device operation (0 = success, !0 = error)
         uint16_t packetSize;    // expected DMP packet size (default is 42 bytes)
         uint16_t fifoCount;     // count of all bytes currently in FIFO
         uint8_t fifoBuffer[64]; // FIFO storage buffer
         // orientation/motion vars
         Quaternion q;           // [w, x, y, z]         quaternion container
         VectorFloat gravity;    // [x, y, z]            gravity vector
         int16_t gyro[3];        // [x, y, z]            gyro vector
         float ypr[3];           // [yaw, pitch, roll]   yaw/pitch/roll container and gravity vector
         double K_angle,K_angle_dot,K_position,K_position_dot;
         double K_angle_AD,K_angle_dot_AD,K_position_AD,K_position_dot_AD;
         double position_add,position_dot;
         double position_dot_filter;
         int speed_real_l,speed_real_r;
         int pwm,pwm_l,pwm_r;
         int Turn_Need,Speed_Need;
         float angle, angular_rate;
         bool blinkState = false;
         int rx_count=0;
         byte buf_tmp=0;
         uint8_t i2cData[14]; // Buffer for I2C data
         volatile bool mpuInterrupt = false;     // indicates whether MPU interrupt pin has gone high
         void dmpDataReady()
           mpuInterrupt = true;
         void setup()
           Wire.begin();// join I2C bus (I2Cdev library doesn't do this automatically)
           TWBR = 24; // 400kHz I2C clock (200kHz if CPU is 8MHz)
         //  Serial.begin(9600);
           // initialize device
           Serial.println(F("Initializing I2C devices..."));
           // verify connection
           Serial.println(F("Testing device connections..."));
           Serial.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed"));
 code goes like this..
pls refer http://www.instructables.com/id/2-Wheel-Self-Balancing-Robot-by-using-Arduino-and-/

thanks in advance...


Hi sudheesh19, I'm currently using the same code to get my own Self Balancing Robot working.

The SPD_PUL_L 4 and SPD_PUL_R 5 are encoder connections.
The SPD_INT_L 3 and SPD_INT_R 7 are the AttachInterrupt functions, related to encoder reading. 
The   K_AGL_AD A0, K_AGL_DOT_AD A1, K_POS_AD A2 and K_POS_DOT_AD A3, are from the PID_PWM tunning, you can use a potentiometer to calibrate them.

The only part that I've not been able to understand is this:
K_angle = 34 * 25.6;
K_angle_dot = 2 * 25.6;
K_position = 0.8 * 0.209;
K_position_dot = 1.09 * 20.9;

I've looked everywhere trying to find a reason for those numbers, specially the 34, 2, 0.8 and the 1.09, but I've failed miserably.

If you have info regarding that part, please, let me know.


Hi Mr. JoshepKerr. i am making the same balance car. But it doesn't work. Can you give me the schematic of your project. I will really appreciate. My gmail: dolongbkdn1411@gmail.com.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131