when I double click the axis max or min ,i can change it's value; how can I disable this .
c# graph disable change axis range
ActiveX Controls to Native .NET
Hello,
I am new to Measurement Studio and this community and I am currently faced with upgrading legacy code. Is there a conversion process from existing Measurement Studio ActiveX controls to the native .NET libraries? Or must this be done manually?
Regards,
Ben
Move XYRangeAnnotation from its borders when click on it
How can move an XYRangeAnnotation from its corners and resize the annotation using the mouse ?
Any help ?
Data acquisition in real time
Hello,
I'm trying to read a NI9213 in real time. I can read some value but I have an issue.
My code is :
myTask = DaqSystem.Local.LoadTask("TaskNIMAX")
'Verify the Task
myTask.Control(TaskAction.Verify)
analogInReader = NewAnalogMultiChannelReader(myTask.Stream)
' Use SynchronizeCallbacks to specify that the object
' marshals callbacks across threads appropriately.
analogInReader.SynchronizeCallbacks = True
analogInReader.BeginReadWaveform(1, myAsyncCallback, myTask)
PrivateSub AnalogInCallback(ByVal ar AsIAsyncResult)
Try
If (Not (runningTask IsNothing)) AndAlso runningTask Is ar.AsyncState Then
data = analogInReader.EndReadWaveform(ar)
analogInReader.BeginMemoryOptimizedReadWaveform(1, myAsyncCallback, myTask, data)
Debug.Print((data(0).Samples(0).Value).ToString)
EndIf
Catch exception AsDaqException
MessageBox.Show(exception.Message)
myTask.Dispose()
EndTry
EndSub
The task is configure with continuous sampling (1 sample at 500 Hz). You can see the value read on the file debug.txt.
My question is why I have many time the same value ? What is wrong in my code ?
Thanks
Ni:graph fails in WPF with events
I a trying to create an interface that implements a Measurement Studio 2013 graph in Visual Studio 2015.
I have successfully added the graph to the form and tested it for about a week, but now I'm trying to add a custom pull out menu to the same form. If I comment out the graph, the project builds and runs as intended. If I disable the events that fire the pull out menu and add the graph back in, the program runs as intended, But if the two are on the form at the same time, I get a XAML Parse error on my last closing .
If I investigate the inner exceptions, I arrive at a NationalInstruments.Control 'Specified Method is not Supported' error.
narrowing it down further, if I removed the event trigger's SourceName property, the project builds, but of course the events no longer fire properly.
<Window.Triggers><EventTriggerRoutedEvent="ToggleButton.Checked"SourceName="btnExpand"><BeginStoryboardStoryboard="{StaticResource ExpandisChecked}"/></EventTrigger><EventTriggerRoutedEvent="ToggleButton.Unchecked"SourceName="btnExpand"><BeginStoryboardStoryboard="{StaticResource ExpandisUnChecked}"/></EventTrigger></Window.Triggers>
Making the above into:
<Window.Triggers><EventTriggerRoutedEvent="ToggleButton.Checked"><BeginStoryboardStoryboard="{StaticResource ExpandisChecked}"/></EventTrigger><EventTriggerRoutedEvent="ToggleButton.Unchecked"><BeginStoryboardStoryboard="{StaticResource ExpandisUnChecked}"/></EventTrigger></Window.Triggers>
clears the error but doesn't provide functionality.
there stack trace shows:
System.Windows.Markup.XamlParseException occurredHResult=-2146233087LineNumber=226LinePosition=7Message='Initialization of 'TEST.MainWindow' threw an exception.'Line number '226' and line position '7'.Source=PresentationFrameworkStackTrace:
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader,IXamlObjectWriterFactory writerFactory,Boolean skipJournaledProperties,Object rootObject,XamlObjectWriterSettings settings,Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader,Boolean skipJournaledProperties,Object rootObject,XamlAccessLevel accessLevel,Uri baseUri)
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream,ParserContext parserContext,Object parent,Boolean closeStream)
at System.Windows.Application.LoadComponent(Object component,Uri resourceLocator)
at TEST.MainWindow.InitializeComponent()in C:\Users\allusers\Documents\Visual Studio2015\Projects\TVROTR\TVROTR\MainWindow.xaml:line 1InnerException:HResult=-2146233067Message=Specified method is not supported.Source=NationalInstruments.ControlsStackTrace:
at NationalInstruments.Controls.Internal.MultiEnumerator.System.Collections.IEnumerator.Reset()
at System.Windows.LogicalTreeHelper.FindLogicalNode(DependencyObject logicalTreeNode,String elementName)
at System.Windows.LogicalTreeHelper.FindLogicalNode(DependencyObject logicalTreeNode,String elementName)
at System.Windows.LogicalTreeHelper.FindLogicalNode(DependencyObject logicalTreeNode,String elementName)
at System.Windows.LogicalTreeHelper.FindLogicalNode(DependencyObject logicalTreeNode,String elementName)
at System.Windows.FrameworkElement.FindNamedFrameworkElement(FrameworkElement startElement,String targetName)
at System.Windows.EventTrigger.ProcessOneTrigger(FrameworkElement triggersHost,TriggerBase triggerBase)
at System.Windows.EventTrigger.ProcessTriggerCollection(FrameworkElement triggersHost)
at System.Windows.FrameworkElement.TryFireInitialized()
at System.Windows.FrameworkElement.EndInit()
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.InitializationGuard(XamlType xamlType,Object obj,Boolean begin)InnerException:
How can I have both on the form at the same time?
here is the full code for the window if it helps:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TEST"
xmlns:ni="http://schemas.ni.com/controls/2009/xaml/presentation"
x:Class="TEST.MainWindow"
mc:Ignorable="d"Title="MainWindow"Height="768"Width="1024"WindowState="Maximized"WindowStyle="None"><Window.Resources><Style x:Key="ExpandCollapseToggle"TargetType="{x:Type ToggleButton}"><SetterProperty="Template"><Setter.Value><ControlTemplateTargetType="{x:Type ToggleButton}"><Border x:Name="borer"BorderThickness="1"CornerRadius="2"BorderBrush="{x:Null}"><Border x:Name="innerBorer"BorderThickness="1"CornerRadius="2"BorderBrush="#00FFFFFF"><Grid><Grid x:Name="BGCollection"Opacity="0"><Rectangle x:Name="rectangle"Opacity="1"RadiusX="15"RadiusY="15"Stroke="{x:Null}"><Rectangle.Fill><LinearGradientBrushEndPoint="0.5,1"StartPoint="0.5,0"><GradientStopColor="#FFB0B0B0"Offset="1"/><GradientStopColor="#FF615F5F"Offset="0.553"/><GradientStopColor="#FFD4D4D4"Offset="0"/></LinearGradientBrush></Rectangle.Fill></Rectangle></Grid><Path x:Name="path"Fill="{x:Null}"Stretch="Fill"HorizontalAlignment="Stretch"VerticalAlignment="Center"Height="50"Width="20"RenderTransformOrigin="0.5,0.52"Data="M4.5,2.0956774L8.25,5.8456774 4.5,9.5956774"Stroke="#FFEBF6FF"Margin="19.293,0,5.707,0"StrokeThickness="4"><Path.RenderTransform><TransformGroup><ScaleTransformScaleX="1"ScaleY="1"/><SkewTransformAngleX="0"AngleY="0"/><RotateTransformAngle="0"/><TranslateTransform X="0" Y="0"/></TransformGroup></Path.RenderTransform></Path><Path x:Name="path_Copy"Fill="{x:Null}"Stretch="Fill"HorizontalAlignment="Stretch"VerticalAlignment="Stretch"RenderTransformOrigin="0.5,0.5"Data="M4.5,2.0956774L8.25,5.8456774 4.5,9.5956774"Stroke="#FFEBF6FF"Margin="5.218,6,9.782,6"Height="50"Width="20"StrokeThickness="4"><Path.RenderTransform><TransformGroup><ScaleTransformScaleX="1"ScaleY="1"/><SkewTransformAngleX="0"AngleY="0"/><RotateTransformAngle="0"/><TranslateTransform X="0" Y="0"/></TransformGroup></Path.RenderTransform></Path></Grid></Border></Border><ControlTemplate.Triggers><TriggerProperty="IsChecked"Value="True"><SetterProperty="Data"TargetName="path_Copy"Value="M6.75,2.0956774L3,5.8456774 6.75,9.5956774"/><SetterProperty="Data"TargetName="path"Value="M6.75,2.0956774L3,5.8456774 6.75,9.5956774"/></Trigger><MultiTrigger><MultiTrigger.Conditions><ConditionProperty="IsChecked"Value="false"/><ConditionProperty="IsMouseOver"Value="true"/></MultiTrigger.Conditions>
How to Draw Mulit Chart without slow down?
I have to grawing in chart plot 8 plots in 500~600 time in 1 second, but using PlotYAppendMultiple will slow down a lot. I want to know how to draw a graph without slowing down.
IntensityGraph Custom Horizontal Axis
Hi,
I am using the IntensityGraph in WPF and have the following problem:
- The horizontal axis is time and I want it to be from 0 to X seconds (say 5, for example).
- I want to update the graph every 0.2 seconds.
- When I reach the end of the graph I want it to roll over or scroll, so I need to remove some of the old points and replace them with new ones.
My question is:
How to configure the IntensityGraph and how to add data to the DataSource such that on the X axis I have 25 data points and the labels remain from 0 to 5 as initially set. In my attempts, I had the X axis display all labels form 0 to 25 or I could only display 5 points (setting the range 0,5 I see labels 1 to 5 and only 5 points).
Any example would be helpful.
Thank you,
Cosmin.
Writing to TDMS file question
Greetings from Michigan,
I have a program that writes/appends data to a TDMS file. When the file is "full" (when datapoints in ChannelGroup(0) >= xAmount), the program creates a new TDMS file and continues on. It's automated. My question is straight forward: Instead of creating a whole new TDMS file, can't I just create a new ChannelGroup and continue to fill the next tab in the existing TDMS file with data, then continue on in that fashion? That way, a single test (continuous data streaming for hours or days) will consist of only one (1) TDMS file with many tabs of filled data as opposed to many TDMS files where each only has one tab filled with data. Maybe this is the common way of doing it?
I don't want to invest time and effort trying it before I know that's its not a big deal to do it.
Thanks,
D
Getting plots to paper/reports/image file
I have been away for a year and I need to make a report from data collected in Measurement Studio. I believe I can easily work with image files like JPG and possibly others.
In Labview in the past I used:
Plot.Waveform.VI
Picture to Pixmap VI
Write JPEG File VI
to create an image that I could insert into a document file.
I am collecting the data into an array of AnalogWaveform<double> and saving it into a TDMS file if that makes a difference.
Also, second question, I cannot seem to find complete object reference documentation for Measurement Studio. If I have an object like NationalInstruments.Controls.Graph, where do I go to get a complete Reference Documentation of all of the properties I can access and methods I can call, and what objects are available in the same namespace or assembly.
Time duration setup for daq genaration signal
hi
i'm using DAQ NI 6343 for generation sinewave signal in AO0 output
i need to start this signal for couple of milliseconds and stop it afterwards , this is my time_duration variable.
how i can do this automatically without manual start/stop button in GUI.
i tested it by timer1 method, but this make collision in threads.
Thanks very much
"The specified channel is already a member of a TDMS channel Group"
Greetings,
I have an application where I am streaming data to TDMS. I have set up a channel group and I am able to write to TDMS fine. However, I need to code it so that when the datacount in the first tab (looking at first channel in the group) reaches x-amount, say 1,000,000, I need to dynamically create another tab (channel group) and continue streaming data. The program should just continue to add tabs as they fill up with data.
Maybe there is a simple way to do this but I'm not finding it. In short, I want to just take the channels in the first tab, "copy" them over to a new tab and continue streaming. Through the TDMS methods, I am able to getchannels, getchannelgroups, etc. from the TDMS file. But I cannot seem to add these channels to another channel group (new tab) or the program throws an exception error - "The specified channel is already a member of a TDMS channel group".
The only work around to this, which I have not tried yet, is to make the channel names different on each iteration that I want to add a new channel group. I anticipate that will be very cumbersome. Is there a simpler way to make this work?
Controlling Multiple GPIBs in C#
Hello everyone,
I am currently trying to write some C# code which sends commands to anywhere from 1 to 5 GPIB 488.2's through GPIB-USB-HS adapters. I have my code working for the most part but am running into trouble when sending commands to more than one controller. Below is my method for a calibration cycle on my company's instrument, most of which can be ignored. It simply takes in settings from the GUI and uses the GPIB to send motor commands to a microcontroller.
Everything works fine except when I am controlling more than one, it constantly throws the exception: 'System.InvalidOperationException' in NationalInstruments.NI4882.dll due to the inner exception "EndWrite was called before BeginWrite." The problem stems from sending an EndWrite to the first device after sending the first BeginWrite. This throws a flag on the other devices which haven't received their BeginWrite commands (it doesn't happen when I am controlling just one GPIB with the same code)
What is the best way to control multiple GPIBs to avoid this error? I am using the NationalInstruments.NI4882.dll in VisualStudio2015 (I implemented the work around to be able to use Measurement Studio 2015 in Visual Studio 2015). I saw something about a function called TriggerList to command multiple GPIB's but have no idea what .dll it is part of. I also am not sure which .dll contains the full function list for the GPIB's such as SENDIFC, ibwait, ibwrt, ect. All I have access to is the board and device class commands. I tried adding other .dll's to my project such as the gpib-32.dll, the visa32.dll, and the ni4882.dll but receive an error stating that they are not valid COM components.
To sum up the problems I need help with:
- What is the best way / function to command multiple GPIB's via C#
- How do I access the complete GPIB function list as illustrated in this manual: NI-488.2 Function Reference Manual For Windows
- How do I add the rest of the .dll's such as visa32.dll to my project? (I found a post on the forums describing several various steps to try but was unable to get it working, such as using tlbimp.exe to generate a working .dll)
I would greatly appreciate any help with these issues. I have been stuck for quite some time now. My program does run but occasionally gets tripped up by the exceptions and thus is not suitable for production yet.
private void Run_Click(object sender, EventArgs e) { int nc = Int32.Parse(textBox9.Text); //Read in number of cycles long y; y = Convert.ToInt64(Convert.ToDouble(textBox8.Text)); //Read in Dwell Time cycleTime = (int)y; List<string> steps = new List<string>(); // Create list of attenuation steps steps.Add(textBox1.Text); steps.Add(textBox2.Text); steps.Add(textBox3.Text); steps.Add(textBox4.Text); steps.Add(textBox5.Text); steps.Add(textBox6.Text); steps.Add(textBox7.Text); _worker = new BackgroundWorker(); _worker.WorkerSupportsCancellation = true; xxx = 1; int[] cycles = new int[nc]; cycles = cycles.Select(i => 5).ToArray(); if (nc % 1 == 0) { if (cycleTime > 1.5) { _worker.DoWork += new DoWorkEventHandler((state, args) => { do { if (_worker.CancellationPending) break; foreach (int element in cycles) { Console.WriteLine(xxx); xxx++; for (int i = 0; i < 7; i++) { if (_worker.CancellationPending) break; try { if (checkBox1.Checked) { //Device 1: device.BeginWrite( ReplaceCommonEscapeSequences(steps[i]), new AsyncCallback(OnWriteComplete), null); } if (checkBox2.Checked) { //Device 2: device2.BeginWrite( ReplaceCommonEscapeSequences(steps[i]), new AsyncCallback(OnWriteComplete), null); } if (checkBox3.Checked) { //Device 3: device3.BeginWrite( ReplaceCommonEscapeSequences(steps[i]), new AsyncCallback(OnWriteComplete), null); } if (checkBox4.Checked) { //Device 4: device4.BeginWrite( ReplaceCommonEscapeSequences(steps[i]), new AsyncCallback(OnWriteComplete), null); } if (checkBox5.Checked) { //Device 5: device5.BeginWrite( ReplaceCommonEscapeSequences(steps[i]), new AsyncCallback(OnWriteComplete), null); } if (xxx > nc) { stop = false; } dwellPause = new PauseClass(); dwellPause.Pause(cycleTime * 1000); } catch (Exception ex) { ex.ToString(); MessageBox.Show(ex.Message); } } } } while (stop); }); _worker.RunWorkerAsync(); Run.Enabled = false; Stop.Enabled = true; } else { stringReadTextBox.Text = "Error: Dwell Time Too Short!"; } } else { stringReadTextBox.Text = "Error: Number of Cycles Must Be A Whole Number!"; } stringReadTextBox.Text = "Cycling For Calibration Is Complete!"; }
WPF Graph: How to get the history of data previously written with ChartCollection?
PCIe-6733, two AO tasks and two triggers ,I need your help!
Hey
I create a task and config the trigger,it works .But after that ,I create the 2rd task and config trigger ,I got a error: -89137.
So i want to know WHY?
thanks
Navi
4461 DAQmx independent input channels
Dear Community,
at the moment I am working on the data acquisition using a PXIe-4461.
I have managed to read out one channel, also both channels simultaniously is no problem.
When I do so I am creating a task by:
tOsc = new NationalInstruments.DAQmx.Task(sTaskName); tOsc.AIChannels.CreateVoltageChannel("PXI1Slot4/ai0:1", "AnalogIn", AITerminalConfiguration.Pseudodifferential, -10, 10, AIVoltageUnits.Volts);
Which gives me a task from which I can read waveform data of both channels.
What I have tried but did not get to work (I guess I have some kind of missunderstanding, I just startet working with this Hard/Software) is to create a task (array) for each analog channel like:
NationalInstruments.DAQmx.Task[] tOsc; int nChannel = 2; tOsc = new NationalInstruments.DAQmx.Task[nChannel]; for (int iChannel = 0; iChannel < nChannel; iChannel++) { tOsc[iChannel] = new NationalInstruments.DAQmx.Task(sTaskName); string sViChannelName = "AnalogIn_" + Convert.ToString(iChannel); string sResource = "PXI1Slot4/ai" + Convert.ToString(iChannel); tOsc[iChannel].AIChannels.CreateVoltageChannel(sResource, sViChannelName, AITerminalConfiguration.Pseudodifferential, -oSD.OscRange[iChannel], oSD.OscRange[iChannel] , AIVoltageUnits.Volts); }
which would give me the possibility to manage my settings and tasks convinient in arrays.
However, using this for task creation and configuration works fine, also
tOsc[iChannel].Control(TaskAction.Verify);
in the for loop give no error.
When I try to start the task I get the error message that the resource is occupied.
My gues would be that I block the resource already by starting one task for the module.
But how I could manage and use both channels independent?
Thanks for reading and I am looking forward to your replies.
Best wishes
Johannes
Chebychev LPF always gives Attenuating Sine Wave
Hello,
No matter what I pass through to the Chebyshev low-pass filter, I am getting an attenuating sine wave back.
I have tried passing double values derived from an FFT based on the code below:
FFTFrequency = Index * ForcingFunctionSampleRate / ForcingFunctionBlockSize FFTMagnitude = ComplexDataArray(Index).Magnitude FFTGraphedMagnitude = 2 / ForcingFunctionBlockSize * FFTMagnitude
I then use the X and Y Values of "FFTFrequency" and FFTGraphedMagnitude and pass those into the LPF function. I use the FFTGraphedMagnitude values as the input for the LPF function.
I have also attempted to completely skip this code, and pass in the ComplexDouble data from the FFT directly to the LPF function. It, again, gives me an attenuating sine wave for the .Real values.
What am I doing wrong?
Sample Rate is 1623.377 Hz, block size is 8192. Passband ripple is 1 db. Filter order is 10.
I am trying to LPF (cutoff frequency) at 140 Hz.
Here is my original function, a combination of multiple sine waves at frequencies of 180.3752, 162.3377, 147.5797, 124.8751, 108.2251, 90.18759, 81.16883, 70.58159, 60.12506, 50.73052, 40.58442, 30.06253, 20.04169, and 10.02084 Hz.
Here's the FFT graph based off of the code that gives me the X and Y values I pasted above:
And here is where it always goes sideways, regardless of the input data into the LPF function:
I am completely baffled at what to do next, or what to test. Any and all help is greatly appreciated. I am using .NET 4.0 inside of Visual Studio 2013. I have the Professional edition.
Thank you,
John Lindsay
niDMM_32.dll loading problem
Hi,
I have problem "impossible to load niDMM_32.dll" when I try to open usb-4065 device.
Thanks
Unable to locate 64bit National Instrument Assemblies for deployment
Looking here It would appear that there are specific 64bit versions of NI assemblies
http://zone.ni.com/reference/en-XX/help/375857A-01/xml/netdeploymentfiles/
I am not able to find Program Files\National Instruments\MeasurementStudioVS2013 and I am probably missing something simple, but I do not see an option in the NI measurment studio installer to install deployment files in this location... I am converting a 32bit application to 64bit and I am unable to run it due to a badimageformat exception caused by NationalInstruments.Analysis.Professional.dll
What am I missing here? How do I find the 64bit versions of the NI libraries?
How to create a multiple tasks to continuously read Digital channels?
Hi NI Community,
I am currently experiencing a problem where if I try to create multiple tasks that each continuously read from different digital input channels, I get the following exception:
The specified resource is reserved. The operation could not be completed as specified.
This only happens once I start the second task. Is it not allowed to continuously sample from two digital input tasks simultaneously?
I am using an NI USB-6509 device, which has 96 channels.
The workaround would thus be to add all channels to one task and continuously sample from there, but would require a bit of rework. I also don't particularly like the concept of that approach, since all of my outputs are set as individual tasks per output channel port. In other words, I would like to use one task per port of 8 pins, regardless of whether it's an input or output port. All my pins are set up as digital. I need to continuously measure the input pins in order to have an event fire when an input pin changes state.
If you require any source code to take a look, let me know. I don't just want to dump all of it here.
Thank you in advance.
GPIB 488.2 Board ID's Will Not Reset C#
When plugging in 5 GPIBs simultaneously, a board ID is automatically assigned ranging from 0 to 4. This ID seems to be permanently set - if the 4th GPIB is then plugged in by itself, the board ID must be set to its original value of 3 or else it will give a missing GPIB error. This causes a problem if one loses track of what each GPIB's board number is when plugging it back in later. How can the board ID's be reset? I implement board.SendInterfaceClear() from the NationalInstruments.NI4882.dll for each GPIB when my program is initialized but this does not fix the error. There is not a Interface Clear function for the NI device class (it should be SendIFC but for some reason that is not contained in the NationalInstruments.NI4882.dll as far as I can tell - in fact, more than half of the GPIB 488.2 function list is not part of the device or board classes and I have no idea how to access them. They are not contained in the GPIB 488.2 .Net example code that is installed with the drivers either. I am using driver version 16 and am coding in C# with Visual Studio 2015 with the manual implementation of the .licsx file in order to use Measurement Studio 2015 (see NI link for this work around: http://digital.ni.com/public.nsf/allkb/8C93FFDC5014C57586257EC30054830A). Everything else about my code and implementation of controlling 5 GPIBs work fine as long as the correct board ID is always assigned to the GPIB - this is not acceptable though as several people in my company running the code are not tech savy enough to handle the problem. Can somebody please help me reset my boardID's and if possible, help me access the missing functions? Using a different version of Visual Studio is not acceptable nor do I think that would allow access to the full function list as they aren't shown in the example code installed with the GPIB drivers. Thank you all for your time, I would greatly appreciate any help offered as this is a hindrance to our company's product development.