Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Trouble running MATLAB code
Date: Mon, 6 Oct 2008 23:25:08 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 58
Message-ID: <gce6ok$jmr$1@fred.mathworks.com>
References: <gc91iq$fq8$1@fred.mathworks.com> <gcd256$7b0$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1223335508 20187 172.30.248.35 (6 Oct 2008 23:25:08 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 6 Oct 2008 23:25:08 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1528031
Xref: news.mathworks.com comp.soft-sys.matlab:493926


"Sherryl Radbil" <sherryl.radbil.dontspamme@mathworks.com> wrote in message <gcd256$7b0$1@fred.mathworks.com>...
> Hi Matthew,
> Please provide the exact and entire error message you get and also which line you get it on.
> 
> This sounds like an error we've seen returned by the MCC driver but it is usually associated with trying to add more channels to your object than exist, so it's surprising that you're seeing it.
> 
> It's unclear how this program works since TriggerRepeat and RepeatOutput are being set to zero. Can you explain?
> 
> Sherryl
> 

Hi Sherryl. Thank you so much for replying. This is a more simplified version of the code. The TriggerRepeat was a typo and should have been infinite. In short, I have set up an infinite loop to acquire voltage inputs from a strain gauge.

Unfortunately, the daq does not allow simultaneous input and output, so what I have created is a loop that turns off output everytime I need input and vice versa.

In this version, the daq will simply output whatever the input voltage is.

ie. vin = vout

Here is the code:

ai = analoginput('mcc',0);
addchannel(ai,0:1);
ao = analogoutput('mcc',0);
addchannel(ao,0:1);

duration = 0.001;
set(ai,'SampleRate',1000)
ActualRate = get(ai,'SampleRate');
set(ai,'SamplesPerTrigger',ActualRate*duration)

set(ai,'TriggerRepeat',inf);
set(ao,'RepeatOutput',0);

control_variable = 1;

while( control_variable==1 )

start(ai);
pause(0.1);
    
vin = peekdata(ai,1);

putdata(ao,[vin(1,1) vin(1,2)]);
    
stop(ai);

start(ao);
pause(0.1);
stop(ao);

clear(ai);
clear(ao);

end;

stop(ai);
delete(ai);