MATLAB Answers

National Instruments & Matlab

13 views (last 30 days)
James Kim
James Kim on 5 Nov 2018
Answered: Brian Hu on 8 Nov 2018
Hello, I have using NI 9401, NI9237, and NI9215. When I run the code below,
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear
clc
devices = daq.getDevices
s = daq.createSession('ni')
s.DurationInSeconds = 10;
s.Rate=2000;
addAnalogInputChannel(s,'cDAQ1Mod2','ai0','Bridge')
addAnalogInputChannel(s,'cDAQ1Mod3','ai0','Voltage')
addCounterInputChannel(s,'cDAQ1Mod1','ctr0','PulseWidth')
addClockConnection(s,'cDAQ1Mod1/PFI1','External','ScanClock')
ch1=s.Channels(1)
set(ch1)
ch1.BridgeMode= 'Half'
ch1.NominalBridgeResistance = 350;
[data,time] = s.startForeground;
release(s)
plot(time,data(:,1))
title('Bridge')
figure(2)
plot(time,data(:,2))
title('Voltage')
figure(3)
plot(time,data(:,3))
title('Frequency')
figure(4)
plot(time,data(:,4))
title('PulseWidth')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I keep getting this error
NI Error -200414:
Requested sample clock source is invalid.
Property: DAQmx_SampClk_Src
Corresponding Value: Default
Device: cDAQ1
Task Name: _unnamedTask<79>
Status Code: -200414
Can anyone explain why I am getting this error?

Answers (1)

Brian Hu
Brian Hu on 8 Nov 2018
It seems that you might have the ordering of your inputs slightly mixed up when you call the addClockConnection function. Here is a link to an example that might be helpful for resolving this issue.

Community Treasure Hunt

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

Start Hunting!

Translated by