Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

operational amplifier circuits etc.

Status
Not open for further replies.
Thanks, MrAl.

Just a quick note for the picture "sensor222.jpg".

A1 should be connected as a differential amplifier. It's not really right the way it is now.
A2 should be connected as a buffer or not used at all. It's not connected right the way it is now.

I don't get it. In my humble view the picture shows A1 connected in inverting configuration and A2 connected as a buffer with unity gain. Where do I have it wrong?

Please have a look here. Suppose Vin=10V and voltage drop across R_sense is 1V. The gain of A1 is set at -(1/4). In the given case, differential voltage, V_diff, is: V_diff = 9-10 = -1. The order of subtraction is important here. We cannot write (10 - 9) because we are applying the input voltage to inverting input of A1 and not non-inverting input.

The Vout would be (V_diff)(gain) because it's the differential voltage which gets amplified. Therefore, (-1)(-1/4) = 1/4. Do I have it correct? Could someone please let me know? Thanks.

Regards
PG
 

Attachments

  • opamp33.jpg
    opamp33.jpg
    70.3 KB · Views: 1,339
Last edited:
Hi,

Sure. I think what you are forgetting is that you should have a secondary method to test your result about what that result should actually be. For an op amp circuit in the linear mode, a common method is to check for what the voltage is on one input terminal after knowing what the voltage is on the other terminal by calculating it. In this case, we know the non inverting input resistance is very high so we get roughly +10v at that terminal. You can then ask yourself what does it take on the output of the op amp (also knowing the 9v voltage) to get +10v on the other terminal too.

Also remember that for an op amp the gain from the aspect of the input on the inverting terminal side is Rf/Rin, in this case R4/R3, which equals 1/4 as you noted. However, the gain from the aspect of the non inverting terminal is 1+R4/R3, and the output depends on BOTH inputs, not just the one.

Going about it with this in mind, the gain from the inverting side is 9*0.25=-2.25, and the gain from the non inverting side is 10*(1+0.25)=12.5, so the total output voltage is 12.5-2.25=+10.25 volts. Since this is not what you were after, you need to change the circuit of the op amp.

To correct this, the op amp is made into a true differential amplifier. This is done by repeating all the gain resistors from the inverting side to the non inverting side. The input resistor is the same as the inverting side input resistor, and there is a fourth resistor added from the non inverting terminal to ground, and that value must be the same as the feedback resistor.
I'll modify your drawing unless you want to.
 
Thank you, MrAl.

This is my request to you that please be to the point because I want to get over this stuff soon. Thanks for the understanding.

Q1:
That was nice to know. I believe you are referring to this circuit which was originally modified by me for use in previous posts. Is this the one you had in mind? Do you think this sensor is a correct one?

Don't you think that the gain of A2 is way too much because -100mV would be amplified to (-100m)(-250/1)=250V. Such a high voltage cannot be handled be an opamp, right?

I had thought that a unity gain opamp is considered a buffer but in post #20 you didn't consider A2 in this 'incorrect' circuit as a buffer. Could you please tell me why?

I don't think an opamp such as LM741 can be used in such a sensor circuit where input voltage is too low. Could you please tell me some popular differential opamp ICs? One I found is THS4531.

Q2:
The current sensor ACS712 (here is the datasheet) without any modification has sensitivity of 185 mV/A and it can detect current in both directions.

Current of +/-5A makes +/-0.925 volts.
0.925V/5A=0.185V/A

-5A in= 2.5V-0.925=1.575
0A in = 2.5V-0=2.5
+5A in = 2.5V+0.925=3.425

Now please have a look on this circuit which increases the sensitivity to 610mV/A from original 185mV/A. Suppose +5A current flowing thru the sensor which would mean the sensor will output voltage of 2.5+0.925=3.425V at the inverting input of the opamp. What should be the voltage at Vout? By the way, the circuit can be found on page #12 of the datasheet. Thanks.

Regards
PG
 

