06-19-2007 08:27 AM
06-19-2007 09:53 AM
Not to be pedantic, just trying to be clear.
1. You (probably) do not truly need to "read" simultaneously. Rather, you need a means to capture and read such that the data is correlated / synced in time.
2. This is a bit more problematic for period measurement because measurement time is not under your control. It is implicit in the signals being measured.
3. I program with LabVIEW and don't know how to configure tasks from within Matlab.
4. All that said, the first step is to configure all the period measurement tasks to use an "Arm Start" trigger. They should all get triggered by the same signal, which may be something you control. On a 6602, I often generate an edge using DIO 0, which is also known as PFI 0 when specifying the Arm Start Trigger terminal.
5. Start the counter tasks before generating the trigger edge. Then both of them will start counting time simultaneously.
6. When you read the buffers of periods, you may need to do some post-processing to trim the data down. The cumulative sum of the periods will be the timestamp associated with each period measurement. The two counters' timestamp values will probably all be different, and one will contain later data than the other which you may want to trim.
-Kevin P.
06-19-2007 10:39 AM
06-19-2007 11:10 AM
06-19-2007 01:50 PM
06-19-2007 04:23 PM
Yes you can. This was what I was driving at, not successfully, in item #4 of my first post.
The pin assigned for DIO 0 is the *same* pin known as PFI 0. You can make a Digital Output task using Dev_X_/port0/line0 which controls the state of that pin and can then assign a counter task to use the terminal PFI 0 as the Arm Start trigger terminal. Since they are the same physical pin, there's no screwdriver work.
It would also be possible to generate a single pulse on a spare counter and use that counter's output as the Arm Start trigger. Again, no screwdriver work.
-Kevin P.
06-20-2007 10:52 AM
So I tried something out and it didn't work. In words, I tried to create a signal to PFI0 (task 3) to trigger Ctr0 and Ctr1 (task 1 and 2). I'm going to paste it in here and maybe you'll ahve a few comments for me. I'm only pasting the pertinent trigger code. The code to create/read in the counters is fine.
%Create Digital Output Task
%Define Variables for Write
%Define Write
%Define Trigger Properties
%Start Tasks
When this runs I get an error (-89120) on both task1 and task2 start functions and read functions. The error info says:
Source terminal to be routed could not be found on the device.
Make sure the terminal name is valid for the specified device. Refer to Measurement & Automation Explorer for valid terminal names.
Property: DAQmx_DigEdge_ArmStartTrig_Src
Property: DAQmx_DigEdge_ArmStartTrig_Edge
Source Device: Dev1
Source Terminal: Dev1/port0/line0
Task Name: _unnamedTask<1F>
Status Code: -89120
Any clues?
06-20-2007 11:06 AM
Yep. I don't know the syntax for text-based language DAQmx calls, but you need to specify ArmStartTrigSrc in terms similar to "dev1/PFI0" and not in terms meant for digital i/o terms such as port0/line0. This may seem silly since they map to the same physical pin on the 6602. However, that isn't true on other boards. Only terminals designated as PFI can be connected to the edge-sensitive triggering circuitry. So when configuring the trigger, you have to refer to the pin in terms of its PFI identity.
-Kevin P.
06-20-2007 01:44 PM
PHEW, I finally got it to work. My problem for the longest time was figuring out what to call the trigger pin. So the DO is written to "Dev1/port0/lin0" while the trigger is read from simply "PFI0". Not "Dev1/PFI0". Not "Dev1/port0/PFI0". Simply "PFI0". Thanks for your help Kevin. You've been awesome.
-Mike