peak to peak of voltage

Thread Starter

king40

Joined Jul 17, 2013
75
hi
how possible to measure peak to peak of voltage in bascom avr
i measure voltage with this code :
Rich (BB code):
Enable Adc
Config Adc = Single , Prescaler = Auto
Start Adc
Enable Interrupts
Dim Read_adc As Word
Dim Volt As Single
Read_adc = Getadc(6)
Volt = Read_adc / 1024
Volt = Volt * 25
lcd volt
but i dont know to measure peak to peak of voltage :(
thanks of any help
 

WBahn

Joined Mar 31, 2012
29,976
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?
 

WBahn

Joined Mar 31, 2012
29,976
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?
 

Papabravo

Joined Feb 24, 2006
21,159
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?
 

joeyd999

Joined Jun 6, 2011
5,234
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?
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?
 

Thread Starter

king40

Joined Jul 17, 2013
75
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?
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 ?
 

WBahn

Joined Mar 31, 2012
29,976
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?"
 

WBahn

Joined Mar 31, 2012
29,976
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 ?
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.
 

Thread Starter

king40

Joined Jul 17, 2013
75
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
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
 

Thread Starter

king40

Joined Jul 17, 2013
75
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.
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:
 

WBahn

Joined Mar 31, 2012
29,976
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:
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?
 

WBahn

Joined Mar 31, 2012
29,976
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
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.
 

Thread Starter

king40

Joined Jul 17, 2013
75
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?
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:
 

WBahn

Joined Mar 31, 2012
29,976
Why don't you pick ONE thing and learn how to measure that ONE thing, before trying to measure "all detail" about the waveform?
 
Top