one shot PWM

one shot PWM

Postby ronco » Thu Nov 08, 2012 1:09 am

Hi,

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 :D

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.

one shot PWM.jpg


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
ronco
 
Posts: 317
Joined: Thu Aug 18, 2011 2:58 pm

Re: one shot PWM

Postby ronco » Thu Nov 08, 2012 11:57 am

.. i dont get it to work :(

it causes jitter .. and it i think the dubble buffer of the atmel timer makes it impossible -.-


regards felix
ronco
 
Posts: 317
Joined: Thu Aug 18, 2011 2:58 pm

Re: one shot PWM

Postby chris ables » Thu Nov 08, 2012 2:55 pm

That's to bad but you are the man at this pwm coding ! Hey can you make a 550hz output file for 2.1 for me ? Or will that even work with an atmel328 ? Would like to see what these simonk is really capable of . :D
chris ables
 
Posts: 317
Joined: Wed Feb 08, 2012 8:42 pm
Location: United states

Re: one shot PWM

Postby ronco » Thu Nov 08, 2012 3:53 pm

Hi,

more then 499Hz are not possible because you cant do a 2ms dutytime over 500hz .. and there must be some "low" time between the signals so the ESC knows that it is still a signal. 488 is a good value for standard PWM.

ill try some more things with one shot PWM ;)

regards felix
ronco
 
Posts: 317
Joined: Thu Aug 18, 2011 2:58 pm

Re: one shot PWM

Postby chris ables » Thu Nov 08, 2012 9:51 pm

Sounds great & good luck hope you get it ! 8-)
chris ables
 
Posts: 317
Joined: Wed Feb 08, 2012 8:42 pm
Location: United states

Re: one shot PWM

Postby Alexinparis » Fri Nov 09, 2012 10:59 am

Hi Felix,

It's a very interesting approach :)
I hope it could work.
The jitter is maybe due to the delay to reactivate the hardware PWM.
In your scheme, you assume it is 0, maybe it is not ?

Alex

ronco wrote:.. i dont get it to work :(

it causes jitter .. and it i think the dubble buffer of the atmel timer makes it impossible -.-


regards felix
Alexinparis
 
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm


Return to Ideas

Who is online

Users browsing this forum: No registered users and 1 guest