Can somebody explain rail-to-rail input/output?

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.
May 11, 2008
22,551
1,471
126
:)

One more thing you should know, because the whole success of your amplifier / effects processor will depend upon it. It is most undesirable to have a loud "pop / click" noise when you turn your pre-amplifier / guitar effect processor while connected to the PA amplifier. Because this can kill speakers and PA amplifiers and makes for a very disturbing "bang" to the audience. The audio technicians will not like you after such an event, i can promise you that.

Always make sure that your electronic device has support electronics added with it that prevent such "pop / click" sounds at powerup and powerdown.

I should note that although the example circuit i made works, it is far from ideal. At powerup, the - input of the opamp is held at 0,82V because of the empty 100uF capacitor C3. The +input is held at almost ~2,5V. Because of the empty 10uF capacitor C1 and the high output impedance of the guitar element.
Thus the output of the opamp may at powerup swing from 0V to +9V for a moment because the +input is more positive then the - input.
You may hear this as a loud pop noise at power up.
The output dc level should stabilize at 0V within 250ms after powerup with a 10kΩ resistor load. It might be a good idea to add this resistor at the output since most amplifiers have an input impedance of about 50kΩ.

It seems that the 100uF capacitor C3 in combination with the LT1490 has the effect in the simulation to not create a powerup "pop or click" noise.
I do not know if this is a simulation error or not.
 
Last edited:
May 11, 2008
22,551
1,471
126
The red signal is the + input voltage of the opamp.
The green signal is the output voltage of the opamp.
The seacolour signal is the voltage over the load.
You can see it stabilizes after about 250ms at 0V.

dclevelpowerup.jpg
 
Last edited:
May 11, 2008
22,551
1,471
126
I forgot the following checkbox [Start external DC supply voltages at 0V] at the transient tab of the spice analysis :
I have checked it and now it also shows the powerup "pop / click" bulge in the output voltage.
 
May 11, 2008
22,551
1,471
126
Here is a better example :
Use another opamp to generate half the supply voltage used as a bias voltage.
This voltage becomes the virtual GND level for the circuit and now you have a +4,5V supply together with a -4,5V supply seen from V_div2.
This makes it easier to provide a bias voltage to your circuit.

The 220Ω resistor is needed because opamps do not like it when the output is connected to a large capacitive load directly to GND.
Large capacitive loads on the output of an opamp may cause an opamp to oscillate.
The 220Ω resistor makes the load resistive again.

The divider resistors are 100kΩ but can easily be 1MΩ. This will lower static current draw and increase battery life time.
After about 0.5 to 1 second, the output is stabilized at 0V and ready to work.
The frequency response is still good.
I increased the timestep in the transient analysis to 1us from 100ns for faster calculation.
There is hardly any pop or click bulge, this should work much better.



opamppu.jpg
 
Last edited:
May 11, 2008
22,551
1,471
126
I read that you wanto to use 5V or lower supply sources.
What you need is low power optimized opamps such as the LMV358 or the TLV271.
The LMV358 is the low power version of the LM358.
Both LMV358 and TLV271 are rail to rail output opamps.
The inputs work grom GND level up to VCC - 1,35V for the TLV271 and GND up to VCC -1V for the LMV358.


product pages :
http://www.ti.com/product/lmv358

http://www.ti.com/product/tlv271

Special low noise low distortion and low power audio opamp : LME49721
This one is rail to rail input and output as well.
http://www.ti.com/product/lme49721#description

The NE5234 from NXP :
http://www.nxp.com/products/amplifiers/operational_amplifiers/series/NE_SA5234.html
 

dwell

pics?
Oct 9, 1999
5,185
2
0
WG: Great info. Thanks again. Need time to parse it all. Think you can share the LTS project from the post above so I can check it out?

I just got a bunch of LM358 ICs in from China. I'm able to build amps the run at 5v using inverted op-amp schematics. My ultimate goal is to pump it into an Arduino's analog in for signal processing. I think I got the signal in ok, not working on DSP and output.

Use a circuit similar to:

https://instruct1.cit.cornell.edu/courses/ee476/FinalProjects/s2004/ddb25/complete2.htm

Minus the diodes. I don't understand the purpose. Voltage limiting?
 
May 11, 2008
22,551
1,471
126
WG: Great info. Thanks again. Need time to parse it all. Think you can share the LTS project from the post above so I can check it out?

I just got a bunch of LM358 ICs in from China. I'm able to build amps the run at 5v using inverted op-amp schematics. My ultimate goal is to pump it into an Arduino's analog in for signal processing. I think I got the signal in ok, not working on DSP and output.

Use a circuit similar to:

https://instruct1.cit.cornell.edu/courses/ee476/FinalProjects/s2004/ddb25/complete2.htm

Minus the diodes. I don't understand the purpose. Voltage limiting?

