06-28-2018 01:55 AM
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
Solved! Go to Solution.
06-28-2018 01:59 AM
06-28-2018 02:34 AM
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
06-28-2018 03:53 AM
06-28-2018 04:01 AM
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
06-28-2018 04:27 AM
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!):
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.
06-28-2018 07:37 AM - edited 06-28-2018 07:39 AM
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.
06-28-2018 07:46 AM
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...
06-29-2018 01:08 AM
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