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

Confirming that I'm getting all samples

$
0
0

Hello--

I have an application where I'm sending a 100Hz pulse to a device and I'd like to measure 27 analog inputs for each cycle of the pulse.  My DAQ is an NI-USB 6363 OEM.
I've configured the task to trigger off the counter output (PFI12 in this case), and have the system capturing a finite number of samples for each cycle (1M samples /27 channels @ 100Hz = 370 samples per cycle).  Despite this, I seem to be only getting about 22-24 samples for every 100 cycles.  I'm not getting any buffer overruns, so I'm not sure where the data is going.  Below is my code:

Public Function StartPulse(ByVal CycleParams As CycleParameterType, ByVal SampleRate As Double, ByRef ErrMsg As String) As Boolean
        With CycleParams
                PressHiTime = .PressureOnTime / 1000
                PressLoTime = (.Period - .PressureOnTime) / 1000
                VentHiTime = .VentOnTime / 1000
                VentLoTime = (.Period - .VentOnTime) / 1000
                VentLagTime = (.LagTime) / 1000
                SamplesPerSnap = Convert.ToInt32(SampleRate * .Period) / 1000
        End With

        If AIRunningTask Is Nothing Then
            Try
                AITask = New Task()
                AITask.AIChannels.CreateVoltageChannel("/" & DAQName & AIPort, _
                                                       "AnalogInputs", AITerminalConfiguration.Rse, AIMinVoltage, AIMaxVoltage, AIVoltageUnits.Volts)
                AITask.Timing.ConfigureSampleClock("", SampleRate, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, SamplesPerSnap)
                AITask.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger("/" & DAQName & PressurePulseOutputChannel, DigitalEdgeStartTriggerEdge.Rising)
                AIReader = New AnalogMultiChannelReader(AITask.Stream)
                AIRunningTask = AITask
                AIReader.SynchronizeCallbacks = True
                AITask.Control(TaskAction.Verify)
                'Pressure Signal Generation
                PressurePulseTask = New Task()
                PressurePulseTask.COChannels.CreatePulseChannelTime("/" & DAQName & PressurePulseCounter, _
                                                            "PressureSignal", COPulseTimeUnits.Seconds, COPulseIdleState.Low, _
                                                            0, PressLoTime, PressHiTime)
                PressurePulseTask.Timing.ConfigureImplicit(SampleQuantityMode.ContinuousSamples)

                'Vent Signal Generation
                VentPulseTask = New Task()
                VentPulseTask.COChannels.CreatePulseChannelTime("/" & DAQName & VentPulseCounter, _
                                                            "VentSignal", COPulseTimeUnits.Seconds, COPulseIdleState.Low, _
                                                            VentLagTime, VentLoTime, VentHiTime)
                VentPulseTask.Triggers.StartTrigger.Type = StartTriggerType.DigitalEdge
                VentPulseTask.Triggers.StartTrigger.DigitalEdge.Edge = DigitalEdgeStartTriggerEdge.Rising
                VentPulseTask.Triggers.StartTrigger.DigitalEdge.Source = "/" & DAQName & PressurePulseOutputChannel
                VentPulseTask.Timing.ConfigureImplicit(SampleQuantityMode.ContinuousSamples)

                'Count the Signals
                CountPulseTask = New Task()
                CountPulseTask.CIChannels.CreateCountEdgesChannel("/" & DAQName & CountPulseCounter, _
                                                                  "CountPulses", CICountEdgesActiveEdge.Rising, 0, _
                                                                 CICountEdgesCountDirection.Up)
                CountPulseTask.CIChannels.All.CountEdgesTerminal = "/" & DAQName & PressurePulseOutputChannel
                CountPulseReader = New CounterSingleChannelReader(CountPulseTask.Stream)

                'Start 'em up!
                CountPulseTask.Start()
                VentPulseTask.Start()
                AIReader.BeginReadWaveform(SamplesPerSnap, AIAsyncCallback, AITask)
                PressurePulseTask.Start()
                Debug.Print(AITask.Timing.SampleClockSource)
            Catch ex As Exception
                AIRunningTask = Nothing
                AITask.Dispose()
                StatusCheckTimer.Enabled = False
                ErrMsg = ErrMsg & " " & ex.Message
                StartPulse = False
                Exit Function
            End Try
        End If
        StartPulse = True
    End Function

    Private Sub AICallback(ByVal ar As IAsyncResult)
        Dim ErrMsg As String = ""
        Try
            If (Not (AIRunningTask Is Nothing)) AndAlso AIRunningTask Is ar.AsyncState Then
                ' Retrieve data
                AIData = AIReader.EndReadWaveform(ar)
                'Plot your data here 
                DataToQueue(AIData)
                AIReader.BeginMemoryOptimizedReadWaveform(SamplesPerSnap, AIAsyncCallback, AITask, AIData)
            End If
        Catch ex As DaqException
            DAQError = ex.Message
            StopPulse(ErrMsg)
        End Try
    End Sub


    Private Sub DataToQueue(ByVal sourceArray As AnalogWaveform(Of Double)())
        Dim i As Byte = 0
        Dim tmpstr As String = ""
        Dim tmpAIdata(NumChannels - 1, SamplesPerSnap - 1) As Double
        Dim dataCount As Integer = sourceArray(i).Samples.Count
        For i = 0 To NumChannels - 1
            For j As Integer = 0 To (dataCount - 1)
                tmpAIdata(i, j) = sourceArray(i).Samples(j).Value
            Next
            If i = SystemPressureChannel Then
                AIPressure = tmpAIdata(i, dataCount - 1)
            End If
        Next i
        AISnap.Add(tmpAIdata)
    End Sub

