Help Measuring Voltage

Go To Last Post
13 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Everyone

I want to use a ATMega 16 to measure voltage and current on an Alternator test bench and Log the data.

My first problem after doing some calculations is that I won't be able to use the ADC of the AVR to measure the voltage. I need it to display/record up to 40V DC with a resolution of 0.1V. With the 10bit ADC this doesn't seem possible. High speed is not required. Is there another way of doing this or do I have to use an external ADC with higher resolution?

Second problem is that the test bench already has a current shunt being used by a gauge to display the current. The current shunt is 200A 50mV deflection. What would be the best way to handle this? Feed it through an OP-Amp to amplify the voltage or just feed it into one of the AVR ADC pins and use the micro to do the calculations. I thought the voltage might be a bit low (50mV).

The other thing I had a question about is what is going to happen to the output of the current shunt if I exceed 200A? Besides probably damaging the shunt, will the voltage exceed 50mV or is that the maximum output. I would think that it would still increase?

Any help with this would be appreciated.

Regards

Chippa

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

10 bits gets you 1024 counts. Since you want a .1v resolution, 10 bits would get you to 102.4 volts.

For your shunt, just use an op-amp for some gain.

Your shunt will have some maximum current limit. It will likely be above 200 amps. The rating of 50mV for 200A just lets you know how to calculate the measurement. If you're drawing 400A, you'll read 100mV. If you're drawing 100A, it will be 25mV.

---
Formerly Torby. Stitch626 just seemed a more descriptive nicname.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What am I missing? 10 bits give 1024 discrete values, and a resolution of 0.039 volts.

Did You mean "with an accuracy of 0.1 V"?

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Use a voltage divider on the 0-40VDC line to scale it down to 0-5VDC That'll give you .039 volts per ADC value. Drop the last bit and it's .0781 If you need to increase acuracy drop the next bit and go up to .15v per ADC value. That's close enough to .1volt per ADC value and about as noise immune as you're going to get on an AVR without special PCB design.

-Curiosity may have killed the cat
-But that's why they have nine lives

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Im trying to learn all I can from reading these forums, so if I may threadjack for just one moment.

Sceadwian wrote:
Use a voltage divider on the 0-40VDC line to scale it down to 0-5VDC That'll give you .039 volts per ADC value...

So if I understand correctly, by putting a voltage divided on the 40v line, we can drop that to something mearsurable by the AVR (0-5). Since we have a 10bit adc, 40 volts will never be more precise then +/-.039v because we have 1023 steps we can measure. At the avr though, we will actually be measuring that 0-5v as it is stepped down by the voltage dividier so it will see steps in the .004v range. Am I close?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok so I must of stuffed up my maths

So with a voltage divider circuit which limits the input to 5V from 40v and we have 10bit ADC

5 / 1024 = 0.00489 per step

now to convert back to the actual voltage

0.00489 * 8 = 0.0391 per step

Is my maths right??

I think I made a mistake when I first worked it out because from this it would roughly work out that for every 3 steps would be 0.1V. An I right or have I completly stuffed this up??

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sounds like the same math I came up with.
40/1023 = .0391
5/1023 = .0048
.0048 * 8 = .0391

So as I understand it, you have plenty of resolution and could actually measure up to 102.3 v and still get .1 +/-

Begs a good point though, I have always used 1023 for my adc conversions. Should I be using 1024?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

recalculate with 1024 and see if it makes a difference! In practice it's usually easier just to round off to 1000. That way you can estimate in your head!

5/1000 = 0.005000 2.26%error
5/1023 = 0.004887 0% error
5/1024 = 0.004882 0.12%error

Go electric!
Happy electric car owner / builder

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't require lightening speed for the project as it is for testing alternators I get back for warranty and can't fault. At the moment I run them in the test bench for up to 2 hours at different loads and have no way of monitoring them if I leave the room. So I was thinking of making up a data logger to log the data which could be sent to a PC for display and printed out to return to the customer. The data collected would not change a lot except when the load is changed.

What sort of problems am I going to have with interference using 10Bit ADC os is it better to stick with 8Bit?

I am using a STK500 an wanted to get it up and running with that before looking at PCB design or is that not going to be possible due to interference?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Begs a good point though, I have always used 1023 for my adc conversions. Should I be using 1024?

Yes, 1024 is correct. Look into the datasheet.

resolution is VRef / 1024.

But your scale is form 0 to 1023, so maximimum decodeable voltage is 1 LSB off VRef.

Klaus
********************************
Look at: www.megausb.de (German)
********************************

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

fearthepenguin wrote:
Since we have a 10bit adc, 40 volts will never be more precise then +/-.039v because we have 1023 steps we can measure.

We need to differentiate between resolution and accuracy.

The resolution is 0.039 volts.

The accuracy is (from the mega16 data sheet) +/- 2 LSB, ie. +/- 0.068 volts. (This is the abridged answer. See the section ADC Accuracy Definitions in the data sheet for more on this.)

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ahh, good point. Thank you very much! I learn more reading this forum then any of the books I have picked up so far.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Looks like you have a good handle on it now.

---
Formerly Torby. Stitch626 just seemed a more descriptive nicname.