LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Understanding the Basic Function Generator in LV.

Solved!
Go to solution

Refer the code below. Its been for configured for 1 Hz frequency  500 samples @ 1Khz rate . And the loop timing is set for 1 sec. 

 

My understanding was that for every call, this Function produced 500 samples to represent a full 1 Hz waveform.  But it does not seem to be the case... looking at the code below I am running it for one iteration and  I get the 500 samples all right but it only represents half the sinewave and to get the full sine wave I need to run for 2 iterations.

 

And the next thing is the the number of points reported by the History ...it reads 1 ;  should it not be 500 ?? 

 

So how exactly does this function work ?

 

Sine_Generation.png

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 10
(2,572 Views)
Solution
Accepted by topic author MogaRaghu

Hi Moga,

 


@MogaRaghu wrote:

Its been for configured for 1 Hz frequency  500 samples @ 1Khz rate .

 

My understanding was that for every call, this Function produced 500 samples to represent a full 1 Hz waveform.  But it does not seem to be the case... 


To represent a sine wave with a frequency of 1Hz you need to show a waveform of 1s length.

But you create only a waveform of 0.5s length, as is given by simple math: 500 samples / 1000 samples/s = 0.5s

 


@MogaRaghu wrote:

And the next thing is the the number of points reported by the History ...it reads 1 ;  should it not be 500 ?? 

So how exactly does this function work ?


The history of the chart is correct, when it claims "1 waveform"! The history length is counting the input data, which in your case are waveforms…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 10
(2,557 Views)

Hello GerdW,

 

I read your reply more than once. Both the points that you mentioned can never be understood by just reading the LV help which I have done so many times before posting the query here. 

 

Yes both the aspects are not very obvious to grasp... like for instance many data loggers treat the number of samples as that number to equally space out on the chosen waveform. So when I chose a 1 Hz Sine, I expected the 500 "points" to be equally spaced out to represent the 1 Hz Sine.  So to sum up can i say that the Function generates a signal of X Seconds given by Samples / Sampling rate ? 

 

Second the number of points in History data . Again here I have run trials with a simple random signal generator inside a loop and see each dot plotted constitutes a "point" for history data. Here I was tripped by the samples count once more....😓

 

Thanks for the inner view !!

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 3 of 10
(2,527 Views)

Hi moga,

 

your expectations are wrong...

 

LabVIEW doesn't use "points", instead it calls them samples. And you requested a waveform consisting of 500 samples, with a samplerate of 1kHz.

You get what you asked for!

 

(It doesn't matter if you request for a sine signal of 0.01Hz, 1Hz or 100Hz. It also doesn't matter if you request sine, saw, or noise.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 10
(2,517 Views)

Yes I now see why the default Sampling rate and #samples are both set to 1000 !! 

 

Incidentally there was yet another thing that I was trying to understand about the X-Axis scale setting ... the moment I knew that LV treats one full waveform as one whole item, it was easy to set the X-Scale max to 10 and see 10 full waveforms by setting the iteration count to 9 !  Anyway the X-Scale setting is always a challenge when it comes to setting for real time random waveforms. 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 5 of 10
(2,448 Views)

Hi Moga,

 


@MogaRaghu wrote:

Yes I now see why the default Sampling rate and #samples are both set to 1000 !!


You create a waveform of 1s length with these default settings. Still I can see no relation to your sine wave…

 


@MogaRaghu wrote:

Anyway the X-Scale setting is always a challenge when it comes to setting for real time random waveforms. 


Why do you think so? Enable autoscaling…

What are "real time" waveforms? (You know the meaning of "realtime" in computer (and LabVIEW) context?)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 10
(2,445 Views)

Sure I know what a RTOS is and by real time in this context i was referring to the time on the clock on wall !! 

 

A typical data logging scenario looks like this for me :

 

1 or 2 channels of Analog data ( mostly hydraulic pressure signals ) read in a while loop running at 50mS. The DAQMx for this acquisition is setup with a sampling rate of 4kHz and number of samples per channel set at 200 / channel. The collected samples are averaged to get one sample for every iteration. 

 

Having got the data I need to plot them on a chart and the chart must have X-Axis reading "real time " 😀

 

So far so good ... the complication arises when the user wants to fix the X Axis Maximum value based on the process need. Some cases it could be just 10 seconds and in some cases it could be a minute. SO we provide a front panel control called PlotSec  and when the user sets it the plot should reach the end in the set time and then the scrolling to happen.  The X-Axis should  show the actual time .  

 

A sample of the trial is attached below :

 

1Ch_DAQ.png

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 7 of 10
(2,435 Views)

Hi Moga,

 

don't fiddle with X axis scaling properties (like multiplier) in each iteration…

 


@MogaRaghu wrote:

the chart must have X-Axis reading "real time " 😀

The X-Axis should  show the actual time .


Then plot waveforms in the chart. Enable the X axis to use the timestamp of the waveforms, then it will show the "actual time" (when the waveform was created)…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 10
(2,432 Views)

Though I don't know how, this VI does what I want. I can set the X-Axis max and I get that.  The only difference is that I am initializing the property nodes twice in the stacked structure and it works. If I delete the duplicated setting of the Prop nodes , then the X-Axis is never what I want.  Just curious how that happens...

 

AI_Plot_SettableX_AxisMax.png

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 9 of 10
(2,382 Views)
Solution
Accepted by topic author MogaRaghu

Hi Raghunathan,

 

using a stacked sequence with duplicated code almost always is wrong (aka Rube-Goldberg)!

 

See this:

Usually setting the chart just once should be enough.

Also note all those other subtle changes to your code…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 10 of 10
(2,379 Views)