1

I am trying to control a fan using Raspberry Pi. For that I tried to use the PWM pin in raspbery Pi. I am using Qt C++ to control the fan. I installed the wiring Pi and run the Wiring pi using command line and I checked the man page of Wiring Pi. The man page not given any exact detail to set frequency and change duty cycle

I failed to set a fixed frequency(25KHz) and set duty cycle from 0 to 100% using wiring pi and man page details.

How toset a fixed frequency and vary duty cycle in Raspberry Pi PWM pin using wiring Pi or any other solution I can use in my Qt C++ code to control the PWM pin.

Ghanima
  • 15,958
  • 17
  • 65
  • 125
Arun Kumar K S
  • 303
  • 1
  • 3
  • 11

1 Answers1

1

My pigpio library has several ways of setting PWM.

The more usually used will be hardware timed PWM on any gpio with a (default) frequency of 800Hz and a dutycycle which may be varied between 0 and (a default) 255. For C see gpioPwm.

If that does not suit there is more flexible PWM generated by the two hardware PWM channels. A frequency in the range 1Hz-125MHz (I doubt anything above 30MHz will have any useful effect) with a selectable dutycycle between 0 (off) and 1000000 (fully on). For C see gpioHardwarePWM.

joan
  • 71,852
  • 5
  • 76
  • 108