项目作者: eleschrott

项目描述 :
Convert a low pwm frequency of 980Hz up to 32Khz
高级语言: Makefile
项目地址: git://github.com/eleschrott/PWM-Frequency-Booster.git
创建时间: 2017-10-16T14:49:17Z
项目社区:https://github.com/eleschrott/PWM-Frequency-Booster

开源协议:GNU General Public License v3.0

下载


PWM-Frequency Booster

Convert low pwm frequency of ~980Hz up to ~32Khz


If it’s necessary to have higher frequency on puls width modulation than a standard MCU is able to and its not practicable to increase the controller timer frequency, you can use this solution.
If your fan works like a speaker, you know what I mean :smirk:

An ATtiny85 or similar MCU, convert the low pwm-frequency of 976.5625Hz (e.g. a standard Arduino pwm frequency) up to
32KHz. You need only a cheap ATtiny model, this program and a 10k resistor. The duty cycle of the puls is not touched, that means:

  1. Input Duty Cycle = Output Duty Cycle

In this example an ATtiny85 is used.


Schematics:

  • The low pwm input is on pin3 (PB4), the high pwm output on pin5 (PB0)
  • On pin1 a 10k resistor is connected direct to VCC
  • The two caps are standard blocking capacitors

Software:

In the header section you can find some values to adjust the program according to your situation:

  1. #define PWM_INPUT // PWM low frequency input pin
  2. #define PWM_OUTPUT // PWM high frequency output pin
  3. #define PWM_FREQ_HIGH // PWM frequency: 0 = 16KHz or 1 = 32KHz
  4. #define DUTY_MIN_LIMIT // min limit according your fan
  5. #define DUTY_MAX_LIMIT // max limit according your fan

To get more or less precise values you can adjust the SAMPLE_RATE. More accuracy needs more time, try with some values to find the best for your project. A good guide value is times of 256, 512 or 1024.

  1. // some examples:
  2. #define SAMPLE_RATE 512 // verry fast reaction
  3. #define SAMPLE_RATE 1024 // fast reaction, but a smaller accuracy
  4. #define SAMPLE_RATE 1280 // little bit slower reaction, but better accuracy
  5. #define SAMPLE_RATE 1536 // good agreement of speed and precision
  6. #define SAMPLE_RATE 1792 // slower reaction of pwm changes, but high accuracy

If you try out some diffent values of SAMPLE_RATE, its a good idea to deliberate about SAMPLE_TIME. This time is in dependence of the rate. Higher sample rate needs more time to calculate the duty cycle, so the sample time should also grow and vice versa.


Programmer:

One hint to program the MCU: Its important to erase the Fuse Low Byte CKDIV8 of the MCU to get 8MHz Clock frequency!


Example on MiniPro Universal Programmer:



Example with Atmel ICE Programmer and Atmel Studio: