Path: news.mathworks.com!not-for-mail
From: "Gautam Vallabha" <gautam.vallabha.nospam@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: synchronizing posttrigger DAQ with two boards
Date: Mon, 11 May 2009 14:20:02 +0000 (UTC)
Organization: The MathWorks Inc
Lines: 41
Message-ID: <gu9c6i$fpe$1@fred.mathworks.com>
References: <go6o36$c5f$1@fred.mathworks.com> <go7o8h$2r1$1@fred.mathworks.com> <goh945$lpa$1@fred.mathworks.com>
Reply-To: "Gautam Vallabha" <gautam.vallabha.nospam@mathworks.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1242051602 16174 172.30.248.37 (11 May 2009 14:20:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 11 May 2009 14:20:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1056585
Xref: news.mathworks.com comp.soft-sys.matlab:539008



The basic issue is how to get pretrigger data when you have synchronized input channels. This can be done in software only (i.e., without depending on specific hardware triggering capabilities) as follows:
1) Continuously get data from both channels,
2) Store the data in a circular buffer
3) when the trigger occurs (this can be a user-initiated event such as a button press), log the pretrigger data from the circular buffer.  

This FileExchange entry demonstrates this procedure in more detail:
  http://www.mathworks.com/matlabcentral/fileexchange/24027

Gautam

"S.J." <oceansounds7@gmail.com> wrote in message <goh945$lpa$1@fred.mathworks.com>...
> Hi Sherryl,
> 
> Thanks for the excellent suggestions.  I've played around with the StopFcn, TriggerFcn, etc., but I'm not seeing how this would yield a simultaneous trigger.  Perhaps I'm not thinking about this correctly?  Here is my thought process:
> 
> I think a TriggerFcn is more appropriate than a StopFcn, because I still need to run getdata to pull the data into the workspace from both daq devices.
> 
> Thus, I set the main device TriggerFcn to run a callback that triggers the secondary device.  
> 
> But....it still takes time to run the TriggerFcn callback and then trigger the secondary device.  As far I can tell this would yield the same delay as just typing "trigger(maindevice)" and then "trigger(secondarydevice)" in the body of the program.
> 
> I'll try some other ideas in the meantime..
> 
> Thanks!
> 
> 
> "Sherryl Radbil" <sherryl.radbil.dontspamme@mathworks.com> wrote in message <go7o8h$2r1$1@fred.mathworks.com>...
> > Hi S.J.,
> > Glad you like the support for RTSI that was made available in R2008b.
> > Others reading this thread can find out more at
> > http://www.mathworks.com/access/helpdesk/help/toolbox/daq/rn/brw8x4l-1.html#brqy2tk-3
> > http://www.mathworks.com/access/helpdesk/help/toolbox/daq/brt7oe_-1.html
> > and the shipped file: demosync_ai_and_ao.m
> > 
> > Regarding how to have one device stop another, consider using the StopFcn callback
> > http://www.mathworks.com/access/helpdesk/help/toolbox/daq/stopfcn.html
> > 
> > Set the StopFcn for the main device and in the callback itself call stop on the secondary device. You could use the main device's UserData property to store the handle to the secondary device.
> > 
> > Sherryl