pikvm
pikvm copied to clipboard
kvmd-fan takes over *both* hardware PWM channels
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
- Setup a servo on PWM channel 0
- Connect a fan to PWM channel 1
- Start
kvmd-fanpassing the correct fan pin as argument - 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
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.
Hi, I believe instead of make servo plugin to use software pwm, why don't we make to fan use software pwm?
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