Indeed. The diodes are used to limit the signal voltage to GND-0,6V and VCC +0,6V.

image005.jpg


From the schematic i get the impression that the opamps are fed by a separate dual rail powersupply. From the text it is noted that the powersupply for the opamp must be more positive than +5,5V and more negative than -5,5V.

However...
If i am not mistaken, the ADC stage of an atmel mega mcu cannot process voltages more negative than GND level or more positive than AVCC(the reference voltage of the ADC). Hence the diodes. And here also the problem can be found. The opamps have a symmetric powersupply seen from GND and operate with GND as reference level. The circuit however works with 2,5V as reference level. This is the bias voltage, similar as the circuit as shown in post 29 of this thread. When the ADC has a reference voltage of 5V and is 10 bits, it means that 2,5V is equal to value 512. 10bits is 1024 ADC counts is equal to 5V. Just do reference level divided by the maximuam amount of ADC counts. 5V/(1024-1) = 4.89mV per ADC count.
2,5V is 512 ADC counts. Thus you can use a single supply opamp as well instead of a symmetrical dual supply.

You will have to take my word for this, but the 10 bits of the ADC cause enough distortion (THD) that the distortion(THD) of a single supply opamp with respect to symmetrical supplied opamps is not relevant.
Do note that this is a very low number. In practice you would not notice since you are going to distort the signal anyway.
 

dwell

pics?
Oct 9, 1999
5,185
2
0
Having trouble totally getting this.

Arduino expects a 2v range with a DC offset of 1v:

http://www.instructables.com/id/Lo-fi-Arduino-Guitar-Pedal/step4/Normalize-the-Input-and-Output/

This is the only real "trick" when it comes to the hardware for this system. Audio happens as an AC signal from -1 V to +1 V, but the analog inputs on the Arduino run from 0 V (Ground) to some positive voltage called the analog reference (5 V by default). You can specify this positive voltage in code or with an external reference.

Since -1 V to +1 V is a 2 V range, we'll choose something smaller than 2 V for our analog reference value. It turns out 1.1 V is specified as a built in internal reference, which works out nicely.

So I take the output which is 5v with a 2.5v output and fork it one way across a voltage divider to get ~2v with a 1v offset and another across a capacitor to set it to 5V with a 0v offset.

This should work and is the right thing to do, right?

U8OPP.png


Output clips a lot after the second amplification stage.

Project:

https://www.dropbox.com/s/vg0w7ul5ux9rmzt/lm358amp.zip
 
May 11, 2008
22,551
1,471
126
The idea is that you work your way back from the end to the beginning.

Forget the range of 1 V to -1V.
What you want is the best possible analog to digital conversion of your signal, using almost all available bits.
Assuming you have an actual 5V reference for your ad converter, i would use that. Using a 2,5Volt bias, you have a +2,5V range to -2,5V range.
Another advantage of a harder signal is that your signal will then be more louder than the noise that you do not want.
High quality pre-amplifiers for audio systems may work at voltages of 20V while only outputting a signal to 1V amplitude. A very large dynamic range with low noise from the environment :eek:

Thus you know that your amplifier must amplify your input signal (a 1kHz sine wave) to a maximum level of 5V peak to peak also written as 5Vtt. This means that your amplifier can amplify your signal to a maximum of +2,5V for the positive peak and -2,5V for the negative peak. Thus the maximum amplitude of the signal is 2,5V.

images


f0333-01.jpg



A given situation :
Assume you are inputting a signal that is a sine wave of 1kHz and with a given maximum amplitude. Take for example an amplification factor of 10. This means that when the peak to peak signal is 5Vtt your input signal can be a maximum of 5Vtt / 10 (amplification factor) = 0,5Vtt. Thus a maximum amplitude of 0,25V for a sine wave. You can also calculate the RMS value but that is not important in this case. RMS value is not important when designing the pre amplifier for the analog to digital converter = ADC.
You are only interested in the maximum value peak to peak.



In reality you should use an amplitude that is a bit lower to keep the THD low. For example 2,45V or 2,4V.
Otherwise you are going to clip your signal at the ADC stage and transform your signal into a square wave and will be a cause for unwanted distortion.
But you want to perform the distortion and signal manipulation in software, thus you want proper amplification in hardware only, no wanted distortion in the hardware.
Of course there will always be some THD but you want to keep that as low as possible when it is unwanted.
 
Last edited:
May 11, 2008
22,551
1,471
126
I will give you some more hints :
You have a guitar element. That element will produce a certain signal with a given amplitude. I am sure, that the element has a specification sheet explain how much signal it can produce as a maximum amplitude in a certain load impedance.

After doing a quick lookup, i found values ranging from 50mVrms to 1Vrms. The amplitude can be found by multiplying the rms value with 1.414 for a sine wave : The square root of 2.

