Hey Wes,
Sounds like you need the basics of servo explanation. Fortunately Adafruit has a nice tutorial on Servos that eventually goes down to the low level details of what type of waveform servos need to control them:
TL;DR - To answer your question quickly, the .setServos() function will ultimately create a PWM waveform on the control input of the servo. This waveform basically tells the servo to set itself to a particular orientation. The servo knows when it’s at the correct orientation because it has a potentiometer inside of it that relays position feedback of the output shaft. Essentially it turns a geared motor one direction or another until it sees the correct voltage on the potentiometer. It glitches about because it’s randomly driving the motor back and fourth around this control point. The more load you put on the servo, the more it will “fight” to retain it’s position and the more noise you may hear.
The twitch you are experiencing may be due to a glitch in the signal sent to the servo. This is fairly common when updating the duty cycle of a PWM output when you do it in such a way that it re-initializes the PWM and then sets the duty cycle. This may be the case inside Pixy, but I’m sure it’s easy to resolve. To verify this, you would need to monitor the PWM output with an oscilloscope to look for irregularities in the waveform around the intervals when you are updating the .setServos() function. I will offer to help out here since I have a 'scope. Would you post your Arduino Code so that I may duplicate your setup? Just paste it in, select it all, and click the [PRE] button to format it like this (so we can read it easily):
if(someTest == true) {
// do stuff
}
else {
// don't do stuff
}
Even if there is a glitch in the PWM, you can avoid transferring this to your servo without a fix to Pixy’s code. To do this you can just not update the .setServos() function if your servo values have not changed since the last time you sent them. Just keep track of them with a newPos and oldPos value, like this:
if(newPosX != oldPosX || newPosY != oldPosY) {
pixy.setServos(newPosX, newPosY);
oldPosX = newPosX;
oldPosY = newPosY;
}