 # Puzzle solved! "rail - rail" op amp buffer; chinese IC's were all junk.

I'm testing "rail to rail" op amps using this simple circuit - a non-inverting buffer.
Using a UNO I generate a series of step voltages using PWM at 31kHz or 3.9kHz using an RC filter.
(I've tried both with identical results)
The step voltage is sustained for around 400-500msec between changes.
Step voltage is calculated by measuring Vcc with the "secret voltmeter", then Vstep = n * Vcc/255.

I measure the voltage vFilter at the input of the op amp and VDUT at the output, using A0, A1 ADC's.

Here is the simple test circuit and here the results using three different modern op amps; LMC6482, TLC2272, TLV2462

The graphs are created in excel by copying and pasting the output from the serial monitor, plotting VFilter and VDUT against the calculated ouput voltage in mV.

I've included the code for completeness although I dont feel its very relevant, as it works very well with the LMC6482, and all I have done between tests is change the op amp. Even the pin-outs are identical.

I've also checked the results (roughly) with a 10k potentiometer providing the input voltage, and measuring voltages with multimeters. So it would not appear to be connected to the program or measurement using the arduino.

The puzzle -
1: why is the filter voltage affected - the input bias current for the op amps should not move it more than a millivolt at most.

and the output -

2: why does the tracking misbehave above 4500mV - limited compliance? but the load is just the adc input.

3: but why does it go crazy below 1500mV?

The TLC2272 and TLV2462 are referenced in this TI application note -
Application of Rail-to-Rail Operational Amplifiers solarChar.ino (6.73 KB)

johnerrington:
I'm testing "rail to rail" op amps using this simple circuit - a non-inverting buffer.
Using a UNO I generate a series of step voltages using PWM at 31kHz or 3.9kHz using an RC filter.
The voltage is calculated by measuring Vcc with the "secret voltmeter".
I measure the voltage vFilter at the input of the op amp and VDUT at the output, using A0, A1 ADC's.
Here is the simple test circuit

Hi there John. You mentioned PWM at 31 kHz or 3.9 kHz. So maybe one question is ---- why 'or'? Which is it? 31 kHz? Or 3.9 kHz?
You did mention that you plotted one quantity against the other. But the graphs should probably have labels and units --- just to make sure everything is clear.

Also, the PWM in going into that RC filter. The voltage that you calculate ------ still needs to be a time-averaged voltage maybe, right? That's because the output of the RC filter is not going to absolutely constant.

Looking at the time waveforms (input to the op-amp as well as output of the op-amp) on an oscilloscope may provide some clues too.

And - general multimeters typically provide 'RMS' sort of measurements ----- and usually involving either constant 'DC' voltage or current measurements, or measurements on sinusoidal waveforms, and maybe it can get RMS of squarewaves and/or PWM waveforms too. But you have an RC charge/discharge circuit .... so the result might not be meaningful all the time.

Thanks @Southpark, I've amended graphs and aded an explantion of the pwm.

Yes Vout (average) = n * Vcc/255 where n is the pwm value sent to digital out.

Measurement with a DC voltmeter shows the correct values when N=0 and N=255

The filter is chosen to have a cut-off several octaves below the PWM frequency, but well above the step shanhge frequency to avoid degrading edges.

Hi,
What if instead of unity gain, you configured for some gain, you may need some input series resistance to help with that initial offset you see at 0V input on the 2272, 2462.

Tom... 2: why does the tracking misbehave above 4500mV - limited compliance? but the load is just the adc input.

Which is about 10K load impedance (capacitive). Note that most of the data and graphs in the datasheets are specified at No Load. The LMC6482 has the best loading characteristics. For the TLC227, see the various plots with 10K loading.

Did you try adding a load resistor on the low impedance op amp output ?
Are you sure a single pole filter is enough ? Have you tried cascading RC filters ?

The distortions in the graphs correlate with the several orders of magnitude increases in the input bias currents: 20 fA, 1 pA and 4.4 nA, for the LMC6482, TLC2272, TLV2462 respectively.

@jremington - they do. The LMC shows no distortion of filter or VDUT

@dlloyd - no, the input of the ADC is (21-6-1 ) 1-100k in series with 14pF: RAin = 100M (26.8)

I'll try it with some gain and see what happens.

The filter - vripple should be 50dB down with a 31kHz PWM and 720Hz Fc.

Did you try adding a load resistor on the low impedance op amp output ?

no, but its a thought. something else to try.

no, the input of the ADC is (21-6-1 ) 1-100k in series with 14pF: RAin = 100M

Yeah, but your plots show 2 inputs in use, so ...

The problem with high source impedances arises when you are switching the input multiplexer from one pin to another. If you have two inputs, one at 0.5V and one at 4.5V, when you switch from one to the other, the input has to charge (or discharge) that 14 pF capacitor.

If the signal source is very high impedance, having to charge the capacitor may cause the input voltage to drop temporarily. If the ADC converts on the input while is is still charging the capacitor, you will get an incorrect value.

I would try a test using just one ADC input or alter your code to capture the data for each input separately or allow more settling time, then view with serial plotter.

Also the input and output "SHOULD" be the same so the 0.14 microsecond time constant should not be an issue.

If the signal source is very high impedance,

• it isnt. In fact R VDUT should be about 100 ohms.

Not being disparaging Dlloyd, your thoughts are gratefully received and helping me to check for what isnt the issue.

I've also tested with a gain of 2 - even worse, see pic!

I can understand for example the point of encoding a waveform such as an audio waveform using PWM, and then using a low pass filter having a suitable cutoff frequency to recover the audio waveform - with a bit extra to be done such as removing DC offsets. Or PWM for driving a DC motor directly.

But having a regular PWM waveform with a pwm period of approximately 31 kHz presented to the input of low pass filter ------ is probably something I didn't expect we would need to ever do. Is the applied PWM a 50% duty cycle one?

Maybe grabbing an oscilloscope - and observing the waveform at the input to the op-amp (at the '+' terminal) will allow us to see some dynamic activity at that node. And can use the scope to check out the voltage at 'A1' ----- the op-amp output too.

Silly question but is this some kind attempt to make a DAC ?
I totally understand the desire to test rail to rail op amps which I think you are doing a very good job of, but wht is the purpoe of the filter ? Is that to compare performance ? If so it seems to be working.

johnerrington:
I generate a series of step voltages using PWM at 31kHz or 3.9kHz using an RC filter.
(I've tried both with identical results)

The step voltage is sustained for around 400-500 msec between changes.

A 31 kHz PWM waveform has an approximately 0.032 millisecond period.

And a 3.9 kHz PWM waveform has 0.256 millisecond period.

Does the step voltage of 400 to 500 millisecond relate in some way to the PWM duty cycle? The maximum duty cycle in a 31 kHz PWM waveform of 100% would correspond to just 0.032 millisecond.

Does the step voltage of 400 to 500 millisecond relate in some way to the PWM duty cycle? The maximum duty cycle in a 31 kHz PWM waveform of 100% would correspond to just 0.032 millisecond.

the term "step" is a reference to how long the filtered output sustains the commanded voltage by virtue of the pwm command. The step ends when he changes the pwm command. It has nothing to do with the duty cycle because it refers to the filtered output . (as I see it. John can 'concur' (or not))

Consider what duty cycle is used. And then predict the output of the RC filter based on the duty cycle (high time and low time) of the input PWM signal. Predict that output versus time. This gives an idea about how the output voltage of the RC filter will change with time ----- we get an idea of time scale. And then determine whether or not it makes sense to use the ADC of the arduino to do what you're aiming to do.

Well first of all , it’s a low pass filter so it basically
converts pwm to dc but the cutoff frequency is 10
times higher than what you would need to get dc
(I usually use 4.7k and 4.3uF which has an fc of 7.8 Hz)
He obvious doesn’t want dc because his fc is 720 Hz so he has some other objective.

“Consider what duty cycle is used. And then predict the output of the RC filter based on the duty cycle (high time and low time) of the input PWM signal. Predict that output versus time. This gives an idea about how the output voltage of the RC filter will change with time ----- we get an idea of time scale. And then determine whether or not it makes sense to use the ADC of the arduino to do what you’re aiming to do.”

I’m not sure I know what he is trying to do.

is this some kind attempt to make a DAC

yes, as the Uno lacks a DAC I'm using PWM - DC as also described here

At 31kHz Xc = 1k and R =47k so there is a residual 2% ripple.
I COULD make C bigger, but only at the expense of degrading the edges of my step waveform.
Presently the rise time is 0.2mSec so within 0.1% at 1.4msec.

Step waveform - series of successive voltage increases from 0 to Vcc with a step duration of around 250msec. The marker dots on the graphs indicate step points.

I usually use 4.7k and 4.3uF which has an fc of 7.8 Hz

presumably using a 470Hz or 940Hz PWM?

To be clear on my objectives I'm putting together a tutorial / short list of op amps for arduino projects; yes I know there will be exceptions but these should cover most applications. So I needed to test them (and my assumptions)

Just for silliness I tested a TL062 - which is NOT rail-rail. The results are pretty much as you would expect.

Note - it DOESNT change the vFilter line, VDUT tracks Vfilter "reasonably well" between 1.5 - 4.0 V and as expected from the data sheet, the output can not be much more then Vcc-1 or less than 0V +1; and the "phase change" at 0v is documented in the data sheet.

I'm rapidly concluding the TLC & TLV are faulty - new -well, unused but I've had them a little while. I've tested another of each from the same batch - same results. I've ordered new ones.

Did you try it without Arduino and other sources of digital noise? Such as potentiometer (for input voltage swing), op amp and DMM?

Ok ....... just getting my bearings straight here heheh. A pwm waveform have say a peak voltage of say 5 volt ---- has a time-average (over a single pwm period) equal to the duty cycle times 5 volt.

So if the duty cycle happens to be 50% (with 50% of the time being 5 volt and 50% of the time being zero volt), then the average voltage over 1 pwm period will be 2.5 volt.

The thing here is ..... when PWM is produced by a circuit ----- and if we just so-happen want to measure the time-average of the voltage over 1 pwm period, then we would need a device or method that can actually do that for us. A device that actually does provide a result equal to the average voltage over one period ----- such as an RMS measurement, or something. It probably won't be just a case of an RC circuit with a single ADC measurement.

yep, very first post

I've also checked the results (roughly) with a 10k potentiometer providing the input voltage, and measuring voltages with multimeters. So it would not appear to be connected to the program or measurement using the arduino.

if we just so-happen want to measure the time-average of the voltage over 1 pwm period

but I'm not; I'm using the RC filter to get the average voltage across 31kHz * 0.25 sec (or thereabouts)
= 8000 periods.

To get the average across 1 period you would need to sample at around 1000 samples in that period.