Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

C# DaqSystem.Local.LoadTask()

Hello to all.

I use NIDaq with C# without Mesurement Studio.

I created a task in NIMax that commands an output ON when it's OFF; when i run the task from NIMax it works perfectly.
Then i write:

 

NationalInstruments.DAQmx.Task nimaxTask = DaqSystem.Local.LoadTask("NIMaxTask");
DOChannel doChan = nimaxTask.DOChannels[0];
DigitalSingleChannelReader doReader = new DigitalSingleChannelReader(nimaxTask.Stream);
DigitalSingleChannelWriter doWriter = new DigitalSingleChannelWriter(nimaxTask.Stream);
bool value = doReader.ReadSingleSampleSingleLine();

if (value)
   doWriter.WriteSingleSampleSingleLine(autoStart: true, false);
else
   doWriter.WriteSingleSampleSingleLine(autoStart: true, true);

 

But i can't get it to work: the output never goes ON and no error is reported; i checked with debugger and doChan exists and has the correct name, and the line "doWriter.WriteSingleSampleSingleLine(autoStart: true, true);" is executed.

If i create a task with C# code, application works perfectly.

 

I'm also confused about the usage of the DaqSystem.Local.LoadTask():

from what i understand it's possible create a Task in NIMax and then load it with DaqSystem.Local.LoadTask() function;

to execute it, however, it's not enough call task.Start(); but it needs to get the channels and then read and write them as needed.
But then what is the difference with the creation of the Task from C#, avoiding NIMax ?
What is the correct use of DaqSystem.Local.LoadTask() and when should I use it ?

 

Thanks.

0 Kudos
Message 1 of 2
(867 Views)

I made an error  on NIMax task:i leave "Invert" signed. Now i uncheck "Invert" and all works.

 

Howerer, my doubts about using the function remain.

 

Thanks.

 

0 Kudos
Message 2 of 2
(845 Views)