pikvm icon indicating copy to clipboard operation
pikvm copied to clipboard

kvmd-fan takes over *both* hardware PWM channels

Open jacopo-j opened this issue 3 years ago • 1 comments

Describe the bug kvmd-fan, which uses the wiringpi library, takes over both hardware PWM channels regardless of the pin where the fan is connected. This results in devices (such as a servo) connected to the other channel to stop working. As discussed on Discord, the program may need to switch to bcm2835.

To Reproduce

  1. Setup a servo on PWM channel 0
  2. Connect a fan to PWM channel 1
  3. Start kvmd-fan passing the correct fan pin as argument
  4. The servo stops working

Expected behavior Starting kvmd-fan does not affect the other PWM channel

PiKVM info:

  • Raspberry Pi board version: RPi 4
  • PiKVM platform: v2-hdmi
  • Video capture type: CSI bridge
  • KVMD version: 3.61-1
  • uStreamer version: 5.1-2
  • Linux kernel: 5.15.25-10-rpi-ARCH

jacopo-j avatar May 21 '22 15:05 jacopo-j

It can't be fixed since both pwm on pi uses the same clock source: https://www.airspayce.com/mikem/bcm2835/

Both PWM channels are driven by the same PWM clock, whose clock dvider can be varied using bcm2835_pwm_set_clock(). Each channel can be separately enabled with bcm2835_pwm_set_mode(). The average output of the PWM channel is determined by the ratio of DATA/RANGE for that channel. Use bcm2835_pwm_set_range() to set the range and bcm2835_pwm_set_data() to set the data in that ratio

I believe that the easiest way would be to fix the servo plugin to optionally use software pwm.

mdevaev avatar Jun 10 '22 04:06 mdevaev

Hi, I believe instead of make servo plugin to use software pwm, why don't we make to fan use software pwm?

NyaMisty avatar Nov 30 '22 16:11 NyaMisty

Since 0.24 kvmd-fan can work in soft pwm mode. To enable it add these lines to /etc/kvmd/fan.ini:

[main]
pwm_soft = 80

mdevaev avatar Dec 02 '22 11:12 mdevaev