# Op Amp to read current with a PIC?

Discussion in 'General Electronics Chat' started by spinnaker, Dec 14, 2010.

1. ### spinnaker Thread Starter AAC Fanatic!

Oct 29, 2009
5,665
2,187
I am trying to figure out a way to read current using a PIC microcontroller.

I came up with this little voltage divider.

I quickly realized that there will be only about 25 micro volts dropped across that .1 ohm resistor with a source voltage of 30 volts. Divide that by 6 (my divider) and lower my input voltage to a couple of volts and the difference between the two voltages is tiny. Probably beyond what the ADC on my PIC is going to be able to detect.

Is there a better way to do this? I figured I need an op amp but I found this project which uses no opamp.

Here is the voltage divider part. It makes no sense to me. It looks to me like both sides of that sense resistor are tied to ground???

What are they trying to do here?

So if I do really need an op amp. What do I need? I was thinking an Instrumentation Amp.

If I am on the right track:

1. Which op amp? I am thinking a rail to rail capable of a single +5 supply.

2. How do I determine the values of all of those resistors other than the gain resistor?

3. For the gain formula, what is AV? Is that the Amplified Voltage?

4. Where would I connect the inputs to my amp? Right across the sense resistor?

File size:
5.8 KB
Views:
129
2. ### Jaguarjoe Active Member

Apr 7, 2010
770
91
See if you can rethink your sense resistor value to give you more voltage to work with. You will have a hard and expensive battle dealing with microvolt signals. Why take a miniscule voltage and reduce it even more by dividing it by 6?

Av is the gain of the instrumentation amp. You saw where it can not exceed one, right? Building these from discrete components is a real bear. You need highly matched components. You don't need one anyhow.

In your other circuit, in this case, GND and the ground symbol are not the same. One side of the sense resistor is a power supply ground, the other side at circuit ground. This allows the current sensing resistor to be referenced to power supply ground.

How much current are you measuring over what voltage range?

3. ### spinnaker Thread Starter AAC Fanatic!

Oct 29, 2009
5,665
2,187
That is why I am posting here. This is the idea I came up with.

I am not dividing the difference. I am dividing the voltage so my PIC can read both voltages.

So the + and the Gnd are actually the power supply?

How would I show two different grounds in Spice?

I will be measuring no more than 1.5A.

4. ### spinnaker Thread Starter AAC Fanatic!

Oct 29, 2009
5,665
2,187
I think I have it figured out!

or maybe not. I am only getting around 1.2 mv on Analog 2. That does not seem right.

File size:
16.3 KB
Views:
107

Apr 7, 2010
770
91
6. ### spinnaker Thread Starter AAC Fanatic!

Oct 29, 2009
5,665
2,187

Thanks I have seen these and it is the route I may be going but this should be more simple.

7. ### t_n_k AAC Fanatic!

Mar 6, 2009
5,448
784
They are sensing both the voltage and the current. The 6.8K + 100K across the supply forms a voltage divider to scale the input for the voltage sensing and the 0.47Ω senses the current draw from the 0-70V supply. Presumably the 100K is included as input protection to the PIC analog input for the current sensing task.

The 0-70V output to the "LOAD" is taken from the +ve rail to the GND node. You would have to apply some load to obtain a sensible load current indication. A 140Ω LOAD would give a load current of ~0.5A with the full 70V supply setting. With 0.5A and 0.47Ω sensing resistor you would have a current related signal of 235mV to the related PIC input. Under the same conditions the voltage related signal PIC input would be ~4.457V.

8. ### spinnaker Thread Starter AAC Fanatic!

Oct 29, 2009
5,665
2,187
Thanks for the help. Since you are helping here, I have a simlar post regarding this circuit. I am going to delete it.

OK sorry for being so dense but exactly where is the load connected in this circuit? Is it just across those two input pins on the left?

Why does he label the other side output?

9. ### t_n_k AAC Fanatic!

