peak to peak of voltage

Discussion in 'Embedded Systems and Microcontrollers' started by king40, Aug 2, 2013.

  1. king40

    Thread Starter Member

    Jul 17, 2013
    75
    0
    hi
    how possible to measure peak to peak of voltage in bascom avr
    i measure voltage with this code :
    Code ( (Unknown Language)):
    1.  
    2. Enable Adc
    3. Config Adc = Single , Prescaler = Auto
    4. Start Adc
    5. Enable Interrupts
    6. Dim Read_adc As Word
    7. Dim Volt As Single
    8. Read_adc = Getadc(6)
    9. Volt = Read_adc / 1024
    10. Volt = Volt * 25
    11. lcd volt
    12.  
    13.  
    but i dont know to measure peak to peak of voltage :(
    thanks of any help
     
  2. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,795
    How many samples can you take per cycle of the waveform you are measuring?

    What ability to you have to put circuitry in front of the A2D?
     
    king40 likes this.
  3. king40

    Thread Starter Member

    Jul 17, 2013
    75
    0
    i dont know about take samples of per cycle in waveform :confused:
     
  4. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,795
    Well, what you are expecting to do? Take a single voltage measurement at one moment in time and somehow get the peak-to-peak voltage of the waveform?
     
    king40 likes this.
  5. Papabravo

    Expert

    Feb 24, 2006
    10,142
    1,790
    Well....
    If the waveform is a sine wave then it has an amplitude and a frequency. The reciprocal of the frequency is the period. In order to have some chance of measuring the peak value you need to determine the period. This can be done with some precision by locating the zero crossings. The peaks are one quarter of a cycle before and after the zero crossings.
    Does that help?
     
    king40 likes this.
  6. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,678
    2,737
    This seems like a rather round-about way of peak detection. Why not just sample the signal *fast enough* to capture the peaks, and keep your low and high values?
     
    king40 likes this.
  7. king40

    Thread Starter Member

    Jul 17, 2013
    75
    0
    thanks for answer :)
    yes exactly :rolleyes:
     
  8. king40

    Thread Starter Member

    Jul 17, 2013
    75
    0
    i think most of the voltage have sine waveform.

    your means is:
    i can measure period of frequency by create a timer
    and then measuring peak by the period ?
     
  9. king40

    Thread Starter Member

    Jul 17, 2013
    75
    0
    thanks
    how i can take sample of signal??
     
  10. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,795
    Okay, then I just measured a voltage and it was 1.435V. What is the peak-to-peak voltage?

    If you can't do it based on one measured value, how can you possibly hope to write a computer program to do it?

    But now let's say that I measure the voltage every, say, 5ms and I get the following results:

    Voltage (V)
    31.257
    31.746
    5.216
    -22.282
    -23.748
    2.258
    30.200
    32.642
    7.185
    -21.173
    -24.587
    0.295
    29.041


    What is your best estimate of the peak-to-peak voltage?

    How might you do this programmatically?

    There are a number of different ways, some simpler and some more accurate than others. Which is "best" depends on your needs. The real question isn't, "which is best?", but rather something more like, "which method is the simplest/cheapest while also being good enough?"
     
  11. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,795
    Knowing the period isn't going to give you the peak-to-peak voltage. In theory it would allow you take one measurement at one peak and then another measurement at the other peak. But it tricky to get it good enough and the time you spend trying to find the period and the proper time reference to you, you could have just brute forced the measurement of the min and max values and calculated the peak-to-peak votlage directly.
     
    king40 likes this.
  12. king40

    Thread Starter Member

    Jul 17, 2013
    75
    0
    i'm new in avr bascom and want to learning
    i use external 12MHZ crystal
    and my micro is ATMEGA 32
    my min voltage is 0
    and my max voltage is 25
    i can measure voltage but
    i dont know how to measure peak to peak of voltage
     
  13. king40

    Thread Starter Member

    Jul 17, 2013
    75
    0
    i think this way very good
    if i measure the one peak i have max values
    and if i measure the other peak i have min values
    but how i can measure amplitude in max values and min values :confused:
    [​IMG]
     
  14. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,795
    Are you trying to measure peak-to-peak voltage or are you trying to measure amplitude. These are NOT the same thing. Make up your mind!

    Go back to the post where I gave a list of measured values and try to answer the question. What is the peak-to-peak voltage of that data set? Now plot the data on a time axis, knowing that the measurements were taken 5ms apart. What is your best estimate of the peak-to-peak voltage based on the drawing?
     
    king40 likes this.
  15. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,795
    The min voltage that you can measure is 0V. The max voltage you can measure is (probably) 2.5V (unless you have a voltage divider or other attenuator).

    But these are the min/max we are talking about, they are the capabilities of your system. The min/max we are talkiing about are the min and max values OF THE WAVEFORM being measured.
     
    king40 likes this.
  16. king40

    Thread Starter Member

    Jul 17, 2013
    75
    0
    i wants in first post measure peak to peak of voltage
    but when i see post#5 by @Papabravo
    this post change my mind
    this is possible to measure all detail about waveform of voltage
    like amplitude ,wavelength ,.....??:rolleyes:
     
  17. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,795
    Why don't you pick ONE thing and learn how to measure that ONE thing, before trying to measure "all detail" about the waveform?
     
Loading...