Arduino projectsElectronic projects

LM317 and PWM control from Arduino

LM317 and PWM control from Arduino

LM317 and PWM control from Arduino

There are very inexpensive ready-made voltage regulator modules, that is, a stabilizer based on LM317 chips . Here is a schematic diagram of the assembly and connection of such a module or a separate LM317 chip:

LM317 and PWM control from Arduino

Since this block follows the typical LM317 application circuit, it is great for powering small device projects or any other circuit requiring constant voltage. According to the documentation, the LM317 chip is an adjustable three-pin positive voltage regulator capable of delivering more than 1.5A in the output range from 1.25V to 37V. Only two external resistors are required to set the output voltage. The LM317 also includes current limiting, thermal overload protection, and safe work area protection. The overload protection remains operational even if the ADJ contact is disconnected.

LM317 and PWM control from Arduino

 

The following is a functional block diagram of the LM317. The ADJ’s 1.25V bias-input op-amp allows easy programming of output voltage or current (but not both). For voltage regulation devices, two resistors set the output voltage.

Since the value of VREF is constant, the value of R1 determines the amount of current flowing through R1 and R2. The value of R2 determines the fall of IR from the ADJ pin to GND – higher values ​​of R2 are translated into higher V OUT. But since the LM317 sends its bias current to the OUT pin, the load or feedback must draw this minimum current to regulate, otherwise the output potential may be too high.

This is a small addition in the form of using a 240 ohm resistor as the top resistor R1. R1 at 240 ohms is the main requirement for the LM317 when used as a voltage regulator, since the internal 1.25 V reference must have a resolution of 100 µA. The specification for the minimum load current is 3.5 mA typical, 10 mA maximum. With a 240 ohm resistor as R1, we will get about 5 mA of current flowing through the lower resistor R2.

LM317 and PWM control

If the top resistor R1 is left in place and the bottom resistor R2 is replaced with a voltage source, the output voltage of the LM317 will be about 1.25 V higher than the input. Therefore, if we apply AC voltage from an external source, such as a microcontroller, we can control the output of the LM317 instead of using a traditional trimmer or potentiometer.

Let’s combine a basic LM317 stabilizer circuit with a microcontroller to create a remote controlled regulated power supply.

Now that the voltage regulator has been chosen, it’s time to build the rest of the circuit around it. Adjusting m/s with an external voltage source is fine, but how do you get the voltage changed on the ADJ pin? The easiest way is to use the Arduino’s Pulse Width Modulation ( PWM ) with an op amp. The figure below shows the idea.

Useful:   Proximity switch for the lamp homemade!
LM317 and PWM control from Arduino

An analog voltage is created here using an LM358 op amp (IC2A) along with a resistor (R3) and a capacitor (C4) to form an RC low pass filter (LPF). The LPF converts the PWM voltage to a DC signal. Increasing the PWM frequency should reduce the output ripple. Similarly, increasing the value of the resistor produces the same result but increases the rise time of the RC network. It is possible not to use an operational amplifier, but it has advantages. For example, it forms a certain degree of protection for Arduino.

PWM Program for Arduino

The input to the circuit is a 5V PWM signal from the Arduino Uno. The Arduino Uno PWM has two default frequencies – 490Hz and 980Hz. This uses digital pin D3 with a 490Hz PWM output. Here is a basic PWM sketch on an Arduino Uno.

int pulseOut = 3; // D3

void setup()

{

pinMode(pulseOut, OUTPUT);

}

void loop()

{

analogWrite(pulseOut, 0); // Minimum

delay(6000);

analogWrite(pulseOut, 128); // Middle

delay(6000);

analogWrite(pulseOut, 255); // Maximum

delay(6000);

}

During testing, a conventional 9V/1A DC adapter was used to power the Arduino circuit and the LM358, and the LM317 module was powered by a 12V PSU. A 9V power supply will work for the LM358, but the maximum output from it will only be close to 5V. This results in a maximum output voltage of 0f 6.2V from the LM317 module (2.2V is the minimum output voltage). You can of course change the op amp power supply voltage after setting the op amp to multiply the 0-5 V PWM input by 10 (or so) to get higher output voltages from the LM317.

 

The higher the frequency of the PWM signal, the less the voltage ripple at the output of the low-pass filter circuit. If the default frequency of the D3 digital PWM output (490Hz) is used, it is too low for a decent setting. It is necessary to increase this PWM frequency to a few kHz to get a more stable output voltage. You can do this by changing the Arduino timer register.

LM317 and PWM control from Arduino

This is how the idea turned out for the unusual use of the LM317 stabilizer, which can be used in a variety of automation devices .

6 Comments

  1. Do you understand the extraordinary energy of solar photovoltaic cells? I did some research study online as well as figured out that this modern technology can actually assist create power! Would love to hear your thoughts on it.

  2. Доски объявлений могут быть полезными для поиска арендных жилых помещений или соседей для совместной аренды.

  3. I haven’t checked in here for some time because I thought it was getting boring, but the last few posts are good quality so I guess I’ll add you back to my everyday bloglist. You deserve it my friend 🙂

  4. Я благодарен автору этой статьи за его способность представить сложные концепции в доступной форме. Он использовал ясный и простой язык, что помогло мне легко усвоить материал. Большое спасибо за такое понятное изложение!

  5. Я просто не могу не поделиться своим восхищением этой статьей! Она является источником ценных знаний, представленных с таким ясным и простым языком. Спасибо автору за его умение сделать сложные вещи доступными!

Leave a Reply

Back to top button