Volt-Ammeter

Greetings.

First of all please excuse the apparent ignorance of mine...:(

I am planning on building a lab power supply, it will have adjustable symmetric outputs, around +/-1,5 to +/-30Vdc @~5A max, i want to set up a digital Volt-Ammeter using PIC uC and an 2x24 LCD display, my problem is with the Current measuring part of the device, the shunt that is, witch is on the ground side of the load, something like this:
[IMGDEAD]http://img823.imageshack.us/img823/4404/shuntao.png[/IMGDEAD]

I cannot have symmetric outputs in this config cus of the ground side shunt, and i want to moove the shunt on the "+" side but for the life of me i cannot find a good working solution, i need te correctly read the voltage drop on the shunt and have a linear amplification on it from 0 to 5V max, cus that is what the PIC controller needs on the analog imput, can u please guide me in the right direction? i would prefere OA config but i cannot seam to find the right way to use it so any help would be greatly appreciated.

Thanks for your time and best of all.
Marian.
 

palstanturhin

Member
2011-06-17 11:26 am
1stly, you have the opamp there. Amplify the signal from the shunt with it - A LOT!
Put the shunt(s) to pos. and to the neg. rails. Use 0.001ohm shunts or possibly the rail itself (the wire) as the shunt... The shunt resistance has no importance, the smaller the better... Do the measurement correction with the opamp (adjustable gain).
Voltage error from an almost 0 ohm shunt will also be "almost zero"...
What is the pic ADC? 8bit?
 
...Do the measurement correction with the opamp (adjustable gain)...
That's just it, this is my problem, i cannot seam to come up with a correct way/configuration of reading the voltage on the shunt with the OA and amplify it, i end up with grounding issues witch i cannot seam to solve. Again i appologise for the ignorance but i am in need and i'm not ashamed to admit it...
 

palstanturhin

Member
2011-06-17 11:26 am
Definite drawback is that if the shunts are on the pos/neg rails, you must have the opamp power floating - separate powersupply for them...
You have the full schematic for the negative part already there, now just turn it upside down to get the positive rail...

But i think i see your point...
How to then read these two potentials with just one PIC?
What is easier - use 2 pics or 2 ADCs and get the data from them to the pic via optoisolators?

Or did you already consider keeping the two power supply rails completely separate untill the very end gnd terminal at the PSU output?
Then you could have the shunts at the two GND-rails?
 
This is the device in question ( exept the display witch in my case is 2x24 ), i dont care about the negative rail, only the pos rail will be monitored since that is what will be mostly used. I need the output to have common ground so the shunt must be moved on the + side of the pos rail, and as i have sayd i do not know of a way to read the voltage drop with the OA, with the shunt on the + side, i have grounding issues, so i need a schematic with what can be done, the one i have posted cannot just be turned upside down and that would be it. So any help would have to contain a schematic.
 

Attachments

  • voltmetru ampermetru pic16f876.pdf
    41.2 KB · Views: 73

FoMoCo

Member
2012-12-04 10:04 pm
A standard differential amp (which can be made from an op-amp) will work to measure the voltage in the positive rail without needing a separate supply. You can also buy op-amps that are designed specifically for this. Barring that, a magnetic sensor, such as a LEM module, can be used.
 
I understand your problem!

The difficulty is measuring a small differential voltage (across the small series R) in the presence of a large (and changing) common-mode voltage.

The classic solution is an "instrumentation amplifier". Google it, there are loads of examples. Most have input buffer amps which cannot operate outside the op-amp supply rails, so not usable here.

A simpler solution is the classic op-amp differential amplifier. 4 resistors around a classic op-amp. Look it up and have a study! It requires close matching of resistors, but that is not difficult to "fiddle" with a one-off DIY solution.

Have a read and ask again if you need to. It is possible to solve this in an interesting and DIY way!

Your English is very good, BTW!
 
Yes, only now i get it, and @FoMoCo please accept my humble apologyes... you gave me the solution but i was to dumb to see it :(

I've simulated it and it seams to work well:
Amplificator diferential2.PNG

The resistor vallues are just for testing it, i need to read further about this config before i decide what is best, but the thing is i now have a viable solution and that's great. Thanks allot for the ideeas and for your patience.
 

FoMoCo

Member
2012-12-04 10:04 pm
Yes, only now i get it, and @FoMoCo please accept my humble apologyes... you gave me the solution but i was to dumb to see it :(

I've simulated it and it seams to work well:
View attachment 350077

The resistor vallues are just for testing it, i need to read further about this config before i decide what is best, but the thing is i now have a viable solution and that's great. Thanks allot for the ideeas and for your patience.
You can switch connections for the sense resistor and get rid of the second op-amp and a negative supply. Also, be sure to size your resistor values so that the common mode input range of the op-amp isn't exceeded.
 
Indeed the sense resistor conections can be switched, thank you, that makes it possible to use single supply, but i think i still need a second amplifyer stage for greater amplification flexibility, cus when calibrating the device i need to be able to adjust the amplification in order to get the best accuracy. I would use the 5V line of the PIC controller, and LM358 operational amplifier in witch case i see that the input common mode voltage range is between -0,3V up to Vcc, so i need to make sure i do not have more that 5V on the imputs and that's a problem cus the only way i can make sure i do not have more than 5v on In+ for example at max voltage ( arround 30V ) is to have an order 6 divider there and that would mean not only no voltage amplification but rather attenuation ( is it even possible? ), a solution as i can see it would be to power the LM358 directly from the pos rail, in it's datasheet i can see that the max power supply voltage for single one is 32V, i would reduce that voltage to a max of let say 25V by use of some zenner witch would make sure that the supply voltage cannot exeed it's breakdown voltage, that way the common mode input range would increase with the output so it would be much easyer to get it right... eyther that or i am way off base here...
 

FoMoCo

Member
2012-12-04 10:04 pm
Good point. Once you attenuate the input to stay in the common-mode range, it doesn't give you much flexibility without adjusting two resistors for gain. The second stage would make it easier to calibrate.

By the way, attenuation is possible. Short of a floating supply, that's the only way to make this work easily.
 
Great, and i was affraind to mention that word, cus i didn't wanna say something ridiculous:D

So when powering the OA from the PIC's power line my option would be set up the resistor vallue as so at max output i will not exceed CMIR, and then the second noninverting amplifier set's up the voltage amplification the way i need it. Now, how about the other option i have mentioned? the one that would mean poering the LM358 from a variable supply ( the pos power rail ), would it be a problem that voltage will vary?
 
Witch datasheet are u reffering to? i've consulted more that 20 different ones but didn't find any "25'th figure"...

I am hesitating to power the 358 directly from the power rail, the voltage could exceed the maximum allowed limmit and i do not want to worry about that any time i increase the voltage on the power supply, a zenner could make sure i do not go above some chosen limmit but i worry about another thing, the power rail will varry accordingly with what i need to power at any given time, and a varrying supply i fear could do harm to the OA or to it's performance, maybe i could do with powering it from just before the series pass regulator, that way no matter what voltage level i set up for the outputs the OA will have a fixed power supply ( i will regulate it to somewhere near 30V ), so bearing that in mind it seam i have 2 possible solutions:

1.-Powering the 358 from the PIC's power supply 5V, and making sure that the OA's imputs do not exceed those 5V ( that is what is needed for the CMIR, -0,3V up to Vcc ), that will imply attenuation at the first stage, the differencial amplifier, and having a second noninverting stage with adjustable amplification to suit the needs for the PIC controller;

2.-Powering the 358 before the series pass regulator or from another power source, somwhere near 30V regulated, that way the CMIR has a much larger range, i can go with a gain of 1 witch would mean half the voltage on the output ( at any given vallue ) so far from the max cmir limmit, after that a second adjustable amplifier again to calibrate it for the PIC.

Witch one do you think would be best?
 

FoMoCo

Member
2012-12-04 10:04 pm
Remember that the output cannot go all the way to the supply rail. If you supply it with 5V the '358 can give about 3V max output. I'd use either a 7812 (7815) regulator, or similar Zener, to supply 12 or 15 volts, respectively. This will give you more headroom on the input and require less attenuation.

Just be sure to use a 1K (or so) resistor between the '358 and the PIC, just in case the '358 delivers more than 5V for some reason. Most PICs have input diodes that allow a series resistor to be good enough protection.

One other thing to be aware of: I had a 16F685 (I assume the same ADC is used in other mid-range PICs) that would get upset when the input voltage for the ADC exceeded supply, even with the resistor. It would not be damaged or latch up. It just read 0x00 as a conversion result until power was cycled. That was frustrating to figure out.

How I fixed the problem:
Image1.png
 
I cannot be sure but i think thet in the original schematic the 5V power line for the 358 was used exactly to protect the PIC, the software written so as it could work with a variation from 0 to about 3V ( a bit more perhaps ), my big problem is that despite the fact that i do have a programmer and the PC software needed for it, i haven't the slightest ideea of how to write a software for any given PIC ( i know it's shamefull but that's the truth ) so i cannot know exactly what imput margin the software is desiged for, i've asked the one that gave me the hex file for detailes but he only sayd that it is good for 50V and 10A... i guess i just have to make sure i cannot go more than 5V on the imput and then try to calibrate it, eyther by changing the shunt as needed or by changing the amplification, i cannot see any other way...

Regarding that max 5v on the PIC imput, i've thought at first to config the shunt and amplification so as it cannot allow more than 5V at the output for those ~5A max, but it is no enough cus what if a shorted output or overload? the power supply it's self will be imune to that ( i'll make it so ) but that would mean much more than 5A current on the shunt so more than 5V on the output of the OA... please explain a bit your suggestion for this? as i see if the OA goes more than +5V D1 will be forward biased and it will carry the margin to the PIC power supply line, but woudn't that increase the pic's supply voltage? or isn't that 5V the pic's supply? I appologise if i am hard headed...
 
Thank you, i did found that config in other datasheets but wasn't sure if it was the one you suggested till now. I have decided tough to go with the differencial amplifier, simulations made me happy, and i will go with a separate supply for the OA, somewhere around 15 or 20V depending on what i have at my disposal, my problem now is not knowing how to write the code and so i cannot know if the old one would still work nor do i know what it exactly needs at the imput to work properly, i guess i'll just have to go by try and error... this is the code in question, too bad i do not know how to read it or edit it...
 

Attachments

Last edited:

FoMoCo

Member
2012-12-04 10:04 pm
That code is useless. It's in hex. There's no easy way to read it. You need the source if you want us to read it. Otherwise, just make sure you can adjust the gain until things match.

For your earlier question: It's highly unlikely that you can raise the 5V supply with the output of that op-amp.