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

Measurement Studio for C# language

$
0
0
Recentely, I am trying to edit C# language to control the National Instruments Cards in computer, did any one has data about it? Any help will be appreciated.

WPF Custom Axes labels

$
0
0

Hi,

I would like to have the HorizontalScale of an IntensityGraph labeled in units of π (Pi). I found much about the LabelFormat (which i reckon is only available in WinForms), where I could just set the custom numeric format string to something like ("#.## π") and scale my horizontal values to 2 (from 2*Pi), but I could not find this in WPF. It would also be nice to have it like 1/2π or π/2 and not 0.5π.

Can anybody help me?
Thanks

Phasor Diagram with .NET Graph Controls

$
0
0

I would like to have something similar to the phasor diagram shipped with Electrical Power Controls and I wonder if anyone was able to do the phasor diagram with .NET graph controls? NI has not shipped a built-in phasor diagram control but I guess someone with strong knowledge of measurement studio may be able to create have something with .NET graph controls.

 

vector_diagram.gif

NI VISA process command simultaneously

$
0
0

HI,

I'm using VB.net and messagebase of NI VISA v14 for instrument communication. I found that NI VISA is not processing command simultaneously. It is queuing all the command I send and process one by one.

May I know is there a way I can do to let NI VISA process the command I send simultaneously?

Thanks.

WPF Graph - AxisDateTime with AbsoluteTimeStamp

$
0
0

Hello,

 

I am trying to plot a few Observable Collection to Graph with AxisDateTime.

 

Graph:

<ni:Graph x:Name="Graphs_HPT_Temperature" PreferIndexData="False" RenderMode="Raster" Margin="10,10,10,10" Interactions=""><ni:Graph.Axes><ni:AxisDateTime Location="Near" Label="Time (s)" Orientation="Horizontal"><ni:AxisDateTime.MajorDivisions><ni:RangeLabeledDivisions TickMark="Rectangle"/></ni:AxisDateTime.MajorDivisions></ni:AxisDateTime><ni:AxisDouble Label="Temperature (°C)" Orientation="Vertical" Range="0, 100, System.Double"/></ni:Graph.Axes><ni:Graph.Plots><ni:Plot Label="Temp 1"><ni:PlotRendererGroup><ni:LinePlotRenderer Stroke="IndianRed"/><ni:PointPlotRenderer Stroke="Black" Fill="IndianRed"/></ni:PlotRendererGroup></ni:Plot><ni:Plot Label="Temp 2"><ni:PlotRendererGroup><ni:LinePlotRenderer Stroke="DimGray" /><ni:PointPlotRenderer Stroke="Black" Fill="DimGray"/></ni:PlotRendererGroup></ni:Plot><ni:Plot Label="Temp 3"><ni:PlotRendererGroup><ni:LinePlotRenderer Stroke="Blue" /><ni:PointPlotRenderer Stroke="Blue" Fill="LimeGreen"/></ni:PlotRendererGroup></ni:Plot></ni:Graph.Plots></ni:Graph>

I am defining source of data like this (all three data sources - randValues, randValues2 and randValues3 - are ObservableCollection<double> :

Graphs_HPT_Temperature.Data[0] = randValues;
Graphs_HPT_Temperature.Data[1] = randValues2;
Graphs_HPT_Temperature.Data[2] = randValues3;

ObservableCollections are filled with data every second. The following picture describes my problem, when I am using AxisDateTime, the showing date is relative (starting from 1.1.0001) and not absolute. How can I get the absolute date (timestamp) on my AxisDateTime?

ni_picture.PNG

I know I can use Waveform structure for these, but when the ObservableCollection contains more than 1000 samples, I need to delete first sample of the collection. Unfortunately, Waveform contains only Append function.

 

Thanks for your answer.

LicenseException when using NationalInstruments.Analysis

$
0
0

Hi Sir :

We have purchased Measurement Studio 2013 standard edition.

My OS is win 7 64 bits.

When I use the function of NationalInstruments.Analysis, I get a LicenseException error likes attached file.

Could you tell me how to solve this problem?

Is it the version of Measurement Studio 2013 issue?

Or, I need to buy or install some kind of controls and I could solve this problem.

Please give me your suggestion!

 

Best regards,

Marcus 

quard encoder for servo

$
0
0

Hey, 

I have to make an encoder reader using ni daq card , in c# , my task is to read the pulses from encoder of servo drive and send the position according . I am listing my task in sequence for more clarification and also attaching the sample  picture .

 

encoder.PNG

 

1)    first i have to detect both  pulse A and Pulse b

