• AVR Freaks

Hot!Reading Analog Value

Page: 123 > Showing page 1 of 3
Author
john_ive
Super Member
  • Total Posts : 198
  • Reward points : 0
  • Joined: 2017/05/22 22:22:08
  • Location: 0
  • Status: offline
2019/03/18 04:33:26 (permalink)
0

Reading Analog Value

Hai,
Now I’m working in an Multimeter Project,to measure VAC Voltages
In that there are three points.
1.Phase with 230VAC
2.Neutral
3.Supply 2(VAC).Vary from 0VAC to 5 VAC.
The Neutral wire is connected to GND of MCU’s(PIC16F877A) power supply for reference.Phase wire connected to AN0 by resistor network and by adding diode and Supply 2 connected to AN1 by adding diode.While running the ADC code the voltage of phase and Supply 2 are measured correctly by neutral as reference.
 
My doubt is how to measure the voltage between Phase and Supply 2..?            
post edited by john_ive - 2019/03/18 04:43:27
#1

54 Replies Related Threads

    jack@kksound
    code tags!
    • Total Posts : 3198
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: offline
    Re: Reading Analog Value 2019/03/18 08:14:34 (permalink)
    0
    If you have measured the voltage of the Phase and Supply 2 signals with respect to Neutral then you can find the voltage difference between Phase and Supply 2 with simple arithmetic, no need to use the ADC to measure it.
    #2
    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: Reading Analog Value 2019/03/18 12:32:28 (permalink)
    0
    So long as the measurements are taken simultaneously, or at least very close together in time.
     

    Nearly there...
    #3
    PStechPaul
    Super Member
    • Total Posts : 2294
    • Reward points : 0
    • Joined: 2006/06/27 16:11:32
    • Location: Cockeysville, MD, USA
    • Status: online
    Re: Reading Analog Value 2019/03/18 17:23:12 (permalink)
    0
    Simple arithmetic if all AC signals are in phase. Otherwise use a differential amplifier to read Phase to Supply2. Not sure if you need instantaneous voltage sample or true RMS.

     
    #4
    john_ive
    Super Member
    • Total Posts : 198
    • Reward points : 0
    • Joined: 2017/05/22 22:22:08
    • Location: 0
    • Status: offline
    Re: Reading Analog Value 2019/03/19 00:53:33 (permalink)
    0
    How to do arithmetic calculations to find Supply 2..?
    Is their any formula..?
    #5
    pcbbc
    Super Member
    • Total Posts : 1098
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: offline
    Re: Reading Analog Value 2019/03/19 03:18:07 (permalink)
    0
    Really?
    voltage_difference = voltage_phase - voltage_supply;

    #6
    rpg7
    Super Member
    • Total Posts : 1380
    • Reward points : 0
    • Joined: 2003/11/07 12:47:35
    • Status: offline
    Re: Reading Analog Value 2019/03/19 06:14:45 (permalink)
    0
    I think you also need a resistor network for supply2.  5VAC is about 7Vpeak.
     
    #7
    john_ive
    Super Member
    • Total Posts : 198
    • Reward points : 0
    • Joined: 2017/05/22 22:22:08
    • Location: 0
    • Status: offline
    Re: Reading Analog Value 2019/04/25 01:50:51 (permalink)
    0
    By using PIC18F4520 I tried to read the DC voltage from 0VDC to 5VDC.The DC supply is connected to AN0 pin by using the above circuit.
     
    When the above code is run means,there is no output in LCD.It simply showing 0000 as voltage.
    I checked the LCD with predefined value.It working fine.
     
    Please help to solve this issue.How to read the voltage from AN0 pin..?

    Attached Image(s)

    #8
    pcbbc
    Super Member
    • Total Posts : 1098
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: offline
    Re: Reading Analog Value 2019/04/25 02:39:28 (permalink)
    +1 (1)
    You can read the voltage from AN0 using some code.
    #9
    john_ive
    Super Member
    • Total Posts : 198
    • Reward points : 0
    • Joined: 2017/05/22 22:22:08
    • Location: 0
    • Status: offline
    Re: Reading Analog Value 2019/04/25 02:42:29 (permalink)
    0
    pcbbc
    You can read the voltage from AN0 using some code.


    Sorry Can you explain..?
    #10
    Mysil
    Super Member
    • Total Posts : 3325
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re: Reading Analog Value 2019/04/25 04:04:28 (permalink)
    +1 (1)
    Hi,
    If you have code to measure one voltage on one pin,
    then you may use very similar code to measure another voltage on another pin.
     
    What is the source code you are trying to use for voltage measuremrnts with PIC18F4520. 
    There is no code shown in message #8.
    In MPLAB X, there is a 'Package' tool that will collect all files needed to reproduce a project, into a .zip file.
    The .zip file may be used as attachment to a forum message.
     
        Mysil
    #11
    john_ive
    Super Member
    • Total Posts : 198
    • Reward points : 0
    • Joined: 2017/05/22 22:22:08
    • Location: 0
    • Status: offline
    Re: Reading Analog Value 2019/04/25 04:07:52 (permalink)
    0
    I'm really sorry for inconvenience.
    i can't attach the code.
    I'm trying on that...
    #12
    john_ive
    Super Member
    • Total Posts : 198
    • Reward points : 0
    • Joined: 2017/05/22 22:22:08
    • Location: 0
    • Status: offline
    Re: Reading Analog Value 2019/04/25 04:13:58 (permalink)
    0
    If the code is copied from mplab x ide and pasted with in [code] and clicked on SUBMIT POST means there is no response on page.
     
    Tried with different browsers also.
    #13
    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: Reading Analog Value 2019/04/25 04:24:25 (permalink)
    +1 (1)
    That means your code contains one of the expressions that triggers the stupid firewall on this forum.
    Most probably a word ending with "char", immediately followed by "(".
    Try zipping the file first, or renaming "char" to "chr".
     

    Nearly there...
    #14
    pcbbc
    Super Member
    • Total Posts : 1098
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: offline
    Re: Reading Analog Value 2019/04/25 04:27:07 (permalink)
    +1 (1)
    john_ive
    If the code is copied from mplab x ide and pasted with in [code] and clicked on SUBMIT POST means there is no response on page.
     
    Tried with different browsers also.


    The forum firewall is blocking you due to some crazy rules.  Usually it is some function named ...Chár(....) in your code.


    Some options to workaround this stupid issue are:
    a) Do not name any functions Chár(...) in your code
    b) Attach as an attachment
     
    Note I have used an accented "a" in the above so I can post this message.
    #15
    john_ive
    Super Member
    • Total Posts : 198
    • Reward points : 0
    • Joined: 2017/05/22 22:22:08
    • Location: 0
    • Status: offline
    Re: Reading Analog Value 2019/04/25 04:35:44 (permalink)
    0
    Please find the code in ZIP file
    #16
    1and0
    Access is Denied
    • Total Posts : 9297
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Reading Analog Value 2019/04/25 04:44:42 (permalink)
    +1 (1)
    At a quick scan of your code, the ADC reading looks okay, but you have to convert the digit numbers to ASCII for display to the LCD. 
    #17
    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: Reading Analog Value 2019/04/25 04:46:05 (permalink)
    +1 (1)
    I suspect that
        lcd_putch(iv_temp2);
        lcd_putch(iv_temp4);
        lcd_putch(iv_temp6);
        lcd_putch(iv_temp7);

    should be
        lcd_putch(iv_temp2 + '0');
        lcd_putch(iv_temp4+ '0');
        lcd_putch(iv_temp6+ '0');
        lcd_putch(iv_temp7+ '0');

     

    Nearly there...
    #18
    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: Reading Analog Value 2019/04/25 04:47:21 (permalink)
    +1 (1)
    I also suspect that the itoa() function could make your life much easier.
     

    Nearly there...
    #19
    john_ive
    Super Member
    • Total Posts : 198
    • Reward points : 0
    • Joined: 2017/05/22 22:22:08
    • Location: 0
    • Status: offline
    Re: Reading Analog Value 2019/04/25 04:50:28 (permalink)
    0
    After disabling the ADC pin and predefined value is given to input_volatge variable means,the predefined value is correctly shown in display.
     
    #20
    Page: 123 > Showing page 1 of 3
    Jump to:
    © 2019 APG vNext Commercial Version 4.5