If we assume you can have an input signal between 50mVrms and 1Vrms : 70mVpeak to 1.414Vpeak amplitude.

Now you know the minimum input signal level and the maximum input signal level.
Thus now you can start to create the first raw design specifications :

2,5V will be your bias voltage or the 0V level of the audio signal.
You can convert a signal with a maximum amplitude of 2,5V.

You want a maximum amplification for a minimum input signal of 70mV peak to get a 2,5V output signal from your amplifier stage.
You want a minimum amplification for a maximum input signal of 1.414V peak to get a 2,5V output signal from your amplifier stage.
If you calculate the amplification, which is output signal divided by input signal, you can calculate the needed resistors and potentiometer value for minimum and maximum amplification.

After prototyping you will need to make some adjustments such as lowering the maximum amplification to prevent clipping at the maximum input signal amplitude.

Please use the VCC/2 circuit to create a stable 2,5Volt source. You can find it in the post above. What you can also do, is remove the 100uF capacitor and remove the 220Ω resistor. Then the output of the opamp will directly compensate for any variations on the output(the 2,5V). The frequency response may change a bit, but not much to be problematic.

Good luck.
 
Last edited:
May 11, 2008
22,551
1,471
126
How to calculate the amplification of a non inverting opamp amplifier circuit :

image_thumb%25255B2%25255D.png



If you use the values of your amplifier circuit, you will find out how much your amplifier is amplifying for each separate stage.
The entire amplification is just multiplying the gain (amplification) of the first stage with the gain of the second stage.

For example : If your first stage has a gain of 10 and the second stage a gain of 20, your total amplification will be 10*20 = 200.
 
Last edited:
May 11, 2008
22,551
1,471
126
You may wonder why i am not answering your questions directly. For me it is not difficult to provide you with the complete circuit you need.
But then i would take the pleasure of creating your own circuit from you and the whole learning and solving puzzles that is a part of being creative.
Thus i decided i shall teach you how to "fish"...
It will benefit you in many ways.
^_^
 

dwell

pics?
Oct 9, 1999
5,185
2
0
You may wonder why i am not answering your questions directly. For me it is not difficult to provide you with the complete circuit you need.
But then i would take the pleasure of creating your own circuit from you and the whole learning and solving puzzles that is a part of being creative.
Thus i decided i shall teach you how to "fish"...
It will benefit you in many ways.
^_^

I definitely have all of the pieces together. Thanks for the past four posts. I agree with the "teaching to fish" philosophy.

Tell me if I am on the right path:

1. Assume a 1Vrms signal is coming out of the guitar.
2. Set the DC offset to op amp stage 1 with a voltage divider. Higher input impedance is better. I'm shooting for 2.5v bias voltage?

1. Where I am getting hung up is how to divide the amplification tasks between both stages of the op amp.
2. The AD is expecting ~1.1v. Do I need to reduce voltage before sending to analog in. Do I do it via a voltage divider, diodes, or power source voltage divider?

What's the difference between dividing with a source voltate component?

G2kRh.png


And limiting the output via a divider?

XkUh2.png


Sorry for the daft questions. I'm really trying learn this stuff but it's a ton to absorb all at once for someone without an EE background.
 
May 11, 2008
22,551
1,471
126
You must work your way from the end to the beginning.

The 2,5V bias was an example to use with an ADC input with a voltage range from GND to 5V. In the example, you must see the 2,5V bias as equal to the 0V level of the signal. So forget the 2,5V for a moment. But do not forget that you need a bias voltage to set the 0V level of the input signal to. The zero level of the input signal is where the center of the cross is in the second picture.


images


f0333-01.jpg


You have a 1Vrms signal. If we assume a sinewave, we have an amplitude of 1,414V.

You want to use the ADC input with a 1,1V reference voltage. This means that your ADC can processes a signal with a maximum voltage level of 1,1V.
Thus value 1023 is equal to 1,1V and value 0 is equal to GND level.

http://arduino.cc/en/Reference/AnalogReference

Configures the reference voltage used for analog input (i.e. the value used as the top of the input range). The options are:

DEFAULT: the default analog reference of 5 volts (on 5V Arduino boards) or 3.3 volts (on 3.3V Arduino boards)
INTERNAL: an built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328 and 2.56 volts on the ATmega8 (not available on the Arduino Mega)
INTERNAL1V1: a built-in 1.1V reference (Arduino Mega only)
INTERNAL2V56: a built-in 2.56V reference (Arduino Mega only)
EXTERNAL: the voltage applied to the AREF pin (0 to 5V only) is used as the reference.



Your amplitude is 1,414V thus your peak to peak voltage is 2.828V.
Now you know what to do from reading the other posts:

