05-21-2019 02:24 AM
Hello All,
i have created a couple of tasks in MAX and i want to load and execute these task in my application C#.
what i can find in the doc is just how to load the task by its name : Task myTask = DaqSystem.Local.LoadTask(TaskName);
now task is loaded, how can i access to every channel and execute the desired channel based on the name ?
Thank you
05-21-2019
05:39 PM
- last edited on
12-19-2024
01:31 PM
by
Content Cleaner
I believe you are looking for the CreateChannel Method:
http://zone.ni.com/reference/en-XX/help/370473J-01/ninetdaqmxfx40ref/html/m_nationalinstruments_daqmx_dichannelcollection_createchannel/
This will allow you to pull in the channels from your task.
05-22-2019 01:52 AM
Your example shows how to create channel.
my request is : i already have defined "task" in MAX and i want to load --> Execute --> get mesurement , independently if they are DI, DO,AO...
For example in the image i attached i want to execute task : 12VLin_HW_1 and the channel sysSpg12V.
so far i found this method that load saved task from MAX but there is no further code examples
DaqSystem.Local.LoadTask(TaskName);
05-23-2019
02:11 PM
- last edited on
12-19-2024
01:31 PM
by
Content Cleaner
I was looking further into your issue and I realized that you are trying to run a specific channel from a task, which you cannot do in C# or LabVIEW. If you want to run those channels separately you need to put them in different tasks. Once the task is loaded all channels that are configured will run. To run the task I recommend referring to the getting started guide here:
Using NI-DAQmx in Text Based Programming Environments
05-24-2019 02:15 AM
Good morning,
so far i succeeded to read a bulk or single Channel from a stored Task AI or DI, here is the example i use :
// Laden die ausgewählte Aufgabe var aiTask = DaqSystem.Local.LoadTask(TaskName); using (aiTask) { // Laden den angegebenen Kanal aiTask.Stream.ChannelsToRead = ChannelName; // Konfigurieren den Reader AnalogSingleChannelReader reader = new AnalogSingleChannelReader(aiTask.Stream); // Verify the Task aiTask.Control(TaskAction.Verify); //Führen den Reader aus return reader.ReadSingleSample(); }
now i want to do the same but this time with outputs. (AO or DO). unfortunatly there is no defined API that let you select the desired AO channel like :
// Laden den angegebenen Kanal aiTask.Stream.ChannelsToRead = ChannelName;
is there any alternative ?
05-28-2019 01:30 PM
I recommend using the DAQmx commands in the link that I sent. That is the recommended method of running tasks made in MAX.
Also, in the future I recommend posting to the Measurement Studio forum for help on this issue. DAQExpress is a different product and it doesn't sound like that's what you're using, you're likely to get more responses in the appropriate forum.
05-29-2019 02:26 AM
Thank you Conner for the support,
even though thats not solving my issue but im satisfied with the support.
Regards.