Any thoughts on what the problem is?  Do I need to configure the sample clock source?Thanks!!!Sandheep


National Instruments is not loading

$
0
0

Hi,

 

now it is strange.. I have made a WIX setup file which seems to work OK in the most cases. But in one customer computer (Win2012R2)  the new NationalInstruments.Commnon is not installed into GAC. There is an older version from a previous setup file.

 

the installation project is using MStudioCommon.2012_x64.msm merge module.

 

Can there be any reason why the NationalInstruments.Common assembly is not installed correctly just in one computer? I have all newest NI sw in my development machine.

 Thank you for any help,....

Vertical Intensity Graph ChartCollection data type

$
0
0

Hi,

We are using VerticalIntensityChartCollection described in M19753 question.

Everything looks fine except we have to use ChartCollection<double, double> against double[]  because we want to show calculated frequency values in X-Axis (for example our chart range between 750 MHz  to 1250 MHz). When we use double[], graph range always starts from zero.

We are calculating frequency and amplitude values as double values with graph size and  store them in a ChartCollection<double,double> and we want to use this collection to print VerticalIntensityGraph.

 

When we change double[] to ChartCollection<double,double> VerticalIntensityChartCollection's Append method  has error.

 

How could we accomplish this, 

 

Best Regards,

Hakan,

 

 

 

 

 

 

Customizing NumericTextBoxDouble WPF User Control

$
0
0

Hello,

I am interested in customizing the NI NumericTextBoxDouble WPF control. My goal is to end up with a NumericTextBoxDouble user control that looks like the screenshot below. For the custom control I would like to inherit from the NumericTextBoxDouble class (since it has all the functionality I need and is what my code currently uses) and then customize/override the controls appearance. I'm not exactly sure where to get started and I have few questions (I'm not even sure if these are the right questions to ask)...

  • Is it possible to hide the up/down buttons that are part of the NumericTextBoxDouble control?
  • Is it possible move the location of the up/down buttons that are part of the NumericTextBoxDouble control?
  • Am I better off creating an entirely custom control from scratch?

2018-12-27 09_20_01-.png

Any advice is appreciated, thanks!

How can we Deploy Measurement Studio 2013 with Visual Studio 2017 and DAQmx

$
0
0

Greetings!

 

We have finished our application and are now looking to deploy it to the customer's PC. The application was built with Visual Studio 2017 and worked with major success on our development platform; however, we've not yet been able to successfully deploy the application to the target PC without installing the developer's edition of Measurement Studio.

 

Initially we used VS2017 + Measurement Studio 2013 + DAQmx 17.6 runtime. This was the bare bones approach with the latest tools we had on-hand. Though, the NI community later discovered an issue deploying Measurement Studio with DAQmx 17.6.

See: Error 2765 Developing a Program in Visual Studio™ and NI-488.2

 

The issue being that MSI installer is unable to install the merge modules that are required for running Measurement Studio/DAQmx.

 

