02-08-2023 09:31 PM
I do not quite get this!
I am feeding an external digital TTL 5V pulsed signal to USB 6218 on Port0/line0 terminal and setting it as a scan clock i.e., to PFI0 terminal.
However, the task (ext triggered analog output) ignores the external clock and runs irrespective of what terminal I assign the scan clock to or even when I unplug the external signal. This is weird!
For example if I set clock to PFI12 when in reality the external signal is on PFI0, I still am able to run the task.
I tried the same on a different USB DAQ (6366) exactly same process, identical signal and there it behaves properly i.e., if the clock signal is removed or wrongly assigned the task 'times out' which is expected behavior.
I looked at the manual of 6218 and it does appear that I can use triggering on the PFI0..3 channels.
So what am I missing ?
Looked at Max configuration. Looks good. However, Max does not show up Port0 in configuration mode and only shows Port1 for Powerup option. Not sure what that implies?
Is the device damaged?
In the 'test device' on Max I see Port0/line 1 blinking because I have the digital input.
Thanks
Solved! Go to Solution.
02-09-2023 09:52 AM
Bump?
I really need help because perhaps I am not interpreting manual correctly? Ni Support?
I have attached Max configuration png file and as you can see I do not see Port 0.
I have also attached Max Test png file and everything is greyed out.
I wonder if that is the case how can I even use these ports as PFi's where manual clearly says I can send signals to clocks and can use as triggers?
I have a USB6212 and it shows similar features which makes me think there is a big gap between reality and what is in the manual or I am just not understanding things correctly.
Thanks
02-09-2023 10:09 AM - edited 02-09-2023 10:32 AM
I have attached png that clearly shows when I generate a task for Analog output I can do that with PFI0-3 channels.
And if I unplug the input to PFI0, I get a time out
Therefore I believe this must be some glitch in the Matlab command?
02-09-2023 11:13 AM
It will be helpful if you would post all the code in question. I myself don't know the Matlab API, but recall threads over the years that identified some limitations.
One key point of clarification: you say, "it always writes irrespective of PFI0 (unplugged or plugged)". Do you mean that the function call to Write data to the task seems to work without error? Or that the AO signal you defined and write actually gets physically generated at an I/O pin? It's important to keep in mind that these are *not the same thing*.
After writing data to the task, do you then call a Start function?
These things and more would be clearer after you post the code in full.
-Kevin P
02-09-2023 11:27 AM - edited 02-09-2023 11:57 AM
Here is the code.
I am convinced I have not understood Matlab syntax properly. Or not yet understood NiDAQ. Sigh!
02-09-2023 11:55 AM - edited 02-09-2023 11:57 AM
With this new code I made some headway but not sure I understand it yet
So now if I unplug the clock from PFI0, I do not get any errors. The mirror DOES NOT move but nothing happens and no errors.
But if I comment out the 'start', then it runs as intended and when I unplug the clock I get a timeout error.
%start
So what am I doing wrong with 'start'? Does start need a 'trigger'?
Thanks
02-09-2023 01:20 PM
I am following https://www.mathworks.com/help/daq/daq.interfaces.dataacquisition.write.html in particular the section "Generating repeating signal in the Background"
That link was helpful. After a little quick skimming over lunch, I can see that Matlab's data acq API is playing by different rules than the DAQmx API I'm used to in LabVIEW. It's probably trying to be helpful by reducing the # of functions and arguments you need to know about. But that's also a reduction in the functionality you're able to control or make use of.
Of note: the link shows that calls to Write will automatically start the task running. This is not the normal way DAQmx behaves for buffered & hardware-clocked AO tasks.
Summary (for me): I'm not too much help here. I know a bunch of stuff about external clocking and sync using DAQmx, but the Matlab API doesn't seem to provide access to some of the important stuff. It seems a little bit like the DAQ Assistant -- not many choices available, so relatively quick to make simple stuff work. But also limited in configurability, so potentially impossible to make certain complex stuff work.
Maybe you should also look for help over at the Mathworks' site among Matlab-oriented folks that are more likely to have detailed knowledge of their data acq toolbox, how it does and doesn't work, what you can and can't do with it.
-Kevin P
02-09-2023 02:33 PM
Instead I have decided to switch to LabView for now. I did reach out to Matlab community but no response. But I will rephrase my query and ask again given that I have found a temporary solution. Looks like everything works provided ‘start‘ has an accompanying ‘trigger channel (not clock channel).