Attachments

  • current_sensor666.jpg
    current_sensor666.jpg
    40.6 KB · Views: 1,195
  • sensor222n.jpg
    sensor222n.jpg
    28.9 KB · Views: 1,195
  • acs1.jpg
    acs1.jpg
    43.7 KB · Views: 5,527
Hi,

Q1:
sensor666.jpg:
This circuit has an overall gain of 27.8 approximate.
This means that the 100mv signal gets amplified to 2.78 volts.
Input offset for the op amps could be critical for these circuits.
An input offset of 1mv in the last stage gets amplified to 250mv on the output. Common op amps typically have input offsets in the 2mv to 10mv range. Think about what that can do to the output.
Special op amps can be used that have extremely low input offsets and low input offset drift too.

sensor222n.jpg:
The "buffer" in this circuit is not connected as a buffer. A buffer
gets its input at the non inverting terminal. To make an inverting
buffer, you need two resistors to set the gain to -1.

Q2:
acs1.jpg:
You have to watch the offset in that circuit because there is a secondary
offset to think about. That's the inherent offset from the sensor IC
itself with zero input. It may not be exactly 2.500v, and anything
different than the divider voltage of the two 100k resistors means
another offset is introduced into the system. There is probably also
some temperature drift on this spec, but you could check that.

Overall:
These circuits all reqire strict attention to the DC offsets of the
IC chips, op amps and sensors alike, because the offset gets amplified
and it appears as an error at the very output. Steps have to be taken
to reduce the offset either directly (choice of op amp) or indirectly (through some zero
offset adjustment).
What else is unfortunate is that the DC offset never goes away in DC coupled circuits. If there is 1mv at the very input, it gets amplified all the way to the output.
Also, the op amp used in some of these circuits could have an offset of 7mv which is really a lot. Even the lowly LM358 is better than that.
 
Last edited:
Thanks a lot, MrAl.

Coming again to "Q2" from my previous post. What should be the voltage at Vout? Let's look at it first from ideal and theoretical point of view then afterwards we can see what issues can happen when such a circuit is used in real world. Thank you.


By the way, did you mean to say "-2.78 volts" in the quoted text below?

Q1:
sensor666.jpg:
This circuit has an overall gain of 27.8 approximate. This means that the 100mv signal gets amplified to 2.78 volts.

Regards
PG
 
Hello,

Yes, the output will be -2.78v approximate. Sometimes we dont mention the sign when talking about amplitudes, but yes it is negative for that 100mv oriented with the most positive polarity on the left side of the sense resistor and most negative on the right side of that resistor.

I guess you dont want to discuss input offsets right now. I hesitate to avoid talking about this when i see current sense circuits because it is such an important aspect of this kind of circuit. What happens is people do the theory and get it all oh so perfect, but then when they build the actual circuit they see large errors and wonder why. So this is one of those circuits that has a critical secondary aspect that must be addressed in real life. For example, with 2mv offset i think i calculated an 18 percent error at full load output. That's huge, and it gets much worse as the load drops down to 1/2 load, 1/4 load, etc. If you rather not discuss this right now that's fine, but keep it in the back of your mind for a later time.
 
The current sensor ACS712 (here is the datasheet) without any modification has sensitivity of 185 mV/A and it can detect current in both directions.

Current of +/-5A makes +/-0.925 volts.
0.925V/5A=0.185V/A

-5A in= 2.5V-0.925=1.575
0A in = 2.5V-0=2.5
+5A in = 2.5V+0.925=3.425

Now please have a look on this circuit which increases the sensitivity to 610mV/A from original 185mV/A. By the way, the circuit can be found on page #12 of the datasheet.


These are the values for Vout when circuit is analyzed:

-5A in:
The 712 IC outputs 1.575V.
1.575V gets amplified to Vout=2.5{1+(3.3/1)}+1.575(-3.3/1)=5.55V

0A in:
The 712 IC outputs 2.5A.
2.5V gets amplified to Vout=2.5{1+(3.3/1)}+2.5(-3.3/1)=2.5V