The question right now is whether it is possible to deploy without the workaround suggested in the article. It appears that the Measurement Studio Installer Builder tool isn't available in the 2013 edition.

 

At this moment, we've also checked the latest version of DAQmx (VS2017 + MS2013 + DAQmx 18.6). It appears that this issue was not yet fixed.

It might be possible to try an earlier version of DAQmx (say 9.6.1), but this does break some of the API's we are using. This might be a decent option if we can locate the NI-DAQmx API documentation.

 

Help is much appreciated!

WPF Graph Zoom Behavior

$
0
0

Hi,

When calling the Zoom method on the WPF graph, all the parameters are "relative". i.e. when refreshing the plots and chart boundaries, the zoom rectangle is defined as relative to the new graph boundaries.

Those were our conclusions after implementing this feature. I've tried and couldn't find any documentation about this behavior.

I would like to know:

  • Where can I find any documentation describing the zoom behavior when refreshing the plots and chart boundaries?
  • Is it possible to define "absolute" zoom boundaries, i.e. zoom in absolute (and not relative) values per axis?
  • Was this behavior changed from the WinForms to the WPF graph?

Thanks in advance!

  Nimrod S.

Error on ReadSingleSampleInt32

$
0
0

Hello--

I'm having an issue where a ReadSingleSampleInt32 call results in an error.  Some background:

I have a counter which counts pulses.  It gets initialized/started as follows:

 

CountPulseTask = New Task()
CountPulseTask.CIChannels.CreateCountEdgesChannel("/" & DAQName & CountPulseCounter, _
                                                  "CountPulses", CICountEdgesActiveEdge.Rising, 0, _
                                                 CICountEdgesCountDirection.Up)
CountPulseTask.CIChannels.All.CountEdgesTerminal = "/" & DAQName & PressurePulseOutputChannel
CountPulseReader = New CounterSingleChannelReader(CountPulseTask.Stream)
CountPulseTask.Start()

Then, every 100ms (via .NET timer control), I obtain the count as follows:

 

 

    Public Function GetCount(ByRef ErrMsg As String) As Long
        Dim tmpCount As Long
        Try
            tmpCount = CountPulseReader.ReadSingleSampleInt32()
        Catch ex As Exception
            'CountPulseTask.Dispose()
            ErrMsg = ex.Message
            GetCount = ErrLong
            Exit Function
        End Try
        GetCount = tmpCount
    End Function

I've got an intermittent but reliable situation where the GetCount sub throws an exception--sometimes after 8k counts, sometimes after millions of counts.  I haven't seen this issue on my dev system, but my client has seen the error on their deployment system.  As a result, debug information is limited--I know that makes diagnosis very difficult.

 

But i'm wondering if anyone is aware of any reasons why a ReadSingleSampleInt32 call would work fine for millions of cycles, and then all of a sudden throw an exception. Not knowing the specific error, it's been hard to search the forums for possibilities.  I can confirm with near certainty that the counter task is still valid and running.

 

Any thoughts would be greatly appreciated.

Thanks!

Sandheep

 

 

Unable to load DLL nianlys.dll after upgrading Measurement studio support for Visual Studio 2017

$
0
0

Hello team,

 

Recently we have installed the beta version of NI to support Measurement studio for Visual Studio 2017. After the upgrade we have updated all the references accordingly. The .Net Winforms application was packaged and installed on client machine, we are seeing the below runtime exception.

 

System.DllNotFoundException: Unable to load DLL 'nianlys.dll': A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)     at NationalInstruments.Analysis.Internal.s.d(Double[] A_0, IntPtr A_1, Double& A_2)     at NationalInstruments.Analysis.Math.Statistics.Mean(Double[] inputData)   

 

We used to have the same issue prior to the upgrade to Visual Studio 2017 using Visual Studio 2013, upon doing some research in previous posts, we learned to add the merge module nianlys.msm / nianlys_x64.msm to the setup project, doing so resolved this run time exception. Now after the upgrade we are running into the same issue again and we are not able to find the merge module for nianlys.msm to add to our setup project. Seems after the upgrade to Visual studio 2017 NI has removed this merge module or replaced with any other merge module.

 

This is a show stopper issue for us. Kindly help in resolving ASAP.

 

Thanks,

Baba

 


Console Offline Installation using Package Manager

$
0
0

NI has a desciption for offline installation using the Package Manager and a private feed:

    http://www.ni.com/tutorial/53918/en/

