Setpoint = -0.5;
Also, change this motorControlPID.SetSampleTime(50);tomotorControlPID.SetSampleTime(1);and see what happens.This is assuming that the library allows for 1 millisecond sampling period.
Show us a video of what you mean when you say bot working fine. Or at least fine for a while.Also, show us a video of this off-balance problem.A lot of us are using 6050 and our bots are balancing very nicely. The accelerometers can provide angle readings that are good enough for the bot to balance properly. The gyro-scopes can also be used to measure angles fairly accurately over relatively short duration, and could (if we want to) be combined with the accelerometer angle measurements to get better estimates of the bot's inclination angle.You mentioned you get consistent readings ...... and I assume consistent and accurate. If you're getting consistent readings all of the time when you test the bot by holding it in your hand, and the motors always move in the correct direction (as you mentioned), then there shouldn't be any reason for the bot to run off in the wrong direction.