The ADC has a range of 1.1V but the signal is 2.828V.
Your input signal is larger than your ADC can process.
The bias for your 1.1V must be set to half the ADC reference voltage.
With 5V it is 2,5V. With 1.1V it must be... (Please fill in the answer.)

Since your input signal is larger than your ADC can manage, you must not amplify the signal but do the opposite, you must attenuate the signal.

You must however use a buffer with a unity gain and use what you have used before to set the output of the opamp to the half of 1.1V.


I should note that if i am not mistaken, the ADC of the ATMEGA used in the arduino can only sample at a maximum sample rate of 15000 samples per second. This means that your audio signal cannot be any higher than 7kHz.

I will post an example circuit later or tomorrow for you.
 
Last edited:
May 11, 2008
22,551
1,471
126
I made this quick and dirty. It is not perfect but it works.

guitar_connect.jpg




From left to right :
The guitar element is AC coupled through capacitor C1. Thus no DC voltage will pass here.
The first opamp stage is a buffer to make sure we do not put to much load on the guitar element and we make sure the 0V level of the signal is centered around a bias voltage of ~2,5V. The output of the first opamp has a low output impedance. Ideal to drive a low pass filter.
The second stage is a low pass filter to attenuate signals. I made it quick and dirty and have not calculated it. I only estimated the value for a cutoff frequency of ~7kHz. The output of the second opamp can deliver enough current (in comparison to the guitar element) to directly drive the potentiometer.
The resistors R5 & R6 together are the potentiometer and set the amount of attenuation.
The output signal from the wiper of the potentiometer is AC coupled through C3 to the third stage.
The third stage is another opamp buffer but this buffer sets the attenuated signal to half the ADC reference voltage you want to use.
The output of the opamp can be direclty coupled to the ADC input of the ADC but you must use a 1K resistor in series to be save to prevent damage to the arduino MCU when the opamp output swing at 6V voltage level for some reason.
You can build it to see how it works. As you see, sometimes you need multiple stages to create a proper circuit.

It works but has some quirks i expect but it will help you to get started.
Good luck. ^_^






Frequency response :

guitar_connect2.jpg
 

dwell

pics?
Oct 9, 1999
5,185
2
0
Thanks WG! I'm not going to straight up build this. I've modeled it over in LTS and am going to try and understand it stage-by-stage before trying to build my circuit. I think a good exercise would be to learn to use a JFET as either the input or output buffer so I don't need two dual-op amps in the circuit.

http://www.muzique.com/lab/buffers.htm

This really helps. I think I am 80% there in understanding the circuit I'm not 100% there with understanding the second stage but will brush up on the LPF post above. I get R8 and C4 but not R7 and C5.
 
May 11, 2008
22,551
1,471
126
Thanks WG! I'm not going to straight up build this. I've modeled it over in LTS and am going to try and understand it stage-by-stage before trying to build my circuit. I think a good exercise would be to learn to use a JFET as either the input or output buffer so I don't need two dual-op amps in the circuit.

http://www.muzique.com/lab/buffers.htm

This really helps. I think I am 80% there in understanding the circuit I'm not 100% there with understanding the second stage but will brush up on the LPF post above. I get R8 and C4 but not R7 and C5.


What you see in the lpf are two low pass filters. This filter is called a second order low pass filter and it is callled an active filter because the opamp is the active component. Resistors, inductors and capacitors are passive components. I never really thought about how it works.
Maybe this is why it works :
An RC filter is effectively a time delay component. I think since the opamp is a buffer, that the output of the opamp follows the input in signal amplitude level. But this is an opamp with a 2nd order rc filter. As long as when the frequency is low enough, the output signal will have more or less the same amplitude as the input signal.
Thus the voltage difference over C5 is near 0V. No current will flow through C5. But as the input signal frequency increases, the output votage level will decrease, and there will be more voltage difference over C5, a current will flow, increasing with higher frequencies.


The link does not seem to work anymore for me at the moment.
But when using fets for your output stage, do not forget to dc couple the output of the jfet to the adc. And make sure (if you use a source follower) that the junction between the source and the resistor connected to the adc must be biased at half your adc reference voltage. If you use the drain as the output, you must also set the drain resistor junction connected to the adc at half the adc reference voltage.
 
May 11, 2008
22,551
1,471
126
There is also an easier way to hold an ac signal to a dc level : The clamp circuit !

I have uploaded some of my electronics library and made it available to the public.
See the electronics thread that i will create in a few minutes.
 
May 11, 2008
22,551
1,471
126
Here is an example circuit of a clamp circuit that clamps an ac sine wave signal to a voltage of around ~442mV. This means that the 0 level of the signal is shifted upwards from 0 volt to 0.442V.
The 0 level is the center of the graticule in the 2nd picture below.

clamp1b.jpg



f0333-01.jpg


This picture is a more detailed picture about how everything is named :

rise_time_and_pulse_width.gif
 
Last edited: