i have an MPU6050 module hooked up to an arduino uno and a number of servos connected to a PCA9685, i have the x and y axis of the gyroscope hooked up to control 2 of the servos, the problem i am having is that the motion comes out jittery.
currently i take a moving average of the raw gyro data then using some maths i mix that for the servo control then i take a second average and it is still comes out erratic and jittery.
i have tried a few different theory's to "smooth" the data but i am still suffering the jitter.
//----------------------------------------------//
//Position Mixing//
int GX = map(MnXAv, 0, 400, -100, 100);
int GXa = map(MnXAv, 0, 400, 100, -100);
float SnL = GX + MnYAv;
float SnR = GXa + MnYAv;
//------------------------------------------------------------------Averging mixed values--//
int SnLRead = 10; // number of samples
int SnLSum = 0; //sum of samples
for(int k = 0; k <SnLRead; k++){
SnLSum += SnL;
delay(1);
}
int SnLAv = SnLSum / SnLRead;
any ideas on how i can get a smoother output to the servo positions