as im doing a new ESC code i did some test with higher PWM frequencys .. i choosed 3,9kHz because it was easy to code. i noticed that my test quad was much more stable with that. so the motor signal transfer time still disrupts with 488Hz
but as normal ESC's cant read signals with less then 1-2ms dutytime, ampere dieter showed me a good thing named one shot PWM

that means we just send a PWM signal if there is a new signal complete (one cycle done). with this we can reduce the time the new signal takes to be tranfered to the ESC's.
this can also be done with HW PWM .. if we just activate the PWM when writing new motor values
.. i did some test code tonight .. but ill test it tomorrow
this is just for the nanowii to test:
Code: Select all
// one shot
void writeMotors() { // [1000;2000] => [125;250]
//set new Values
OCR1A = motor[0]<<4; // pin 9
OCR1B = motor[1]<<4; // pin 10
OCR3A = motor[2]<<4; // pin 5
TC4H = motor[3]>>8; OCR4D = (motor[3]&0xFF); // pin 6
cli();
// reset timers
TCNT1 = 0;
TCNT3 = 0;
TC4H = 0;
TCNT4 = 0;
// enable overflow interrupts
TIMSK1 |= (1<<TOIE1);
// enable PWM
TCCR1A |= (1<<COM1A1); // connect pin 9 to timer 1 channel A
TCCR1A |= (1<<COM1B1); // connect pin 10 to timer 1 channel B
TCCR3A |= (1<<COM3A1); // connect pin 5 to timer 3 channel A
TCCR4E |= (1<<OC4OE5); // connect pin 6 to timer 4 channel D
sei();
}
// clear overflow interrupts & disable PWM
ISR (TIMER1_OVF_vect){
static uint8_t state = 0;
if(state){
TCCR1A &= ~(1<<COM1A1);
TCCR1A &= ~(1<<COM1B1);
TCCR3A &= ~(1<<COM3A1);
TCCR4E &= ~(1<<OC4OE5);
TIMSK1 &= ~(1<<TOIE1);
state = 0;
}else state = 1;
}
what do you think ?
regards felix