rawrms += adcbuf[count] * adcbuf[count] ;
As I keep trying to explain, there is nothing magic about RMS values. The RMS, and peak are proportional to each other. RMS is difficult to measure, peak is easy. Measure the peak and calculate the RMS from it if you need to but even comparing peak voltages should be enough. If you want an RMS equivalent of a peak sine measurement, divide by sqrt(2), if its a modified sine or some other wave shape, divide by an apropriate amount. Look for more information atL https://masteringelectronicsdesign.com/how-to-derive-the-rms-value-of-pulse-and-square-waveforms/
I can't understand why a simulator should show ripple on an unloaded reservoir capacitor. 100nf should be enough, the only load on the rectifier will be the current through the potential divider and that should be very small. You CAN make the value bigger, it will not make the peak reading wrong but it does mean the response time to the voltage falling will be slower.
If you insist on taking many readings, you will need lots of memory, at least two bytes per sample if you are using a normal 10-bit ADC unless you use a rolling average calculation. It would probably be easier to use an RMS to DC converter, something like an AD536 or equivalent and measure it's DC output.
Brian.
for (i=0 ; timer_interrupt == 1; i++) {
v_adc = (ADCRead(channel)*5)/1023; // outputs 0-5 value
v_squared = v_adc*v_adc; // square the 0-5v signal
Pacc = Pacc + v_squared; // store the result in an accumelator
}
v_mean = Pacc/i;
v_rms = sqrt(v_mean); // takes the sqrt of the accumelated values
v = (v_rms *350)/5; // as 350v is the peak of actual voltage... I will rectify it and use a voltage divider... but no filter, so it can be like sinewave shape but +
unsigned int i;
float v_adc;
unsigned long v_squared;
double v, v_rms, v_mean;
unsigned long Pacc;
unsigned short channel;
RMS converter ICs are very good and accurate but they do add to the overall costs. They work regardless of the input wave shape.
Your code method is good but it might have some problems. The first is that you can't measure negative voltages with the ADC, the second is that 'i' increments repeatedly until the 20mS interrupt so there is a danger of it overflowing it's maximum value. A safer method would be to limit the measurement to a fixed number, say 200 samples at 100uS intervals. It may be easier to set the ADC conversion time to pace the measurements than to use timer interrupts. It really depends on how efficiently your compiler can handle floating point division and multiplication as these are usually slow to execute. If it seems too slow, try using the raw ADC readings without scaling to 5V each time.
Brian.
People are using voltage dividers.
Yes, that's the problem with trusting Proteus. Just for fun, try to feed the input signal to VIN and ground CC, without any coupling capacitors. You'll notice that the simulation works, it's up to you to explain why. My suggestion would be a regular circuit simulator, e.g. LTSpice.
The simulation problems suggest that the Proteus AD736 model doesn't actually reproduce the chip's behavour.
Nevertheless I believe, that the simulated waveforms in standard circuit are correct. Ripple is present by nature of the rms circuit and will occur with other rms chips as well. The datasheet discusses the dimensioning of Cav and additional Cf for different applications.
A possible solution is to accept a certain amount of ripple and let a boxcar averager filter it in the microcontroller. The overall response time will be faster than ever achievable with purely analog signaöl processing.
1-3.
4. There's is no need for an exact sampling frequency. But the RMS measurement must be either performed on full periods, or use low-pass filtering sufficient to average the fluctuation caused by a different measurement window.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?