필터 지우기
필터 지우기

external triggering of NI USB-6341with Matlab

조회 수: 6 (최근 30일)
lissa  Anderson
lissa Anderson 2012년 7월 18일
Hi,
I have a 32 bit Matlab 2012a running in a 32 bit Windows 7. When I use the DAQ toolbox, I can generate my desired pulse train with the following code:
s = daq.createSession ('ni');
ch = s.addCounterOutputChannel('Dev1', 0, 'PulseGeneration')
s.DurationInSeconds = 4;
s.Channels.DutyCycle = 0.5;
s.Channels.Frequency = 20;
s.startForeground;
The output PFI is automatically set to PFI12, so I just connected my wire to that! But when I use Matlab external triggering and send the external triggers, nothing happens in output:
[tc,idx]= s.addTriggerConnection('external','Dev1/PFI1','StartTrigger')
I am sure that my board line (PFI1) received the triggers (I checked it with NI Measurement and Automation Explorer). Should I do something more to link say PFI12 must follow PFI1 triggers?
I would be very thankful if you guys help me to figure it out.

답변 (2개)

Manisha
Manisha 2012년 7월 20일
Hi Lissa,
Counter output channels are not affected by the trigger connection you added in session based interface currently. This is mentioned in the doc.
You can however use your analog output channel to output a pulse train and user trigger connection to start the ao channel.
s = daq.createSession ('ni');
ch = s.addAnalogOutputChannel('Dev1', 0, 'Voltage');
s.Rate = 10e3;
[tc,idx]= s.addTriggerConnection('external','Dev1/PFI1','StartTrigger');
frequency = 20; duration = 4;
numberOfPulses = frequency * duration;
numberOfPointsInHalfPulse = s.Rate*(1/frequency)/2;
dataToOutput = [ zeros(1,numberOfPointsInHalfPulse) ...
ones(1,numberOfPointsInHalfPulse) ]';
s.queueOutputData( repmat(dataToOutput,numberOfPulses,1));
s.startForeground;
Hope this helps,
Manisha

lissa  Anderson
lissa Anderson 2012년 7월 20일
편집: lissa Anderson 2012년 7월 20일
Hi Manisha,
Thanks for the answer. I ran all of your lines. All the lines worked unless the last last line which after 9-10 second of thinking gave back the following warning and error:
*Warning*: This change caused queued output data to be
flushed. Use queueOutputData to queue data before starting
the object.
*Error*: Timeout expired before start trigger was received. Timeout
for External Triggers can be modified by the property
'ExternalTriggerTimeout' on the session.
During that busy time I sent some external triggers but no output train came out. Do you have any suggestions?
  댓글 수: 1
Manisha
Manisha 2012년 7월 20일
Have you confirmed that your trigger is attached to PFI1? What is the amplitude of your trigger pulse?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simultaneous and Synchronized Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by