02-17-2015 01:58 PM
I have just installed Measurement Studio onto my development machine. I'm using Visual Studio 2012 Pro. I have an existing forms application that I have been working on but now I want to add some of the controls available in Measurement Studio, particularly the waveform graph. Is there a property or something that I can edit that will allow a user to change the scale min/max values on the X and Y scales of the graph? I have found that I can adjust the min/max values in the properties pane, but I need to be able to allow the user to adjust as needed during runtime. Like click on the max value of the X-axes and change the value. Pardon my ignorance if this is an easy one, but I'm new to Labview and Measurement Studio. Thank you
02-18-2015 06:51 AM - edited 02-18-2015 06:56 AM
Hi,
In the waveformgraph properties, check "Edit Range" and you will be able to change range on axes in runtime.
Plus click on the arrow on the top-right of the graph, select interraction mode "edit range" (see attached file)
02-20-2015 09:57 AM
Thank you, that worked. I have another question regarding the Waveform Graph though that I want to ask here first before starting another post/thread. I downloaded an example Waveform Graph program from NI called "SimpleGraph.2012". It works and simulated an analog signal and for the most part, is pretty much what I want to do in my program. There is an assembly called "
NationalInstruments.Analysis.SignalGeneration" in that program. I tried copying that assembly into my code ("Imports NationalInstruments.Analysis.SignalGeneration) but I'm getting an error in my program:
"Warning 4 Namespace or type specified in the Imports 'NationalInstruments.Analysis.SignalGeneration' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases. C:\Users\dmckin01\Documents\Visual Studio 2012\Projects\DualSpindleII\DualSpindleII\Forms\Main.vb 11 9 DualSpindleII"
I "believe" this is due in part because I have Measurement Studio Standard Edition and not Enterprise? I did some digging in the directories and I believe that assembly is in the Enterprise version, not the Standard. Is this correct?
So, why does the example program work but my program has an error when importing that assembly? Last but not least, what is that assembly for and do I need it???
Thank you
02-21-2015 06:47 AM
When I try to use analysis.signalgeneration, I need to add a references to NationalInstruments.Analysis, but Standard works well
References => rightclick, add references NI directory\...\aasemblies\current\
02-25-2015 12:26 PM
Regarding the scaling of the axes, you can certainly edit them using the properties, and I guess you could make your own interface with text boxes and buttons or sliders or whatever, but there is a feature that is not very discoverable that you should use: If the InteractionMode of the axis is set to allow user interaction, and the scaling is set to Fixed (not "AutoScale___"), you can take the following actions while the application is running. You may have to click the graph to properly assign focus.
These can be difficult to remember, so I often add a ToolTip or label to my graph saying something like "Hold shift to zoom and control to pan. Right click to go back." so that it's a little more discoverable for my end users.
For the signal generation problem, I wasn't able to get that to work with Standard, I ended up rolling my own simple sine wave generator, the core of which looks like this:
public double[] Next() { for (int i = 0; i <= this.sampleCount - 1; i++) { // next angle = time delta / period * 2 pi = time delta * 1/f * 2pi = time delta * f * 2pi var nextAngle = previousAngle + (2 * Math.PI * timeDelta * this.frequency); var nextValue = Math.Sin(nextAngle) * this.amplitude; // Change amplitude when passing through 0 to avoid discontinuities if (nextAmplitudePending & ((previousAngle <= Math.PI & nextAngle > Math.PI) | (previousAngle <= 2 * Math.PI & nextAngle > 2 * Math.PI))) { nextAmplitudePending = false; amplitude = nextAmplitude; // No need to update nextAngle as we've only changed the amplitude nextValue = Math.Sin(nextAngle) * this.amplitude; } // Change frequency when passing through max amplitude (when derivative is zero) to avoid discontinuities // May not be strictly necessary; since we step only previous value + tiny angle, frequency change can happen smoothly at any time //If nextFrequencyPending And // ((previousAngle < Math.PI / 2 And nextAngle > Math.PI / 2) Or // (previousAngle < 3 * Math.PI / 2 And nextAngle > 3 * Math.PI / 2)) Then if (nextFrequencyPending) { frequency = nextFrequency; nextFrequencyPending = false; nextAngle = previousAngle + (2 * Math.PI * timeDelta * this.frequency); nextValue = Math.Sin(nextAngle) * this.amplitude; } // Offset angle back by 2 Pi if possible if (nextAngle > 2 * Math.PI) { nextAngle -= 2 * Math.PI; } var span = 1; var offset = 0; Values[i] = (nextValue - offset) / span; previousAngle = nextAngle; previousValue = nextValue; } return Values; }
and the class for which is attached.
There is also a sine generator in the Ni Daq examples under Analog Out\Generate Voltage\ContGenVoltageWfm_IntClk\CS\FunctionGenerator.cs, but that only generates buffers that have a integer number of cycles per buffer. That's great if your application doesn't need to change the amplitude on the fly, and can use WriteRegenerationMode.AllowRegeneration, but doesn't work well for live updates.