How can i read input/output voltages of inverting Buck-boost with a microcontroller

Thread Starter

Tiago Rocha

Joined Jul 12, 2021
30
Hello,

I would like to know what can i use and how can i read input/output voltages of inverting Buck-boost (like the one shown in the image) with a microcontroller?

I should connect ground of microcontroller to a single node, like the one in red rectangle, right? (attached image).

When the Mosfet is off, that node (red rectangle) has a positive voltage. Also, the ADC of microcontroller can not read negative voltages.
 

Attachments

Papabravo

Joined Feb 24, 2006
21,159
You need a microcontroller with an Analog to Digital Converter. They normally have an input range which is related to the microcontroller's power supply voltage. It could be +5 Volts or even 3.3 Volts.

There are several different techniques for measuring current and you can pick one of them and arrange for the output to be an analog voltage in the proper range for the micro controller. (Google "Current to Voltage Converter")

There are several different ways to measure voltage and you can pick one of those and arrange for the output to be an analog voltage in the proper range for the microcontroller. (Google "Basic Operational Amplifier Configurations")
 

ronsimpson

Joined Oct 7, 2019
2,988
Buck-boost (like the one shown in the image)
The circuit you show is an inverting power supply that makes a negative voltage from a positive one. If that what you wanted to post?

If your computer can measure voltage it is likely it con only measure 0 to 3.3V. The input voltage to your power supply is maybe 0 to 10V. You will need a voltage divider (two resistors) to reduce the input voltage by 1/3 so the computer can read it.
 
Last edited:

crutschow

Joined Mar 14, 2008
34,284
When the Mosfet is off, that node (red rectangle) has a positive voltage
That node will have a positive voltage with respect to the micro ground only if you ground the negative output.
Does your system configuration allow that?

If not, to read the negative output voltage, you could use an inverting op amp configuration with a gain of <1.
That will generate a positive voltage less than the magnitude of its negative input, so it can be read by the micro.
A rail-rail type op amp will work for that purpose with only a positive supply voltage.
 

Thread Starter

Tiago Rocha

Joined Jul 12, 2021
30
That node will have a positive voltage with respect to the micro ground only if you ground the negative output.
Does your system configuration allow that?

If not, to read the negative output voltage, you could use an inverting op amp configuration with a gain of <1.
That will generate a positive voltage less than the magnitude of its negative input, so it can be read by the micro.
A rail-rail type op amp will work for that purpose with only a positive supply voltage.
To read the input voltage i think i can use a simple voltage divider with no problem (3.3V max in my case), but to read the output voltage i cant use a voltage divider, so the inverting opamp is the best solution?
 

Thread Starter

Tiago Rocha

Joined Jul 12, 2021
30
The circuit you show is an inverting power supply that makes a negative voltage from a positive one. If that what you wanted to post?

If your computer can measure voltage it is likely it con only measure 0 to 3.3V. The input voltage to your power supply is maybe 0 to 10V. You will need a voltage divider (two resistors) to reduce the input voltage by 1/3 so the computer can read it.
I'm aware of that, perhaps, my doubt is more about how to read the output voltage, since i cant connect microcontroller ground to more than one node, and the output voltage is negative.
 

ronsimpson

Joined Oct 7, 2019
2,988
Assumption. The ADC input voltage is 0 to 3.3V. and 0 and 3.3V are stable.
ADC is in the computer and lives on +3.3V and 0V.
Want to measure about -10V.
Make R1 & R2 so that -10V causes about 0V or about 0.5V on the ADC and when "-10V" is at zero the ADC will read almost 3V.
1635427931909.png
If the math is too hard; rename +3.3V to 0V, 0V to -3.3V and -10V to -13V and the math will be easy.
or
Set R1 so there is 3.0V across it and R2 has 10.3V across it. So -10V will read 0.3V on the ADC. (R1=30k and R2=103k) OK you can't get 103k so use 30k & 100k.
RonS.
 

MisterBill2

Joined Jan 23, 2018
18,176
Probably, to get anything close to an accurate, low-noise, stable voltage reading from an analog input you will need to use an isolation amplifier with some gain. So there is a whole lot unknown relative to your question.
 

Reloadron

Joined Jan 15, 2015
7,501
Hello,

I would like to know what can i use and how can i read input/output voltages of inverting Buck-boost (like the one shown in the image) with a microcontroller?

I should connect ground of microcontroller to a single node, like the one in red rectangle, right? (attached image).

When the Mosfet is off, that node (red rectangle) has a positive voltage. Also, the ADC of microcontroller can not read negative voltages.
Something you may want to consider is the use of an ADS1115, ADS111x Ultra-Small, Low-Power, I 2C-Compatible, 860-SPS, 16-Bit ADCs With Internal Reference, Oscillator, and Programmable Comparator . Since you mention use of a uC (micro-controller). Nice feature is 16 bit A/D and has a I2C bus out making for very easy interface. It will also measure a negative voltage as well as positive voltage using a single 5 volt supply. You may also want to read this thread which has a very good link on how the A/D works and how it measures both negative and positive voltages. This is a link on using the ADS 1115. Another nice feature is the programmable gain. A Google of ADS 1115 will bring up modules available so all the work is already done for you. Another nice to have is they have 4 single ended or two differential channel analog inputs.

Ron
 

Ian0

Joined Aug 7, 2020
9,669
Are you thinking of implementing the control of the buck-boost converter digitally?
If so, I wish you luck.
There's a reason that there is a huge choice of analogue switched-mode supply controller ICs.
 

MisterBill2

Joined Jan 23, 2018
18,176
Digital control of a switching power supply, if it is intended to provide regulation and current control, may not be as good as internal analog control schemes normally are. The computer doing the control is simply not able to think that fast, to put it ion plain terms. And the intermediate stages needed to protect the inputs from assorted spikes and noise will make it even slower. Not much way around that, considering also the delay in A/D converters.
There is a good reason that the best minds in the industry use analog circuits to operate in switcher mode power supplies.
 

Thread Starter

Tiago Rocha

Joined Jul 12, 2021
30
Digital control of a switching power supply, if it is intended to provide regulation and current control, may not be as good as internal analog control schemes normally are. The computer doing the control is simply not able to think that fast, to put it ion plain terms. And the intermediate stages needed to protect the inputs from assorted spikes and noise will make it even slower. Not much way around that, considering also the delay in A/D converters.
There is a good reason that the best minds in the industry use analog circuits to operate in switcher mode power supplies.
I was thinking about controlling the MOSFET with 100kHz pwm frequency.
Will the microcontroller fail the job? I'm using the Infineon XMC4500 Relax kit and it (supposedly) has enough speed to read and control the mosfet.
 

Ian0

Joined Aug 7, 2020
9,669
The microcontroller might manage it, but will your software?
Have you read and understood Network Analysis and Feedback Amplifier Design by Hendrik Bode?
How well do you understand digital signal processing? How well do you understand how to control the phase response of the feedback loop? Do you understand the Nyquist criterion for stability, as well the Nyquist's sampling theory?
And why would you want to spend £34 on the Infineon XMC4500 Relax kit when a UC3842 costing 34p would do the job?
 
Top