EEVblog Electronics Community Forum

EEVblog => EEVblog Specific => Topic started by: EEVblog on June 15, 2013, 12:43:02 am

Title: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: EEVblog on June 15, 2013, 12:43:02 am
How a diode voltage inverter circuit works.
Turns any PWM or clock signal into a low power negative voltage rail.
This can be clocked from a microcontroller, existing DC-DC converter, 555 timer etc.

EEVblog #483 - Microcontroller Voltage Inverter Tutorial (https://www.youtube.com/watch?v=LtoPHevexTM#ws)
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: c4757p on June 15, 2013, 12:57:15 am
Deja vu?  :) Oh, inverting!
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: EEVblog on June 15, 2013, 01:02:10 am
Deja vu?  :) Oh, inverting!

The same, but different  ;D
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: Rufus on June 15, 2013, 01:43:29 am
I think it worth noting that these charge pumps put large current spikes into the supply and ground rails of what is driving them particularly on start up. You can add some series resistance to the drive to reduce the amplitude and loose a bit of performance.

Not likely to cause damage but it will generate noise.

Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: dentaku on June 15, 2013, 01:46:49 am
Nice.
When you where getting that ripple I was wondering if you can use something similar to this method to change a square wave signal into a saw wave? Preferably one that's not shifted up or down.
It would be useful for the basic junky breadboard synth experimentation I'm interested in.
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: EEVblog on June 15, 2013, 04:14:05 am
When you where getting that ripple I was wondering if you can use something similar to this method to change a square wave signal into a saw wave?

Many better ways of doing that I'm sure.
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: nitro2k01 on June 15, 2013, 09:22:43 am
Nice.
When you where getting that ripple I was wondering if you can use something similar to this method to change a square wave signal into a saw wave? Preferably one that's not shifted up or down.
It would be useful for the basic junky breadboard synth experimentation I'm interested in.
The problem is with producing a saw from a square is that the square wave amplitude signal is inherently missing information about the slope of the corresponding sawtooth wave. Most naive attempts to build a square->saw converter will make the amplitude vary with the frequency, because the angle of the slope is kept the same and the phase is just reset on one of the square's edges.

One way of solving it is with a PLL (phase locked loop) as shown here: http://electro-music.com/forum/topic-31920.html (http://electro-music.com/forum/topic-31920.html)
The circuit consists of two chips. A 4046 PLL chip which generates a higher frequency square wave which tracks the input, and a 4024 binary counter, which is then fed into a cheapo r2r DAC consisting only of a resistor ladder. In a practical circuit you may want to  put an op amp buffer at the end as well.

I suspect you're building your own oscillator, and you have simply only built a square wave oscillator so far (maybe a 555 or a simple op amp oscillator.) If so, you might want to ditch the idea of getting a sawtooth from a squarewave and look up options for sawtooth VCOs. You'll have to add a couple more components, but it will be worth it. I can personally recommend the XR-VCO as a versatile and fun voltage controlled oscillator, though that's a bigger project yet.

http://www.birthofasynth.com/Thomas_Henry/Pages/XR-VCO.html (http://www.birthofasynth.com/Thomas_Henry/Pages/XR-VCO.html)

Good luck!
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: poorchava on June 15, 2013, 12:30:47 pm
I'm using this method to get opamp negative voltage, especially when I have 2 spare HC14 channels somewhere. It only adds 3 ceramic caps, one resistor and a BAT54S or equivalent diode.

Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: Rasz on June 15, 2013, 08:10:12 pm
The more you show this scope the worse it looks.
Pixel doubled horizontally with no aliasing, looks like something running on C-64.
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: NiHaoMike on June 15, 2013, 09:35:41 pm
I think it worth noting that these charge pumps put large current spikes into the supply and ground rails of what is driving them particularly on start up. You can add some series resistance to the drive to reduce the amplitude and loose a bit of performance.

Not likely to cause damage but it will generate noise.
Or for a "lossless" solution, use an inductor. (The ones I have built were too small to need that. I just use a resistor since the losses are negligible at the currents I use them at.) You'll definitely want to have series resistance or inductance if you're driving it with a DC/DC converter since the spikes can false trip the overcurrent protection.
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: dentaku on June 16, 2013, 12:27:24 am

