PWM Arduino

PWM (Pulse-width modulation) can be implemented on the Arduino Diecimila and Duemilanove in several ways:

  - Bit-banging PWMarduino PWM

  - Fast PWM

  - Phase-Correct PWM

  - Fast PWM Mode with OCRA top

Pulse-width modulation is a way of encoding a voltage onto a fixed frequency carrier wave (like on FM or AM radio)

Writing a value from 0 to 255 on a Arduino PWM pin, will cause the pin to output a PWM signal whose on time is in proportion to the value written, a value of 255 will be 5 volts on the PWM pin.

Becouse de power limitation of the Arduino PWM pins, I used in my schematics 2pcs of BD139 power transistor, one for every fan.

To protect PWM pins from the higher voltage (12v DC) I used an two channel optocoupler (LTV-826)

The schematics of this Arduino PWM shield is very simple, and anyone can build it. You can download all the project files you will need it here

Arduino PWM

Part list:

- 35mm x  60mm single sided copper PCB

 - T1, T2 BD137 or BD139 Power transistor

 - D1, D2 1N4001 diode (general purpose silicon rectifier diodes)

 - IC1 LTV 826  2 channel Optocoupler

 - R3, R4 10K ohm 0.25-0.5w resistor

 - R1. R2 220 ohm 0.25-0.5w resistor

 - R5 1K ohm 0.5w resistor

 - L1 3mm Red LED

 - 2pcs of 2 wire connector (for date signals and DC 12v power)

 - 2pcs JST 3-Pin Connector Plug (mainboard fan connector)

 

Also this shield you can use it for LED light dimmer.

I made a very useful step by step guide about how you can make your own home made pcb.

In this video you can see this arduino pwm shield in action :)

Arduino Source code for testing the PWM shield

 /*

PWM Arduino Fan speed controller

This example shows how to fade two DC Fan's using the analogWrite() function.

The circuit:

Created 12 Nov 2012

By DIY-GreenEnergy

modified 03 Dec 2012

*/

int fan1 = 9; // Optocoupler 1

int fan2 = 10; // Optocoupler 2

void setup() {

// nothing happens in setup

}

void loop() {

for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {

// sets the value (range from 0 to 255):

analogWrite(fan1, fadeValue);

// wait for 400 milliseconds to see the dimming effect

delay(400);

analogWrite(fan2, 0);

}

delay (3000);

// fade out from max to min in increments of 2 points:

for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=2) {

// sets the value (range from 0 to 255):

analogWrite(fan1, fadeValue);

// wait for 400 milliseconds to see the dimming effect

delay(400);

analogWrite(fan2, 255);

}

delay (3000);

}

arduino-pwm-shi...
arduino-pwm-shield-1 arduino-pwm-shield-1
arduino-pwm-shi...
arduino-pwm-shield-fan-seed-controller arduino-pwm-shield-fan-seed-controller
arduino-pwm-shi...
arduino-pwm-shield-PCB arduino-pwm-shield-PCB
arduino-pwm-shi...
arduino-pwm-shield-schmatics-1 arduino-pwm-shield-schmatics-1
arduino-pwm-shi...
arduino-pwm-shield-schmatics-2 arduino-pwm-shield-schmatics-2
arduino-pwm-shi...
arduino-pwm-shield-with-two-dc-fan arduino-pwm-shield-with-two-dc-fan

Go to top