Use of clock and trigger in a daq.session

11 views (last 30 days)
Dan-Timon
Dan-Timon on 23 May 2012
Hi,
I'm trying to make a triggered measurement of several signal sources using the session interface with a NI USB-6361. My setup is the following:
  1. External Trigger on PFI0
  2. Analog data on ai2
  3. External counter signal on PFI5 (ctr3)
What I am trying now is to make a measurement of the analog data on every trigger and simultaneously read the current counter. There are several problems:
  1. Even with R2012a it is not possible to use the external trigger as an actual trigger, but solely as start trigger. When will more trigger options be available?
  2. With startForeground, the counter should be set to 0. However, after the measurement, the first counter data is not zero. It seems that between the reset of the counter and the first measurement lie about 0.05 seconds.
  3. What is a clock connection? I couldn't find anything on the internet or in the documentation which explained the difference between trigger and clock.
  4. When using the ClockConnection, the first counter data is correctly 0. However, with sample rates around 100k I get an error stating a timeout.
I hope someone has answers or ideas to something of the above stated problems.
Greetings, Dante
My code:
s = daq.createSession('ni');
s.addCounterInputChannel ('Dev1', 'ctr3', 'EdgeCount');
s.addAnalogInputChannel('Dev1', 2, 'Voltage');
tc = s.addTriggerConnection('External','Dev1/PFI0','StartTrigger')
%cc = s.addClockConnection('External','Dev1/PFI0','ScanClock')
s.Rate = 100000;
s.DurationInSeconds = 0.01;
[data, timeStamps] = s.startForeground();
plot(timeStamps, data);

Answers (1)

AndTim
AndTim on 6 Jul 2012
Hi,
I haven't really worked with a counter channel yet, but concerning your other questions:
1. You can use s.TriggersPerRun to trigger the measurement multiple times.
3. A clock connection clocks the acquisition of your input channel. For example if you connect a 1 kHz TTL to the input for the ClockConnection, every time a rising edge is detected, one datapoint is recorded. Basically the clock connection can be seen as a trigger, but it doesn't start the acquisition of a trace of datapoints, but rather of just one datapoint. (within the inverse samplerate after the edge is read.)
4. You get a timeout if the frequency of the signal for the clock connection is too far away from your specified samplerate. If you specify your Rate to for example s.Rate = 10000, but your signal has a frequency f = 1000 Hz, the card expects to acquire 10000 edges per second, but it only sees 1000.
Hope that helps, Tim

Categories

Find more on Simultaneous and Synchronized Operations in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!