In reply to http://tvwbb.com/showthread.php?46004-INTRODUCING-the-quot-Roto-Damper-quot&p=705356&viewfull=1#post705356
I didn't want to hijack Ralph's thread too much.
I'm not sure if the issue was the ADC ISR or the Serial ISR. Either way there are enough ISR events to mess up the determinism of the system.
This code matches the original servo movement more or less
ISR(TIMER1_CAPT_vect)
{
unsigned int cnt = OCR1B;
digitalWriteFast(PIN_SERVO, HIGH);
cnt = TCNT1;
OCR1B = cnt + pid.getServoTarget();
}
RC Servo's are far more sensitive to pulse width than refresh rate assuming there is no mechanical binding holding the servo from moving. Basically I'm finding out how long the ISR got delayed and adding that to the turnoff event so the length of the pulse should be more consistent. Unfortunately this only corrects 1/2 the issue as the turn off event may or may not get hit.
Doing some simple count measurements. The original ISR would vary the pulse width between 0 and 25 counts of desired. Modified is around 0-12 counts. Two counts is about 1uSec if I recall right. So 25 counts is ~12 uSec which exceeds the deadband of most analog servos which cause them to start trying to move. 12 counts is ~6usec and should be fine outside of a digital servo. Digital servo's can go down to <1 uSec deadband on really good ones.
I didn't want to hijack Ralph's thread too much.
I'm not sure if the issue was the ADC ISR or the Serial ISR. Either way there are enough ISR events to mess up the determinism of the system.
This code matches the original servo movement more or less
ISR(TIMER1_CAPT_vect)
{
unsigned int cnt = OCR1B;
digitalWriteFast(PIN_SERVO, HIGH);
cnt = TCNT1;
OCR1B = cnt + pid.getServoTarget();
}
RC Servo's are far more sensitive to pulse width than refresh rate assuming there is no mechanical binding holding the servo from moving. Basically I'm finding out how long the ISR got delayed and adding that to the turnoff event so the length of the pulse should be more consistent. Unfortunately this only corrects 1/2 the issue as the turn off event may or may not get hit.
Doing some simple count measurements. The original ISR would vary the pulse width between 0 and 25 counts of desired. Modified is around 0-12 counts. Two counts is about 1uSec if I recall right. So 25 counts is ~12 uSec which exceeds the deadband of most analog servos which cause them to start trying to move. 12 counts is ~6usec and should be fine outside of a digital servo. Digital servo's can go down to <1 uSec deadband on really good ones.