I suspect you're building your own oscillator, and you have simply only built a square wave oscillator so far (maybe a 555 or a simple op amp oscillator.) If so, you might want to ditch the idea of getting a sawtooth from a squarewave and look up options for sawtooth VCOs. You'll have to add a couple more components, but it will be worth it. I can personally recommend the XR-VCO as a versatile and fun voltage controlled oscillator, though that's a bigger project yet.

http://www.birthofasynth.com/Thomas_Henry/Pages/XR-VCO.html (http://www.birthofasynth.com/Thomas_Henry/Pages/XR-VCO.html)

Good luck!

That looks good. I'll have to read that tomorrow.
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: einstein on June 16, 2013, 04:50:55 pm
How much current can you draw from such a circuit, can you calculate/estimate that with a formula if you have the capacitor value's? What if you use 4700µF caps? Same question for the voltage doublers?
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: Rufus on June 16, 2013, 05:00:57 pm
How much current can you draw from such a circuit, can you calculate/estimate that with a formula if you have the capacitor value's? What if you use 4700µF caps? Same question for the voltage doublers?

I bet Einstein could work it out.

Go read the voltage doubler vblog thread again.
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: einstein on June 16, 2013, 05:37:30 pm
So with the 4700µF and a switching frequency of 100 hz, and a supply voltage of 5 volt and ideal diodes, i have 4700*10^-6*5*100= 2.35 Amps? Is that right ?
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: nitro2k01 on June 16, 2013, 06:37:17 pm
einstein: You can't just choose random component values without knowing what the hell you're doing. With a 4700 µF cap, you'd nearly short out the rails on each cycle. The current spikes will cause you a lot of problems. But if you have a +5V power supply, and transistors, which can handle 10-20A peak current, (subject to be limited by wire resistance and capacitor ESR) and you don't mind the microcontroller rebooting a few times due to a brownout condition during startup, and maybe later too, then go for it.
(Or put if you can't see through the layer of sarcasm, no, you're doing it wrong.)
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: Rufus on June 16, 2013, 06:38:34 pm
So with the 4700µF and a switching frequency of 100 hz, and a supply voltage of 5 volt and ideal diodes, i have 4700*10^-6*5*100= 2.35 Amps? Is that right ?

With an ideal driver and into a short circuit load - yes.
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: einstein on June 16, 2013, 08:38:04 pm
So it would give you 2.35amps, but it's very hard to realise it cause of the high capacitor charge currents...
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: Rufus on June 16, 2013, 09:05:22 pm
So it would give you 2.35amps, but it's very hard to realise it cause of the high capacitor charge currents...

Only into a short circuit. With ideal components it is equivalent to a -5v supply with 2.1 ohms in series.

So for example at 0.5A it would output about -4v.

Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: SeanB on June 17, 2013, 05:30:26 am
Driving it using a 4700uF cap will work, but you will be using a pretty big switch, like an audio amplifier chip. I did once use 2200uF and a TDA2009 to make a voltage doubler and it did work, but needed a pretty big heatsink on it as well. Ran at around 5kHz, and whistled a little in the input capacitors and inductor filter.

Using a MCU pin you will be hard pressed to have more than about 2mA of output current before you have appreciable voltage droop. Not much but often good enough to use in low power circuits. If you need more it will be better to use an inductor or a transformer based supply and a regulator chip.
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: Telequipment on June 18, 2013, 06:58:48 pm
Thank You Dave  ,I really enjoy these videos , and the down to earth way you explain them, unlike the evening class teacher ,who can send me to sleep in seconds, you have my full attention
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: joaoc on June 18, 2013, 08:14:20 pm
Hey Dave. I follow your VBlog for a long time but i've never registered myself.

Great videos and topics by the way!

This video made me thinking... You talked about using this in a opamp, and i've seen it being used like that, but i'm with a doubt here, this negative supply is only good for a few uA, while the positive could be capable of Amps.
How will the opamp deal with this very different (capable) supply currents? will it "suck" all from the positive supply?

Thanks

Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: einstein on June 19, 2013, 12:01:23 pm
I think that for a correct operation, the opamp current is limited to the current out of your inverter. Correct me if i'm wrong.
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: EEVblog on June 19, 2013, 12:11:50 pm
This video made me thinking... You talked about using this in a opamp, and i've seen it being used like that, but i'm with a doubt here, this negative supply is only good for a few uA, while the positive could be capable of Amps.
How will the opamp deal with this very different (capable) supply currents? will it "suck" all from the positive supply?