+5A in:
The 712 IC outputs 3.425V.
3.425V gets amplified to Vout=2.5{1+(3.3/1)}+3.425(-3.3/1)=-0.553V

Are the values calculated above correct? Please let me know. Thanks.


This is my general interpretation of 610mV/A gain :

-5A in= 2.5V-3.05=-0.55
0A in = 2.5V
+5A in = 2.5V+3.05=5.55

Regards
PG
 
Last edited:
Hello again,

Yes that is correct when the results are rounded.

The overall transfer function is:
Vout=2.5-0.6105*I

and that 0.6105 factor comes in because we are using a 3.3k resistor instead of using a 122k/37 value resistor which would make it a perfect 0.610 instead of 0.6105, but no big deal really.

So i get results:
-0.5525v
+2.5000v
+5.5525v

and rounded (away from zero) to three significant figures:
-0.553v
+2.50v
+5.55v
 
Thank you, MrAl.

Now let's proceed further with that current sensor ACS712.

I want to use that sensor in a school project. Please note that I'm not after very, very accurate system.

I will be using 10-bit built-in ADC of a microcontroller and also will be using internal Vdd and Vss of the microcontroller as reference voltages for the ADC. The input voltage range of ADC is 0-5V.

Also don't forget that the sensor is a bidirectional one. The maximum current we will be measuring is going to be 2.3A. The sensor is a +/-5A sensor. You can see the datasheet here. The part number for +/-5A sensor in the datasheet is ACS712ELCTR-05B-T.

Q1:
First let's consider the case of when the sensor is used without any gain increasing circuit added to it like this.

-2.3A in= 2.5V-0.4255 = 2.0745
0A in = 2.5V-0=2.5
+2.3A in = 2.5V+0.4255 = 2.9255

We will only focus on the case of +2.3A case. Don't you think that the ADC won't give accurate readings because the range, 2.5 to 2.9255, is very narrow? Or, do you think that the ADC will work fine even when the range is that narrow?

Q2:
For this question I'm going to assume that the narrow range will affect the operation of ADC. The range can be extended by using a circuit similar to the gain increasing circuit we were discussing previously. Please have a look on this circuit and notice that the resistor R3.

