Author Topic: TrueRMS Digital Voltmeter  (Read 31523 times)

0 Members and 1 Guest are viewing this topic.

Offline septer012Topic starter

  • Regular Contributor
  • *
  • Posts: 68
  • Country: us
    • http://www.danielbjohnson.net
TrueRMS Digital Voltmeter
« on: December 10, 2009, 08:13:17 am »
Gotta design one, so I can be considered for an internship.  Anyone have any advice?  I am researching, but if anyone knows of any good white papers, I would love to hear from you!!!

For instance, I was reading about but couldn't quite locate the necessary steps to compute a Crest Factor.

Thanks
« Last Edit: December 10, 2009, 08:15:25 am by septer012 »
Daniel
 

Offline EEVblog

  • Administrator
  • *****
  • Posts: 37738
  • Country: au
    • EEVblog
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19519
  • Country: gb
  • 0999
 

Offline septer012Topic starter

  • Regular Contributor
  • *
  • Posts: 68
  • Country: us
    • http://www.danielbjohnson.net
Re: TrueRMS Digital Voltmeter
« Reply #3 on: December 10, 2009, 04:55:00 pm »
Wow Dave thanks alot.  I was on Analog.com for an hour yesterday and didn't find any of that.  I was trying to learn about Integrating A/D converters because I read that was how most current cheap meters are made. Reading alot on maxim-ic and agilents websites.

The paper question really reads "Design a RMS Voltmeter that uses a microcontroller"  I am just trying to make mine a little more impressive. So I can measure triangle waves, squarewaves, higher then powerline frequency, etc.  Hopefully it works.
Daniel
 

Offline septer012Topic starter

  • Regular Contributor
  • *
  • Posts: 68
  • Country: us
    • http://www.danielbjohnson.net
Re: TrueRMS Digital Voltmeter
« Reply #4 on: December 10, 2009, 05:17:33 pm »
Thanks Hero, I just re-looked at that thread and it is helpful,

To be honest the first time I looked at that thread I left when people started talking about transformers because they dont use transformers in digital meters.  But now that I look a little deeper it is alot of good info for what im doing. Thanks.
Daniel
 

Offline EEVblog

  • Administrator
  • *****
  • Posts: 37738
  • Country: au
    • EEVblog
Re: TrueRMS Digital Voltmeter
« Reply #5 on: December 10, 2009, 08:47:19 pm »
Are you actually allowed to use a True RMS converter chip? If so your job is easy, you just read the DC output of the True RMS chip with the PIC's ADC.

Otherwise you have to sample at a high rate and get your PIC to do the RMS calculations. That could either be done on a "snapshot" of data, i.e. sample the input signal and then do the processing (easiest), or do a continuous "moving window" type display with background sampling (harder).

What is your input voltage range(s)?

Dave.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19519
  • Country: gb
  • 0999
Re: TrueRMS Digital Voltmeter
« Reply #6 on: December 10, 2009, 11:26:29 pm »
I'm not expert with this kind of thing but is it not possible to sample at a lower frequency over a long period of time?

Maybe that would be as as accurate as sampling at a high frequency.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 17815
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: TrueRMS Digital Voltmeter
« Reply #7 on: December 11, 2009, 09:37:09 pm »
I think basically the more samples taken per second the more accurate measurements will be and the higher the frequencies that can be accurately measured
 

Offline septer012Topic starter

  • Regular Contributor
  • *
  • Posts: 68
  • Country: us
    • http://www.danielbjohnson.net
Re: TrueRMS Digital Voltmeter
« Reply #8 on: December 12, 2009, 06:01:48 pm »
Really it doesn't say.  I could use a PIC and do the math but the chip will most likely give me better results.  I got almost a week break from the project because I emailed the guy and told him I had prior obilgations (finals) this upcoming week.

I think im going to use one of those analog devices chips to a PIC18F A/D port (I will have to decide if 10 bit is good enough)  I have to figure out how to switch between the Resistor (range) Load on the input and also notify the PIC which of the ranges im in.
Daniel
 

Offline qno

  • Frequent Contributor
  • **
  • Posts: 422
  • Country: nl
Re: TrueRMS Digital Voltmeter
« Reply #9 on: December 12, 2009, 10:25:50 pm »
Why not bet on both horses?
Make the software for the RMS calculation and order the chip.
It will take some tinkering to get the circuit working.

10 Bits is 1024 resolution or a bit better than 0.1% because RMS is always a positive number.
With some errors in the circuit you can shoot for a 1% accuracy.

Why spend money I don't have on things I don't need to impress people I don't like?
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19519
  • Country: gb
  • 0999
