03-11-2021 01:26 PM
Hi,
I have been using digital inputs on a USB-6343 and using a task running with python nidaqmx. Now I want to add analogue ins but I can't because you can't mix line types. I could use a second task for analogue data, but I call configure_logging to record my digital data and if I did that for the the analogue data it would presumably produce a data file that is not in sync.
Is there any good way of synchronizing the two, or do I just need to rewire and recode the digital lines so they are analogue ins? Or is there something else to do in this situation?
Thanks,
Tristan
Solved! Go to Solution.
03-12-2021 05:32 AM
I don't know any of the Python DAQmx syntax. Is "configure_logging" a DAQmx function that automatically logs your task's data to a .tdms file?
If so, then you don't need to worry about the file(s). Your main *real* issue is to sync the hardware. You can do that by sharing a sample clock. For example, configure the new analog task in a normal way but configure the digital task to use something like "/Dev1/ai/SampleClock" as its own sample clock. Then be sure to start the digital task before starting the analog (so it's ready to receive the 1st sample clock signal and be sync'ed in hardware to the analog samples).
-Kevin P
03-12-2021 10:04 AM
Thanks Kevin, I believe I have it working by setting the source parameter as follows:
di_task.timing.cfg_samp_clk_timing(rate=daq_sf,
source="ai/SampleClock",
active_edge=nidaqmx.constants.Edge.RISING,
sample_mode=nidaqmx.constants.AcquisitionType.CONTINUOUS)
I will have to do some testing to confirm but it seems to be correct.
03-15-2021 09:47 AM
Do I have to run the digital task with the analogue task or can it be the other way around?
03-15-2021 10:24 AM
Unsure what you mean. It isn't about with vs. without. It's about before vs. after.
The code section you posted shows that you configured your DI task to "borrow" a sample clock from the AI task. With this configuration, it's important to start the DI task *before* starting the AI task. That way the DI task is armed and ready to do its sampling before the AI task starts producing a sample clock signal.
-Kevin P
03-15-2021 10:28 AM
Sorry that was a mistake, I meant 'before'. Or more precisely, can the AI task use the DI clock, rather than the DI task having to use the AI clock?
03-15-2021 10:34 AM
From what I understand, all X-series devices (63xx, as far as I know) allow you to derive a sample clock internally for DI and DO tasks. Previous generations (M-series, others) required digital tasks to borrow a shared sample clock from elsewhere, such as an AI or AO task.
So, with your X-series device, I *believe* you can go either way. Either DI or AI can configure their clock independently, and then either AI or DI can borrow it (and be started *first*).
-Kevin P