VREG Click: adjustable power supply with Arduino Uno


In this blog post, I will show you how to use the Vreg click from MikroElektronika with an Arduino Uno, using one Arduino Uno click shield from MikroElektronika.

With this click board we can make a variable power supply, capable of delivering an output voltage between 1.25V and 17V, for an input voltage of maximum 20V. Rough and fine adjustments of the output voltage have been implemented, and we can also choose some preset voltages. Output can be turned on or off in the Arduino code.

Vreg click from MikroElektronika

Vreg click from MikroElektronika

First, we will take a look on the hardware, focusing on the operating principle and on some calculations regarding the use of DAC and ADC to control the LM317 regulator. Then, a code example for Arduino IDE is provided. Finally, some extra explanations and conclusions are given.

Working principle

To understand how the Vreg click works it pays off to draw the schematic of the power stage in a different way:

Vreg click: power stage

Vreg click: power stage

Now things look different. The op-amp is part of the LM317’s feedback loop. Its output will change in such way that Vsense matches Vset. Vsense is also applied to one of the A/D channels of the MCP3204, so it can be checked in software, too.

The only missing thing, in my opinion, is a lowpass filter between the op-amp output and the ADJ pin. Without this filter, oscillation is possible, with a negative impact on the output jitter.

Maximum and minimum voltages

The VREG click documentation specifies a maximum input voltage of 20V. The maximum voltage that we can get depends on the dropout over the LM317. While the datasheet doesn’t give an explicit value for the dropout voltage, on page 4 we find a minimum value of 3V for the “Input-to-output differential voltage”. Considering this, we can calculate the maximum output voltage as:

Back to our schematic. When the output voltage is 17V, the value of the SENSE voltage is:


Let’s take a closer look at the MCP4921 DAC, and we start by computing the LSB voltage, which is the ideal voltage between two successive codes. The gain will be set to 1, as this is the only setting that will work when the click board is powered from 3.3V. If we switch the power jumper into the 5V position, then we will be able to use gain x2. My choice is to set the gain to 1, as it allows for a better use of the dynamic range of the MCP4921.

The value to be written to the DAC to achieve an output of 1.5454V is:

A similar computation must be made for the minimum output voltage. The minimum voltage is 1.25V, for which we calculate a value of:

The lowest value to be written to the DAC to obtain this output value is:

MCP3204: voltage sensing

The MCP3204 is a four channel, 12 bit ADC. In this click board it is used to read the input voltage, the output voltage and the sense voltage applied to the inverting input of the LM358. The schematic is as follows:

Vreg click: voltage sensing

Vreg click: voltage sensing

From the MCP3204 datasheet we have:

where is the voltage applied to one channel of the MCP3204 and is the reference voltage. Thus, we have:

Let’s assume we want to measure Vin, which is applied to channel2, via a voltage divider made by R3 and R4. In this case, we have:

The same computation can be made for the other channels, as all the voltage dividers in the sensing circuits have identical values.

Artificial load

There’s an artificial load implemented with the other half of the LM358 used as a comparator. Note that the implementation is as a simple comparator, with no hysteresis. I would expect to have that load to jiggle between on and off states when the voltage is close to the threshold.

For a reference voltage of 2.048V, and considering the voltage divider made of R18 and R17, the threshold voltage to switch on the load is:

Output switch

The output of the Vreg click can be switched on and off via the PWM signal on the mikroBUS socket. Put the PWM pin low to disable output, put it high (or just leave it floating, R15 will pull it high).

1 2 3

Leave A Reply