Re: TrueRMS Digital Voltmeter
« Reply #10 on: December 12, 2009, 11:35:31 pm »
You'll need to put a precision rectifier before the ADC input if you want to meause it using a PIC.
 

Offline qno

  • Frequent Contributor
  • **
  • Posts: 422
  • Country: nl
Re: TrueRMS Digital Voltmeter
« Reply #11 on: December 17, 2009, 10:10:48 pm »
Or you can use a -2.5 to 2.5 range having your zero point half way the range.
Why spend money I don't have on things I don't need to impress people I don't like?
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19519
  • Country: gb
  • 0999
Re: TrueRMS Digital Voltmeter
« Reply #12 on: December 17, 2009, 10:22:37 pm »
That will work but a precision rectifier effectively adds another bit to the level of accuracy and can be easily DC coupled to the input.
 

Offline septer012Topic starter

  • Regular Contributor
  • *
  • Posts: 68
  • Country: us
    • http://www.danielbjohnson.net
Re: TrueRMS Digital Voltmeter
« Reply #13 on: December 18, 2009, 08:39:07 am »
I will have to research all of this.

How did you measure negative voltage on a Positive ADC?
Daniel
 

Offline jahonen

  • Super Contributor
  • ***
  • Posts: 1054
  • Country: fi
Re: TrueRMS Digital Voltmeter
« Reply #14 on: December 18, 2009, 04:35:38 pm »
How did you measure negative voltage on a Positive ADC?

This is usually done with biasing the input voltage zero point on mid-scale of the ADC range, e.g. if your ADC input range is 0-5 V, input zero volts produces 2.5 volts on the ADC input. Full negative input then makes 0 volts and full positive 5 volts at the ADC input, respectively.

As far as the accuracy is concerned, I'd keep the analog portion as simple as possible. Simple front-end with protection, scaling and perhaps filtering is optimum solution. Each component you put there, adds (frequency dependent) error, drift, noise etc. Then do all the processing possible in the digital domain. Digital computation is exact and predictable, analog is not.

Regards,
Janne
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19519
  • Country: gb
  • 0999
Re: TrueRMS Digital Voltmeter
« Reply #15 on: December 18, 2009, 11:07:39 pm »
I must add that an AC coupling capacitor is required to couple the AC signal to the input.

Here's a schematic for a precision rectifier, it's more complicated but has the advantages of better precision and it's DC coupled so it won't reject DC signals.

Source: CA3140 data sheet.
 

Offline qno

  • Frequent Contributor
  • **
  • Posts: 422
  • Country: nl
Re: TrueRMS Digital Voltmeter
« Reply #16 on: December 21, 2009, 01:03:25 pm »
There are 2 issues with the circuit.
You need to connect the output to a high impedance load. It will not drive an ADC correctly.
It is slew rate limited.
Why spend money I don't have on things I don't need to impress people I don't like?
 

Offline jahonen

  • Super Contributor
  • ***
  • Posts: 1054
  • Country: fi
Re: TrueRMS Digital Voltmeter
« Reply #17 on: December 21, 2009, 07:40:20 pm »
Rectifier is not required at all, a simple resistor network shown here will accomplish the negative inputs DC-coupled quite easily, here is one for -10…+10 volts in and 0-5 volts out. Of course, one would still need a buffer for ADC driving but that is required more or less anyway.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19519
  • Country: gb
  • 0999
Re: TrueRMS Digital Voltmeter
« Reply #18 on: December 21, 2009, 10:19:34 pm »
There are 2 issues with the circuit.
You need to connect the output to a high impedance load. It will not drive an ADC correctly.
It is slew rate limited.
What's the bandwidth and input impedance of the ADC?

EDIT: The resistor network does look like the simplest approach.
« Last Edit: December 21, 2009, 10:21:36 pm by Hero999 »
 

Offline septer012Topic starter

  • Regular Contributor
  • *
  • Posts: 68
  • Country: us
    • http://www.danielbjohnson.net
Re: TrueRMS Digital Voltmeter
« Reply #19 on: December 21, 2009, 10:38:36 pm »
I am going to try to design with  this flowchart:

measurement probes => Resistor range select => Analog Devices AD636 TrueRMS/DBout => Jahonens Midpoint scaler => High impedence buffer? => PIC18F4550 A/D.



Thank you Jahonen, I really had no idea how to do that!

Hero, I was just going to try to keep it easy and use one of the 13 onboard, 10-bit ADCs on a Microchip PIC18F4550.  I am looking through the datasheet for bandwidth and input impedance.  (maybe these are characteristic measurements they require you to measure yourself?)


