I`m trying to get a Z-axis position with help of my MPU6050.I`m using code from this sample: https://github.com/helscream/MPU6050_Arduino

X and Y axes are ok, but Z axis is constantly drifting to something around "~90" after rotation.. If someone can help me getting Z-axis value not just from gyro or accel, but "corrected" to be a real Z value with errors fixed?

I have tried an i2cdev lib for DMP readings (https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050/Examples/MPU6050_DMP6)this one is getting better values (e.g. is able to detect the direction of rotation, and is +/- precise) but it collects an error very quickly and sometimes continue to slowly drift values a little when the sensor motion is stopped.

That`s really cool that you are so clever and know the "angular velocity" word, but you should also know that in real world most people are interested in the actual sensor positions in a X/Y/Z angular dimension.

"Position" of a device generally refers to the location of it. If you are interested in the orientation of the device, then use the word "orientation".

Gyroscopic sensors enable you to estimate the orientation of a device. They are of no use for estimating position.

Any gyroscopic sensor has an accuracy error ( called "drift" ), which varies with time and temperature and varies from device to device.

The variation in the apparent orientation of the device calculated by continuous integration of the apparent rotational velocity, will appear to drift slowly around in three dimensions due to the drift error of the individual angular velocity measurements.

The calculated orientation can be corrected by knowing the direction of "up" ( or down ), using the accelerometer reading combined with an assumption that the device is not subject to actual linear acceleration.

However, the apparent rotation of the device about the vertical axis, cannot be corrected by knowing the direction of up or down, because an change in the position of the device by rotation about the vertical axis, does not give rise to a discrepancy between the predicted and actual direction of gravity, which would enable the estimate to be corrected.

If your device operates so that it generally has a constant axis orientation, so that it presents only one axis of motion to the vertical direction, then you can measure the rate of drift manually by experiment, and adjust the readings from the gyroscopic sensor by a corresponding, offsetting, amount, which will reduce the apparent motion for as long as the device's drift error remains approximately constant. This method won't work very well for a device where the orientation changes a lot in all directions, like a stunt aircraft or a football.

The other method for correcting orientation drift is to use another orientation reference, for terrestrial application, this would be a geomagnetic field sensor.