I'm going to try this code on a ChipKIT Uno32 because of the incredibly fast processing speed in comparison to the Arduino. (80Mhz) I think that should take the loop time down significantly, thus potentially leading to better balance.
One thing I really don't understand is the Kalman filter.
Patrik, or Kas, could one of you offer any insight into being able to further tune balance by changing the Kalman parameters?
I am also in the middle of getting my robot to balance.. Tried to implement the original coding from KASbot but I haven't yet managed to change the PID values etc.
It's only when you try to do this yourself that you realise how challenging it is! Hopefully I will get my balancing program working soon... RC control is a long way off!
I know what you mean that it is deemed most effective to place the IMU as close to the wheel axle as possible. However my thinking was that because the gyroscope measures the angular velocity, I thought it would be most effective if the gyroscope was as close to the top of the structure ie. where the battery is so it would measure any slight variations in angular velocity...
I could be wrong in the this... Let me know your thoughts!
I just built a balancing robot using ATmega328 and Arduino libraries myself. I built it using a toy truck as a base, while not as stable as some other builds it is easy on the wallet. Here is a short video:
You can find more information on the theory and the build on my blog (three parts):
Thanks Eugene and Lauszus for the advice, I fully understand now why the IMU should be as close as possible to the axis of rotation.
However, I am quite close to achieving balance with the current setup, I am kinda short on time to move the IMU to the lower deck as the project deadline is fast approaching... Or am I just wasting my time trying to achieve balance with the IMU located where it currently is?? (about 50mm above the axis of rotation in the vertical direction)
My current stumbling block is finding the correct PID parameters.. I am using the original coding as posted by Kas in the initial thread on this topic
Am I correct in thinking that I should tune the terms in this manner. Tune Kp value first then Ki value then the Kd value and finally the "outside" K value? The coding I am referring to shown here:
float K = 1.4;
int Kp = 3;
int Ki = 1;
int Kd = 6;
int last_error = 0;
int integrated_error = 0;
int pTerm = 0, iTerm = 0, dTerm = 0;
int updatePid(int targetPosition, int currentPosition) {
error = targetPosition - currentPosition;
pTerm = Kp * error;
integrated_error += error;
iTerm = Ki * constrain(integrated_error, -GUARD_GAIN, GUARD_GAIN);
dTerm = Kd * (error - last_error);
last_error = error;
return -constrain(K*(pTerm + iTerm + dTerm), -255, 255);
}
I will try to post a video today to show the stage of balancing that I am at!
Hey guys I am thinking about trying to build one of these self balancing robots. I have an arduino r3 motor shield. Im curious if I can find good enough motors that I can control with my shield and not push the 2 amp limit.
Select typical operating setting for desired speed, turn off integral and derivative part, and then increase Kp to max or until oscillation occurs.
If system oscillates, divide Kp by 2.
Increase Kd and observe behaviour when changing desired speed by about 5% and choose a value of Kd that gives a fast damped response.
Slowly increase Ki until oscillation starts. Then divide Ki by 2 or 3.
I more or less followed that, but I then fine tuned it myself. I recommend using a wireless application, so you can set them wirelessly, as mentioned in the video, as you have to spend a lot of time finding those values.
#Wmgatorfan08
Yes I think it is possible to make a very low cost segway using those parts, but I don't think the performance will be as good, but I will still be a great learning experience and a fun project. Just take a look at AlphaZeta robot: Balancing robot for dummies - #43 by AlphaZeta - Robotics - Arduino Forum
That only cost approximately 20$ excluding the motors!!
I think your forgot to insert the link for your IMU
I feel pretty comfortable with this IMU. I have been reading a lot about it and have already found several examples of code to get the data that I need. I have been using arduino for about a year now so I feel pretty confident with my ability to get the board working. I am not as familiar with I^2C as I should be but I am reading and working on it now.
My main concern is the motors. I know that selecting the proper motors and wheels will make or break the project. Ultimately I am thinking I need something with a lot of torque that can respond quickly. I don't think I need high rpm, but it must spin fast enough to catch up with itself when falling.
Also correct me if I am wrong, but I am thinking something around a foot to foot and a half tall with the center of mass being around the motors. From what I am reading the IMU needs to be near the top?
For best results, the IMU needs to be placed near the center of the gravity of your build, wherever that is. Typically, the higher the center of gravity is, the easier it is to balance as the timing becomes less critical.