DSPRelated.com
Forums

convert dB to dBV

Started by ngeva0 December 6, 2005
I have a set of random data that was generated by sampling the noise. Right
now I am plotting the PSD of the noise in dB. How do I plot it with respect
to dBV? The reason for doing this is because the magnitude I got in the
plot using MATLAB is in dB. But on the dynamic signal analyzer, it shows
the similar plot but the magnitude is in dBV. I want to make sure what I
got from MATLAB is correct by checking with the signal analyzer.The
following is my code:

Fs=50000;

datasize=size(RANDOM);
numsample=datasize(1);
numsample=numsample;

FFTX=fft(RANDOM(:,2),numsample);
X=FFTX(1:floor(numsample/2)).*conj(FFTX(1:floor(numsample/2)));

BW=1.5*Fs*numsample;
X=X/BW;

Omega=(0:numsample-1)/(numsample)*Fs;
Omega=Omega(1:floor(numsample/2));

H=plot(Omega,10*log10(X));
set(H,'Color','BLACK');

The file name is called RANDOM. Thanks for your help!! 



To calculate in decibels, you need to know the reference, e.g. dBV,
dBm, etc as dB is a gain (or attenuation) from that reference.  If I
remember correctly, dBV should mean that 0 dB is equivalent to 1V and
dBm is similarly referenced to 1mV.

>To calculate in decibels, you need to know the reference, e.g. dBV, >dBm, etc as dB is a gain (or attenuation) from that reference. If I >remember correctly, dBV should mean that 0 dB is equivalent to 1V and >dBm is similarly referenced to 1mV. > >
Yes I have been searching online and I think you need to know the reference voltage. But I don't know exactly how you find this reference voltage. In my setup, I have a noise generator, and a oscilliscope that is connected to a computer. The output of the generator is connected to one of the channels on the oscilliscope. Then sample the waveform on the osciliscope using the computer. Thus, I will get a set of random data. How do I find the reference voltage? Is it the amplitude of the noise generated by the noise generator? Is it from the ocsiliscope? Thank you.
ngeva0 wrote:

>>To calculate in decibels, you need to know the reference, e.g. dBV, >>dBm, etc as dB is a gain (or attenuation) from that reference. If I >>remember correctly, dBV should mean that 0 dB is equivalent to 1V and >>dBm is similarly referenced to 1mV. >> >> > > > Yes I have been searching online and I think you need to know the > reference voltage. But I don't know exactly how you find this reference > voltage. In my setup, I have a noise generator, and a oscilliscope that is > connected to a computer. The output of the generator is connected to one of > the channels on the oscilliscope. Then sample the waveform on the > osciliscope using the computer. Thus, I will get a set of random data. How > do I find the reference voltage? Is it the amplitude of the noise generated > by the noise generator? Is it from the ocsiliscope? Thank you.
The reference voltage is a consequence of your analog to digital converter, which in this case is your o-scope. The easiest way to find this would be to put a known voltage into the scope (like the 1.5V from a flashlight battery, or the square wave test signal on the scope, if it has one). Read in your file and look at it with a text editor, then figure out how to go from the information on the o-scope screen to the information in the file. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
the ref for 0 dBv = 1Volt

the ref for 0 dBm = 1 mW  yes Watt  of power not voltage
(this is commonly used for all RF work except CATV)

the ref for 0 dBmV = 1 mV yes Volt
this is commonly used for CATV

Mark

>ngeva0 wrote: > >>>To calculate in decibels, you need to know the reference, e.g. dBV, >>>dBm, etc as dB is a gain (or attenuation) from that reference. If I >>>remember correctly, dBV should mean that 0 dB is equivalent to 1V and >>>dBm is similarly referenced to 1mV. >>> >>> >> >> >> Yes I have been searching online and I think you need to know the >> reference voltage. But I don't know exactly how you find this
reference
>> voltage. In my setup, I have a noise generator, and a oscilliscope that
is
>> connected to a computer. The output of the generator is connected to
one of
>> the channels on the oscilliscope. Then sample the waveform on the >> osciliscope using the computer. Thus, I will get a set of random data.
How
>> do I find the reference voltage? Is it the amplitude of the noise
generated
>> by the noise generator? Is it from the ocsiliscope? Thank you. > >The reference voltage is a consequence of your analog to digital >converter, which in this case is your o-scope. The easiest way to find >this would be to put a known voltage into the scope (like the 1.5V from >a flashlight battery, or the square wave test signal on the scope, if it
>has one). Read in your file and look at it with a text editor, then >figure out how to go from the information on the o-scope screen to the >information in the file. > >-- > >Tim Wescott >Wescott Design Services >http://www.wescottdesign.com >
Hi Tim: Thanks for you advice. The data I got in the file matches to what is on the screen of the o-scope (the data pattern looks like the periodic square wave I put in). The voltages measured seem reasonable. But the magnitude I got in the MATLAB is about -20 to -40dB off from the magnitude in dBV shows on the signal analyzer(same plot, only the magnitude is off). I divided my data by 100, then plotted again. Now the magnitude in dB shows in the MATLAB is close to the magnitude in dBV on the signal analyzer. Does it mean anything?
ngeva0 wrote:

