Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use more than one task?

Dear all,
 
I am trying to collect data from four(atleast two) different channels at the same time but with different settings. so i designed the program starting with two create virtual channel vis. but the program seems to have problem with start task vi. when i used the program with only one virtual channel vi, i had no problem. does it mean i cant use multiple tasks in the same program? is there any way to get around with it? dev??
 
i attached the program for more clarifications.
 
Many thanks
Rishe.
0 Kudos
Message 1 of 9
(4,407 Views)

Hi all,

this is the continuation of my previous post. i want to know the same thing for output tasks as well. in otherwords, is it possible to send two different signals through one channel? for example, with two create virutal channel vis, can i send AO voltage through one and counter output through another one?

thanks again

Rishe.

0 Kudos
Message 2 of 9
(4,400 Views)
Hi Rishe,
 
I will answer your posts separately. You can only have one analog input task per device at a time. If you want to read from multiple channels on a device with different configurations, you can call the DAQmx Create Virtual Channel several times back to back and build the channels into one task.
--
Michael P
National Instruments
0 Kudos
Message 3 of 9
(4,385 Views)
Rishe,
 
A task can only be of one type (analog input, analog output, counter input, counter output, digital input, digital output). If you want to do counter output and analog output, this requires two different tasks.
--
Michael P
National Instruments
0 Kudos
Message 4 of 9
(4,384 Views)

Hi Michael and all,

Thanks for your kind reply. I understand what you said except how to recall the create channel vi several times. is it should be in a while loop or something? same thing with output as well. i understand that a task could be of only one type. but if i want two different tasks should be done, what i have to do?

I will give an example. one of the main aims of this program is to drive a motor with an analog signal. at the same time, i also want an option of sending a constant voltage (may be in form of a pulse) to the motor so that i can change its initial position. so i was trying to use the counter output option as well. now it becomes two tasks. so how could i do this?

hope i make it clear this time. the attached program may clarify further.

sorry if my question sound obvious but i m using labview only for the past 3-4 months and i dont know much about it.

Thanks a lot.

Rishe.

 

0 Kudos
Message 5 of 9
(4,379 Views)
Hi Rishe,
 
I have attached an example that configures multiple channels on the same device. Take a look at this VI.
 
If you have created a counter output task and an analog input task, then just put them in the same VI! That's all there is to it. You could even take a counter example from the NI Example Finder and copy its block diagram into an analog input example's block diagram.
 
The links in this KnowledgeBase article will also be helpful.
--
Michael P
National Instruments
Message 6 of 9
(4,360 Views)

Hi Michael and all,

Thanks for your response. The example you have given is very helpful. thanks for that. i think i can try the same thing for output tasks as well. i will try with myself first and if i couldnt i will come for your help once again. hope u dont mind. 🙂

thanks again

Rishe.

0 Kudos
Message 7 of 9
(4,343 Views)
Michael,
I think I have a slightly different situation.

I am trying to control the speed of a DC motor using Pulse Width Modulation (PWM). So here there are two tasks that goes one after another cyclically untill the program is stopped.

Task 1. With some user given duty cycle and frequency, produce pulses initially at a counter to fire the the Gate of a MOSFET driver that drives the motor.
Task 2. When the motor starts rotating, get the speed of the motor by using another counter.
            compare the speed of the motor with some set speed and update the duty cycle accordingly and produce the pulses with new duty cycle [Here the control is again going to Task 1 in a cyclic fashion]
1 ->2->1->2 in a cyclic fashion.

so in this case, how do I connect the two taks together?

This is what I tried:
Tried connecting the "error out" of task 2 to "error in" of Task 1.
I get the error that no edges were counted/acquired. Obviously true since the motor will not rotate as the Gate of MOSFET has no pulse width modulated signals to get fired and so the motor wont rotate.

and when I tried connecting the "error out" of Task 1 to "error in" of Task 2. It wont allow me to do that.


[Apart from the above two, I am acquiring voltage signal]

I am using M series, PCI6221 and LabVIEW 8.

Please advise. I also attached a picture





Message Edited by UBAP on 03-02-2007 09:57 AM

Message Edited by UBAP on 03-02-2007 09:59 AM

0 Kudos
Message 8 of 9
(4,036 Views)
Hello UBAP,

For your application, you should be able to run the two tasks in parallel and combine the error clusters outside the while loop. I believe the problem you are having stems from the fact that you have not configured a task for your counter input operation in the bottom half of your diagram. For an example of how to read a digital frequency on a counter I would recommend that you examine the example entitled Meas Dig Frequency-Low Freq 1 Ctr.vi. There is another example that takes an analog voltage input and scales a PWM counter signal according to this input voltage. This example is called PWM-Counter Output.vi and might provide you with a good starting point for your PWM application. Both of these examples can be found by opening the NI Example Finder; you can find this utility in the "Find Examples ..." option of the Help menu in LabVIEW. The counter input example can be found by browsing to Hardware Input and Output>>Counter Measurements>>Digital Frequency and the PWM example can be found by browsing to Hardware Input and Output>>Control. These examples should give you a basis for your programming in LabVIEW. I hope this information is helpful. Let me know if there's anything else I can do to help.

Matt Anderson

Hardware Services Marketing Manager
National Instruments
0 Kudos
Message 9 of 9
(3,992 Views)