Thank you all!
Daniel
 

Offline jahonen

  • Super Contributor
  • ***
  • Posts: 1054
  • Country: fi
Re: TrueRMS Digital Voltmeter
« Reply #20 on: December 22, 2009, 05:50:11 pm »
If you are using an AD636, then you shouldn't need the scaling network, at least for the RMS output. The RMS output is never negative. An AD636 can produce buffered unipolar output, as AD636 contains internal buffer amplifier (in=pin 7 and out=pin 8) perfectly capable of driving the ADC directly. Only caveat there is that the buffer is an emitter follower. Thus it can't sink current. See datasheet fig. 5 and fig. 13. The dB output however, requires level shifting. It also seems to have a quite large temperature coefficient.

Nasty thing about ADCs is that their input impedance is often nonlinear. When the sampling switch closes, the apparent input impedance may drop considerably. Although seemingly low-bandwidth circuit, you might end up with quite fast buffer anyway to reduce the settling time. You might need a buffer if the signal goes also somewhere else. Otherwise, the ADC sampling can cause noise (glitches) on the signal. Figure 21-3 in the PIC datasheet shows the ADC input structure. PIC ADC has several kilo-ohms of internal series resistance (Rss+Ric).

There are some caveats using the AD636 but it can give greater bandwidth than just plain PIC ADC. I'm not so sure if AD636 will improve the accuracy, as the ADC is in the loop anyway. Direct digital computation is better at low frequencies and has better temperature stability. Perhaps just using the MCU ADC could work up to some kHz, if sampling rate would be at least 20 kHz. The cost is of course greatly increased computation requirement, but digital hardware is amazingly cheap nowadays.

Regards,
Janne
« Last Edit: December 22, 2009, 06:13:26 pm by jahonen »
 

Offline septer012Topic starter

  • Regular Contributor
  • *
  • Posts: 68
  • Country: us
    • http://www.danielbjohnson.net
Re: TrueRMS Digital Voltmeter
« Reply #21 on: December 22, 2009, 07:39:12 pm »
You know Janne that makes more sense, its simpler. 

Probes > Range R Network > AC Coupling capacitor > Midpoint Scaler > Buffer > PIC ADC

My PIC will know range selected by circuit logic.

I will Sample on the ADC as fast as I can.  Store data per nyquist and compute 1) square 2) mean 3) square root of the mean

VRMS = [ Avg(v^2) ] ^-1

See any flaws in that?

I will also measure DC Volts by taking a ADC reading before the AC Couple.

I should be able to display four things:   VRMS , DC_offset , VRMS+DC_offset , Crest factor
Daniel
 

Offline jahonen

  • Super Contributor
  • ***
  • Posts: 1054
  • Country: fi
Re: TrueRMS Digital Voltmeter
« Reply #22 on: December 22, 2009, 09:07:48 pm »
Your concept seems ok to me. You could save the AC coupling capacitor by calculating the DC-offset (take mean of the samples) in software and then subtracting this value from samples before RMS calculation to calculate AC RMS, or you could calculate AC+DC RMS without any additional processing, like on some Flukes. This of course reduces the dynamic range, e.g. it is difficult to measure a 1 mV sine on top of 10 volts DC without using any AC-coupling.

Calculations seems fine to me. Crest factor is just ratio of peak to RMS.

RMS calculation gives best results (zero ripple per definition) if done for integer number of periods. You might need to perform some form of software trigger to find the period so that you'll know when to start taking the samples and when to stop. Or then just calculate long "enough". High frequencies are not the problem, but very low frequencies will need some thought. Obviously, one would have hard time measuring RMS on something like 1 mHz signal with any method :) Some simulations and calculations about this might be appropriate here to estimate the requirements.

Regards,
Janne
 

Offline septer012Topic starter

  • Regular Contributor
  • *
  • Posts: 68
  • Country: us
    • http://www.danielbjohnson.net
Re: TrueRMS Digital Voltmeter
« Reply #23 on: December 22, 2009, 10:55:14 pm »
That sounds like a simple solution so I don't waste time calculating too many extra ADC sources.

Here is what my circuit looks like:

http://www.danielbjohnson.net/assets/Uploads/TrueRMS-imagecheck1.png
The image is very large.

I am kind of unsure about the input part but ill think about it.
Daniel
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19519
  • Country: gb
  • 0999
