Discussion:
digital start ref for analog input trigger using DAQMX BASE for linux
(too old to reply)
BattelleV
2008-07-24 18:40:09 UTC
Permalink
Hello,
 
I am using the NI-USB 6215 DAQ under Linux without Labview. I am using the NI DAQMX Base C api.
 
What I need to do is read data from an analog input when a digital reference trigger is set high, further I need to set the trigger high from within the same thread.
The output is used to trigger two things (something external as well as something that provides input to the DAQ).
 
I can succesfully setup a single analog task to read data from an input.

I can succesfully setup a single digital task to set an output high.

I can succesfully setup a single analog task to read data from an input, with a digital start reference (verified by providing an external reference).
What I cannot do is within a single thread start two tasks one to setup an analog read with a digital start reference, and another to output a signal that is fed back and used as the reference. The Readme for DAQMX Base states that the Base API is not threadsafe and so a single thread should be used to setup tasks and channels.
The Readme file further states that an analog task and a digital task can both run simultaneously. 
It looks like the two calls I am doing,  DAXmxBaseWriteDigitalU32 and DAQmxBaseReadAnalogF64 both block, so it appears that sequentially I can set the output high but in doing so end up missing the rising edge transition.
 
Any insight would be appreciated.
 
 
PBear
2008-07-25 21:10:07 UTC
Permalink
Hi BattelleV,
Instead of discussing how to get you implementation to work, I'd like to know exactly what your application is expected to do. I mean this from a higher level perspective.
Are you looking to press a button with your mouse which will in-turn start an analog acquisition? When this happens, are you also looking to output on a digital line? If this is the case, I would go about this a bit different. First off, I would only create an analog input task and not worry about the digital task. Since clicking a button in software is a software trigger, I would just monitor that control via a callback and then  start your analog acquisition. I would also have my ai/starttrigger exported to a PFI line. This way when your analog input begins, this PFI line will output a high which you can read with your external device.
I hope this is helpful.
BattelleV
2008-07-25 21:40:12 UTC
Permalink
I have multiple sources from which I expect to acquire data.
One is attached to the DAQ, the other is RS232 based. It is vital that the data collection during this period be synchronized. fortunately the RS232 based source accepts a trigger.
In order for this synchronization to occur, I plan on sending the trigger using the DAQ to the RS232 based source as well as to the DAQ to start reading the analog input.
There are no mouse clicks or user interaction to start data collection, this is an embedded device with a scheduler loop that will command both devices to collect data and parse the data.
 
PBear
2008-07-28 21:10:06 UTC
Permalink
Hi BattelleV,
I believe this setup will still work for you. If you export the ai/starttrigger trigger pulse via a PFI line, this will synchronize your two operations. When you call the DAQmxStart function for your analog task, the ai/starttrigger will be asserted and your RS232 device will receive the pulse at this moment. Thus your RS232 device will know when your analog acquisition begins.
You will not have synchronization by starting a digital task and then sending a 'T' to be written to a digital task who's output is wired to a PFI line that your analog task monitors in order to trigger the acquisition. This has inherit software delays and is non-deterministic. Simply set up a single analog task that outputs a pulse when the acquisition starts.
BattelleV
2008-07-31 20:10:11 UTC
Permalink
PBear,
Can you elaborate on the following:
You will not have synchronization by starting a digital task and then sending a 'T' to be written to a digital task who's output is wired to a PFI line that your analog task monitors in order to trigger the acquisition. This has inherit software delays and is non-deterministic. Simply set up a single analog task that outputs a pulse when the acquisition starts.
I don't see what the software delays are, aren't the digital tasks and the analog tasks sharing a commong timebase (clock?)?
My goal essentially is to have the following,
a scheduler thread in a process (process 1) which calls an operation in another process (process 2 ) to setup the RS232 Device to start collecting data when it sees a trigger high.
The same thread then calls another operation in process 2 to start a task on the DAQ analog input (say collect x number of samples after a digital trigger)
Process 1 now calls another operation in process 2 to start the trigger (assert a 1 for X seconds).
Process 1 now calls an operation in process 2 to see if the trigger has finished asserting.
Process 1 calls a read operation in process 2 on the RS232 Device to see what data it recieved while the trigger was high.
Process 1 calls a read operation in process 2 on the DAQ task to see what data was read.
Process 2 clears the analog and digital tasks.
 
PBear
2008-08-01 21:40:11 UTC
Permalink
There is an inherit software processing time associated when calling the DAQmxWrite and when the board actually generates the signal. There is also a propagation delay from the generation to the input of the PFI line. While this may be small and insignificant, the BEST way to do this would be what I suggested as everything is contained in one task and synchronization is guaranteed. You're not wrong by any means, but the best way to do this is to minimize your code and take advantage of the PFI functionalities of the board.
Loading...