LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How many methods are there to add hardware timed timing control to the DAQ and outside circuit?

Solved!
Go to solution
Highlighted

Hi there!

 

I am about to add hardware timed timing control to my DAQ and outside circuit to substitute the "WAIT" vi. I haven't found a suitable method to achieve the goal.

So may I ask how many common methods are there to add hardware timed timing control to the DAQ and outside circuit? 

(M series DAQ and LabVIEW 2016)

 

Thanks a lot!

 

Best,

Jason

0 Kudos
Message 1 of 9
(1,090 Views)
Highlighted

Hi leo,

 

DAQmx allows to set the timing of a task using the DAQmxTiming function.

Haven't we diuscussed this before in your other thread(s)?

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
Message 2 of 9
(1,088 Views)
Highlighted

Hi GerdW,

 

Thanks for your reply!

I try to use the onboard timing but labview returns can't find it on PCI6221.

So I set a counter as the source of DAQmxTiming and set the values the same as 'wait', but it won't work like 'WAIT' vi.

So I am not sure how to fix the problem. Are there any snippets or examples to deal with the problems?

 

Thanks!

 

Best,

Jason

0 Kudos
Message 3 of 9
(1,082 Views)
Highlighted

Can you upload the code you have with a comment indicating where you want to Wait?

Some additional information about what you're trying to do and why Wait is unsuitable might be helpful.


GCentral
0 Kudos
Message 4 of 9
(1,059 Views)
Highlighted

Hi cbutcher,

 

Thanks for your reply!

 

I just want to know how to use a DAQmxTiming function to achieve the same function like the WAIT vi in the follow snippet.

 

Thanks!

 

Best,

 

Jason

 

ex1.jpg

0 Kudos
Message 5 of 9
(1,056 Views)
Highlighted
Solution
Accepted by topic author leo321

Aha! Much easier to help now.

 

I'm not sure if you and GerdW have already discussed this, but I'll try and recap the key points. I'm going to discuss both Reading and Writing, even though your question is about Writing samples (I hope you don't mind!):

  • General:
    • The DAQmx Timing node sets up the timing instructions for a task.
    • When you don't use the DAQmx Timing node, you read/write samples when you use the Read/Write node - this is "On-Demand" sampling.
    • If you use the Timing node, then samples are acquired/generated according to the Start node and the timing you specify.
    • If you want to run continuously, set the mode to "Continuous Samples" - this is an input at the top of the Timing node.
  • Reading:
    • In Continuous mode, the number of samples controls the buffer size - it doesn't control the number of samples you read at once - this is controlled by the input to the DAQmx Read call inside your loop
    • Since you can always (almost) read a value, there are generally fewer errors you can make with reading
  • Writing:
    • Writing (as in your case) is similar. When you write samples, there are additional concerns relating to regeneration and the need to write samples before you start.
    • When you Start, the DAQ device will begin to output the samples that you already wrote using DAQmx Write!
    • If you didn't write any values, then it will by default "Regenerate" values, meaning it will write whatever was last in the buffer in a loop. This is probably a bunch of False values (I think...) when you just turn on the device
    • If you disable regeneration, then you'll get an error about samples being unavailable.

So, to write your 4 arrays samples, first call DAQmx Timing, and set Finite Samples generation (with the number of samples necessary for one channel), then use DAQmx Write with the array of samples (N channels, N samples), then call Start. You can then either use Wait and Stop, or probably more safely, you can loop with a Wait and check for "Is Task Done?", then Stop and Clear.

 

Since you have a While loop around your setup, it'll probably be a little more complicated, but it's not obvious to me what you're doing there... Perhaps you can explain how the arrays are changed, and why the outer loop runs as fast as possible without checking if the arrays are changed or not, and so on.


GCentral
Message 6 of 9
(1,050 Views)
Highlighted

That's a really excellent summary from cbutcher in msg #6!   I hope a lot of DAQ users find and read it.  If so, it's worth making one little arguably nit-picking correction in reference to configuring DAQmx Timing:

  

  • Reading:
    • In Continuous mode, the number of samples controls the buffer size 

Actually, in when DAQmx Timing is set to Continuous mode, DAQmx auto-sizes the buffer by default based on the specified sample rate.  (A manual override is still possible however.)

 

(Note: endpoints of sample rate ranges are ambiguous in the table.  From experience getting burned in some inherited code, I can vouch for the fact that a sample rate of 10kHz makes a buffer size of 10k samples not 100k.)

 

(FWIW, I have a vague memory that DAQmx may not have always done auto-sizing this way.   I think there was a time it compared what you wired and what the auto-size table suggested and used whatever was larger.  Longer ago it may not have done auto-sizing at all, though it would have been hard to notice in well-written code.) 

 

 

-Kevin P

 

 

P.S.  Did a quick test with a simulated device.  It appears that DAQmx still *does* in fact use the larger of {what you wire,  what the auto-size table suggests}.  So the linked article is also not entirely correct, and if you wire in a large enough buffer size, DAQmx Timing *will* honor it.

Message 7 of 9
(1,037 Views)
Highlighted

Oops! I saw that Kevin_Price had replied to this thread and my first thought was "Oh dear, what did I get wrong?". It's always great to learn new things, so things for the link to the auto-sizing values. I guess I misread/understood the help files and should have checked more carefully at some point in the past.

 

Perhaps alternatively I just wire overly large buffer sizes...


GCentral
Message 8 of 9
(1,032 Views)
Highlighted

Hi cbutcher,

 

Thank you very much for your great reply! That's very helpful!

 

I am using the code to control a decoder and I need it work periodically, so I am trying to add HW timing control (if we set it a task as T1) to substitute the wait vi in the loop. On the other hand, I need T1 to control the other part to send out data like active matrix. As a result, I hope two parts of design can work in the same time line.

 

Thanks a lot!

 

Best,

Jason

 

0 Kudos
Message 9 of 9
(1,012 Views)