Self-balancing robot. Detection of Set-Point. Error

Hi Friends!
I need your help...
I am making a self-balancing robot with Arduino Uno and sensor MPU 6050. I am using a simplificated Kalman filter. The stability is ok. But...because is difficult to do a perfect calibration of sensor MPU 6050 the 0° is approximately 4°. In addition, I detected that some times when I am switching on the robot, this value change. So, why happen? And do you have any idea to compensate this error? I am thinking (I don't know how to do it) that, if is possible to know the perfect 0.0°, the angle detectated of MPU will be my new SetPoint.
Thanks!

I am thinking (I don't know how to do it) that, if is possible to know the perfect 0.0°, the angle detectated of MPU will be my new SetPoint.

You KNOW the "perfect 0.0°". The problem is that when the robot is in that orientation, the MPU6050 is reporting some other angle.

You need to determine what the measured angle is, when the MPU6050 first starts up, and subtract that initial angle from all future angle values.

Ok. Thanks. I will try it and I will tell you something.

I am using a simplificated Kalman filter.

If it is the one that a lot of people have tried to use, and then give up, it is wrong and a waste of time, memory and effort.

So....there are some sensor better? Are you telling me that this sensor not work well?
Thanks

No. The sensor is not the problem.

The mpu6050 is a perfectly acceptable sensor for this project. Are there "better" sensors? Sure, but the difference is $$$.

An ideal approach to balancing is to find the balance point first.
To do this, configure your robot with battery and anything else you want mounted to it. Then manually tilt it until it is as close to balanced as you can get it. Note the angle visually. Now, find a way to hold it in that orientation without it moving. Maybe a stand, or couple tools or chop sticks to prop it up. Now, run code on it that will read out the sensor values at that angle. Those values are your target, or set point, angles.

Thanks! Your recomendations works very well! Its true, the initial value is the Set-Point.

But, i want to add that if you look the evolution of input angle from sensor MPU, have two parts: a short part, where from an initial value, the values increase, decrease and increase again, and second part or stationary part, where the values not change and have the same value than initial point.

Other question: My Set-Point is in equilibrium position. But, how a Segway knows this point? I want to say, my robot allways has the same weight and the same devices in the exactly the same position. But on a Segway can be a fat man, a children, small or tall woman...etc.

Thanks!

Maybe a stand, or couple tools or chop sticks to prop it up.

Chopsticks? Chopsticks are for eating. Hold your damned robot up with forks. 8)

josepramon:
Thanks! Your recomendations works very well! Its true, the initial value is the Set-Point.

The first thing to do is ---- to do measurements with the 6050, to calibrate it, so that you get satisfactory angle measurements....... ie. correct angle measurements with reference to the vertical (in a vertical plane).

The 6050 needs to be made to provide accurate and reliable angle measurements before it can be used for controlling a robot.

I've played around with a self-balancing robot and for the initial calibration phase right after switching it on, it is set to rest on a horizontal surface. The design of the body (3D printed) is such that when the body is lying horizontally on the floor, the sensor is vertical, or very close to 0 degrees. After the calibration, the robot moves briefly to show that it is ready and then the robot can stand up on its own or by moving it upright. If you want to have a look at the project itself, it's open source. It's called B-Robot: https://www.jjrobots.com/much-more-than-a-self-balancing-robot/ and you'll find all the code on its GitHub page: GitHub - jjrobots/B-ROBOT_EVO2: New and improved version of our Balancing Robot B-ROBOT

my self balancing robot working good but some time's my motors are not working in anti-clock wise rotation what can i do,am use 100rpm geared motor and l293d drive.
plz help me friens.....