Question:

  How can I do offline installation unantended (console) from the private feed?

 

WPF Graph Editable Lables or Annotations

$
0
0

Hello.
I am using NI Graphs in my WPF application and I would like to add label (or annotation) at the position where the user double-clicked. These labels must be editable and movable. Is that realizable? Can you help me to solve this issue please? Changing color of the label would be also the nice to have.

Thank you very much for support.

VerticalIntensityChartCollection freeze and unreponsive

$
0
0

Hi,

We are using VerticalIntensityChartCollection described in M20207.

We want to build a high resolution intensity graph and set VerticalIntensityChartCollection capacity as 400  to be able to increase vertical resolution and GenerateData method creates randon data array with size of graph's width.

 

Timer thicks every 200 milliseconds and when that interval decrese graph start to freeze and application become unreponsive.

I have attached complete example and in case of failure added code below.

 

Best Regard,

Hakan,

<Window x:Class="VerticalIntensityGraphExample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ni="http://schemas.ni.com/controls/2009/xaml/presentation"
        Title="MainWindow" Height="480" Width="640" WindowState="Maximized" ><Grid><ni:IntensityGraph  x:Name="graph"><ni:IntensityGraph.ColorScale><ni:ColorScale x:Name="colorScale1"><ni:ColorScaleMarker Color="Red" Value="0"/><ni:ColorScaleMarker Color="Orange" Value="-10"/><ni:ColorScaleMarker Color="Yellow" Value="-40"/><ni:ColorScaleMarker Color="Green" Value="-65"/><ni:ColorScaleMarker Color="Blue" Value="-100"/><ni:ColorScaleMarker Color="DarkBlue" Value="-120" /></ni:ColorScale></ni:IntensityGraph.ColorScale><ni:IntensityGraph.VerticalAxis><ni:AxisDouble x:Name="verticalAxis1" Adjuster="ContinuousChart" Orientation="Vertical"/></ni:IntensityGraph.VerticalAxis><ni:IntensityGraph.HorizontalAxis><ni:AxisDouble x:Name="xAxis" Adjuster="FitExactly" Orientation="Horizontal" Range="750, 1250, System.Double" /></ni:IntensityGraph.HorizontalAxis></ni:IntensityGraph></Grid></Window>

 

 

namespace VerticalIntensityGraphExample
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private const double YIncrement = 10/400.00;
        private readonly DispatcherTimer timer;
        private readonly VerticalIntensityChartCollection<double, double> chart;
        public MainWindow()
        {
            InitializeComponent();

            chart = new VerticalIntensityChartCollection<double, double>(capacity: 400);
            // Initialize chart with data.
            chart.XStart = 750.0;
            //chart.XIncrement = 100.0;
            chart.Append(0, new double[0]);
            // Tell graph about data, and intervals.
            xAxis.MajorDivisions = new RangeLabeledDivisions { Mode = RangeDivisionsMode.CreateIntervalMode(chart.XStart, chart.XIncrement) };
            graph.DefaultVerticalInterval = YIncrement;
            graph.DataSource = chart;
            // Use a timer to update chart data.
            timer = new DispatcherTimer(TimeSpan.FromMilliseconds(200), DispatcherPriority.Normal, OnTimerTick, Dispatcher);
        }
        private void OnTimerTick(object sender, EventArgs e)
        {
            var graphPlotArea = graph.GetPlotAreaSize();
            int length = (int)graphPlotArea.Width;
            double xIncrement = (double)(500.00 / length);
            chart.XIncrement = xIncrement;
            chart.XStart = 750.0;
            graph.DefaultHorizontalInterval = chart.XIncrement;
            // Add a new set of data after the previous point.
            var previous = chart[chart.Count - 1];
            double y = previous.Index + YIncrement;
            double[] z = GenerateData(length); //Enumerable.Repeat(y * 2.0, length).Select((v, i) => v + i).ToArray();
            chart.Append(y,z);
        }

        Random rnd = new Random();
        private double[] GenerateData(int length)
        {
            int newLength = length;

            double[] data = new double[newLength];

            for (int i = 0; i < newLength; i++)
            {
                data[i] = rnd.Next(-125, 0);                     
            }
            return data;
        }
    }
}

 

run visa without .net framework compatibility installed

$
0
0

Hello,

 