Mar 6, 2009
5,448
784
The load would be connected between the positive pin (or node) marked as + and the pin marked GND. The power flow is from left to right.

The sequence from left to right is

Power In ---> Voltage / Current sensing ---> Load

Unless you connect a load you won't measure any current.

Last edited: Dec 15, 2010
10. ### spinnaker Thread Starter AAC Fanatic!

Oct 29, 2009
5,665
2,187

Yeah thanks I think I got it. I should actually work on this stuff when I catch up on my sleep.

Something like this?

But I am reading a -307 in Spice at Analog 2???

I also included my actual Spice file.

File size:
13.9 KB
Views:
99
File size:
467 bytes
Views:
17
11. ### t_n_k AAC Fanatic!

Mar 6, 2009
5,448
784
More like this ....

File size:
2.8 KB
Views:
38
12. ### spinnaker Thread Starter AAC Fanatic!

Oct 29, 2009
5,665
2,187

Thanks! Got it!

Would I be better with a higher value sense resistor?

13. ### SgtWookie Expert

Jul 17, 2007
22,194
1,763
I prefer drawing it like the attached; it's easier to understand quickly that way - to me, anyway.

Note that I've decreased the Iout resistor, and added caps for both lines. This is necessary if you're going to use the ADC function on a uC, as it needs a low-impedance input.

As far as increasing the current sense resistor - you'd start consuming a lot of power there instead of the load. With a 2A load and Rsense = 0.47 Ohms, you'll need a 3W resistor already; and it needs to be non-inductive to boot.

You'd be a lot better off with a Hall-effect current sensor. Very low power loss by comparison.

File size:
55.9 KB
Views:
42
14. ### spinnaker Thread Starter AAC Fanatic!

Oct 29, 2009
5,665
2,187
For some reason your image is a little fuzzy but I think I know what you are doing there. Thank you.

I knew I should have waited for you to weigh in before pressing that submit button on Digikey!

Yes I do know to add the caps. I did not add them in my divider because I was concentrating on the divider part.

When you say curent sense needs to be "non inductive". Do you mean non wire wound? That is what I ordered.

I do have a non working DMM that I can salvage. I read another post of yours regaarding the brass bar inside. I guess I can use that instead? I am not at home right now but is that brass bar used for the lower amp connection as well as the 10 amp? Or is there another current sense resistor in there.

Regarding Hall Sensor. I did a bit of reading and searching on them. Pretty cool! But seem to be expensive and most seem to come in surface mount. I do not think my skills are good enough for surface mount. I did see one on Newark that was 3A in a package I could probably easily mount but not sure if it is what I need or not. Sparkfun sells a breakout board with a tiny surface mount chip that is good for 5 amps but they are something kike \$9.95.

15. ### SgtWookie Expert

Jul 17, 2007
22,194
1,763
Did you click on the image to bring it up, and then again to make it full-size?

Browsers nowadays seem to "scrunch" large photos to fit the screen, and don't always do a good job of it.. It's more clear if you're looking at the full-sized version.

I don't have much time to be on AAC anymore. You might've had a long wait.

OK, just so you know.

There are non-inductive wirewound resistors, but unless they specifically say "non-inductive", they're probably the wrong kind.

The brass bar is used for the higher current measurements.

You pay for the convenience. Radio Shack sells a 2-axis acceleration sensor for around \$32. The IC itself is around \$3.

16. ### spinnaker Thread Starter AAC Fanatic!

Oct 29, 2009
5,665
2,187
Image working just fine here at home. Must be the browser and / or proxy server at work.

What do they use for a current sense resistor in those meters for the lower current I am not seeing anything big.

Are there any easy to use current sensors out there? I found this one on Newark but if I am reading the data sheet correctly, it is way over kill for my purposes.

Newark only gives a search on Quiescent Current it does not seem to give a search on sampled current. Makes it kind of hard to search. I found nothing on Mouser in an easy to use package.