LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

daqmx create task

Hello all;

 

I have a small issue that i would like to solve if possible.

 

I have created 2 tasks under Max and each one of them has 3 channels.

 

I want to do an adquisition of 4 out of the 6 total channels (continuos say 1000 samples @ 1000 hz) until i decide to stop the adquisition.

 

(what i have done when the number of channels iam trying to acquire from are 2 or less is:

-> if both channels are under the same task then use task property (channels), get the channels of interest and for each channel use the channel property node (activechannel, AI max, AI min, etc) most likely on a for loop, then add the timing function (continuos, 1000hz rate) and then inside the loop (with shift registers on both error and task reference) i would put the read function (voltage, multiple channels, multiple sample, 1d waveform) index the waveform and get the mathematical median of the waveform for each channel, at the outside end of the loop a clear task.

->>> a socond approach to aquire  2 channels under the same task is to wire the task name constant to the start task function and the task reference and error into the loop and again setup the read function the same way as the previous variant and have the clear task outside of the loop.

 

i have noticed tho that even with the median function right before the indicator the value is alot less steady than the first variant.

again all the channels and task have been previously created under max their respective parameters.

 

is this the way to go when aquiring channels under the same task dinamically?

 

-> if both channels are on different stasks i have to connect the both tasks constant one on a different shift register, then inside the loop start one of the task on the read function depending how many channels does that task has index the channel do the mean, then stop the task conect the error out from the stop to a second start task do the same over and over.

this stopping starting tasks i suspect is not the best way to go about it.

 

(the reason why i havent post at least a picture of such setup is because iam at home and my labview lacks the daqmx functions)

 

please advice me if for both cases my approach is a good onbe otherwise advice me into what changes should i make.

 

what about aquiring lets say 5 channels out of the 6 channels dynamically?

iam trying to create a new task (not to be reflected under max temporarily) dynamically and i would like to add all the channels of interest to this new task and inside the loop index my read function and get all the channels values.

and i do nto want the jittering, i want the values to be steady (the process iam trying to meassure i dont think it needs more than 1000 samples/sec at 1000 hz) but since i would be aquiring from say 5 channels i would need to increase those parameters.

 

I would apreaciate any help in this matter.

 

 

0 Kudos
Message 1 of 7
(4,256 Views)

here i'm uploading a vi which has the steps i take a different scenarios

 

 

0 Kudos
Message 2 of 7
(4,233 Views)

Well there is a lot going on there. I guess the first thing I would suggest would be to set up each channel individually. If you are not always going to be using them together than you have to separate them. The way I do this is to set up global channels and when the VI starts or is changed I stop the Daq channels and restart them. You can not tell that this has happened but it runs great.

 

Order od ops:

VI INI (Build channel array)

Start daq

Read from daq

Changes occurs then stop daq

VI INI (Build new channel array)

Start Daq

Read from daq

 

This will mean that you will have to move everything inside of the while loop. To do this I would use a state machine system to handle the stopping and starting of the daq system.

Tim
GHSP
0 Kudos
Message 3 of 7
(4,230 Views)

first of all thanks for attempt to answer my question.

 

i chose to group the tasks by the type of process i was going to be acquiring (position, pressure etc)

and insode those tasks i chose to group the channels each representing a given sensor of the given type of process.

 

i will not necessary acquire from all the channels of a given task, on the other hand, the acquisition will vary by unit

ex: unit one might need to meassure only the pressure process (sensor_1 0-100 psi and sensor_2 0-500 psi)

unit_2 might need three different processes, pressure (sensor_1, position sensor_1, acceleration sensor_3)

 

if indeed i must have all the channels together under a task or separate on their own (with their own task) i could do either of this

for case1 have 1 task common to all channels

case 2  have n tasks with 1 channel each separating each channel

 

(the type of process that will be used is chosen by the user before the acquisition so i end up with a array of clusters of each clusters composed by(task name, channel name, physical channel of every process the user decides to meassure.

 

i have two modes, one mode is a xy graph of two equal or different processes (which only has 2 channels involved at the same time)

the other mode is a process vs time  which can have up to 6 different channels of different or same process.

 

the part that i bothering me is the adquisition part (i believe i havebeen successfull on the xy mode) but once i try to acquire from more than two channels from different processes (or tasks) i get errors.

 

you stated: "The way I do this is to set up global channels and when the VI starts or is changed I stop the Daq channels and restart them"

how do you do this part? is it similar to what i have done?

am i using the wrong daqmx function of the wrong order?

 

thanks again for your help

0 Kudos
Message 4 of 7
(4,224 Views)

@caluctra wrote:

first of all thanks for attempt to answer my question.

 

i chose to group the tasks by the type of process i was going to be acquiring (position, pressure etc)

and insode those tasks i chose to group the channels each representing a given sensor of the given type of process.

 

i will not necessary acquire from all the channels of a given task, on the other hand, the acquisition will vary by unit

ex: unit one might need to meassure only the pressure process (sensor_1 0-100 psi and sensor_2 0-500 psi)

unit_2 might need three different processes, pressure (sensor_1, position sensor_1, acceleration sensor_3)

 

if indeed i must have all the channels together under a task or separate on their own (with their own task) i could do either of this

for case1 have 1 task common to all channels

case 2  have n tasks with 1 channel each separating each channel

 

(the type of process that will be used is chosen by the user before the acquisition so i end up with a array of clusters of each clusters composed by(task name, channel name, physical channel of every process the user decides to meassure.

 

i have two modes, one mode is a xy graph of two equal or different processes (which only has 2 channels involved at the same time)

the other mode is a process vs time  which can have up to 6 different channels of different or same process.

 

the part that i bothering me is the adquisition part (i believe i havebeen successfull on the xy mode) but once i try to acquire from more than two channels from different processes (or tasks) i get errors.

 

you stated: "The way I do this is to set up global channels and when the VI starts or is changed I stop the Daq channels and restart them"

how do you do this part? is it similar to what i have done?

am i using the wrong daqmx function of the wrong order?

 

thanks again for your help




You can set up Global virtual channels in DaqMX or in your code. If you look up examples you should be able to find them. You do not need to set the acquisition to continuous. Yo uneed to get a property node and read the data that is a valiable. Set the sample clock to finite sample and then you just need to read what is in the buffer. The Daq assistant will not give you a very big buffer so you may need to set a larger buffer as part of the start.

Tim
GHSP
0 Kudos
Message 5 of 7
(4,221 Views)

ok, i went ahead and change all the channels to globals, and deleted all the tasks i had.

 

iam attempting to acquire from three channels (now global)

i have been succesfull in adquiring from the three channels at the same time but the acquisition is not as smooth as i would like it to be.

i believe iam missing something.

please take a look at the vi iam attaching, which has comments in it.

 

thanks again

 

0 Kudos
Message 6 of 7
(4,206 Views)

Look at what I did> Is is so much easier than what you are making it.

Tim
GHSP
0 Kudos
Message 7 of 7
(4,193 Views)