Let's assume R3=5k and let's focus on only positive current (and don't forget maximum current is 2.3A).

Code:
0A in:---------------------Vout = 2.5V---------------------:----------------10-bit ADC integer reading in integer  = 512 //range is 0 t0 5V
0.5A in:-------------------Vout = 2.0375V-----------------:--------------------------------------------------------- = ?
1A in:---------------------Vout = 1.575V-------------------:--------------------------------------------------------- = ?
1.5A in:-------------------Vout = 1.1125V------------------:--------------------------------------------------------- = ?
2A in:---------------------Vout = 0.65V--------------------:--------------------------------------------------------- = ?
2.3A in:-------------------Vout = 0.3725A-----------------:---------------------------------------------------------- = ?


I hope the values for Vout are good but I'm not able to come up any simple formula to calculate ADC readings for corresponding voltages in the table above. Could you please help me with it? Approximately, ADC will output "0" when input current is around 2.7A which outside the range of maximum we will be measuring.

Thanks you.

Regards
PG
 

Attachments

  • sensor0001.jpg
    sensor0001.jpg
    71.8 KB · Views: 552
  • current_sensor000.jpg
    current_sensor000.jpg
    36.5 KB · Views: 3,531
Hi again,

With no amplification the range of the ADC will in fact be limited, but to evaluate the impact on the signal measurement you only need to find the error in the measurement with say a 1 bit error in the ADC. Doing this will give you a good idea what to expect in the real world.
With no amp, the output is Iin*0.185+2.5, and with 0.000A input we get 2.5v output, and with 2.300 A in we get 2.9255v output, so the (plus or minus) output range is 2.9255-2.5=0.4255v. The bit voltage for a 10 bit ADC with a reference of 5v is 5/1024, and so the output range translates to a digital count range of 87. Since the total count range spans 1024, that means we'll only be using about one-twelfth of the available digital range. That makes the 10 bit ADC look like a 7 bit ADC so we loose 3 bits right off the bat. The impact on the input however is such that one count equals 2.3/87=26.4ma, or 0.0264 amps. That has to be taken as the error that can occur at ANY input however, so best case is we will be off by slightly more than 1 percent and worst case is pretty bad anyway because with a low current there will always be more percent error.

With a gain of 5, the count range is boosted to about 87*5 (five times what it was with a gain of 1). That means we've reduced the possible error to a little more than 1/5 percent (0.2 percent error, which is 2 tenths of one percent error).
That's much better for sure. It also means that we get better error at lower current levels.

To digitize the current, first calculate the bit voltage which is 5/2^10=5/1024. Then calculate the output voltage of the amplifier (can make it a gain of 1 for no amplification), then divide that Vout by the bit voltage of 5/1024, or multiply by 1024 and divide by 5, and that is also equivalent to multiplying by 204.8, and after that take the "floor()" of that result, and that gives you the digital count for the ADC.
So a simple example is if we have 0 amps input we have 2.5v output, and 2.5*204.8=512, then take the floor of 512 "floor(512)" and get 512 again. That was obvious, but if we do 2.29 amps with a gain of 1 we get:
2.29*0.185+2.5=2.92365 and 2.92365*204.8=598.76352, and taking the floor of that: floor(598.76352)=598, so the count would be 598 for that input.
 
Thank you, MrAl.

I would request you that please keep track of the details otherwise we can get wrong results. It would be better if you give my previous post another look.

From your reply to Q1, I conclude that you are of the opinion that using the gain of '5' can improve ADC results. If your answer is 'yes' then Q1 is resolved and we must focus on Q2.

For Q2 we were using this circuit where value of R3 was taken to be 5k. Please note that in the end I would need to use either 4.7k or 5.1k **broken link removed**. I must also mention that I will be using a voltage regulator such as LM7805 to power up the given circuit.

Do you think that the circuit is good for physical implementation as it is, or should some changes be made?

I was able to finding the following results. Please have a look and let me if they are mistakes. The formulas are also given below.

Code:
-2.3A in:------------------Vout = 4.675V---------------------------------------------------------------------------- = 958
-2A in:--------------------Vout = 4.35V----------------------------------------------------------------------------- = 892
-1.5A in:------------------Vout = 3.8875V--------------------------------------------------------------------------- = 797
-1A in:--------------------Vout = 3.425V---------------------------------------------------------------------------- = 702
-0.5A in:------------------Vout = 2.9625V--------------------------------------------------------------------------- =
0A in:---------------------Vout = 2.5V---------------------------------------- 10-bit ADC integer reading in integer = 512 //range is 0 t0 5V
0.5A in:-------------------Vout = 2.0375V--------------------------------------------------------------------------  = 418
1A in:---------------------Vout = 1.575V---------------------------------------------------------------------------- = 323
1.5A in:-------------------Vout = 1.1125V--------------------------------------------------------------------------- = 228
2A in:---------------------Vout = 0.65V----------------------------------------------------------------------------- = 133
2.3A in:-------------------Vout = 0.3725V--------------------------------------------------------------------------- = 76


For positive current, the formula for corresponding current represented by ADC reading is:
if(ADC <= 512)
{512-(ADC reading)}(1/189.4076) //formula applies if(ADC <= 512)

For negative current:
if (ADC > 512)
{(ADC reading) - 512}[-1/{(958-512)/2.3}]

Thanks a lot for the help.

Regards
PG
 
Last edited:
The current sensor ACS712 (here is the datasheet) without any modification has sensitivity of 185 mV/A and it can detect current in both directions.

Current of +/-5A makes +/-0.925 volts.
0.925V/5A=0.185V/A

-5A in= 2.5V-0.925=1.575
0A in = 2.5V-0=2.5
+5A in = 2.5V+0.925=3.425

Now please have a look on this circuit which increases the sensitivity to 610mV/A from original 185mV/A. Suppose +5A current flowing thru the sensor which would mean the sensor will output voltage of 2.5+0.925=3.425V at the inverting input of the opamp. What should be the voltage at Vout? By the way, the circuit can be found on page #12 of the datasheet. Thanks.

The gain on the opamp circuit is -3.3, and the reference point for amplification is 2.5 V. Hence, the output voltage at Vout will be -3.3*0.925+2.5=-0.55 V, in theory, but since the opamp is powered by ground and 5VDC, you dont have that much range too work with and the output voltage is dictated by the opamp rail to rail output voltage limit. I didnt check that data sheet for that OPAMP, but they should have chosen a single supply rail to rail opamp that can go all the way down to ground. Hence the output voltage should be about 0 VDC. If you use an amplifier with that voltage range, then you only have a +/- 4 Amp range at the output of the opamp.

By the way, that is a terrible recommendation for a circuit for providing better sensitivity. The writer of that datasheet must be recommending that circuit as a crude overcurrent fault detector or some other use that does not require accuracy. When you need good accuracy and precision, you should never derive a reference voltage (in this case 2.500 V) directly off the power supply. Not only is the reference set to half the supply voltage, but there is no filter cap either. If you need a high accuracy signal with more sensitivity, you need to use a precision 2.5 V voltage reference on the +pin of the opamp.
 
By the way, that is a terrible recommendation for a circuit for providing better sensitivity. The writer of that datasheet must be recommending that circuit as a crude overcurrent fault detector or some other use that does not require accuracy. When you need good accuracy and precision, you should never derive a reference voltage (in this case 2.500 V) directly off the power supply. Not only is the reference set to half the supply voltage, but there is no filter cap either. If you need a high accuracy signal with more sensitivity, you need to use a precision 2.5 V voltage reference on the +pin of the opamp.

I think this is because the whole sensor is build in such way too. They don't use a stable voltage reference, but instead refer 0A to Vcc/2. Perhaps they felt that this is Ok for low-precision sensor. Here's what they say in the datasheet:

Quiescent output voltage (VIOUT(Q)). The output of the device when the primary current is zero. For a unipolar supply voltage, it nominally remains at VCC ⁄ 2. Thus, VCC = 5 V translates into VIOUT(Q) = 2.5 V.

Therefore, the sensor's output already contains noise from Vcc. Referring the op-amp to Vcc/2 is actually removing the noise that they have introduced in their sensor.

I think this sensor does more harm than good compared to a simple sense resistor.
 
Northguy,

OK, thanks for the correction. I'm surprised they take that approach. I would think that an A/D channel should be used to monitor Vcc/2 in order to compensate for supply loading effects and regulator tolerances/drifting.

I'm really glad you told me this. I use the Allegro A1302 for magnetic field sensing in the lab. I went back and read the data sheet and it is the same method as this current sensor. Fortunately, I've always set Vcc to exactly 5.000 VDC for short term lab measurements.
 
First, the output of most current sensors like this is ratiometric with respect to the power supply voltage. This means the output will be Vcc/2 not an absolute 2.5v for zero input. That means a resistive divider is recommended for the reference. There could still be a variation with temperature however, so another device could be used as the reference with no current input. This may not be necessary with the more modern sensors however...check the data sheet.


Thank you, MrAl.

I would request you that please keep track of the details otherwise we can get wrong results. It would be better if you give my previous post another look.
What exactly are you talking about here? If you see a problem you must state what it is.

From your reply to Q1, I conclude that you are of the opinion that using the gain of '5' can improve ADC results. If your answer is 'yes' then Q1 is resolved and we must focus on Q2.
Yes, in general some gain can help because the circuit then takes better advantage of the ADC input range. Of course it also amplifies any error present in the sensor. If the gain is too high, it could also push the op amp output out of range.

For Q2 we were using this circuit where value of R3 was taken to be 5k. Please note that in the end I would need to use either 4.7k or 5.1k **broken link removed**. I must also mention that I will be using a voltage regulator such as LM7805 to power up the given circuit.
4.7k might be ok, but you do have to check the op amp output at the plus and minus input extremes to make sure that it can actually get to those values.

Do you think that the circuit is good for physical implementation as it is, or should some changes be made?
PG
As mentioned, the output of the op amp has to be able to reach the voltages needed. Some op amps are very limited to what voltages it can reach on the output with a given power supply voltage.

I am keeping the number of questions and data sets down to a more manageable number per reply.
 
I'm surprised they take that approach.

I'm surprised too. They could've provided a pin for the reference. If someone wants to use VCC as a reference they always can connect it to VCC. But if you already have an accurate reference on the board, you could use it instead.
 
Hi,

I think the main advantage of the Hall Effect current sensors is the very low insertion impedance.

The magnetic Hall Effect sensors have a ratiometric output as well.
 
I think the main advantage of the Hall Effect current sensors is the very low insertion impedance.

Even at high currents, shunts, despite being much cheaper and much more accurate, don't pose any significant problems. For example, I use 0.1 mOhm shunts at home. Even at 100A current, such shunt only dissipates 1W - hardly something to worry about.

It is also possible to use part of the wiring as a shunt (zero insertion impedance!)and, after correcting for temperature, it still will be more accurate than hall effect sensor.

The only situation where hall effect sensor has advantage is when you need isolation.
 
Even at high currents, shunts, despite being much cheaper and much more accurate, don't pose any significant problems. For example, I use 0.1 mOhm shunts at home. Even at 100A current, such shunt only dissipates 1W - hardly something to worry about.

It is also possible to use part of the wiring as a shunt (zero insertion impedance!)and, after correcting for temperature, it still will be more accurate than hall effect sensor.

The only situation where hall effect sensor has advantage is when you need isolation.

Hello again,


Well sorry but that's not an accurate picture of the whole story. Yes the HE sensor provides isolation which is very handy sometimes.

For YOU a 0.0001 ohm shunt may work ok, but that's not telling the whole story. For example, what are you using with that shunt, there must be some additional circuitry or else you've got a good voltmeter to measure the voltage. And while it is true that we can measure the voltage drop across a wire and convert to some usable current reading, again we need additional circuitry or a good meter.

So the whole story in addition to the shunt itself is what are you using to measure that shunt voltage drop with. And these days a lot of applications require interfacing the current measurement to a regular microcontroller chip, which can not measure 10mv (100A with 1mohm) very well at all, so there needs to be a well designed amplifier to go with it with a low input offset op amp or some other means to handle the offset.
The HE sensor can interface directly to a microcontroller without any additional circuitry, and imposes little impedance (around 1mohm i think) so it makes a quick and useful current monitor. The isolation is an additional benefit for those apps that really need it, and also means high side sensing is just as simple.

BTW what do you use with your 0.1mohm shunts? I've used brass strips to make shunts in the past and even with the larger temperature coefficient it worked out pretty well. For AC i have also used current transformers designed to fit the task, as well as my own personal current transformers made from old wall warts.
For some of my apps i was able to use a simple 0 to 2.5vac meter because the output of the current transformer allowed that, and for the shunts i had to use an op amp amplifier but the offset is not a problem if the application is AC because a simple capacitor coupling gets rid of that offset.
 
I use actuall shunts (bought them for about $30/piece), and I made my own 4-op-amp circuit, which has a topology similar to instrumentation amplifier followed by a low-pass filter. However, a simple differential amplifier (which you need for hall effect sensor anyway) would work fine. Or you can use special ICs, such as ina282, which, are not expensive and very accurate.

For AC, CT transformers work very good. The problem is that they have a phase shift error. Using very small burden resistor is supposed to decrease phase shift, but then you need to amplify. For myself, I ended up with big burden resistor without amplifier and software correction for phase shift, but I believe that small burden with amplifier is better.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top