author
2Instructables291,667Views75CommentsJoined October 23rd, 2012

Tell us about yourself!

Complete Your Profile

Achievements

10K+ Views Earned a bronze medal
Robotics Contest 2017
Contest Winner Runner Up in the Robotics Contest 2017
Show 1 More »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot3 days ago
    Arduino Self-Balancing Robot

    These lines of code initialize Timer1 so that an Interrupt Serice Routine is called every 5milliseconds. Inside the ISR, the angle of inclination and PID values are computed.

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot6 weeks ago
    Arduino Self-Balancing Robot

    I suppose EA and EB are ENABLE pins which must be connected to 5V supply for the motor driver to work. You can use IN1 & IN2 for one motor and IN3 & IN4 for the other. That should work.

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot7 weeks ago
    Arduino Self-Balancing Robot

    Thank you. The two additional pins are power supply pins to the motor driver. Make sure the AIN2 & BIN2 pins of motor driver are connected to PWM pins of arduino uno. You can also check by using the setMotors() routine alone without the balancing code.

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot3 months ago
    Arduino Self-Balancing Robot

    You can use L293D without any change in the code. Please refer step 2 for connections.

    Reading MPU values and calling setMotors() is done outside the ISR because these operations involve timers and I don't want them to mess with the ISR (I'm not sure if it does).The target angle is to compensate for a bad tilt and was arrived at after some trials.If you find it difficult to balance, try mapping the motorPower to 80 to 255 range.

    Glad to know that you love my project.If you have made any changes, it would be better to first ensure that you are reading the angle of inclination correctly. Please see Step 4 and observe your serial monitor. Tilt your robot in both direction and check whether the angle of inclination is corrrect.

    SDA and SCL pins of MPU6050 are respectively connected to A4 and A5 pins of Arduino Pro Mini. Please refer Step 2 for connection diagram.

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot4 months ago
    Arduino Self-Balancing Robot

    Glad to know that you love this project.I suppose you want the same response from the filter but with a different sampling time. i.e., 8ms. To obtain the same filter response, you need to keep the filter time constant same. From Step5, you can calculate the values of filter coefficients for a time constant of 0.008s. The values are 0.9894 and 0.0106

    init_PID() is a basic timer initialize and start function. The timer registers are set so that an Interrupt Service Routine (ISR) is called precisely every 5 milliseconds. Angle and PID calculation is done inside this ISR.

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot5 months ago
    Arduino Self-Balancing Robot

    Thank you.The line of code converts 16-bit gyro reading to deg/sec. -250 to 250 is the default gyro setting in deg/sec.

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot6 months ago
    Arduino Self-Balancing Robot

    You could use this motor also. I chose the N20 to keep the robot compact. You can buy them for cheap from aliexpress.

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot6 months ago
    Arduino Self-Balancing Robot

    The errorSum is constrained to get over the integral windup problem that is common in PID controllers. The limits are a rough approximate arrived at by visualizing the errorSum values over arduino serial monitor.

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot6 months ago
    Arduino Self-Balancing Robot

    Thank you Jim. Glad to see your robot. Thanks for your comments.

    Very glad to know. Thank you.

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot7 months ago
    Arduino Self-Balancing Robot

    The ultrasound sensor detects any obstacle infront of the robot and commands to steer the robot away from it if the distance to the obstacle is less than 20cm. Please see step 8.

    Yes. You can use them. Just make sure you map the pins correctly so that you need not make any change in the program.

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot7 months ago
    Arduino Self-Balancing Robot

    Hello,Sorry for my late reply. A measure of the elaspsed time is required for calculating gyro angle and integral and derivative terms of PID. Defining a fixed sampleTime and measuring angle and executing PID in intervals of this sampleTime makes the calculation easier. In our program, this is done in the Interrupt Service Routine which is called every 5milliseconds. Reducing the sampleTime would execute PID more frequently. This however also affects the filter time constant which inturn affects the performance of the robot (see Step 5). Hope this clears your doubt. Do share a picture of your robot when its finished.

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot8 months ago
    Arduino Self-Balancing Robot

    Very glad to see your robot and also to hear you like my instructable. Thanks for your comments.

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot8 months ago
    Arduino Self-Balancing Robot

    First of all, you need to make sure that the connections between arduino and the motor driver are correct. For this, use setMotors() to check direction and speed.

    The PWM value given to the motor is calculated from the PID loop. The PID constants are so chosen that the PWM value lies within -255 and +255. constrain() is used to ensure that the PWM values never cross the -255 to +255 limit.

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot9 months ago
    Arduino Self-Balancing Robot

    Thanks for your input :)I suppose in your code, errorSum is not the sum of errors but it stores the value of error for using in next loop. So, errorD is error-errorSum which is same as currAngle-prevAngle. Hence Kd term is same in both cases. So is Kp. Regarding KI, you add (Ki*errorSum*sampleTime) whereas I have added error to get errorSum and then later multiplied with Ki and sampleTime. The only difference I could find is in the PID constants and the way we add each term to obtain motorPower. Isn't that right?

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot10 months ago
    Arduino Self-Balancing Robot

    I'm sorry I haven't interfaced a Bluetooth module yet. I thought I would keep my robot simple and concentrate just on the balancing part.

    Congrats! Please do share a video as well.

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot10 months ago
    Arduino Self-Balancing Robot

    Hello,1. The battery I am using is a Panasonic NCR18650b rated for 3400mah. This will be at 4.2V when fully charged. This is then boosted to a steady 5V level. The motors that I am using is rated for 6V, 200rpm. Make sure you are using a motor rated for 6V. And also make sure you are using an original 18650 battery. There are many fake ones in the market.2. You can use any other motor driver or boost converter as well. As long as they can carry the rated current of the motor, they do not affect the operation of the robot.3. A boost converter ensures that a steady 5V power supply reaches the arduino and the motor. If we do not use a boost converter, as we run the robot, the battery voltage reduces gradually from 4.2V. As the voltage reduces, the motor will get slowed down and the arduino...

    see more »

    Hello,1. The battery I am using is a Panasonic NCR18650b rated for 3400mah. This will be at 4.2V when fully charged. This is then boosted to a steady 5V level. The motors that I am using is rated for 6V, 200rpm. Make sure you are using a motor rated for 6V. And also make sure you are using an original 18650 battery. There are many fake ones in the market.2. You can use any other motor driver or boost converter as well. As long as they can carry the rated current of the motor, they do not affect the operation of the robot.3. A boost converter ensures that a steady 5V power supply reaches the arduino and the motor. If we do not use a boost converter, as we run the robot, the battery voltage reduces gradually from 4.2V. As the voltage reduces, the motor will get slowed down and the arduino and the sensors may stop working.

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot1 year ago
    Arduino Self-Balancing Robot

    I was unsure whether the INT pin of MPU6050 is to be connected or not. After a bit of searching, it seems that the interrupt pin is required only if you are reading DMP values from MPU6050. So I think, the code should work well in our case even with the INT pin left unconnected.

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot1 year ago
    Arduino Self-Balancing Robot

    You are most welcome :)Changing the wheel size is a good option. But I think a larger wheel will give better results as the contact area with the ground will be more.You will have to understand how speed and direction control is achieved using a PWM and a digital pin. Consider just one motor. To drive it forward, we set the digital pin LOW and PWM pin at a desired value ranging from 0 to 255. To drive it reverse, let's say at -100, we first set the digital pin HIGH and set PWM pin at (-100 + 255), i.e, at 155. Remember the digital pin is set HIGH which corresponds to 255. Hence the effective value is 255-155, i.e., 100 at digital pin and 0 at PWM pin. This would drive the motor reverse at a PWM value of 100. Hope it's clear for you now.The targetAngle is an important parameter which I f...

    see more »

    You are most welcome :)Changing the wheel size is a good option. But I think a larger wheel will give better results as the contact area with the ground will be more.You will have to understand how speed and direction control is achieved using a PWM and a digital pin. Consider just one motor. To drive it forward, we set the digital pin LOW and PWM pin at a desired value ranging from 0 to 255. To drive it reverse, let's say at -100, we first set the digital pin HIGH and set PWM pin at (-100 + 255), i.e, at 155. Remember the digital pin is set HIGH which corresponds to 255. Hence the effective value is 255-155, i.e., 100 at digital pin and 0 at PWM pin. This would drive the motor reverse at a PWM value of 100. Hope it's clear for you now.The targetAngle is an important parameter which I forgot to mention earlier. Try to reduce it by arranging components and battery with the wheel axis as center. To set it in program, conduct trials with different values of targetAngle and observe the robot.I'm haven't heard about the RemoteXY app before. Just went through their website and looks like it's really cool. May be I'll try building something using it in the future.Have a nice day.Fellow DIYer from India.

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot1 year ago
    Arduino Self-Balancing Robot

    Hello Serge, Great to see your robot with Bluetooth control.From the description of your problem, I suppose your robot cannot recover once it gets titled and falls over in the same direction of tilting. If that is the case, increase Kp in steps from zero while keeping Ki and Kd zero. You should reach a value of Kp at which your robot recovers from the tilt and falls back in the opposite direction. Once you get your robot to do that, set Ki and Kd with a value of your choice at first and observe your robot's behavior. If it falls over while trying to recover from the tilt, try increasing Ki to correct the error which gets added up (here, the error is the angle of tilt). If your robot doesn't fall over trying to recover but oscillates rapidly about its center, increase Kd to reduce the os...

    see more »

    Hello Serge, Great to see your robot with Bluetooth control.From the description of your problem, I suppose your robot cannot recover once it gets titled and falls over in the same direction of tilting. If that is the case, increase Kp in steps from zero while keeping Ki and Kd zero. You should reach a value of Kp at which your robot recovers from the tilt and falls back in the opposite direction. Once you get your robot to do that, set Ki and Kd with a value of your choice at first and observe your robot's behavior. If it falls over while trying to recover from the tilt, try increasing Ki to correct the error which gets added up (here, the error is the angle of tilt). If your robot doesn't fall over trying to recover but oscillates rapidly about its center, increase Kd to reduce the oscillations.If your robot is still not stable, try changing the filter time constant (see Step 5). Increase the time constant to reduce oscillations and decrease it if you need a quick response.Do share your results. Have a nice day.

    View Instructable »
  • midhun_s followed antoniraj1 year ago
      • Home Improvement : Constructing a Paved Footpath in the Kitchen Garden
      • Growing Termites for Feeding Chicken
      • Growing a Small Kitchen Garden in Your Backyard
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot1 year ago
    Arduino Self-Balancing Robot

    Sorry for my delayed response. Did you download the MPU6050 from the link that I've given in Step 3?

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot1 year ago
    Arduino Self-Balancing Robot

    You need not change your code to fit in L298N. From the last picture of Step 2, you can see that Arduino digital pins 4, 5, 6 and 7 are connected to AIN1, AIN2, BIN2 and BIN1 pins of DRV8833 respectively. Connect these four Arduino pins to your L298N motor control pins. Here, pins 4 & 5 are for controlling the right motor and 6 & 7 for the left. Make sure to set any enable pins on your driver module. Upload the code and check whether both the motors turn in the right direction. Swap the connections to the motor if it rotates in the opposite direction.Regarding the code, I hope you have installed necessary libraries (I2Cdev.h and MPU6050.h). Also, make sure that the MPU6050 is oriented exactly as shown in the photos in Step 2. You will have to do a slight modification in the code...

    see more »

    You need not change your code to fit in L298N. From the last picture of Step 2, you can see that Arduino digital pins 4, 5, 6 and 7 are connected to AIN1, AIN2, BIN2 and BIN1 pins of DRV8833 respectively. Connect these four Arduino pins to your L298N motor control pins. Here, pins 4 & 5 are for controlling the right motor and 6 & 7 for the left. Make sure to set any enable pins on your driver module. Upload the code and check whether both the motors turn in the right direction. Swap the connections to the motor if it rotates in the opposite direction.Regarding the code, I hope you have installed necessary libraries (I2Cdev.h and MPU6050.h). Also, make sure that the MPU6050 is oriented exactly as shown in the photos in Step 2. You will have to do a slight modification in the code if you have arranged the MPU6050 in a different way. I hope this solves most of the issues. Feel free to ask if your problem is not solved.Have a nice day :)

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot1 year ago
    Arduino Self-Balancing Robot

    Hi, Leo. Glad to see your project. Try setting the constants as given in Step 7. The value that you will end up with may be different from what I have used in my code.

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot1 year ago
    Arduino Self-Balancing Robot

    Serial Monitor is a terminal you can access from the Arduino programming environment. Look for the right top corner after opening the Arduino IDE. In Steps 3 and 4, you will need to first connect your Arduino to your computer using a USB-TTL converter. Now upload the sketch and open the Serial Monitor to see the angle of inclination.

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot1 year ago
    Arduino Self-Balancing Robot

    Yup. You will need a USB-TTL converter for programming the arduino pro mini.

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot1 year ago
    Arduino Self-Balancing Robot

    The principle might be the same but you might need some major modifications in the structure.

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot1 year ago
    Arduino Self-Balancing Robot

    It is a library used to interface the ultrasonic distance sensor with the arduino.

    View Instructable »
  • midhun_s's entry Arduino Self-Balancing Robot is a winner in the Robotics Contest 2017 contest 1 year ago
  • midhun_s's entry Arduino Self-Balancing Robot is a finalist in the Robotics Contest 2017 contest 1 year ago
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot1 year ago
    Arduino Self-Balancing Robot

    Continuous rotation servos should also work well. Since the rpm of these servos are generally low, small wheels like the one used here might have to be replaced with large diameter ones.

    I hope you are getting +ve angles when tilting the robot forward and -ve when tilting backward. Now you need to check whether the connections to the motor are done correctly. You can use the setMotors() in your loop and comment out all the other lines of code in your loop. The function works this way: setMotors(leftMotorSpeed, rightMotorSpeed). +ve value of motorSpeed gives forward rotation and -ve gives reverse rotation. Check both motors for speed and direction by giving different values for leftMotorSpeed and rightMotorSpeed ranging from -255 to +255.

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot1 year ago
    Arduino Self-Balancing Robot

    I haven't made a schematic yet. But I hope I have made the circuit clear using the perfboard layouts and the block diagram given in Step 2. Do let me know if there is any doubt.

    View Instructable »
  • midhun_s's instructable Arduino Self-Balancing Robot's weekly stats: 1 year ago
    • Arduino Self-Balancing Robot
      2,077 views
      83 favorites
      8 comments
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot1 year ago
    Arduino Self-Balancing Robot

    Thank you. Once you've finished yours please share it here. All the best.

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot1 year ago
    Arduino Self-Balancing Robot

    I hope you have placed the MPU6050 exactly as shown in the picture. You can also upload the codes in steps 3 & 4 and check whether the angle of inclination is correct (+ve while tilting forward and -ve while tiliting backward)

    View Instructable »
  • midhun_s commented on midhun_s's instructable Arduino Self-Balancing Robot1 year ago
    Arduino Self-Balancing Robot

    Thank you. I'm happy to know that you liked my previous instructable as well.

    View Instructable »
  • midhun_s commented on midhun_s's instructable Robot - Line Follower1 year ago
  • midhun_s followed midhun_s2 years ago
  • midhun_s commented on midhun_s's instructable Robot - Line Follower2 years ago
    Robot - Line Follower

    You will need a programmer. I've used USBasp.Did you try extracting the rar file? You will find main.c in it. Let me know if there's some issue.

    View Instructable »