mathiasvr / bluejay

:bird: Digital ESC firmware for controlling brushless motors in multirotors
GNU General Public License v3.0
479 stars 50 forks source link

PWM duty cycle is too low with higher frequencies #16

Closed mathiasvr closed 3 years ago

mathiasvr commented 3 years ago

I have measured the duty cycle of the different PWM frequencies (24, 48, 96) at offsets with no dithering, and it seems to get slightly lower as frequency goes up. This seems to confirm #2.

Describe the bug The PWM duty cycle gets lower as PWM frequency is increased, for the same throttle input.

Expected behavior The PWM duty cycle should be the same for different PWM frequencies when given same the throttle input.

Configuration:

I think maybe it could be related to rounding (truncation). It could also be because of the resolution (without dithering) being lower with higher PWM frequencies, but in that case, I think it would be preferable to round up instead.

mathiasvr commented 3 years ago

I forgot that the different pwm resolutions (255,1023,2047) are not multiples. The scaling required to get the exact same duty cycle is not really worth it. However, the current scaling should actually slightly increase the duty cycle and not decrease it, so it still appears something isn't right.

mathiasvr commented 3 years ago

After using a different setup I cannot reproduce this and my calculations seem to confirm it. Maybe the other setup I tested affects the pwm duty cycle somehow, not sure if it was only the measurements or actual motor power as well.

I think the "usual" observed power reduction of the higher PWM frequencies is due to dead time insertion being applied more often which affects efficiency. Closing for now.