2)  I have to compare them to see either its clockwise or anti clockwise.

3)  I have to update the counter after ever rising edge of pulse A

please help to start with it .               

 

 

Measurement Studio VS. NI-DAQmx API

$
0
0

Which should I use for my VB.NET GUI to manage our NI USB-6343 DAQ?

Our GUI uses the DAQ to control LED voltage and read photo diode, and then draw chart based on A2D from photo diode.

 

Should I use Measurement Studio to interface and manage the 6343, or use NI-DAQmx ?


Cursor display and events

$
0
0

Hi all,

 

I have a cursor implemented like the example from phansen (SqlDataExample.zip), but I don't seem to have quite understood, what exactly is happening there at some points. As recommended, I use an ObservableCollection of DataPoints[] as DataSource of my Graph, which are implemented as follows:

namespace HansDataAnalyzer {

    [DataTypeDescriptor( typeof( DataPointDescriptor ) )]
    public struct DataPoint {
        public const int PropertyCount = 3; // ID, tan_delta, U_rms

        public int ID { get; set; }
        public double U_scaled { get; set; }
        public double tan_delta { get; set; }

        public DataPoint(MeasurementValue value, double dividerFactor)
            : this()
        {
            this.ID = value.ID;
            this.U_scaled = value.U_rms * dividerFactor / 1000;
            //Anzeige in *10^(-3);    
            this.tan_delta = value.tan_delta * 1000;
        }
    }

    public struct DataPointDescriptor : IOpMultiDimensional<DataPoint> {
        private static readonly ReadOnlyCollection<Type> _dimensionDataTypes = new ReadOnlyCollection<Type>( Enumerable.Repeat( typeof( double ), DataPoint.PropertyCount ).ToArray( ) );

        public ReadOnlyCollection<Type> GetDimensionDataTypes( DataPoint value, Trait decomposeOption ) {
            throw new NotImplementedException( );
        }

        public DataPoint GetDefaultValue( ) {
            return default( DataPoint );
        }

        public IList<IBuffer> DecomposeValues( Buffer<DataPoint> values, Trait decomposeOption ) {
            int size = values.Size;
            double[] U_scaled = new double[size];
            double[] tan_delta = new double[size];
            int[] ID = new int[size];

            for( int i = 0; i < size; ++i ) {
                DataPoint value = values[i];
                U_scaled[i] = value.U_scaled;
                tan_delta[i] = value.tan_delta;
                ID[i] = value.ID;
            }

            return new IBuffer[]
            {
                // Dimensions rendered by graph are listed first.                               
                BufferPool.Default.GetBuffer(U_scaled, Unit.None),
                BufferPool.Default.GetBuffer(tan_delta, Unit.None),
                // Other values are saved by graph, and displayed by cursor.
                BufferPool.Default.GetBuffer(ID, Unit.None)
            };
        }

        public Buffer<DataPoint> ComposeValues( IList<IBuffer> dimensionValues, Trait composeOption ) {
            throw new NotSupportedException( );
        }
    }
}

(Btw: Where does the Graph "know" from, which values of a DataPoint are plotted? As from the comment above (Dimensions rendered by graph are listed first) it seems clear, but if I maybe want to save more data in one point without displaying it in the cursor this will not work (Deleting the line "BufferPool.Default.GetBuffer(ID, Unit.None)" leads to plots where tan delta is plotted over ID but shown as U_scaled...))

 

The cursor with the XAML code:

 

<ni:Cursor Name="tandCursor" PositionChanged="tandCursor_PositionChanged">
    <ni:Cursor.ValuePresenter>
        <local:CustomValueFormatterGroup>
            <ni:ValueFormatterGroup Separator="&#x0A;">
                <ni:GeneralValueFormatter Format="U_scaled={0:0.00} [kV]" />
                <ni:GeneralValueFormatter Format="tan delta={0:0.00} [10⁻³]" />
                <ni:GeneralValueFormatter Format="ID: {0}" />
            </ni:ValueFormatterGroup>
        </local:CustomValueFormatterGroup>
    </ni:Cursor.ValuePresenter>
