LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DaqMX turn off equipment whilst sampling

That's great news 🙂 I'm glad it's finally working for you.

 

You can't determine when the "off" command will happen as this depends on when your processor schedules your thread. Essentially when you split the error wire, LabVIEW creates two threads to manage the task. It is then your processor that decides when to run these tasks.

 

It seems like you've already increased how many samples you read. Another possibility is to increase your sampling rate. Basically you will have to play with the numbers for your sampling rate and samples to read until you find the right combination. 

 

Regards, 

Mahdieh G
Applications Engineer
National Instruments UK&Ireland
0 Kudos
Message 31 of 41
(1,678 Views)

Now that i've put it into my main vi, it isn't working.

 

It comes up with a DAQmx error, see attached.

 

Thanks.

 

 

0 Kudos
Message 32 of 41
(1,663 Views)

Here are a couple of reasons why you would get that error: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000P8kmSAC&l=en-US

 

Based on your code and this document you will need to figure out which reason is causing the error.

 

You may need to set up and clear your task outside of your loop (potentially main loop).

 

Let me know how you get on.

Mahdieh G
Applications Engineer
National Instruments UK&Ireland
0 Kudos
Message 33 of 41
(1,653 Views)

Ok, i've moved the setup and clear parts outside of the main loop, in order to refer to the connection in the subVI i have had to add a name to the create virtual connection box,

 

This happens before my main loop:

 

start.jpg

 

Then in a sub VI in a case structure in my main loop:

 

do.jpg

 

If i just run this it says: daqmx error the value passed to channels "Int" is invalid, this must be a valid channel or virtual task.

 

If i create a task called Int in automation explorer then it says "Int" is reserved.

0 Kudos
Message 34 of 41
(1,639 Views)

There is no need to wire in your task ("int") to the Create Virtual Channel VI and your DAQmx Timing. Just wire them up exactly as before. Move your Create Virtual Channel VI outside of your loop.

Mahdieh G
Applications Engineer
National Instruments UK&Ireland
0 Kudos
Message 35 of 41
(1,617 Views)

I came across the attached picture today, thought you might find it useful too.

Hope it helps

Mahdieh G
Applications Engineer
National Instruments UK&Ireland
0 Kudos
Message 36 of 41
(1,610 Views)

Hi,

     the first image (where i create the virtual channel) is outside the main loop.

 

With regard to teh "Int" name i have tried it with and without,  with it it says DAQmx error "the resource int is reserved" without it it says "the resource unnabed channel(1) is reserved"

 

Cheers, Zac

0 Kudos
Message 37 of 41
(1,590 Views)

- are you using channel 1 anywhere else in your code?

- do you have any other DAQmx sessions open in your code?

- are you closing down your communication channels with channel 1 properly?

- have you tried deleting the task int? (keep a back up of the settings before you do)

Mahdieh G
Applications Engineer
National Instruments UK&Ireland
0 Kudos
Message 38 of 41
(1,585 Views)

 are you using channel 1 anywhere else in your code?

 

        The virtual channel name that is created is not used elsewhere.

        There was another task that refered to the same input pin but i removed it during de-bugging.

 

- do you have any other DAQmx sessions open in your code?

         Yes, the following read occured 1 per second (or longer if user spesifies):

 

Untitled.jpg

 

- are you closing down your communication channels with channel 1 properly?

             i clear the task on program exit.

- have you tried deleting the task int? (keep a back up of the settings before you do)

            Yes, if i dont use a named task but instead rely on it to creat a virtual task it comes back with the same error just saying "daqmq error the resource "unnamed channel" is reserved instead of saying "int" is reserved.

 

 

Thanks, Zac

0 Kudos
Message 39 of 41
(1,580 Views)

Did you see the DAQmx programming picture that I sent you? Everything before the start task should be outside of your loop. Can you make this adjustment and send me a picture of it.

 

Can you also try techniques such as rebooting your pc or disconnecting the devices and reconnecting them again.

 

We know that particualr piece of code works so it's now just a case of integrating it within your project. Again it is good to run the code in highlight mode to see exactly what is causing the error.  At the moment is the error occuring at the Create Virtual Channel vi? 

Mahdieh G
Applications Engineer
National Instruments UK&Ireland
0 Kudos
Message 40 of 41
(1,573 Views)