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.

Average Voltage

Status
Not open for further replies.

philm01

New Member
Good evening everyone,

I have a quick circuits question which I hope someone can help me with.

I am trying to build a circuit which will "compute" the average voltage of an arbitrary waveform (fr example, I have this current sensor which outputs a 0 - 5 V analog signal. To find the average current, I would find the average voltage coming out of the sensor). I am thinking that I will need an integrator. I have been searching on many sites but my find has turned up no results. I hope that someone here will be able to help me on this, thank you very much. (Now, if someone has a better idea on how to accomplish this, then that would be great)
 
Is this AC current? If so, the average is zero and when you measure/calculate it, you simply get the DC bias that you have applied.
 
An RC low-pass filter can act as a running integrator. With the proper time-constant as compared to the lowest frequency of your signal the integrator voltage will be the running average of the waveform. What is the nature of the waveform?
 
Over what period do you want the average? Milliseconds? Months? ....?
Is this a one-time average or a running average?
 
It is a running average that will cover a period of a few milliseconds. I really like the idea of using the low pass filter. Looking up information about that
 
I am looking for a circuit that will output a DC voltage that is the average voltage of an arbitrary waveform
 
Oh and the wavform will be no higher then 5V and no lower 0V. A micro controller is going to be reading the voltage via ADC. I hope this helps.
 
In the absence of more detailed information about your signal which you are trying to average, I have two suggestions.

1 A simple RC lowpass filter, with a time constant of (say) 50ms.
Connect a 10K Ohm resistor in series with the signal and a 5uF capacitor across the signal lines on the downstream side of the resistor.
Easy and simple.

2 Do the averaging in software in the microprocessor.
Have the ADC sample the signal at 1ms intervals (if the ADC can work this quickly), add together the last 8 or 16 readings and then divide the sum by 8 or 16.
(Dividing by a binary number is easy, just shift right by the approriate number of bits, ie 3 to divide by 8, 4 to divide by 16).

JimB
 
The software averaging that JimB described gives you a snapshoot average over the number of samples averaged so you get a new value every n samples. A moving average may be better. In that case you start as JimB noted to get the first sample average of the desired number of samples. Then for each additional sample you add this sample to the sum, subtract the oldest sample in the sum (which you must keep in memory) and then divide by the number of samples to get the average. Thus each sample will give you a new (moving or running) average, similar to what sampling an RC filter output would give.
 
And even better yet, you can use exponential smoothing.

New average = alpha*(New Sample) + (1-alhpa)*(Old average)

alpha is a parameter. Must be less than 1. The less it is the more smoothing you exert.

This way you do not need to keep track of your past samples. You only need to store the new average. Calculation can be done real quick in integers, like for alpha = 0.125

C:
average = (sample + 7*average + 4)>>3;
 
Thank you all very much for your input. I greatly appreciate. I have some screenshots of a voltage signal. This is not mine. I am replicating what someone else did and this is their screenshot. Basically, I am using a gated pulse that will go to a transformer. This is a screenshot of the primary.

I would like to build a circuit that will take this voltage waveform and "compute" the average voltage of this waveform. The output of the circuit will be a DC voltage that is the average voltage of the waveform. I am going to have 4 of these circuits and I am unable to take ADC readings during the pulsing of the transformer. Simply because I will not get enough resolution.

The RC filter looks feasible but I am concerned that it will simply smooth out the waveform and I am not going to get DC. Please correct me if I am mistaken.
 

Attachments

  • DSC_0105.jpg
    DSC_0105.jpg
    3.4 MB · Views: 234
Where is the 0V level on that waveform? The RC integrator will give you the average of the waveform including any DC component. But if it has a negative component then that will subtract from the positive (giving a true average). If you want any negative portion of the signal to be included in the positive average then you will need to rectify the signal with a precision rectifier before averaging.
 
Crutschow wrote:
A moving average may be better.
That is what I had in mind, but did not elaborate on that bit. Thank you for prompting.:)

Philm01 wrote:
The RC filter looks feasible but I am concerned that it will simply smooth out the waveform and I am not going to get DC. Please correct me if I am mistaken.
The LPF will smooth out the fluctuations and you will get a varying DC value which is proportional to the average of the wiggly signal.
How much that DC value varies will depend on the time constant of the LPF compared with the lowest frequency in the signal.

JimB
 
Ok, so I built the RC filter and placed a 5 V square wave (0 - 5V) into it at 100 Hz. I am getting out 3.5 V. I want to check with everyone here, but does that sound correct?

Also, a side question. But I have been wondering about this, are there any guidelines on when to find average voltage or peak voltage (say this voltage is from a current sensor and you had the option to find either average or peak current. During what time would you use average current or peak current.)
 
Ok, so I built the RC filter and placed a 5 V square wave (0 - 5V) into it at 100 Hz. I am getting out 3.5 V. I want to check with everyone here, but does that sound correct?
Nearly.
If the squarewave has an exact 50/50 mark-space ratio, you should get 2.5 volts.
As the mark-space ratio rises to say 90/10, you should get 4.5 volts, and similarly when the m-s ratio is 10/90 you should get 0.5 volts.

Also, a side question. But I have been wondering about this, are there any guidelines on when to find average voltage or peak voltage (say this voltage is from a current sensor and you had the option to find either average or peak current. During what time would you use average current or peak current.)
I am not sure what you are asking here.
If you want the peak value of something, then measure the peak value.
If you want the average value of something, then measure the average value.

JimB
 
If your filter time constant is only 50ms you are going to get a lot of ripple on your DC 'average' from a 100Hz signal (period = 10ms). The time constant should be much greater than the period of the signal.
 
The OP's aside:

Electrical measurments of inductive loads is a pain. Period.
RMS current. RMS voltage and pf are common wanted numbers.

Peak current is also useful. e.g. starting current of a motor.

Lets see: amps, watts, vars, pf.
 
I apologize for the late response.

I want to personally thank everyone for their help.

KeepItSimple, thank you. I think your reply has made a decision for me on what to do. Since I will be measuring inductive loads, I will be finding the RMS Current and voltage for my system. To do that, I will use a low-pass filter to eliminate high voltage spikes and then send it to a peak detector to find the highest voltage. In the microcontroller, I will divide that number by sqrt(2) to find RMS values. I believe that this is the best approach.

Thank you, I will consider this question answered.
 
A reminder that RMS current * RMS voltage is NOT RMS power. You cannot assume that that current is sinusoidal for an inductive load.

You might consider some energy measuring IC's such as these: **broken link removed**

You can also look at some of the application notes for Instrumentation and Isolation Amplifiers. For a start, you can get the instantaneous value of I, the Instantaneous value of V and the instantaneous Power using an analog multiplier. That becomes your start.

See: https://en.wikipedia.org/wiki/AC_power and https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=0CDIQFjAB&url=http%3A%2F%2Fww1.microchip.com%2Fdownloads%2Fen%2FAppNotes%2F30452a.pdf&ei=WrEzU-zwEurH0AHE7YGgCQ&usg=AFQjCNHdeSmk_nM9iguWcp-xtWCjhmjM_g&sig2=9GK84z6O5SV59sCPvRArZQ&bvm=bv.63808443,d.dmQ&cad=rja

Then there is always "good enough".

At work we used analog meters to "keep an eye on the process" and even recorded "POWER", but the voltage was from a phase angle fired source into a transformer. We did, for one experiment, use a real energy meter until I convinced the powers that be to use DC power supplies.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top