2020-05-02, 11:30 PM
(2020-04-16, 04:49 PM)jamos.tan@gmail.com Wrote: I've got it now. For if(pwm_style == 2) you need to modify two lines. Search for if(pwm_style == 2) and if below it mentions 16000, change it to a lower one. I've adjusted it to 1000 and the motor sound is perfect! In the newest motor.ino those are lines:
467: uint16_t OCR1A_u = 1000, OCR1B_u = 1000, ICR1_u = 1000;
482: ICR1_u=1000/DIV_CLOCK; //fPWM=1khz original was 16000, now 1000 is more khz
And of course, for the motor to work at all you need to define the proper board. In my case, even though i use an h-bridge i needed to define the VNH2SP30
119 #define VNH2SP30 // defined if this board is used
Thanks for this man. For myself, however, I turned away from changing the pwm frequency, because it turned out to have undesired side effects. The whole servo system, including the servo slew mechanism, became way more nervous in reacting to input. In particular, the stopping of the motor became so abrubt that it did not sit well with me, and I could not fix that with the slew parameters. So in the lab here the sound is irritating, but chances are on the boat it will drown in the lovely background symphony of wind and water.