</ni:Cursor>

And the according implementation of the CustomValueFormatterGroup:

namespace HansDataAnalyzer
{
    [ContentProperty( "Group" )]
    public class CustomValueFormatterGroup : ValuePresenter {
        public ValueFormatterGroup Group { get; set; }

        protected override UIElement VisualizeCore<TData>( TData value, ValuePresenterArgs args, UIElement existingVisual ) {
            var element = (TextBlock)Group.Visualize<TData>( value, args, existingVisual );
            // Align numeric values on the right side of the cursor's value label.
            element.TextAlignment = TextAlignment.Right;

            return element;
        }

        protected override Freezable CreateInstanceCore( ) {
            return new CustomValueFormatterGroup( );
        }
    }
}

Every time the cursor is moved, I need to do some stuff with the ID "saved" in the according datapoint (Get the whole line out of a database with this ID and plot some data from there). My problem is: I don't know how I can access the "actual" datapoint from within my main window via e.g. the PositionChanged event, nor can I access any method of my window, when the CustomValueFormatterGroup is updated (?) via the VisualizeCore call.
(I can get the ID by splitting element.Text, but I do not understand, how I could pass this on to my main programme). I hope you can understand what I mean...

 

Any advice would be welcome, thanks!

 

DAQmx.2013.msm requires MStudioCommon.2013,msm which can't be found

$
0
0

There have been previous posts regarding compatibility between and packaging of NationalInstrument.Common .20xx files and DAQmx. Those do not apply in this case. I am using MeasurementStudio 2015 for VS2013 and DAQmx 16.1.

 

Using the MStudio Installer Builder, I am trying to make a distribution package that includes the required msm files. When I include the MStudioDAQmx.2013.msm module, I get a dependency error saying it needs Module_Id_Common_2013 - which presumably would be satisfied by MStudioCommon.2013,msm. However, that file is not in Program FIles (x86)\CommonFiles\MergeModules. Only the 2012 and 2013 versions are there. The 2013 dll is installed because I can build my application and run it.

 

Further investigation shows that there are two Dev installer packages for Common - one is version 450 (for 2012?) and one is 451 (for 2013?). However, there is only one Runtime installer package - for 450 - that contains 2012 and 2010 msm files.

 

Is there a 451 (2013) Runtime package for the Common library available for download somewhere?

 

Accessing Unprocessed Point Information in Plot Renderer

$
0
0

I have been writing a program that plots points to a Writable Graph. I am working to overload the Plot Renderer so that I can customize how each point is represented on the graph. I wrote a custom point class that stores an (x, y) coordinate position, a Color, and eventually more attributes. I extended the DataTypeDescriptor class so that the point attributes could be stored in their respective buffers, specifically in the method titled: public IList<IBuffer> DecomposeValues(Buffer<PeakPoint> values, Trait decomposeOption). Now, when I am working in the Plot Renderer class, I want to access the attributes of each point.

 

In the method: RenderGraphCore(PlotRenderArgs renderArgs), I see that renderArgs.RelativeData[0] and renderArgs.RelativeData[1] accesses the processed x and y coordinates (the points are scaled to fit in an area with 0-1 being the range for both the x and y axes). My question is: how do I access the unprocessed point information (ie. the Color and other attributes that I will eventually store in the point class)?

 

Thanks

Calling RenderGraphCore using a Custom DataProcessor

$
0
0

What calls the RenderGraphCore method in the PlotRenderer class?

Does it get called from the DataProcessor; because while implementing a custom DataProcessor class, the RenderGraphCore is not being called. If it is, how can I access plot specific information to pass in through the PlotRenderArgs such as the Plot or the RenderTarget.

 

Thanks

How to get the values which MultiPlotCursor is currently displayed?

$
0
0

How can I get the current valus for processing.

.pic.png

Thanks!

Task cannot be disposed after setting timeout=-1

$
0
0

