Why does my waveform graph display pulses of width 3 ms when I specify them to be 2 ms in LabVIEW? - labview

I am trying to generate pulse waves with a width of 2 milliseconds and frequency of approximately 100 Hz as shown below:
According to this website: http://www.ni.com/white-paper/2991/en#toc1
under the section "Introduction to Pulse Width Modulation" it describes the duty cycle to be 20% if pulse width is 2 ms with a frequency of 100 Hz (or 10 milliseconds).
As you can see in the diagram above the "duty cycle %" indicator correctly computes a percentage close to 20%.
If I perform the calculations correctly, why am I getting a waveform of pulses that have a width of 3 ms instead of 2 ms shown below?
Following is the back panel diagram containing the logic I am using to generate the waveform:

Your generation frequency is 1 kHz, so you are at the minimum resolution.
Your pulse is 2 ms high. I would advise you to make the samplerate higher.

Related

USRP N320 Low Band Center Frequency Shift

I have an USRP N320 SDR and I have an issue with 3 MHz-450 MHz band center frequency value. When I have a signal between 450 MHz and 6 GHz, I can see the actual frequency value of the signal even if I slide the center frequency but below 450 MHz, the signal is shifted negatively when I slide the center frequency. Is there any reason and solution for this issue? Any help?
As you can see in Figure 1, the FM radio signals are correctly seen when I set the Rx Tune Frequency to 100 MHz.
1
But when I slide the Rx Tune Frequency to 110, 120,130 and 140 MHz, the FM radio signals' frequency values are also shifted. As you can see in Figure 2, 3 ,4 and 5.
2
3
4
5
Addition:
The main picture of the blocks and parameters of USRP source are below figures.
Blocks
USRP Source 1
USRP Source 2
USRP Source 3
Also I figured out that when I applied below 450 MHz, for example 100 MHz signal and shifted center frequency with an amount, it shifts the signal double time inverse. I might not explain well but below figures does.
100MHz Signal at 100 MHZ center frequency
100MHz Signal at 95 MHz Center frequency but appeared at 90 MHz
100MHz Signal at 110 MHz Center frequency but appeared at 120MHz
But When I applied a signal above 450 MHz, for example 2 GHz, it does work properly. As you can see in figure below.
2 GHz given signal can correctly seen in any other center frequency

Getting fuel% from analog data

I am getting analog voltage data, in mV, from a fuel gauge. The calibration readings were taken for every 10% change in the fuel gauge as mentioned below :
0% - 2000mV
10% - 2100mV
20% - 3200mV
30% - 3645mV
40% - 3755mV
50% - 3922mV
60% - 4300mV
70% - 4500mv
80% - 5210mV
90% - 5400mV
100% - 5800mV
The tank capacity is 45L.
Post calibration, I am getting reading from adc as let's say, 3000mV. How to calculate the exact % of fuel left in the tank?
If you plot the transfer function of ADC reading agaist the percentage tank contents you get a graph like this
There appears to be a fair degree of non linearity in the relationship between the sensor and the measured quantity. This could be down to a measurement error that was made while performing the calibration or it could be a true non linear relationship between the sensor reading and the tank contents. Using these results will give fairly inaccurate estimates of tank contents due to the non linearity of the transfer function.
If the relationship is linear or can be described by another mathematical relationship then you can perform an interpolation between known points using this mathematical relationship.
If the relationship is not linear than you will need many more known points in your calibration data so that the errors due to the interpolation between points is minimised.
The percentage value corresponding to the ADC reading can be approximated by finding the entries in the calibration above and below the reading that has been taken - for the ADC reading example in the question these would be the 10% and 20% values
Interpolation_Proportion = (ADC - ADC_Below) / (ADC_Above - ADC_Below) ;
Percent = Percent_Below + (Interpolation_Proportion * (Percent_Above - Percent_Below)) ;
.
Interpolation proportion = (3000-2100)/(3200-2100)
= 900/1100
= 0.82
Percent = 10 + (0.82 * (20 - 10)
= 10 + 8.2
= 18.2%
Capacity = 45 * 18.2 / 100
= 8.19 litres
When plotted it appears that the data id broadly linear, with some outliers. It is likely that this is experimental error or possibly influenced by confounding factors such as electrical noise or temperature variation, or even just the the liquid slopping around! Without details of how the data was gathered and how carefully, it is not possible to determine, but I would ask how many samples were taken per measurement, whether these are averaged or instantaneous and whether the results are exactly repeatable over more than one experiment?
Assuming the results are "indicative" only, then it is probably wisest from the data you do have to assume that the transfer function is linear, and to perform a linear regression from the scatter plot of your test data. That can be most done easily using any spreadsheet charting "trendline" function:
From your date the transfer function is:
Fuel% = (0.0262 x SensormV) - 54.5
So for your example 3000mV, Fuel% = (0.0262 x 3000) - 54.5 = 24.1%
For your 45L tank that equates to about 10.8 Litres.

What is the best window size (in seconds) and hop size (in seconds) for a audio sample which has 3 second length?

I have some voice samples with 3s length size for an audio feature extraction project. First I select 0.5s window size and 0.2 hop size but I doubt how to select best window size and hop size for better results.
Unfortunately, these are hyper-parameters that need to be optimized on your data.
I often obtain decent results from a hop_length between 10 ms - 40 ms and a window length between 10 ms - 100 ms, depending on whether you want more frequency- or time- resolution.

GNURadio - WX FFT Plot not showing frequency on the x axis

I'm using WX GUI FFT to display a specific frequency range (38Hz for IR). I can't seem to get the plot to show the frequency range on the x axis. I have it set up like follows:
And here's what it looks like when it runs:
As can be seen there's no frequency range on the x axis.
Any idea what I'm doing wrong?
The display is absolutely correct.
You set the sampling rate, and hence the bandwidth to be displayed, to be nominally 10 MHz, so each of the ten divisions of the x-Axis should be 1 MHz wide.
Now, your center frequency is in fact of course not 0 MHz, but 38 kHz, but WX GUI rounds the numbers for display – it's really not that useful to see "0.038 MHz" as an axis label.
More importantly, you seem to be confused about what the sampling rate and what the center frequency are supposed to be; my gut feeling is that you want to observe an 38 kHz wide channel around 10 MHz. What you do is observe 10 MHz around 38 kHz (which, physically, doesn't make much sense, and you should see very clear warnings about that in the console).
Furthermore, WX is going away with the next release of GNU Radio. Use the Qt GUI instead.

remoteIO input square wave frequency is low

i input to the audioJack a square wave in the frequency of 2-3 khZ for about 5 seconds.
the square wave is 1 and 0 - no negative values.
i get some periodic signal that going between -32000 to 32000 (but my signal is positive!? )
i have check how many times my values are crossing the zero- i get 500 in 5 seconds, which means 100 per second .
what am i missing here ? 3khz is 3000 per second.
my sampling code is in my previous post :
error in audio Unit code -remoteIO for iphone
any explanation on the frequency domain here? am i missing samples ? how can i improve it? should i do :
float bufferLength = 0.005;
AudioSessionSetProperty(kAudioSessionProperty_PreferredHardwareIOBufferDuration, sizeof(bufferLength), &bufferLength);
status = AudioOutputUnitStart(audioUnit);
thanks alot!