Re: TrueRMS Digital Voltmeter
« Reply #24 on: December 22, 2009, 11:17:39 pm »
Nasty thing about ADCs is that their input impedance is often nonlinear. When the sampling switch closes, the apparent input impedance may drop considerably. Although seemingly low-bandwidth circuit, you might end up with quite fast buffer anyway to reduce the settling time. You might need a buffer if the signal goes also somewhere else. Otherwise, the ADC sampling can cause noise (glitches) on the signal. Figure 21-3 in the PIC datasheet shows the ADC input structure. PIC ADC has several kilo-ohms of internal series resistance (Rss+Ric).
I now can see why the precision rectifier I posted would has problems driving an ADC input. I suppose it can be fixed by adding a buffer but it's not worth it and much easier to use the resistors.

Just for future reference: bandwidth wouldn't have been a problem with the op-amp I suggested.
« Last Edit: December 23, 2009, 01:58:59 pm by Hero999 »
 

Offline jahonen

  • Super Contributor
  • ***
  • Posts: 1054
  • Country: fi
Re: TrueRMS Digital Voltmeter
« Reply #25 on: December 23, 2009, 05:42:54 am »
That sounds like a simple solution so I don't waste time calculating too many extra ADC sources.

Here is what my circuit looks like:

http://www.danielbjohnson.net/assets/Uploads/TrueRMS-imagecheck1.png
The image is very large.

I am kind of unsure about the input part but ill think about it.

I don't know if you really meant to buffer the ADC input with 74LS07, but it won't work with analog signals. Use single-supply opamp instead, something like OP777 etc. Also consider carefully the effect of the midpoint scaling network input impedance to divider network, it might have significant effect (just a hunch, I haven't checked it).

Regards,
Janne
 

Offline septer012Topic starter

  • Regular Contributor
  • *
  • Posts: 68
  • Country: us
    • http://www.danielbjohnson.net
Re: TrueRMS Digital Voltmeter
« Reply #26 on: December 23, 2009, 10:43:05 pm »
 ;) I didn't I just couldn't find the right part, but I have now.
Daniel
 

Offline septer012Topic starter

  • Regular Contributor
  • *
  • Posts: 68
  • Country: us
    • http://www.danielbjohnson.net
Re: TrueRMS Digital Voltmeter
« Reply #27 on: December 29, 2009, 08:12:55 pm »
It does affect the circuit but in simulation it has a linear effect so I can math out a good solution.  Now in a real world with temperature differences im sure it wouldn't be a great solution.
Daniel
 

Offline septer012Topic starter

  • Regular Contributor
  • *
  • Posts: 68
  • Country: us
    • http://www.danielbjohnson.net
Re: TrueRMS Digital Voltmeter
« Reply #28 on: December 31, 2009, 10:05:42 am »
Alright thank you everyone who helped me!

I just submitted the final design.  If you are interested in what I came up with, with some of your help of course.

Daniel-Johnson-A2D-TrueRMS-Voltmeter.pdf
Daniel
 

Offline migsantiago

  • Frequent Contributor
  • **
  • Posts: 381
  • Country: 00
    • MigSantiago's Web Site
Re: TrueRMS Digital Voltmeter
« Reply #29 on: February 03, 2010, 03:10:33 pm »
Maybe it's too late but here you have an RMS function in C language. It calculates the RMS value from an array. I wrote it using the multiple trapezium discrete integration. I have used it on audio signals on a PIC18 microcontroller and it works perfectly.

http://www.todopic.com.ar/foros/index.php?topic=24142.msg238149#msg238149

It's written in spanish but the C code is easy to understand.
 

Offline EEVblog

  • Administrator
  • *****
  • Posts: 37738
  • Country: au
    • EEVblog
Re: TrueRMS Digital Voltmeter
« Reply #30 on: February 03, 2010, 10:40:15 pm »
Alright thank you everyone who helped me!

I just submitted the final design.  If you are interested in what I came up with, with some of your help of course.

Daniel-Johnson-A2D-TrueRMS-Voltmeter.pdf

Nice work!

Loved the "The problem statement left much to be desired." bit. That's the kind of subtle shit stir I'd do!

Dave.
 

Offline septer012Topic starter

  • Regular Contributor
  • *
  • Posts: 68
  • Country: us
    • http://www.danielbjohnson.net
Re: TrueRMS Digital Voltmeter
« Reply #31 on: February 04, 2010, 08:23:19 am »
They never called me back that was alot of work! none the less I found a job doing DSP but getting paid as an Intern.
Daniel
 

Offline migsantiago

  • Frequent Contributor
  • **
  • Posts: 381
  • Country: 00
    • MigSantiago's Web Site
Re: TrueRMS Digital Voltmeter
« Reply #32 on: February 05, 2010, 01:08:04 am »
They never called me back that was alot of work! none the less I found a job doing DSP but getting paid as an Intern.

Gratz Man!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf