05-22-2019 09:35 AM
I am working on the bender elements measurements in which I send a wave through one bender element and receive the wave with the other. The problem I have with LabVIEW VI is that I cannot synchronize the two DAQassistants for generating and acquiring sine signals. I think the problem is with the sampling rate and also triggering the signal acquiring with the starting time of sine wave generation. (please see the two VIs which are simple and a bit more complex one).
I would really appreciate if anyone could help me solve the problem. I want the acquire signal start just at the time as the generated sine wave started. Please let me know if there is something not clear in my explanation.
Thanks in advance for your kind help.
05-22-2019 10:44 AM
Step 1 - use regular DAQmx, not DAQ Assistants
Step 2 - no, really, *don't* use DAQ assistants for anything but the very most trivial apps. This isn't one of them.
Step 3 - yes, I'm serious. You can thank me later
Step 4 - search the site here with combos of terms like AO, AI, sync, synchronization, simultaneous.
I can't open the code now to offer specific advice, but I would generally advocate the use of a "shared sample clock." (In cases where AI must sample faster than AO, I use a slightly more complicated but conceptually similar method that shares a sample clock *timebase*.) I find that triggers are often not needed at all, though most of the advice you'll find will start by recommending a shared trigger. Bah, humbug I say.
-Kevin P
05-26-2019 04:46 AM - edited 05-26-2019 04:48 AM
Hi Kevin,
Many thanks for your reply. These days I was trying to solve the problem with DAQmx but since I am not very familiar with the LabVIEW programming I could not program it yet. I am using NI CDAQ-9188XT CompactDAQ Chassis and NI 9269 4ch voltage output, ±10V, ch-ch for generating analog input. I looked into the example of DAQmx in LabVIEW examples (synchronization) and could not find the module that I am using. Do you think with these parts I can use DAQmx or not? I would appreciate if you could guide me further.
Thanks.
Sina
05-26-2019
05:34 AM
- last edited on
12-20-2024
03:00 PM
by
Content Cleaner
Sina,
You may need to learn a little more LabVIEW (or at least some LabVIEW "style", such as trying to keep your wires straight and as horizontal as practical). An excellent source for learning (more) about DAQmx (and how to avoid the Dreaded DAQ Assistant and its Evil Twin, the Dynamic Data Wire) can be found by searching for "Learn DAQmx" on the Web or clicking on this link.
I completely agree with Kevin's excellent advice.
I also suggest that you "start small". Don't try to update either of your routines all at once. Instead of "Bender", for example, write two routines, one to generate a waveform that you can measure with an oscilloscope, the other to sample a waveform that you input either from a separate Waveform generator or simply by putting a 1 MOhm resistor across your differential input terminals of your A/D converter and touching one end (you should see a noisy sinusoid at whatever frequency your A/C Mains utilize, typically 60 Hz or 50 Hz). Instead of the Express VI that generates those hard-to-use Dynamic Data Wires, learn about Waveforms in LabVIEW and use the Signal Generator found on the Waveform Palette. Note that Waveforms are highly appropriate for use with DAQmx.
Bob Schor
06-05-2019 02:27 AM
Hi Bob and Kevin,
I have been programming these days. I have used Daqmx, but I am still stuck in synchronizing the two benders. Would you please take a look at the attached VI to advise what the problem can be. I really appreciate your kind help. Thanks.
06-10-2019 11:52 AM
It looks like you want AO and AI to run at the same sample rate and start at the same time. One easy way to do that is make 2 changes in your code:
1. Configure the AI task to use the AO task's sample clock as its own. In the AI task's call to DAQmx Timing, you can right click the 'source' input terminal to create a constant. Then select the one that looks like "/cDAQ9188XT-1BD9E1EMod5/ao/SampleClock".
2. Since the AI task is going to borrow the AO clock, it's important to make sure the AI task is started (and therefore ready) before you start AO. To do this, simply move the AI task's call to DAQmx Start so it happens *before* the single-frame sequence where AO gets started.
3. The first two things help with sync. This one simply helps. In the AI task's call to DAQmx Timing, you should (probably) wire in a value to the 'samples per channel' input terminal and it should be the same as the # samples the AO task will generate. (Presently this is buried and hidden in the config panel for the Simulate Signal express vi, among the reasons I tend to avoid express vi's).
-Kevin P
06-12-2019 03:55 AM
Many thanks for your excellent suggestion. I modified the code however when I add the sample clock I get the below error:
Error -200414 occurred at DAQmx Start Task.vi:7220001
Possible reason(s):
Requested sample clock source is invalid.
Property: SampClk.Src
Corresponding Value: /cDAQ9188XT-1BD9E1EMod5/ao/SampleClock
Device: cDAQ9188XT-1BD9E1E
Task Name: _unnamedTask<643>"
Please find the enclosed revised code. Would you please advise where I am making a mistake?
Thanks!
Sina
06-12-2019 06:36 AM
You haven't identified your AI module, but I suspect it might be a Delta-Sigma type of converter. I have limited experience with cDAQ, but I know the 9237 (for example) is one such module.
These kinds of modules cannot accept a sample clock signal from the outside, they must generate their own. Typically, they can export them for use by other tasks/modules though. So here are my revised suggestions, let's see if this works out better:
1. Unwire the 'source' input to the AI task's call to DAQmx Timing. Wire the terminal control to the AO task's call to DAQmx Timing. Change the value to something more like "/cDAQ9188XT-1BD9E1EMod1/ai/SampleClock".
2. Swap frames for the 2 calls to DAQmx Start to make sure you AO task is started first now.
3. Learn about and devise a method to compensate for the delay inherent in the AI task due to the Delta Sigma converter. One fairly simple technique is to read extra AI samples because the first N samples represent the time *before* you began generating AO. Discard them and keep the rest.
- Kevin P
10-19-2019 02:20 AM
Thanks Kevin. That solved the problem.
I just realized that I did not reply and thank you.