Making a self balancing bot for as cheap as possible.
After some fine tuning the drunk bot is on its way to rehabilitation...
I am now trying to add in a Sonar Sensor (HC-SR04) to add in obstacle and/or people avoidance. I am having a bit of trouble as I think there is some conflict with the time critical stuff in the ping library and MPU6050 library as the code works intermittently. If anyone has used both of these in a project I would like to hear of it.
As shown in the pictures on the left, the basic platform for my electronics and hardware is just 4 pieces of 6mm threaded rod and some sheets of acrylic which were sourced locally from an acrylic distributor and hardware store respectively.
On the electronics front, I used an arduino uno for the micrcontroller, a MPU6050 for sensing and an L298N motor driver. I originally started out with some super cheap motors from dealextreme here. While these worked to an extent, I made the platform far too big for these motors to work effectively. While I could have made the platform smaller I wanted to make something sizeable in order to interact with kids (some nieces and nephews in particular). This lead me in search of some replacement motors and decent mounts if possible. In searching for alternatives I found some cheap ebay 12V polulu knock offs which even had the same mounting pattern as the 37D polulu mounts.
I wanted to help speed up the PID tuning process as I was just changing values in the code and re-uploading the sketch which got old very quickly. I had a couple bluetooth modules (HC-06) laying around and thought I would utilise one of them in order to speed up this process. I used a bluetooth terminal app to act as a wireless serial monitor and added in code to print the current angle and motor output as well as set the PID values and angle setpoint.
With these new components I went about tuning the PID gains. First by increasing the P until it was somewhat responsive, then I gradually increased the I term to improve its response. Once this was done I adjusted the D term to reduce overshoot. Below is a video of the current state of the bot and as you can see, it's obvious how it got it's name.
I have some ultrasonic sensors and want to add these on to implement some obstacle avoidance, I'm thinking something like a robot that runs away from whoever is chasing it. Watch this space.