Hello, I've written a windows service for change detection using DaqMx 17.0. To avoid throwing timeout exception on BeginReadSingleSampleMultiLine method, I did this at the Task initialization:

 

myTask.Stream.Timeout = -1; // To avoid unnecessary exception

When I try to stop my service, here comes the problem: the codes were simply blocked on the Dispose method causing the service not able to stop correctly.

 

 

        public void Dispose()
        {
            runningTask = null;
            myDigitalReader = null;
            myTask?.Dispose();       // It blocks here
        }

I tried:

 

 

        public void Dispose()
        {
            runningTask = null;
            myDigitalReader = null;
            myTask?.Stream.Timeout=1;
            myTask?.Dispose();      //still blocks 
        }

but no difference.  Without the timeout setting, everything works fine. It looks like once the task start, it cannot be stopped or disposed. The program runs under a .NET 4.6 windows service (Windows 10).Can anyone help?

 

Unregister LeftCntrl and LeftShift keys from Panning and Zooming to None

$
0
0

Hi,

 

I want to use the LeftCntrl and LeftShift keys for my own functions in the PlotArea, but it seems as though the default is set to using them to pan and zoom. Is there any way to change the default interaction for these keys?

 

Thanks


Need Timestamp from AnalogWaveform

$
0
0

Hi,

 I'm using Visual Studio 2015 and Measurement Studio 2015. I'm having problems when using the WaveformAttributeMode on a Stream so that I can read the time samples along with the data. When the program gets to the line below, I get the error "Requested value is not a supported value for this property. The property value may be invalid because it conflicts with another property"

 

myTask.Stream.WaveformAttributeMode = WaveformAttributeModes.Timing

 

I am using VB.Net for this program. The full error is attached. All of the code is taken from a NI example (ContAcqVoltageSamples_IntClk.2013) besides this line. I couldn't find any examples using VB.Net that had time sampling with the data. Any help would be appreciated.

Thanks

Cursor Snapmode Problem

$
0
0

Hi,

I made a simple WaveformGraph and set cursor SnapMode as ToPlot.

My problem is the graph plot cursor along mouse y position (not x position).

For example, at following capture image, I placed mouse near (200,11) position, but snapped cursor placed near (40, 11), which I expect cursor to snapped near (200, 9).

How can I make cursor snapped along mouse x position ?

 

Regards,

Stellar

How to check if reference trigger stopped acquisition? IsDone always false.

$
0
0

Hi, I have a problem in a setup using both the start trigger and reference trigger to start and stop the data acquisition using a hardware signal. Basically my setup is working in that my signal is sampled from the start trigger until the reference trigger, however I now only know that because after the reference trigger no more samples are available. I would like to check if the reference trigger has occurred to close my acquisition screen, and I thought I could do that using the IsDone property of the task. However, IsDone is always false.

 

 

My source looks like this:

 

myTask.AIChannels.CreateVoltageChannel(channelName, "", AITerminalConfiguration.Rse, -5, 5, AIVoltageUnits.Volts);
myTask.Timing.ConfigureSampleClock("", config.SampleRate, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, samplesPerChannel);
var srcTriggerLine = $"/{mxDevice.DeviceID}/PFI0";
myTask.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger(srcTriggerLine, DigitalEdgeStartTriggerEdge.Rising);
myTask.Triggers.ReferenceTrigger.ConfigureDigitalEdgeTrigger(srcTriggerLine, DigitalEdgeReferenceTriggerEdge.Falling, samplesPerChannel);

myTask.Stream.ReadRelativeTo = ReadRelativeTo.CurrentReadPosition;
myTask.Stream.ReadOverwriteMode = ReadOverwriteMode.DoNotOverwriteUnreadSamples;


_reader = new AnalogUnscaledReader(myTask.Stream);
_reader.SynchronizeCallbacks = false;

myTask.Start();
while (!(myTask.IsDone && samplesAvailable == 0)) {    samplesAvailable = (int)myTask.Stream.AvailableSamplesPerChannel;    _data = _reader.ReadInt16(samplesAvailable);
}

First I used the asynchronous method for data acquisition and got a time out exception (as expected), but I changed it to this because I thought I would be better able to handle the stop trigger. Using the asynchronous method I also didn't get an IsDone event. The device I am using is the USB-6211.

 

I could use the time out exception using asynchronous method, or check if availableSamples becomes zero but it I would prefer some way of directly checking if the reference trigger stopped the acquisition since there might be other reasons for samples to be collected (ie an acquisition problem).

TDMS Error - "Type initializer for 'NationalInstruments.Tdms.Internal.e' threw an exception"

$
0
0

Hello all,

 

I've been fighting with Measurement Studio to deploy to a secondary laptop.  It's a simple datalogging application, written in C#, that takes in data from an NI DAQ box and graphs it and logs it to a TDMS file.

 

It's working great on my development computer (measurement studio installed), but when I try to run it on my other laptop (measurement studio not installed), it spits out this exception:

System.TypeInitializationException: The type initializer for 'NationalInstruments.Tdms.Internal.e' threw an exception. ---> System.EntryPointNotFoundException: Unable to find an entry point named 'TDMS_GetLibraryVersion' in DLL 'cvitdms.dll'.
at NationalInstruments.Tdms.Internal.e.TDMS_GetLibraryVersion(UInt32& A_0, UInt32& A_1, UInt32& A_2, UInt32& A_3)
at NationalInstruments.Tdms.Internal.e.a()
at NationalInstruments.Tdms.Internal.e..cctor()
--- End of inner exception stack trace ---
at NationalInstruments.Tdms.Internal.e.TDMS_CreateFileEx(String A_0, TdmsFileFormat A_1, TdmsByteOrder A_2, UInt32 A_3, String A_4, String A_5, String A_6, String A_7, i& A_8)
at NationalInstruments.Tdms.Internal.g.a(String A_0, TdmsFileOptions A_1, String A_2, String A_3, String A_4, String A_5)
at NationalInstruments.Tdms.TdmsFile.a(TdmsFileOptions A_0)
at NationalInstruments.Tdms.TdmsFile..ctor(String path, TdmsFileOptions fileOptions)
at CA02_DAQ_Program.Form1..ctor() in t:\JKelly\CA02 DAQ\CA02 DAQ Program\CA02 DAQ Program\Form1.cs:line 78
at CA02_DAQ_Program.Program.Main() in t:\JKelly\CA02 DAQ\CA02 DAQ Program\CA02 DAQ Program\Program.cs:line 23

I'm creating a few AIVoltageTasks inside the code as well.  When I comment out all of the TDMS code (creating the file, writing to it, etc.), everything works great.  I've tried using the Measurement Studio Installer Builder, but that didn't seem to work either.  I've looked into the merge modules needed, and I tried copying them into the client's laptop's directories, but that didn't work either.

 

What is the proper way to deploy a Measurement Studio application to a laptop that doesn't have it installed?

 

Thanks,

Joe

 

Unexpected behaviour of analogue reference trigger

$
0
0

Hi all.

I have the task that acquires data with analogue reference trigger. The task looks something like this:

task = new Task("");

task.AIChannels.CreateVoltageChannel(
                        SensorPin,
                        SensorName,
                        AITerminalConfiguration.Differential,
                        -10,
                        10,
                        AIVoltageUnits.Volts);
task.Timing.ConfigureSampleClock("", 100000, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, 50000);
task.Triggers.ReferenceTrigger.ConfigureAnalogEdgeTrigger( SensorName, AnalogEdgeReferenceTriggerSlope.Rising, 0.2, 10000);

Input signal have the following form:

signal.png

where

red line - trigger level (0.2),

green line - 10000 samples as presented in trigger configuration.

 

The problem is that this task works perfect when the preTriggeredSamples is about 10000 or less. But when I increase preTriggeredSamples value, the first signal's peak is missed and the second peak is triggered.

Notice that the task starts ealier and there are enough time to fill the pretriggered buffer.

 I have tried to change the buffer size - result is the same.

 

But after that I recreated this task with NI MAX:nimax_1.pngnimax_2.png

 

The task works prefectly with any value of pretriggered samples.

 

I have no idea what I am doing wrong.

Could you help me?

Thank you.

Viewing all 1999 articles
Browse latest View live


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