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

    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

  2. #2
    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 13:09.

  3. #3
    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

  4. #4
    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

  5. #5
    boboco's Avatar
    boboco Guest


    Did you find this post helpful? Yes | No

    Default AC Voltmeter

    Hi All,

    Uludere, I tried to send you circuits etc but I'm a bit of a novice to this forum and the files are too big. I'll cut them down to size this evening and send tomorrow, sorry for the delay.

    Sougata, of course for voltmeters, the PIC ADC is really not suitable for any real precision. Nor is any other normal µcontroller for that matter. RMS-type measurement is easier but not better, especially for low levels and changing frequencies, which is why I even contemplate AC chunks. It isn't necessary here to check the zero cross though, assuming we're sampling offset peak to peak and calculating RMS.

    It isn't necessary to measure the exact voltage value, either, and that in all cases. Of importance is that the measurement system used is consistant, that means it detects the same value of any given voltage at all times. Software correction to convert to the correct RMS values is then easy. The above statement includes your remarks about temperature correction.

    A trick I have used, not for AC voltage but for reading optical sensors, was to couple a number of ADC inputs together and to let one intergrate while another converted. This allows a higher reading rate when reading chunks, and of course for all other cases too. Watch the delay requirement for switching ADCs though.

    Greetings,

    Rob

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


    Did you find this post helpful? Yes | No

    Default While integrating you can use the same ADC input

    Hi,

    I do not rely on the PBP ADCIN command. I setup the ADC take one reading first then start the sampling again. While sampling I do the calculation stuff then I introduce whatever more delay is required (pauseus) and repeat.

    Regards

    Sougata

  7. #7
    boboco's Avatar
    boboco Guest


    Did you find this post helpful? Yes | No

    Default AC Voltmeter

    Hi Sougata,

    I don't use the ADCIN command either, unless I'm feeling lazy or there is no need not to. I switch the registers as required. Especially in many uses (I research in Laser Medicine and build a lot of my own equipment) a different integration time for different inputs can be of benefit.

    I even connect CCD array outputs directly to the ADC input and get excellent results by using the input circuitry in the PIC as a quasi charge measurement device. Set the reference voltages to, say, +3V and +1V and we get a good resolution. We don't even need to decouple the input, the charge function of the input capacitor does that.

    Regards,

    Rob

Similar Threads

  1. Circuit Diagram for interfacing AC to PIC IC?
    By wellyboot in forum Schematics
    Replies: 3
    Last Post: - 8th March 2008, 19: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, 12:02
  3. Ac voltmeter Ampermeter
    By onur in forum General
    Replies: 4
    Last Post: - 27th March 2007, 21:13
  4. Special Offer AC -AC adapter
    By lester in forum Adverts
    Replies: 0
    Last Post: - 9th September 2005, 07:52
  5. Detecting AC current
    By rhino in forum Off Topic
    Replies: 8
    Last Post: - 8th July 2005, 21: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