Need Help On Ac Voltmeter !!


Closed Thread
Results 1 to 22 of 22

Hybrid View

  1. #1
    boboco's Avatar
    boboco Guest


    Did you find this post helpful? Yes | No

    Smile AC Voltmeter

    Hi All,


    most has been already said, but a few points to the remarks of other posters, thanks by the way.

    One safety point to start: by any sort of voltage (current) measurement please be sure that the complete supply to the PIC etc. is either floating or that grounds of both circuits (Voltmeter and Circuit to be tested) are connected to the same level.

    To measure low AC voltages (< ca. 10V) accurately by rectification it is necessary to use ideal diodes. Normal diodes will have a forward drop voltage of ca. 0.6V (silicon) or ca. 0.3V (germanium). Best here is to use two OPs with diodes in the feedback, trimmed to 0V. For those who wish, I will be happy to supply circuits etc.

    OP use has the additional advantage of common mode rejection and quasi-floating inputs. It also allows good frequency compensation and, of course, fine adjustment.

    To avoid such circuitry it can (with a bit of fiddling) be done by setting the PIC power supply ground to have an offset to the half of the AC peak to be measured. Set a resistor divider chain so as to arrange for an AC signal of not more than +/2.5V at an ADC input.

    Read this input as fast as possible at a consistant frequency. While the e.g. PIC16F877 has a 10 bit ADC, you will have an accuracy of not more than 9 bit, so if you measure 300 V you will have a maximal possible accuracy of ca. 0.6V.

    With a 4 meg oscillator and a sample time from say 50 uS you could have a theorectical sample rate of 20 K/S, at 50 Hz a read of 400 per cycle. By adding all values from lowest to highest each cycle, a value can be calculated that will represent the AC voltage.

    By measuring how many reads are possible in the one sweep, a rudimentery frequency value can be detected. By adding new volt and frequency values to the old and dividing by two, each value is averaged and will become more accurate with time. This accuracy will be maintained up to Nyquist, which put very simply says that if you can't have more than one sample per half-wave, you can't measure it. (Not completely right, I know, but good enough for now.)

    If any are interested, let me know with details of max. V, max. F and accuracy and I will be happy to help.

    Greetings,

    Rob

  2. #2
    Join Date
    Aug 2004
    Posts
    64


    Did you find this post helpful? Yes | No

    Default

    Thanks Rob:
    I will try with a RMS to DC converter.
    Regards..
    Ruben de la Pena V

  3. #3
    Join Date
    Apr 2005
    Posts
    32


    Did you find this post helpful? Yes | No

    Default

    thx rob

    i understood like this..

    i am going to Read this input ,which is reduced to 2.5 V ac, every 50 uS.
    then i am going to add all values at each cyle !!

    thx

  4. #4
    boboco's Avatar
    boboco Guest


    Did you find this post helpful? Yes | No

    Post

    Hi Uludere,


    Have you converted to DC (RMS method) or are you reading AC?

    If you have converted to DC, you can read each 50 uS and average the readings, but only if you are reading lower frequencies. Taking as example 50 Hz, you have a cycle period of 20 mS. Reading at 50uS you have 400 reads per 20 mS cycle. Add each input and divide by two each time to average.


    Example:

    readinput:

    ADCIN 0, Readvolts 'Get value

    volts = volts + readvolts 'Add value to volts variable

    volts = volts / 2 'Average volts variable

    GOTO readinput 'Start again

    With this you'll get fairly good results up to about 100 Hz, then it will start getting increasingly erratic.

    If you are measuring AC directly it's a little more complicated. It also depends on if you are measuring floating AC (not swinging symmetrically around ground) or grounded (swinging symmetrically about ground).

    If you have arranged so that the AC is swinging around 2.5V at the PIC ADC input you read inputs and find out the highest and lowest values, which you use to calculate the difference.

    Example

    Readinput:

    ADCIN 0, readvolts ‘Read input

    IF readvolts > highvalue THEN highvalue = readvolts ‘Find maximal value

    IF readvolts < lowvalue THEN lowvalue = readvolts ‘Find minimal value

    Voltsvalue = highvalue – lowvalue ‘Calculate difference to find AC value

    GOTO Readinput


    To be honest, neither method is especially good or accurate, but with the addition of a few components you could create a stable, accurate and precise AC voltmeter, which I think would be of more interest to you than the above two mwthods. If you would prefer that, please let me know and I’ll send you the circuit and details.


    GHreetings,

    Rob

  5. #5
    Join Date
    Apr 2005
    Posts
    32


    Did you find this post helpful? Yes | No

    Default

    thx you very much rob !!

    I wrote this code. for AC measurment . But i didn't check on real device!
    does it work ? It worked with DC :-)
    If you can send any cirtuit and detail , it will be help to us !

    best regards


    Define LOADER_USED 1
    ;Define OSC 20
    'Test Kart LCD
    Define LCD_DREG PORTD
    Define LCD_DBIT 4
    Define LCD_RSREG PORTE
    Define LCD_RSBIT 0
    Define LCD_EREG PORTE
    Define LCD_EBIT 1


    ' Define ADCIN parameters
    Define ADC_BITS 10 ' Set number of bits in result
    Define ADC_CLOCK 3 ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50 ' Set sampling time in uS

    adval var word ' Create adval to store result
    AcVolt var word
    Acvolt2 var word
    volt1 var word
    volt2 var word
    Cnt var byte
    Cnt =1

    ADCON1 = 7 ' Set PORTA and PORTE to digital
    Low PORTE.2 ' LCD R/W line low (W)
    Pause 100 ' Wait for LCD to start up


    TRISA = %11111111 ' Set PORTA to all input
    ADCON1 = %10000010 ' Set PORTA analog and right justify result

    loop:
    For cnt = 1 to 400
    ADCIN 0, adval ' Read channel 0 to adval
    adval= (adval*10)/204 ' 0 -5 V
    volt1 = adval/10
    Volt2= (adval - volt1*10)

    'LCDout$fe, 1 ,"Value: ",dec(volt1) ,".",dec (volt2), " Say:" ,dec say

    ACVolt = Acvolt + (volt1)*(volt1)
    AcVolt2= AcVolt2+ volt2*volt2

    'LCDout$fe, $c0 ,"Value: ",DEC (acvolt )
    'pause 250
    pauseus 50
    next cnt

    acvolt = sqr(acvolt/400)
    AcVolt2= sqr(Acvolt2/400)


    LCDout$fe, 1 ,"RMS AC V: ",DEC (acvolt),".", dec acvolt2' Display value


    ' Pause 1000 ' Wait .1 second
    adval=0

    Goto loop ' Do it forever
    End
    Last edited by uludere72; - 26th January 2006 at 14:09.

  6. #6
    boboco's Avatar
    boboco Guest


    Did you find this post helpful? Yes | No

    Smile AC Voltmeter

    Hi Uludere,

    In general your code goes in the right direction but there are a few problems, for example Cnt is declared as byte (255) so FOR Cnt = 0 TO 400 won't work (Rollover), Cnt must be declared as word. This is not so good then in Loops, using word variables causes enormous delays compared to bytes.

    I'll get something together for you this evening and send it to you tomorrow.

    Best regards,

    Rob

  7. #7
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default RMS to DC converter is the best approach

    Hi,

    For instrumentation purposes it should be kept in mind that the ADC in the PIC is poor in the lower range (Less than 2 Volts). So you need a shifting reference that actually increases the resolution.

    If you measure the AC in chunks you need a zero cross sense circuit to kick your measurement routines.Also noise (motor current) would make it worse.

    As mentioned by lab310 distortion and PF in the input waveform would give erroneous result. You may use a software based pseudo differential measurement technique.

    I believe depending on the accuracy you need you should choose a solution. As mentioned amplifying the AC and introducing a gain of 0.707 do give results but in the lower side the accuracy is not good enough due to the conversion slope.You can handle this in software.

    I would suggest that you go for a RMS converter and use a temperature compensated reference for the PIC. Do the AD in sleep via interrupt. Sample 16 times and do an average.This gives best results.

    Good Luck.

    Regards

    Sougata

Similar Threads

  1. Circuit Diagram for interfacing AC to PIC IC?
    By wellyboot in forum Schematics
    Replies: 3
    Last Post: - 8th March 2008, 20:40
  2. How to read AC mains with an inductance coil
    By KB3BYT in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 20th February 2008, 13:02
  3. Ac voltmeter Ampermeter
    By onur in forum General
    Replies: 4
    Last Post: - 27th March 2007, 22:13
  4. Special Offer AC -AC adapter
    By lester in forum Adverts
    Replies: 0
    Last Post: - 9th September 2005, 08:52
  5. Detecting AC current
    By rhino in forum Off Topic
    Replies: 8
    Last Post: - 8th July 2005, 22:31

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts