LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

New problem: How can I use DAQmx timing in the loop instead of "wait" vi?

Solved!
Go to solution

Dear NI family,

 

Hi there!

 

1. How can I use DAQmx timing in the loop instead of "wait" vi?

 

I hope to use the function of DAQmx Timing, such as setting timing sources, changing duty cycle of timing, setting rate and samples per channel.

 

2. When I click the button "STOP", there always will be LEDs turned on, what should I do to shut all the leds down when I click the STOP button?

 

Could you please show me how to fix the problems? The code is in the attachment.

 

Thanks a lot!

 

Best,

Jason

0 Kudos
Message 1 of 18
(3,637 Views)

Dear ALL,

 

I am new with LabVIEW.

 

May I ask about the duty cycle of vi "wait" in LabVIEW? Is it 50%?

 

Thanks a lot!

 

Best,

 

Jason

0 Kudos
Message 2 of 18
(3,626 Views)

I assume you are referring to the node "Wait (ms)"? Its a node that doesn't return until the specified time has expired. In milliseconds. Fairly equivalent to, say "Sleep()" in Win32 threading models. A basic description is here: http://www.ni.com/white-paper/7592/en/ along with a counterpart that waits for a multiple increment of ms. I'm not sure what you mean by duty cycle in this context, perhaps you can explain further. 

Message 3 of 18
(3,622 Views)

1). "Wait" is a node that doesn't return until the specified time has expired. In milliseconds. Fairly equivalent to, say "Sleep()" in Win32 threading models. A basic description is here: http://www.ni.com/white-paper/7592/en/ along with a counterpart that waits for a multiple increment of ms.

On the other hand DAQMX Timing vi configures the number of samples to acquire or generate and creates a buffer when needed.

The instances of this polymorphic VI correspond to the type of timing to use for the task.

The DAQmx Timing properties include all timing options included and additional timing options.

 

2). Can you be specific which LEDs are you referring to?


CLD Using LabVIEW since 2013
0 Kudos
Message 4 of 18
(3,617 Views)
Solution
Accepted by leo321

I really recommend you to use the built-in help, which will give you info about the different functions. See that small question mark at the top right of the front panel/ block diagram windows? If you turn it on, when you hover your mouse over certain functions, you get a brief description. Inside this Context Help window, usually you can also click on a "Detailed Help" link, which will open up a more detailed help doc!

Also, read through the DAQmx docs, like this: http://www.ni.com/product-documentation/2835/en/#toc3

(do not spend time with the DAQ Assistant, you can do everything with the low level functions you need).

 

Here I show a snippet which should get you started. Note, that you actual requirements should decide what kind of parameters you must use, like for sampling rate, samples per channel, line grouping, etc! Check the documentation how to use line grouping, and that Boolean 2D array should match with the DAQmx Write mode too (actually what are you trying to do with these Booleans? Can you detail your task?).

The usual way when you deal with DAQmx tasks is that, you initialize your Task, set up timing, start task, and now you enter only the While loop! It does not make sense and wrong way to reinit at every iteration! After the while loop stopped (due to an error or the user, see that Boolean OR function?), you can stop and clear the Task, then report any error if happened...

 

scan1a-control decoder-2.png

 

 

 

0 Kudos
Message 5 of 18
(3,609 Views)

Hi leo,

 

2. When I click the button "STOP", there always will be LEDs turned on, what should I do to shut all the leds down when I click the STOP button?

Why do you create a new thread for the very same problem - you already got answers on that!

 

changing duty cycle of timing

Please explain that term!

And please STOP asking the same questions in several places! (I merged the threads…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 18
(3,602 Views)

Hi kartiknattar,

 

Thanks for your reply!

 

The code in the attachment will show you that when clicking the STOP button, there will always be a random led on. So I am just wondering how to turn all the leds off when pushing the STOP button.

 

Thanks.

 

Best,

Jason

0 Kudos
Message 7 of 18
(3,539 Views)

Hi GerdW,

 

Thanks very much for your reply!

 

The duty cycle means how much percentage between on and off when we put a "wait" button in a loop.

For example, if we set 500ms as a constant for a "wait" vi, will there be only 250ms the led is on?(If so, the duty cycle is 50%.)

 

Thanks for your reminding! I just hope to get straightforward answer for the questions.

 

Best,

 

Jason

0 Kudos
Message 8 of 18
(3,538 Views)
Solution
Accepted by leo321

Hi leo,

 

The duty cycle means how much percentage between on and off when we put a "wait" button in a loop.

No, completely wrong expectation on your side!

The wait function will have the loop wait for (atleast) the amount of time you tell it to wait. What you do inside the loop in parallel to the wait function is up to you!

 

if we set 500ms as a constant for a "wait" vi, will there be only 250ms the led is on?(If so, the duty cycle is 50%.)

No! (Completely wrong expectation!)

To reach your goal you could set a wait of 250ms and switch the LED in each iteration…

 

A "wait ms" function does exactly what its name implies: it waits for a certain amount of ms. Nothing more, nothing less.

 

The code in the attachment will show you that when clicking the STOP button, there will always be a random led on. So I am just wondering how to turn all the leds off when pushing the STOP button.

As has been said before: you need to switch off the LEDs right after the loop.

THINK DATAFLOW!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 18
(3,535 Views)

Hi Blokk,

 

Thank you very much! I learn a lot from your reply!

 

I am trying to use these Booleans as switches and also trying to output digital data with a matrix in the other part. So for the two parts of digital output, I am not sure how to hardware timed control by the DAQ. The HW timed control should be synchronized and the high time of the Booleans should be shorter than the other part and be contained.

 

Could you please show me how to do it?

 

Thanks a lot for your snippet! That's very helpful!

 

Best,

Jason

 

 

0 Kudos
Message 10 of 18
(3,488 Views)