As the title says, i need to build a servo mixer that takes in 4 signals coming from a RX. there are 4 output servos that need to move in certain direction based on what the input signal do. for example, when input 1 makes servo 1 and 2 move clockwise, but input signal 2 makes servo 1 and 2 move in opposite directions. (very much like a V-tail mixer on RC where 2 servos move and mix based on the elevator and rudder inputs.)
Anyway, i have the program working correctly now so that the servos move correctly. I basically have 2 mixes per servo pair and 2 pair that operate the same way. so what i did was read the incoming signal and scale to the servo range of motion from 0 to 180 and stored that value, then i read the second signal and scale the range of motion from 180 to 0 to get the reverse channel and save that as well. finally i add both angle values and divide by 2 to get the average of the 2, this works perfectly.
The problem now is that the value of the incoming signals fluctuates ever so sightly. this makes for a slightly different output angle every time the program reads through the code. this cause a .5 to 2 degree servo jitter on the output.
The question now is, what can i do to stabilize these signals or buffer them to ignore those slight variations in output but still respond to deliberate inputs.
cycfaval = pulseIn (cycfa, HIGH); //read pulse from cyclic fore/aft, store in cyclic fore aft val
constrain (cycfaval, 1000, 2000); //constrain the values of cycfaval from 1000 to 2000 Us
FPEval = map(cycfaval, 1000, 2000, 0, 180); // map cyclic fore/aft to front pitch servo
BPEval = map(cycfaval, 1000, 2000, 180, 0); // map cyclic fore/aft to back pitch servo
collval = pulseIn (coll, HIGH); //read pulse from collective, store in collective val
constrain (collval, 1000, 2000); //constrain the values of collval from 1000 to 2000 Us
FPCval = map(collval, 1000, 2000, 0, 180); // map collective to front pitch servo
BPCval = map(collval, 1000, 2000, 0, 180); // map collective to back pitch servo
FPval = ((FPEval+FPCval)/2); // calculate total movement for Front pitch servo
BPval = ((BPEval+BPCval)/2); // calculate total movement for back pitch servo
FP.write (FPval); // write total value to front pitch servo
BP.write (BPval); // write total value to back pitch servo