In version 17 of NI488, the default installer does not install .net framwork compatibility. In this scenario, i can use NationalInstrument.Visa to communicate with my equipement using GPIB in .net.

 

If i check ".net framework compatibility" what do you install exactly ? Is it a good option to use NationalInstrument.Visa.dll without installing ".net framework compatibility" ? 

 

I am asking this question because a lot of our customer are using NI 488 version 17 and earlier and did not check .net framework compatibility during installation.

I also noticed in version 18, the .net framework compatibility is checked by default and can not be unchecked.

 

 

MCU

$
0
0

Hello ,

I entered to make an automatic test bench of a card, and in the test sequences one makes the download of the program of the MCU that it finds in a file (.hex) towards the card, by using the flash magic software , and in the procedure of my test bench, this phase must be automatic, without the intervention of magic flash software, and this is done automatically in labview test sequences. Is there a VI that allows me to automatically download the program to the MCU? What are the protocols to respect? as well as if there are DLLs or drivers.

Thank you in advance .

Include NI-VISA .NET API in Visual Studio 2017 project

$
0
0

This is a follow-up to the question asked here.  How do I go about including a reference to the NI-VISA .NET API in my Visual Studio 2017 C# project?  My earlier projects have used VisaNS.dll, but I gather from the documentation that this has been deprecated in favour of the .NET API.

 

It would be helpful if someone could go through in detail the steps involved in downloading the new API (if necessary) and adding a reference to it in a C# project.  All the documentation I can find on this site still refers to VisaNS.dll.

Error: "NationalInstruments.AnalogWaveform" is not defined

$
0
0

Dear all,

 

I am migrating a controller compiled in Visual Studio 2012 from Win7 to Win10. Upon recompiling a large list of errors occurs as expected. I updated the drivers and .dll, so there are just two errors remaining which seem to be connected:

 

Type 'NationalInstruments.AnalogWaveform' is not defined

Type 'NationalInstruments.AnalogWaveformSampleCollection' is not defined

 

The current driver is NationalInstruments.DAQmx.

 

I do not know what type of error this could be except some internal labelling within the driver changed when the driver got updated.

 

Any ideas?

 

Thank you in advance,

EmpaMan


scatter graph

$
0
0

hello, i am new and need help with plotting Lissajous curves in scatter graph...

i am not sure if i should use multixyplot or xplot and yplot... if multixyplot, it needs that x should be a matrix... is it based on [t,x]? please any help appreciated... kind regards

led in C#

$
0
0

hello i will turn on and off an led in my C# program... i have used led from meausrement studio... any help appreciated... kind regards

ChartCollection serialization

$
0
0

Hello,

I have my C# class with public properties and I do serialization of the instance of this class to XML file. And I would like to serialize also ChartCollection public property. Is it actually serializable? Or how to do it the best and easiest way?

Thank you for support.

 

Alternative for CurveFit.LinearFit in Winforms C#

$
0
0

Hello team,

 

I am using the Beta version of MS 2019 for VS 2017. Due to the lack of merge module NiAnlys.msm in this beta version. I keep getting DllNotFoundException at the client location for my Visual Studio setup project.

Not quite sure why this merge module is taken off and what is the alternative for this merge module in beta version. Until this issue resolved I would like to know if there is a alternative for the CurveFit.LinvearFit() method in C#

 

Since CurveFit.LinvearFit() is the only method I am making use from the NationalInstruments.Analysis.Math and  as I have the above issue. I am trying to find how can I not use the NationalInstruments.Analysis.Math and still make use of a CurveFit.LinvearFit().

 

NI 9237 programming parameters

$
0
0

I'm programming an application in C# and using Measurement Studio. I was trying to set up an NI 9237 strain gauge bridge module to take some readings, but there are some arguments for which I'm not certain what values to use. Here is the code:

 

myTask.AIChannels.CreateBridgeChannel(channelID, "", minimumRangeValue, maximumRangeValue, AIBridgeUnits.MillivoltsPerVolts, ...

 

Then I get lost because I don't know how to complete the remaining arguments. They are:

Bridge Configuration,

Excitation Source,

VoltageExcitationValue

NomBridgeResistance,

 

The bridge resistance I can get, but can anyone help with the configuration, source, and excitation value? I searched for some time to discover this information, but I have not been successful. Any help would be greatly appreciated.

Thanks so much.

Viewing all 2000 articles
Browse latest View live


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