From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling the x-axis in a waveform chart

Hello all
 
I'm trying to make a frequency sweep and plotting the phase and magnitude on two wavefor charts in realtime. I would like to have the x-axis show the frequencies in log scale.
When i try to build an array with t0, dt and y, it changes the y-axis instead of the x-axis.
 
I have attached my vi.
 
could anyone help me please?
 
Regards
0 Kudos
Message 1 of 15
(4,887 Views)
To plot magnitude vs frequency or phase vs frequency in your case, it will be easiest to use a waveform data type. You can select "waveform", "build waveform" from the functions pallette and input your t0, dt (here this would actually be df), and y values for magnitude or phase. Alternatively, you could use an x-y plot if your measurements are not evenly spaced in frequency.
 
If you want to change the x scale to log, you can go to the front panel and right click on your graph. Click on "x scale", "mapping", "logarithmic."
 
I hope this helps.
 
Casey Weltzin
National Instruments 
0 Kudos
Message 2 of 15
(4,884 Views)

Hello and thanks for your answer!

I have tried the things you suggested and a couple of other things(i have spent some time on this problem already). It doesn't seem to work. I have attached my vi with the new changes for the phase chart.

I have tried the thing you suggested for the log-problem, but the "x scale", "mapping", "logarithmic" tab is greyed out and cannot be pushed. I have also tried the "properties", "scale", "log" from the block diagram, but it just pops back when i run the vi.

The funny thing is that everything works for the y-axis???

Regards

0 Kudos
Message 3 of 15
(4,873 Views)
I think that the value that you have wired into the "dt" terminal on the "build waveform" function may be incorrect. The "dt" value in your case is really a delta - frequency. So if you are plotting a bunch of magnitude values for frequencies of 1 Hz, 1.5 Hz, 2 Hz, etc. then your dt would be 0.5 Hz. Your t0 (really f0 here) would be 1 Hz. Try this first and then see if the log scaling option works.
 
I hope this helps.
 
Casey Weltzin
National Instruments
 
0 Kudos
Message 4 of 15
(4,869 Views)

Yes, your right. I was a bit too fast there. Well it still doesn't work. Now i have changed the waveform charts with xy-graphs and this works.

This has resulted in a new problem though. With the waveform charts I made the charts clear at every run by checking "file" / "vi properties" / "execution" / "reentrant" / "clear indicator when called". This doesn't work with the xy-graphs.

I have seen the examples with the empty array to the "Create" / "propertynode" / "History Data". The problem is that i don't have the "History Data" in the menu when I click "Property node". I'm using LabView 8.0. Is the "History data placed somewhere else or caled something else in this version?

0 Kudos
Message 5 of 15
(4,863 Views)
To clear the waveform graph manually, you can right click on the graph and select "data operations", clear graph. With the graph cleared, you can select "data operations", "make current values default" to set the default graph display as clear. Then, anytime you wish to clear the graph you can select "edit", "reinitialize values to default."
 
You can also clear the waveform graph within your code. Create an invoke node by going to your block diagram and right clicking on your graph, then "create", "invoke node", "reinitialize values to default."
 
I hope this helps.
 
Casey Weltzin
National Instruments
0 Kudos
Message 6 of 15
(4,858 Views)

Well, I'm having a little problem with the timing of the "Reinitialize"-"invoke node". I can only get it to work when it is in the end of the loop. It then clears the graph allright, but then it draws the old graphs again when when it is run. I have cleared the graph by "Data operations" / "Make these Values Default". This is also the case if i reinitialize the graph manually by "edit" / "Reinitialize values to default"

Is there a way to get it to set the graph to default before the loop begins and to make it clear the graph completely, so that it only draws the values for the one run?

I have attached my vi with the invoke node set to clear the graph in the end of the loops iterations.

0 Kudos
Message 7 of 15
(4,853 Views)
I'm not sure if you have already tried this, but you can place the invoke node before the loop and wire the error cluster from the invoke node to the loop. This will force the invoke node to execute before the loop does. I hope I understood your question correctly; please let me know if this is not what you are asking for.
 
Casey Weltzin
National Instruments
0 Kudos
Message 8 of 15
(4,850 Views)

Ok, now it reinitializes the graphs before the loops, but it is only cleared for a short moment and then all the old drawings can be seen again. Somehow it doesn't clear the graph completely. There still is some in the memory. Do you have an idea on what could be wrong or any other suggetions on how to clear the graphs on every run?

regards

0 Kudos
Message 9 of 15
(4,847 Views)

A simple method for clearing the waveform graph is to pass in an empty array. Right click on the waveform graph in the block diagram and select "create", "local variable". Wire an empty array into this local variable to clear the graph. To force the graph to be cleared before your main loop, place a sequence structure with only one frame in your block diagram and put the local variable inside of it. Wire the empty array through the sequence structure and onto the border of the loop.

I hope this answers your question.

Casey Weltzin, National Instruments

0 Kudos
Message 10 of 15
(4,842 Views)