No, that's not how it works. A component like an opamp will only take the current it needs. The opamp does not know nor care what current the supply is capable of delivering, only that it can deliver what it needs.
That is a common beginner misconception about voltage and current.
Think of your mains power point. It is capable of delivering 10A maximum current, but if you plug in something that only needs 0.1A, then it only takes 0.1A from the mains socket. The main power socket or supply does not force 10A into the item that is plugged into it.
Same with your car battery, or any other voltage source like this inverter.
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: BravoV on June 19, 2013, 12:13:05 pm
Hey Dave. I follow your VBlog for a long time but i've never registered myself.

Great videos and topics by the way!

This video made me thinking... You talked about using this in a opamp, and i've seen it being used like that, but i'm with a doubt here, this negative supply is only good for a few uA, while the positive could be capable of Amps.
How will the opamp deal with this very different (capable) supply currents? will it "suck" all from the positive supply?

Thanks
As Dave said, there are many methods to generate this negative and/or higher positive rails as previous episode.

Here is the example other method using cheap discrete components in generating positive & negative 15 volt from a single 5 volt source, capable of sourcing few teens of mA of current that should be enough for simple & common op-amp usage, thanks to Jay_Diddy_B for the design.  :-+

(https://www.eevblog.com/forum/projects/design-charge-pump-for-lcd-backlight/?action=dlattach;attach=49166;image)

More details in this thread -> Design: Charge pump for LCD backlight (https://www.eevblog.com/forum/projects/design-charge-pump-for-lcd-backlight/)
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: joaoc on June 19, 2013, 03:51:35 pm
This video made me thinking... You talked about using this in a opamp, and i've seen it being used like that, but i'm with a doubt here, this negative supply is only good for a few uA, while the positive could be capable of Amps.
How will the opamp deal with this very different (capable) supply currents? will it "suck" all from the positive supply?

No, that's not how it works. A component like an opamp will only take the current it needs. The opamp does not know nor care what current the supply is capable of delivering, only that it can deliver what it needs.
That is a common beginner misconception about voltage and current.
Think of your mains power point. It is capable of delivering 10A maximum current, but if you plug in something that only needs 0.1A, then it only takes 0.1A from the mains socket. The main power socket or supply does not force 10A into the item that is plugged into it.
Same with your car battery, or any other voltage source like this inverter.

Yes i know that. Maybe i didn't explain myself right...

Imagine that you have an opamp with split supply. The positive side is can delivery 500mA but the negative can only give 50uA, and in a given moment the opamp is requesting lets say 400mA. Will that come from the positive + negative rails, or just from one? if from both how is distributed?

I guess the question goes to: in a opamp circuit makes any difference the current capability of the negative supply (considering that the possitive has  enough juice)?
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: c4757p on June 19, 2013, 04:53:07 pm
Well, is it sinking or sourcing current? It will source from the positive rail and sink to the negative. Its quiescent operating current flows from the positive rail to the negative, so both equally. If it overdraws on the weak negative rail, the rail will collapse as demonstrated.
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: joycer182 on August 05, 2013, 06:08:50 pm
Hi folks!!! I'm new around here. Kudos for blog and forum are amazing :clap: .

I have a question, how can I use this circuit (used by dave in the video) to feed the negative rail of an opamp?

I tried to use it directly, but it doesn't works. The voltage drop down to 0V (few milivolts).

I'm using an opa2209 from texas instruments, I mesure the consumption for the negative rail, is 4mA tops, I use it as a non inverting amplifier.

How can I do or what do I have to do to get from the dave's circuit at least 5mA without voltage drop?

Thank you very much.

Best Regards.
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: nitro2k01 on August 05, 2013, 09:25:21 pm
4 mA should not be a problem. (Subject to the capacitor size.) More information please. Does the circuit appear to work with no opamp connected? Have you double checked the schematic? Which capacitor size do you use? What is the system Vcc? What are you using to drive the circuit? Maybe your microcontroller's IO ports can't drive enough current.
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: EEVblog on August 05, 2013, 09:51:11 pm
It's a combination of capacitor size and frequency. It should not drop to zero, something sounds wrong.
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: joycer182 on August 06, 2013, 06:09:12 pm
Hi, Thanks for quick response.

Attached you can find what I'm trying to do, it's a simple amplification of a signal from a LDR sensor. The signal is received by a 12bit ADC converter and sent to microcontroller to report to PC through USB.

The trouble is when the circuit is on (+5V usb power) the opamp doesn't work, I measure the -Vcc (out from the voltage inverter) and I get 0V, and without opamp I get aprox. -4,3V. I guess the opamp is not getting the mA that it needs.

In the past I measured the current consumption from the negative rail and I get aprox. 4mA. Thats why, as I said before, I need at least 5mA.

What I need to do to do what I need?

How I can estimate the capacitor I need?

Thanks again, Dave this community is amazing.

Best Regards.
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: Rufus on August 06, 2013, 08:55:38 pm
In the past I measured the current consumption from the negative rail and I get aprox. 4mA. Thats why, as I said before, I need at least 5mA.

With 1uF to ground on its output the opamp is probably oscillating.

The charge on the pump capacitor Q is CV where V is the 5v less two diode drops. That is about 370nC and pumping it 5000 times a second is a current of 1.85mA. That is into a short circuit, the pumped current will drop to nothing as the output voltage approaches -3.7v.

For -2v output the voltage change across the capacitor is 5 - 2 diodes - 2v = about 1.7v and 170nC, at 5kHz that would be 0.85mA. 

You need a bigger capacitor and/or higher frequency, but, choosing a better opamp is preferable and if you chose a rail-rail opamp you would not need a -ve supply at all.

Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: joycer182 on August 06, 2013, 09:58:31 pm
Hi Rufus, the parameters that I choose was aleatory and with thats values I have those results.

There is no problem for me to change the frecuency, the cap values, etc. I only need a guidance in order to get it works.

Quote
That is about 370nC and pumping it 5000 times a second is a current of 1.85mA

How you calcutale the current with the frecuency?


when you say this:

Quote
With 1uF to ground on its output the opamp is probably oscillating.

You referred to the input of ADC converter (out from the op amp) that has a 1uF cap?
You recommended to remove?

Thank you.
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: c4757p on August 06, 2013, 10:14:29 pm
Quote
That is about 370nC and pumping it 5000 times a second is a current of 1.85mA

How you calcutale the current with the frecuency?

One amp is one coulomb per second. 370nC * 5000Hz = 1.85 mC/s = 1.85 mA.
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: joycer182 on August 06, 2013, 10:24:30 pm
jajajjaa How could I forget something like that  :-DD   :-+

Thanks c4757p
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: joycer182 on August 07, 2013, 01:54:00 pm
Hi,

c4757p:
Quote
That is about 370nC and pumping it 5000 times a second is a current of 1.85mA

My confusion was that those 370nC I don't know where he got them (rufus).

Rufus:
Quote
You need a bigger capacitor and/or higher frequency, but, choosing a better opamp is preferable and if you chose a rail-rail opamp you would not need a -ve supply at all.

The opamp that I chose is good for my application, in my country is to hard to buy good stuff, this opamp I bought in mouser electronics, and buy this way is difficult for me. In my country we have exchange control and we don't have much dollars per person (incredible, right?).

I would like to use this opamp (opa2209), when I chose it I don't noticed one detail, this opamp needs at least -3.5V in the negative rail to work properly. So I can't uses with a single supply, in my research I found the Dave's article and I thought this is the solution.

So, change the opamp is not (for now, recently we have problems with imports) an easy solution (I only found in my country ua741, LM358, nothing good enough).

Easy to design here, right?  :'(

I hope you can help me.

Best Regards.
Title: Re: EEVblog #483 - Microcontroller Voltage Inverter Tutorial
Post by: joycer182 on August 10, 2013, 10:04:14 pm
Hi, finally I did it, the circuit is working fine for my application  O0 :-+ . I changed the values of capacitors and PWM frequency and I get great results.

Without the opamp connected to (-Ve) I got -4,16 Volts, and connected I got -2,60 Volts, enough to operate the opa2209.

According datasheet the Common-Mode Voltage Range in opa2209 = (-Ve) + 1,5 Volts, for me would be = -2,60 Volts + 1,5 Volts = -1,1 Volts. Which means I can operate the opamp well.

In the attached file you can find my final config. It works great for me, my amplifier arrangement finally works using a single supply and the dave's voltage inverter circuit. Experimentally I got these results:

Entry signal to amplifier = 0,019 Volts  :-DMM
Out Signal from the amplifier = 0,206 Volts  :-DMM

Theoretically amplifier gain is 11, and I got (0,206 / 0,019) = 10,84 Experimentally  ;D.

Thank you everyone for help me out.

Thanks dave, rufus, c4757p.  :clap: