Quantcast
Channel: Measurement Studio for .NET Languages topics
Viewing all 1999 articles
Browse latest View live

Savitzky-golay Filter Out Of Memory exception

$
0
0

I am developing an application to analyse some very large waveforms, 1-2 GB per waveform. While testing what I have written so far I encountered an Out Of Memory exception when I invoked the Savitzky-Golay smoothing filter on a waveform with ~7,000,000 data points. The application is being built for a 64 bit target environment. I have set  the heap to have an initial size of 50 MB. The machine I am testing on has 4 GB of RAM and Resource Monitor reports that there is lots of memory available when I get the exception.

 

Initially I thought that the issue was that there wasn't a large enough continguous piece of memory to satisfy the need to allocate a large buffer for the return data. But then I tested filtering the same waveform in Diadem 2012. Using Diadem I was able load and display the waveform as well as being able to invoke the Savitzky-Golay filter to successfully smooth the waveform without seeing the Out Of Memory exception.

 

I have stripped everything out of my application except for the code that loads the TDMS file and the code that loads the data from the specified channel and then attempts to invoke the smoothing filter on it. This stripped down app still throws the Out of Memory exception on the large waveform. Interestingly, once I have caught the exception, the Savitzky-Golay filter will throw the Out of Memory exception every time it is invoked thereafter even with small datasets.

 

Since Diadem 2012 is able to smooth large waveforms I know it is possible. I am hoping someone at NI can give me a clue as to how Diadem does it.

 

Thanks in advance.


Should I get Measurement Studio to use old C drivers with C# .NET?

$
0
0

I am making a very simple test automation system for a very old test set using MS Visual Studio and C#. I do not have a large budget so I do not want to purchase NI Measurement Studio if I don't need it. I have seen that there is some kind of wizard that lets me make a "wrapper class" in C# out of old C drivers for old instruments. My instruments are very old and do not have native C# drivers. Does it make sense to pay for NI Measurement Studio only for this function? Is there a simple way to do this without using NI Measurement Studio? I will not be using any charts, knobs, or other special controls. The GUI elements that come with MS Visual Studio are good enough for me. I will not be using any special data processing functions, the standard C# functions are enough for me.

waveformgraph in vb.net

$
0
0

Hi !

I have the LabVIEW dll that get the jitter measurement from Waveform. In my labivew project the waveform is display in Wavefromgraph with ideal bit waveform and actual waveform. The waveform data is appended array and contains t0, dt and YArray. My question is -

 - how can i pass this waveform data to my application (developed by vb.net) 

 - how can i show this waveform in my application using WaveFormGraph. (I can display using PlotYMultiple function but no idea how to include t0 and dt data in the plot)

 

Hopefully my question is clear and can help me.

FFT Fast Fourier transform problem

$
0
0

 

In the sample at National Instruments\MStudioVS2010\DotNET\Examples\Analysis\Enterprise\Filtering

 

we see code at line 1103

 

subsetOfMagnitudes[i] = magnitudes[i]*scalingFactor*Math.Sqrt(2.0); // Storing only half the magnitudes array.

 

my problem is why *scalingFactor*Math.Sqrt(2.0)?

 

using matlab usually dont do this right?

web xydatagraph not refershing

$
0
0

Hi ,

 

We are using  NationalInstruments.UI.WebForms.ScatterGraph to genenarte a graph.   We are facing problem some times the xaxis range is not refreshing. All the plots are added without any issues but Range is not refreshing.Please refer the attachment.

 

Version Details:

Runtime Version : v4.0.30319
Version :9.0.40.292

 

// Before calling  the CreateGraph method we are calling setdaterange method .

//As a default it will show 24hrs interval  after that it will show it in selected date range  which is selected from the top of UI.

 

 

   private void SetDateRange(XAxis xAxis)
          {
              try
              {
                 if (isDefault)
                  {

                      xAxis.Range = new Range((DateTime)startdate, (DateTime)enddate);
                      xyDataGraph.XAxes[0].MajorDivisions.LabelFormat = new FormatString(FormatStringMode.DateTime, "MM/dd/yyyy HH:mm:ss");
                      xAxis.Mode = AxisMode.Fixed;
                      xAxis.AutoSpacing = false;
                      xAxis.MajorDivisions.Base = (double)DataConverter.Convert(startdate, typeof(double));
                      xAxis.MajorDivisions.Interval = (double)DataConverter.Convert(TimeSpan.FromHours(6), typeof(double));
                      xAxis.MinorDivisions.Interval = (double)DataConverter.Convert(TimeSpan.FromHours(1), typeof(double));

                  }
                  else
                  {

                                          xyDataGraph.XAxes[0].MajorDivisions.LabelFormat = new FormatString(FormatStringMode.DateTime, "MM/dd/yyyy");
                      xAxis.Mode = AxisMode.Fixed;
                      xAxis.AutoSpacing = false;
                      if (startdate == enddate)
                      {
                          xAxis.Range = new Range((DateTime)startdate, new TimeSpan(23, 0, 0));
                      }
                      else
                      {
                          xAxis.Range = new Range((DateTime)startdate, (DateTime)enddate.Add(new TimeSpan(23, 0, 0)));
                      }
                      xAxis.MajorDivisions.Base = (double)DataConverter.Convert(startdate, typeof(double));
                      xAxis.MajorDivisions.Interval = (double)DataConverter.Convert(TimeSpan.FromHours(2), typeof(double));
                      xAxis.MinorDivisions.Interval = (double)DataConverter.Convert(TimeSpan.FromHours(1), typeof(double));

                  }
              }
              catch (Exception ex)
              {
                  TM.Trace(LogLevel.Error, ex.Message);
              }
          }

 

// We are adding the graphs as below

 

 private void CreateGraph(double[] ChartDateTime, double[] Values)  try
              {

  try
              {
                  ScatterPlot newPlot = new ScatterPlot();
                  int chartlen = 0;
                  chartlen = ChartDateTime.Length;
                  double[] dataX = new double[chartlen];
                  double[] dataY = new double[chartlen];
                  DateTime[] dateX = new DateTime[chartlen];
                  XAxis xAxis = xyDataGraph.XAxes[0];
                  YAxis yAxis = xyDataGraph.YAxes[0];
                  newPlot.XAxis = xAxis;
                  newPlot.YAxis = yAxis;
                  yAxis.AutoSpacing = false;
                  yAxis.MajorDivisions.Base = 0;
                  yAxis.MajorDivisions.Interval = 3;
                  yAxis.MinorDivisions.Base = 0;
                  yAxis.MinorDivisions.Interval = 1;
                  yAxis.Range = new Range(0, 10);
                  xyDataGraph.YAxes[0].MajorDivisions.LabelFormat = new FormatString(FormatStringMode.Numeric, "0");

                  
                 newPlot.PlotXY(ChartDateTime, Values);
                  xyDataGraph.Plots.Add(newPlot);
                  xyDataGraph.DataBind();

                 
            }
              catch (Exception ex)
              {
                  TM.Trace(LogLevel.Error, ex.Message);
              }       

}

 

Please let us know if we have missed out anything. Please find the attached image.

 

 

Regards

Guhan.S

 

 

 

 

web xydatagraph not refershing

$
0
0

Hi ,

 

We are using  NationalInstruments.UI.WebForms.ScatterGraph to genenarte a graph.   We are facing problem some times the xaxis range is not refreshing. All the plots are added without any issues but Range is not refreshing.Please refer the attachment.

 

Version Details:

Runtime Version : v4.0.30319
Version :9.0.40.292

 

// Before calling  the CreateGraph method we are calling setdaterange method .

//As a default it will show 24hrs interval  after that it will show it in selected date range  which is selected from the top of UI.

 

 

   private void SetDateRange(XAxis xAxis)
          {
              try
              {
                 if (isDefault)
                  {

                      xAxis.Range = new Range((DateTime)startdate, (DateTime)enddate);
                      xyDataGraph.XAxes[0].MajorDivisions.LabelFormat = new FormatString(FormatStringMode.DateTime, "MM/dd/yyyy HH:mm:ss");
                      xAxis.Mode = AxisMode.Fixed;
                      xAxis.AutoSpacing = false;
                      xAxis.MajorDivisions.Base = (double)DataConverter.Convert(startdate, typeof(double));
                      xAxis.MajorDivisions.Interval = (double)DataConverter.Convert(TimeSpan.FromHours(6), typeof(double));
                      xAxis.MinorDivisions.Interval = (double)DataConverter.Convert(TimeSpan.FromHours(1), typeof(double));

                  }
                  else
                  {

                                          xyDataGraph.XAxes[0].MajorDivisions.LabelFormat = new FormatString(FormatStringMode.DateTime, "MM/dd/yyyy");
                      xAxis.Mode = AxisMode.Fixed;
                      xAxis.AutoSpacing = false;
                      if (startdate == enddate)
                      {
                          xAxis.Range = new Range((DateTime)startdate, new TimeSpan(23, 0, 0));
                      }
                      else
                      {
                          xAxis.Range = new Range((DateTime)startdate, (DateTime)enddate.Add(new TimeSpan(23, 0, 0)));
                      }
                      xAxis.MajorDivisions.Base = (double)DataConverter.Convert(startdate, typeof(double));
                      xAxis.MajorDivisions.Interval = (double)DataConverter.Convert(TimeSpan.FromHours(2), typeof(double));
                      xAxis.MinorDivisions.Interval = (double)DataConverter.Convert(TimeSpan.FromHours(1), typeof(double));

                  }
              }
              catch (Exception ex)
              {
                  TM.Trace(LogLevel.Error, ex.Message);
              }
          }

 

// We are adding the graphs as below

 

 private void CreateGraph(double[] ChartDateTime, double[] Values)  try
              {

  try
              {
                  ScatterPlot newPlot = new ScatterPlot();
                  int chartlen = 0;
                  chartlen = ChartDateTime.Length;
                  double[] dataX = new double[chartlen];
                  double[] dataY = new double[chartlen];
                  DateTime[] dateX = new DateTime[chartlen];
                  XAxis xAxis = xyDataGraph.XAxes[0];
                  YAxis yAxis = xyDataGraph.YAxes[0];
                  newPlot.XAxis = xAxis;
                  newPlot.YAxis = yAxis;
                  yAxis.AutoSpacing = false;
                  yAxis.MajorDivisions.Base = 0;
                  yAxis.MajorDivisions.Interval = 3;
                  yAxis.MinorDivisions.Base = 0;
                  yAxis.MinorDivisions.Interval = 1;
                  yAxis.Range = new Range(0, 10);
                  xyDataGraph.YAxes[0].MajorDivisions.LabelFormat = new FormatString(FormatStringMode.Numeric, "0");

                  
                 newPlot.PlotXY(ChartDateTime, Values);
                  xyDataGraph.Plots.Add(newPlot);
                  xyDataGraph.DataBind();

                 
            }
              catch (Exception ex)
              {
                  TM.Trace(LogLevel.Error, ex.Message);
              }       

}

 

Please let us know if we have missed out anything. Please find the attached image.

 

 

Regards

Guhan.S

 

 

 

 

web xydatagraph not refershing

$
0
0

Hi ,

 

We are using  NationalInstruments.UI.WebForms.ScatterGraph to genenarte a graph.   We are facing problem some times the xaxis range is not refreshing. All the plots are added without any issues but Range is not refreshing.Please refer the attachment.

 

Version Details:

Runtime Version : v4.0.30319
Version :9.0.40.292

 

// Before calling  the CreateGraph method we are calling setdaterange method .

//As a default it will show 24hrs interval  after that it will show it in selected date range  which is selected from the top of UI.

 

 

   private void SetDateRange(XAxis xAxis)
          {
              try
              {
                 if (isDefault)
                  {

                      xAxis.Range = new Range((DateTime)startdate, (DateTime)enddate);
                      xyDataGraph.XAxes[0].MajorDivisions.LabelFormat = new FormatString(FormatStringMode.DateTime, "MM/dd/yyyy HH:mm:ss");
                      xAxis.Mode = AxisMode.Fixed;
                      xAxis.AutoSpacing = false;
                      xAxis.MajorDivisions.Base = (double)DataConverter.Convert(startdate, typeof(double));
                      xAxis.MajorDivisions.Interval = (double)DataConverter.Convert(TimeSpan.FromHours(6), typeof(double));
                      xAxis.MinorDivisions.Interval = (double)DataConverter.Convert(TimeSpan.FromHours(1), typeof(double));

                  }
                  else
                  {

                                          xyDataGraph.XAxes[0].MajorDivisions.LabelFormat = new FormatString(FormatStringMode.DateTime, "MM/dd/yyyy");
                      xAxis.Mode = AxisMode.Fixed;
                      xAxis.AutoSpacing = false;
                      if (startdate == enddate)
                      {
                          xAxis.Range = new Range((DateTime)startdate, new TimeSpan(23, 0, 0));
                      }
                      else
                      {
                          xAxis.Range = new Range((DateTime)startdate, (DateTime)enddate.Add(new TimeSpan(23, 0, 0)));
                      }
                      xAxis.MajorDivisions.Base = (double)DataConverter.Convert(startdate, typeof(double));
                      xAxis.MajorDivisions.Interval = (double)DataConverter.Convert(TimeSpan.FromHours(2), typeof(double));
                      xAxis.MinorDivisions.Interval = (double)DataConverter.Convert(TimeSpan.FromHours(1), typeof(double));

                  }
              }
              catch (Exception ex)
              {
                  TM.Trace(LogLevel.Error, ex.Message);
              }
          }

 

// We are adding the graphs as below

 

 private void CreateGraph(double[] ChartDateTime, double[] Values)  try
              {

  try
              {
                  ScatterPlot newPlot = new ScatterPlot();
                  int chartlen = 0;
                  chartlen = ChartDateTime.Length;
                  double[] dataX = new double[chartlen];
                  double[] dataY = new double[chartlen];
                  DateTime[] dateX = new DateTime[chartlen];
                  XAxis xAxis = xyDataGraph.XAxes[0];
                  YAxis yAxis = xyDataGraph.YAxes[0];
                  newPlot.XAxis = xAxis;
                  newPlot.YAxis = yAxis;
                  yAxis.AutoSpacing = false;
                  yAxis.MajorDivisions.Base = 0;
                  yAxis.MajorDivisions.Interval = 3;
                  yAxis.MinorDivisions.Base = 0;
                  yAxis.MinorDivisions.Interval = 1;
                  yAxis.Range = new Range(0, 10);
                  xyDataGraph.YAxes[0].MajorDivisions.LabelFormat = new FormatString(FormatStringMode.Numeric, "0");

                  
                 newPlot.PlotXY(ChartDateTime, Values);
                  xyDataGraph.Plots.Add(newPlot);
                  xyDataGraph.DataBind();

                 
            }
              catch (Exception ex)
              {
                  TM.Trace(LogLevel.Error, ex.Message);
              }       

}

 

Please let us know if we have missed out anything. Please find the attached image.

 

 

Regards

Guhan.S

 

 

 

 

Show round/whole numbers on x-axis when zoomed in

$
0
0

I want to show nice round numbers on the x-axis when the user zooms in.  It seems like I have to choose between CreateIntervalMode and CreateCountMode but I don't think they get me what I want.  What I really want is CreateIntervalMode with an offset because if the user zooms in to a range of 0.24 to 2.26 I would like the interval to be 0.2 but I want the first tick mark to be 0.4 not 0.24.  

 

If I use interval mode then I would get numbers like 0.24, 0.44, 0.64, etc.

 

If I use count mode then I would get numbers like 0.24, 0.42, 0.60, etc (depending on how many counts I specify).

 

Neither of those are what I want.

 

Is there a way to accomplish this?

 

Thanks,
Dan


Power Spectrum for 2 signals

$
0
0

Hello, I'm little noob and I want to show power spectrum from 2 signals :  1 is generated (sinweave) and 1 from acquisition.

 

Is there any way to convert double[] to signal, or composite analogwaveForm ? 

 

Thank you.

 

 

 

AnalogWaveForm<double> data = reader.EndReadWaveform(ar); // read from acquisition

SineSignal sinsignal = new SineSignal(500,1);

double[] sinusSignalGenerated = sinsignal.Generate((int)rateNumericEdit.Value, (int)samplesNumericEdit.Value); // generate signal

 

//SignalGenerator sgen = new SignalGenerator((int)rateNumericEdit.Value, (int)samplesNumericEdit.Value);
//sgen.Signals.Add(sinsignal);
//sgen.Signals.Add();  //add signal from AnalongWaveForm data

AnalogWaveform<double>[] dataGenerated = new AnalogWaveform<double>[2];
dataGenerat[0] = data;
dataGenerat[1] = AnalogWaveform<double>.FromArray1D(sinusSignalGenerated);

 

//acquiredDataWaveformGraph.PlotWaveform(data);
acquiredDataWaveformGraph.PlotWaveforms(dataGenerat);  // show on graph both signals

 


getUnitConvertedAutoPowerSpectrum(data); // Get power spectrum of signal waveform.   // here i must calculate power Spectrum for analogweaveform
// Call the following function to calculate current powerPeak and frequencyPeak.
currentPeakData();

issues using SPI write and read with ni845x.dll in visual studio 2010

$
0
0

Reposting this in the software section:

I am trying to use the .dll supplied with the 8451 to communicate via SPI, and I have most functions (seemingly) working.  When I try to send a message, however, I get an error (-301710 - invalid configuration reference).  Some of the documentation for the dll is... lacking, but I tried passing the configuration handle by reference and value, both giving the same error. 

 

My code flow is as follows:

1. Find device with ni845xFindDevice

2. Open device with ni845xOpen

3. Open device configuration with ni845xSpiConfigurationOpen

4. Set all configuration parameters with their functions

5. Attempt to write data with ni845xSpiWriteRead

6. Close configuration with ni845xSpiConfigurationClose

 

It fails at step 5.  I've tried the method of passing variables, swtiched steps 2 and 3, switched steps 5 and 6, all to no avail. As a side note, I pass the configuration handle (by reference) to a subfunction that performs all of parts 3 and 4.  I am storing the device handles as ULong (which I grabbed from the .h file that was included) and this works for the other functions that require handles. 

 

Does anyone have advice on what to try next?

Open VISA session in c# to RIO0::INSTR cause error

$
0
0

Hi,

 

I use VisaNS.dll  version 13.0.40.167 in a Visual Studio 2010 c# application and try to open a visa session to RIO::INSTR.

HW is NI PXI-7842R

 

shortinterfacenum = 0;

HardwareInterfaceType interfacetype = HardwareInterfaceType.Pxi;

ResourceManager.GetLocalManager().ParseResource("RIO0::INSTR", out interfacetype, out interfacenum);

 

NI I/O Tracer

1.  viOpenDefaultRM (0x05F02E60)
Process ID: 0x000010B8         Thread ID: 0x00001BE0
Start Time: 17:03:58.620       Call Duration 00:00:00.024
Status: 0 (VI_SUCCESS)

2.  viParseRsrcEx (0x05F02E60, "RIO0::INSTR", 8, 0, "INSTR", "RIO0::INSTR", "RIO1")
Process ID: 0x000010B8         Thread ID: 0x00001BE0
Start Time: 17:03:58.648       Call Duration 00:00:00.035
Status: 0 (VI_SUCCESS)

3.  viClose (0x05F02E60)
Process ID: 0x000010B8         Thread ID: 0x00001BE0
Start Time: 17:03:58.684       Call Duration 00:00:00.002
Status: 0 (VI_SUCCESS)

 

private Session rbSession;

rbSession = (Session)ResourceManager.GetLocalManager().Open("RIO0::INSTR");

 

Exception During Open Visa Session to RIO

[System.MissingMethodException] = {"Constructor on type 'NationalInstruments.VisaNS.Session' not found."}

 

Access to NI PXI-7842R using PXI7::15::INSTR works and provides access reading attributes.

 

But I need access to the serial number described in Document ID: 4687QJ5K How Do I Programmatically Get Backplane Information of My RIO Device? but using the .NET Language

 

NI MAX is able to get the information


339.  viFindNext (0x046FBEB0, "RIO0::INSTR")
Process ID: 0x00000728         Thread ID: 0x0000163C
Start Time: 16:32:27.878       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

340.  viParseRsrc (0x025D8338, "RIO0::INSTR", 8, 0)
Process ID: 0x00000728         Thread ID: 0x0000163C
Start Time: 16:32:27.878       Call Duration 00:00:00.012
Status: 0 (VI_SUCCESS)

341.  viOpen (0x025D8338, "RIO0::INSTR", 4, 0, 0x04855700)
Process ID: 0x00000728         Thread ID: 0x0000163C
Start Time: 16:32:27.890       Call Duration 00:00:00.046
Status: 0 (VI_SUCCESS)

342.  viGetAttribute (RIO0::INSTR (0x04855700), RSRC_IMPL_VERSION, 0x0C10C001)
Process ID: 0x00000728         Thread ID: 0x0000163C
Start Time: 16:32:27.936       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

343.  viGetAttribute (RIO0::INSTR (0x04855700), RSRC_MANF_ID, 4086)
Process ID: 0x00000728         Thread ID: 0x0000163C
Start Time: 16:32:27.936       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

344.  viGetAttribute (RIO0::INSTR (0x04855700), INTF_INST_NAME, "RIO0 (NI PXI-78...s/n 0x0154560D)")
Process ID: 0x00000728         Thread ID: 0x0000163C
Start Time: 16:32:27.936       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

 

What is wrong?

 

 

unable to find dependency

$
0
0

My configuration:
Win7 SP1
VS2010 Professional
Measurement Studio 2013 Professional
NI-VISA 5.3
NI-Device Drivers Aug13

 

Problem Description :
I am trying to re-compile code I inherited from an old project.
I am new to Measurement Studio.

 

the original project was compiled with VS2008 using .NET framework 3.5. this project was converted to VS2010, but tried to have it using framework 3.5, not 4.0. I installed both parts of the Aug13 drivers and NI VISA 5.3 after setting up Measurement Studio 2013.

It appears to compile, but I have the following warnings:

WARNING: Unable to find dependency 'NATIONALINSTRUMENTS.UI' (Signature='18CBAE0F9955702A' Version='8.9.35.246')

WARNING: Unable to find dependency 'MICROSOFT.OFFICE.INTEROP.WORD' (Signature='71E9BCE111E9429C' Version='11.0.0.0')

WARNING: Unable to find dependency 'NATIONALINSTRUMENTS.VISANS' (Signature='18CBAE0F9955702A' Version='8.9.35.108')

WARNING: Unable to find dependency 'NATIONALINSTRUMENTS.UI.WINDOWSFORMS' (Signature='18CBAE0F9955702A' Version='8.9.35.246')
WARNING: Unable to find dependency 'INTEROP.SCRIPTING' (Signature='(null)' Version='1.0.0.0')
WARNING: Unable to find dependency 'NATIONALINSTRUMENTS.COMMON' (Signature='18CBAE0F9955702A' Version='8.9.35.156')
WARNING: Unable to find dependency 'NATIONALINSTRUMENTS.VISANS' (Signature='18CBAE0F9955702A' Version='8.9.35.108')
WARNING: Unable to find dependency 'NATIONALINSTRUMENTS.UI.WINDOWSFORMS' (Signature='18CBAE0F9955702A' Version='8.9.35.246')
WARNING: Unable to find dependency 'NATIONALINSTRUMENTS.UI' (Signature='18CBAE0F9955702A' Version='8.9.35.246')

Single End Analog Input

$
0
0

I am trying to read a voltage using an analog input on a NI USB-6008 in C#. I have tried using a Differential and it worked, however, I am constrained and would prefer to use Single-End to read the voltage. However, when I create an instance of an AnalogSingleChannelReader with a Terminal Coniguration of any type other than Differential, it still operates like a Differential. Any ideas as to why this isn't working? And yes, I do know that the Terminal Configuration currently is configured for a Differential in the code.

 

public class AnalogInput
    {
        #region Import Dlls
        [DllImport("NationalInstruments.Common.dll")]
        static extern void Import1();
        [DllImport("NationalInstruments.Common.Native.dll")]
        static extern void Import2();
        [DllImport("NationalInstruments.DAQmx.dll")]
        static extern void Import3();
        #endregion

        #region Private Fields
        Task oTask = new Task();
        string ChannelString = "";
        #endregion

        #region Constructor
        public AnalogInput(AnalogInputChannels Channel)
        {
            ParseInputChannel(Channel);
            oTask.AIChannels.CreateVoltageChannel(ChannelString, "Channel", AITerminalConfiguration.Differential, 0, 10, AIVoltageUnits.Volts);
        }
        #endregion

        #region Public Methods
        public double Read()
        {
            AnalogSingleChannelReader oReader = new AnalogSingleChannelReader(oTask.Stream);
            double Data = oReader.ReadSingleSample();
            return Data;
        }
        #endregion

        #region Private Methods
        void ParseInputChannel(AnalogInputChannels Channel)
        {
            switch (Channel)
            {
                case AnalogInputChannels.In0:
                    ChannelString = "Dev1/ai0";
                    break;
                case AnalogInputChannels.In1:
                    ChannelString = "Dev1/ai1";
                    break;
                case AnalogInputChannels.In2:
                    ChannelString = "Dev1/ai2";
                    break;
                case AnalogInputChannels.In3:
                    ChannelString = "Dev1/ai3";
                    break;
                case AnalogInputChannels.In4:
                    ChannelString = "Dev1/ai4";
                    break;
                case AnalogInputChannels.In5:
                    ChannelString = "Dev1/ai5";
                    break;
                case AnalogInputChannels.In6:
                    ChannelString = "Dev1/ai6";
                    break;
                case AnalogInputChannels.In7:
                    ChannelString = "Dev1/ai7";
                    break;
            }
        }
        #endregion
    }

 

 

Single-End.png

Relay control with NI USB-6343

$
0
0

I am very new to these devices and trying to find my way around. I am trying to use a USB-6343 to control some relays on a test bench, I have looked at all the examples for creating a digital output and here is where I get stuck:

 

Configure the Task to use a burst export clock, which configures the
'       device for Burst Mode Handshaking, setsthe sample clock rate, exports
'       the clock on the specified PFILine, and sets the sample mode to
'       Continuous.

 

I can not figure out how to configure the task for burst export clock in NI-DAQmx tasks. what am I missing? I see the settings for sample clock type and clock source and active edge. am I suppose to configure them manually?

 

is there a simple example for triggering a digital output and producing a continuous signal as long as the trigger is on?

 

Regards,

 

Farid

 

 

How to keep c# .NET GUI responsive during long operations

$
0
0

I am an experienced LabVIEW developer but a newbie c# .NET developer. When I want to keep my GUI responsive in LabVIEW, I use a simple producer/consumer pattern with two while loops. I have been looking into doing this with c#, and it seems like I need to use the system.threading collection. In general the power of this collection seems like massive overkill for what I need to do. Is there a step-by-step guide somewhere describing how to make a simple producer (GUI thread) consumer (instruments, robot, etc) two threaded program using c#?


Fix axis locations

$
0
0

I have a panel to which multiple graphs are being added dynamically. It is important to me that the x axis and y axis of each graph lines up so graphs can be easily compared to each other. This works fine initially, however if i zoom into one of the graphs or perform a ResetZoomPan() the location of the Y axis appears to move on the graph in question, sometimes the divisions on the x axis also change. This means the Y axis on each graph no longer line up with each other making it difficult to draw direct comparisons.

Is there any way to fix the location of the Y axis and prevent it from moving? Also how can the divisions be fixed so we can zoom and reset without them changing?

TDMS Logging Mode LogAndRead

$
0
0

My application requires that I sample 8 AI channels at 100 kHz/channel for several hours and log the data.  The snippet below is an example of what I am attempting to do.

The analog channels are configured, scaled, etc. in NIMAX as a task and loaded in.  If I confgure logging with LoggingMode.Log and comment out the AppendAnalogWaveforms method call in the event handler, everything runs great and all the data is logged.  However, I would like to display 1 sample value form each channel every half second.  So when I switch to LoggingMode.LogAndRead and append the data as shown, I get the "Unknow Error Exception" from TDMS after about a dozen or so appends to the TDMS file.  My thoughts are that I'm getting in the way of sampling and writing due to the high sample rate.  Any suggestions?  Is there a better way to do this?

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using NationalInstruments.DAQmx;
using NationalInstruments.Tdms;
using NationalInstruments;

namespace Production_Test
{
    public static class AnalogInput
    {
        private static Task _analogInputTask;
        private static NationalInstruments.UI.WindowsForms.NumericEdit _numEdit;
        private static TdmsFile _logFile;
        private static TdmsChannelGroup _tdmsGroup;
        private static TdmsChannel[] _tdmsChannels;
        private static AnalogMultiChannelReader _channelReader;

        public static void Start(NationalInstruments.UI.WindowsForms.NumericEdit numEdit)
        {
            _numEdit = numEdit;

            _analogInputTask = DaqSystem.Local.LoadTask("MyVoltageTask");

            _analogInputTask.ConfigureLogging("E:\\MyTestData.tdms", TdmsLoggingOperation.CreateOrReplace, LoggingMode.LogAndRead);

            _analogInputTask.EveryNSamplesReadEventInterval = 50000;
            _analogInputTask.EveryNSamplesRead += new EveryNSamplesReadEventHandler(_analogInputTask_EveryNSamplesRead);

            _analogInputTask.Start();

            _logFile = new TdmsFile(_analogInputTask.Stream.LoggingFilePath, new TdmsFileOptions());

            _tdmsGroup = _logFile.GetChannelGroup("MyVoltageTask");
            _tdmsChannels = new TdmsChannel[_tdmsGroup.GetChannels().Count];
            _tdmsGroup.GetChannels().CopyTo(_tdmsChannels, 0);
            _channelReader = new AnalogMultiChannelReader(_analogInputTask.Stream);
        }

        static void _analogInputTask_EveryNSamplesRead(object sender, EveryNSamplesReadEventArgs e)
        {
            try
            {
                _tdmsGroup.AppendAnalogWaveforms<double>(_tdmsChannels, _channelReader.ReadWaveform(-1));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }

        public static void Stop()
        {
            _analogInputTask.Stop();
            _analogInputTask.Dispose();
        }
    }
}

 

 

Call javascript function on AutoRefresh

$
0
0

Hi,

 

I need to call one javascript function as soon as the timer Ticks,in the following code.Please help me out.

 

<ni:WaveformGraph ID="ChannelGraph" runat="server" Width="620" Height="250">
  <XAxes>
    <ni:XAxis AutoSpacing="False" InteractionMode="None" Mode="StripChart" Visible="False">
    </ni:XAxis>
  </XAxes>
 

  <YAxes>
    <ni:YAxis Mode="Fixed" Range="-1,100" Visible="False">
    </ni:YAxis>
  </YAxes>
</ni:WaveformGraph>

<ni:AutoRefresh ID="GraphRefresh" runat="server" Interval="00:00:1.000" OnRefresh="OnRefresh">
  <DefaultRefre**bleep**ems>
    <ni:Refre**bleep**em ItemID="ChannelGraph" />
  </DefaultRefre**bleep**ems>
</ni:AutoRefresh>

 

 

 

Update grid on Auto refresh Tick

$
0
0

Hi,

 

I have on telerik radgrid in the same page as of the graph constructed by NI. I want to refresh the grid when OnRefresh method called by AutoRefresh. Can any one tell me how to add the item id of grid in the  <DefaultRefre**bleep**ems> of the NI.

 

 

<ni:WaveformGraph ID="ChannelGraph" runat="server" Width="620" Height="250">
  <XAxes>
    <ni:XAxis AutoSpacing="False" InteractionMode="None" Mode="StripChart" Visible="False">
    </ni:XAxis>
  </XAxes>
 

  <YAxes>
    <ni:YAxis Mode="Fixed" Range="-1,100" Visible="False">
    </ni:YAxis>
  </YAxes>
</ni:WaveformGraph>

<ni:AutoRefresh ID="GraphRefresh" runat="server" Interval="00:00:1.000" OnRefresh="OnRefresh">
  <DefaultRefre**bleep**ems>
    <ni:Refre**bleep**em ItemID="ChannelGraph" />
  </DefaultRefre**bleep**ems>
</ni:AutoRefresh>

wpf graph internal axis labels

$
0
0

Is it possible to have axis ticks and/or labels inside plot area to conserve space? So that plot area would occupy 100% of the control, and all labels will be inside.

Viewing all 1999 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>