Arduino Based 12V PWM Generator

by jntan in Circuits > Electronics

2761 Views, 0 Favorites, 0 Comments

Arduino Based 12V PWM Generator

result.JPG

12VDC is an important power source in cars. As a matter of fact, many automotive components like radiator fans, water pumps, valves and small motors can be controlled in a stand-alone fashion with a supply of 12VDC power and 12V PWM control signal, besides the LIN/CAN protocol. If you want to test an automotive part on your bench before putting it into your car, you would probably need a 12V PWM signal and this project will teach you how to generate a 12V PWM signal using Arduino.

Supplies

  • LM339 x1
  • Arduino Uno x1
  • 2.7K/0.25W Resistor x2
  • 1K/0.25W Resistor x1
  • Jump wires
  • Breadboard x1
  • 12VDC power supply x1

Cover.JPG
wiring.JPG
mysetup.JPG
result.JPG

There are four short steps only:

  1. Prepare your parts according to the BOM;
  2. Wire up your circuit according to the diagram provided;
  3. Program your Arduino - the code is provided at the end of the post ;
  4. Test your setup.


I'm including my setup and 12V PWM signal output on oscilloscope for your reference. I hope everyone finds this tutorial useful and enjoys what you do.


Best,


JT_Enliten


Arduino Code:

#include <PWM.h>    
const int PWM_pin = 9;

void setup() {
  pinMode(PWM_pin,OUTPUT);
  InitTimersSafe();
  bool success = SetPinFrequencySafe(PWM_pin, 60);//frequency
  pwmWrite(PWM_pin, 128);//duty cycle
  
}

void loop() {

}