>>ngeva0 wrote: >> >> >>>>To calculate in decibels, you need to know the reference, e.g. dBV, >>>>dBm, etc as dB is a gain (or attenuation) from that reference. If I >>>>remember correctly, dBV should mean that 0 dB is equivalent to 1V and >>>>dBm is similarly referenced to 1mV. >>>> >>>> >>> >>> >>>Yes I have been searching online and I think you need to know the >>>reference voltage. But I don't know exactly how you find this > > reference > >>>voltage. In my setup, I have a noise generator, and a oscilliscope that > > is > >>>connected to a computer. The output of the generator is connected to > > one of > >>>the channels on the oscilliscope. Then sample the waveform on the >>>osciliscope using the computer. Thus, I will get a set of random data. > > How > >>>do I find the reference voltage? Is it the amplitude of the noise > > generated > >>>by the noise generator? Is it from the ocsiliscope? Thank you. >> >>The reference voltage is a consequence of your analog to digital >>converter, which in this case is your o-scope. The easiest way to find >>this would be to put a known voltage into the scope (like the 1.5V from >>a flashlight battery, or the square wave test signal on the scope, if it > > >>has one). Read in your file and look at it with a text editor, then >>figure out how to go from the information on the o-scope screen to the >>information in the file. >> >>-- >> >>Tim Wescott >>Wescott Design Services >>http://www.wescottdesign.com >> > > > Hi Tim: > > Thanks for you advice. The data I got in the file matches to what is on > the screen of the o-scope (the data pattern looks like the periodic square > wave I put in). The voltages measured seem reasonable. But the magnitude I > got in the MATLAB is about -20 to -40dB off from the magnitude in dBV > shows on the signal analyzer(same plot, only the magnitude is off). I > divided my data by 100, then plotted again. Now the magnitude in dB shows > in the MATLAB is close to the magnitude in dBV on the signal analyzer. > Does it mean anything?
You may have an issue with scaling and/or the number of samples you're using. A PSD calculation should take the sampling rate into account to bring the FFT results into the real world -- Matlab may not be doing it right, it may have an oddball way to do the scaling, or you just may not be using the function correctly. I'd look at the help for the function you're using, or if you've made your own PSD calculator I'd double check that you're handling the FFT scaling and sample-rate scaling correctly. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
>ngeva0 wrote: > >>>ngeva0 wrote: >>> >>> >>>>>To calculate in decibels, you need to know the reference, e.g. dBV, >>>>>dBm, etc as dB is a gain (or attenuation) from that reference. If I >>>>>remember correctly, dBV should mean that 0 dB is equivalent to 1V
and
>>>>>dBm is similarly referenced to 1mV. >>>>> >>>>> >>>> >>>> >>>>Yes I have been searching online and I think you need to know the >>>>reference voltage. But I don't know exactly how you find this >> >> reference >> >>>>voltage. In my setup, I have a noise generator, and a oscilliscope
that
>> >> is >> >>>>connected to a computer. The output of the generator is connected to >> >> one of >> >>>>the channels on the oscilliscope. Then sample the waveform on the >>>>osciliscope using the computer. Thus, I will get a set of random
data.
>> >> How >> >>>>do I find the reference voltage? Is it the amplitude of the noise >> >> generated >> >>>>by the noise generator? Is it from the ocsiliscope? Thank you. >>> >>>The reference voltage is a consequence of your analog to digital >>>converter, which in this case is your o-scope. The easiest way to find
>>>this would be to put a known voltage into the scope (like the 1.5V from
>>>a flashlight battery, or the square wave test signal on the scope, if
it
>> >> >>>has one). Read in your file and look at it with a text editor, then >>>figure out how to go from the information on the o-scope screen to the
>>>information in the file. >>> >>>-- >>> >>>Tim Wescott >>>Wescott Design Services >>>http://www.wescottdesign.com >>> >> >> >> Hi Tim: >> >> Thanks for you advice. The data I got in the file matches to what is
on
>> the screen of the o-scope (the data pattern looks like the periodic
square
>> wave I put in). The voltages measured seem reasonable. But the
magnitude I
>> got in the MATLAB is about -20 to -40dB off from the magnitude in dBV >> shows on the signal analyzer(same plot, only the magnitude is off). I >> divided my data by 100, then plotted again. Now the magnitude in dB
shows
>> in the MATLAB is close to the magnitude in dBV on the signal analyzer. >> Does it mean anything? > >You may have an issue with scaling and/or the number of samples you're >using. A PSD calculation should take the sampling rate into account to >bring the FFT results into the real world -- Matlab may not be doing it >right, it may have an oddball way to do the scaling, or you just may not
>be using the function correctly. > >I'd look at the help for the function you're using, or if you've made >your own PSD calculator I'd double check that you're handling the FFT >scaling and sample-rate scaling correctly. > >-- > >Tim Wescott >Wescott Design Services >http://www.wescottdesign.com >
The following is the MATLAB code: Fs=50000; datasize=size(RANDOM); numsample=datasize(1); numsample=numsample; FFTX=fft(RANDOM(:,2),numsample); X=FFTX(1:floor(numsample/2)).*conj(FFTX(1:floor(numsample/2))); BW=1.5*Fs*numsample; X=X/BW; Omega=(0:numsample-1)/(numsample)*Fs; Omega=Omega(1:floor(numsample/2)); H=plot(Omega,10*log10(X)); set(H,'Color','BLACK'); For this case, the file name is called RANDOM because I used a random data. I also tried it using squarewave data. You can change the file name to the file you want to find the PDS of. Thanks for your help!!
"ngeva0" <ngeva0@hotmail.com> wrote in message 
news:buidnUl7u99F8AvenZ2dnUVZ_sGdnZ2d@giganews.com...
> >ngeva0 wrote: >> >>>>ngeva0 wrote: >>>> >>>> >>>>>>To calculate in decibels, you need to know the reference, e.g. dBV, >>>>>>dBm, etc as dB is a gain (or attenuation) from that reference. If I >>>>>>remember correctly, dBV should mean that 0 dB is equivalent to 1V > and >>>>>>dBm is similarly referenced to 1mV. >>>>>> >>>>>> >>>>> >>>>> >>>>>Yes I have been searching online and I think you need to know the >>>>>reference voltage. But I don't know exactly how you find this >>> >>> reference >>> >>>>>voltage. In my setup, I have a noise generator, and a oscilliscope > that >>> >>> is >>> >>>>>connected to a computer. The output of the generator is connected to >>> >>> one of >>> >>>>>the channels on the oscilliscope. Then sample the waveform on the >>>>>osciliscope using the computer. Thus, I will get a set of random > data. >>> >>> How >>> >>>>>do I find the reference voltage? Is it the amplitude of the noise >>> >>> generated >>> >>>>>by the noise generator? Is it from the ocsiliscope? Thank you. >>>> >>>>The reference voltage is a consequence of your analog to digital >>>>converter, which in this case is your o-scope. The easiest way to find > >>>>this would be to put a known voltage into the scope (like the 1.5V from > >>>>a flashlight battery, or the square wave test signal on the scope, if > it >>> >>> >>>>has one). Read in your file and look at it with a text editor, then >>>>figure out how to go from the information on the o-scope screen to the > >>>>information in the file. >>>> >>>>-- >>>> >>>>Tim Wescott >>>>Wescott Design Services >>>>http://www.wescottdesign.com >>>> >>> >>> >>> Hi Tim: >>> >>> Thanks for you advice. The data I got in the file matches to what is > on >>> the screen of the o-scope (the data pattern looks like the periodic > square >>> wave I put in). The voltages measured seem reasonable. But the > magnitude I >>> got in the MATLAB is about -20 to -40dB off from the magnitude in dBV >>> shows on the signal analyzer(same plot, only the magnitude is off). I >>> divided my data by 100, then plotted again. Now the magnitude in dB > shows >>> in the MATLAB is close to the magnitude in dBV on the signal analyzer. >>> Does it mean anything? >> >>You may have an issue with scaling and/or the number of samples you're >>using. A PSD calculation should take the sampling rate into account to >>bring the FFT results into the real world -- Matlab may not be doing it >>right, it may have an oddball way to do the scaling, or you just may not > >>be using the function correctly. >> >>I'd look at the help for the function you're using, or if you've made >>your own PSD calculator I'd double check that you're handling the FFT >>scaling and sample-rate scaling correctly. >> >>-- >> >>Tim Wescott >>Wescott Design Services >>http://www.wescottdesign.com >> > > The following is the MATLAB code: > > Fs=50000; > > datasize=size(RANDOM); > numsample=datasize(1); > numsample=numsample; > > FFTX=fft(RANDOM(:,2),numsample); > X=FFTX(1:floor(numsample/2)).*conj(FFTX(1:floor(numsample/2))); > > BW=1.5*Fs*numsample; > X=X/BW; > > Omega=(0:numsample-1)/(numsample)*Fs; > Omega=Omega(1:floor(numsample/2)); > > H=plot(Omega,10*log10(X)); > set(H,'Color','BLACK'); > > For this case, the file name is called RANDOM because I used a random > data. I also tried it using squarewave data. You can change the file name > to the file you want to find the PDS of. Thanks for your help!! >
You may well be getting tired ( anyone with numsample=numsample in a function probably is or was very tired) why not have a break and a good sleep, plan what you have to do to find out what the sample magnitude is for the peak of a 1 volt sinewave, put a one volt sinewave on your scope ( lots of cycles per fft period but with frequency comfortably less than 25000 Hz ) save in your matlab file. Linearly scale your sample values so that the peak values are at +/- 1.000 and the average amplitude is 0, then run your psd routine - what value in dB do you get? If you change the y axis gain or offset on the scope does it change the sample values that you record? How big is numsample? If you change numsample does it change your dB value for the only big spectral line you should be seeing ( sinewave input) in your matlab plot ? Best of Luck - Mike
ngeva0 wrote:
>>ngeva0 wrote: >> >> >>>>To calculate in decibels, you need to know the reference, e.g. dBV, >>>>dBm, etc as dB is a gain (or attenuation) from that reference. If I >>>>remember correctly, dBV should mean that 0 dB is equivalent to 1V and >>>>dBm is similarly referenced to 1mV. >>>> >>>> >>> >>> >>>Yes I have been searching online and I think you need to know the >>>reference voltage. But I don't know exactly how you find this > > reference > >>>voltage. In my setup, I have a noise generator, and a oscilliscope that > > is > >>>connected to a computer. The output of the generator is connected to > > one of > >>>the channels on the oscilliscope. Then sample the waveform on the >>>osciliscope using the computer. Thus, I will get a set of random data. > > How > >>>do I find the reference voltage? Is it the amplitude of the noise > > generated > >>>by the noise generator? Is it from the ocsiliscope? Thank you. >> >>The reference voltage is a consequence of your analog to digital >>converter, which in this case is your o-scope. The easiest way to find >>this would be to put a known voltage into the scope (like the 1.5V from >>a flashlight battery, or the square wave test signal on the scope, if it > > >>has one). Read in your file and look at it with a text editor, then >>figure out how to go from the information on the o-scope screen to the >>information in the file. >> >>-- >> >>Tim Wescott >>Wescott Design Services >>http://www.wescottdesign.com >> > > > Hi Tim: > > Thanks for you advice. The data I got in the file matches to what is on > the screen of the o-scope (the data pattern looks like the periodic square > wave I put in). The voltages measured seem reasonable. But the magnitude I > got in the MATLAB is about -20 to -40dB off from the magnitude in dBV > shows on the signal analyzer(same plot, only the magnitude is off). I > divided my data by 100, then plotted again. Now the magnitude in dB shows > in the MATLAB is close to the magnitude in dBV on the signal analyzer. > Does it mean anything?
In the frequency domain, PSD is usually measured in dB referenced to power, sometimes 1 watt, in a 1Hz band or dB Volts per sqrt(Hz). Recall Parseval's theorem. I think the psd function in matlab does the bandwidth correction for you. The frequency domain spreads the power out over all the analysis frequencies. Some people take an alternative approach of putting a pure tone of known amplitude and a bin center frequency and using a fudge factor to correct things so that a 1 volt tone indicates 1 volt/sqr(Hz) on the frequency domain display. When I plot psd results I label the y axis explicitly, i.e. in acoustics we often reference to a micro pascal, so I would label it dB re 1 micropascal in a 1Hz band.