10-14-2013 11:03 AM
Hi. Im doing a projec with C# and its basicalyy consists of several tasks.. wich i already created each one with different sampling buffers.. some of them voltage , some timer and so on.. The very first task reads at 48khz a stream of 4800 samples and plots it in a wavegrapf.. that runs ok.. the point is.. the next task is the acquisition of one voltage sample at the the same 48khz samling rate an display it in a numericedit control.. when i run the wizard to attach the task to the output it only allows me to choose a wavwformgraph.. i cant see the option to connect these tasks to a numericcontrol with the help of the wizard.. nonetheless i did run some test in another form doing the tasks manually like this ..
namespace MultTaskinDAQ
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void led1_StateChanged(object sender, ActionEventArgs e)
{
Task TvoltTask = new Task();
AIChannel ToolVoltChannel;
ToolVoltChannel =
TvoltTask.AIChannels.CreateVoltageChannel("Dev1/ai1", "ToolVoltChannel", AITerminalConfiguration.Rse, -10, 10, AIVoltageUnits.Volts);
TvoltTask.Timing.ConfigureSampleClock("", 48000, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, 2);
AnalogSingleChannelReader readerTV = new AnalogSingleChannelReader(TvoltTask.Stream);
double[] data = readerTV.ReadMultiSample(2);
double mean = Statistics.Mean(data);
numericEdit1.Value = (mean);
TvoltTask.Dispose();
Task TcurrTask = new Task();
AIChannel ToolCurrChannel;
ToolCurrChannel =
TcurrTask.AIChannels.CreateVoltageChannel("Dev1/ai0", "ToolVoltChannel", AITerminalConfiguration.Rse, -10, 10, AIVoltageUnits.Volts);
TcurrTask.Timing.ConfigureSampleClock("", 48000, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, 1);
AnalogSingleChannelReader readerTc = new AnalogSingleChannelReader(TcurrTask.Stream);
double[] datatc = readerTc.ReadMultiSample(1);
double meantc = Statistics.Mean(datatc);
numericEdit2.Value = (meantc);
TcurrTask.Dispose();
Task TdataTask = new Task();
AIChannel ToolDataChannel;
ToolDataChannel =
TdataTask.AIChannels.CreateVoltageChannel("Dev1/ai0", "ToolDataChannel", AITerminalConfiguration.Rse, -10, 10, AIVoltageUnits.Volts);
TdataTask.Timing.ConfigureSampleClock("", 48000, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, 4800);
AnalogSingleChannelReader readerTd = new AnalogSingleChannelReader(TdataTask.Stream);
double[] datatd = readerTd.ReadMultiSample(4800);
waveformGraph1.PlotY(datatd);
TdataTask.Dispose();
}
}
}
and it works perfect every time i hit the button it performs the three tasks and shows in the nucmeric and in the waveform.. (still must find out how to loop these as fast as possible).. but this code is uneficcietn cause i see theres many things and exception habndling that the wizards generate that im not contemplating here manually..
So i decided to buy the Professional edition as to do every thing trough the wizards.. but i cant see the option to connect differnt tasks to different output controls .. only lets me choose waveformgrapf.. any sugestions?
10-15-2013 05:01 PM
Hi RENATOMUSICA,
If you want to customize the GUI further beyond the DAQ Assistant in Measurement Studio, you will have to modify the C# code and Design.
A simple example of sending the data to a numeric control can be found in the Measurement Studio Examples:
\National Instruments\MStudioVS2012\DotNET\Examples\UI\WindowsForms\NumericEdit\SimpleNumericEdit\cs