JNR wrote in message news:<5065000000080000008D510000-1023576873000@exchange.ni.com>...
> I have a program that records and displays data from several channels
> of a NI DAQ board. Also, it plays an AVI in Media Player included as
> an ActiveX object in the VI.
>
> I would like to automatically start playing the AVI when the voltage
> on one of the channels on the DAQ board reaches a certain level.
>
> I am thinking of using a global variable to change the Play State of
> Media Player from 0 to 1, in order to start playing.
>
> The problem is this. The part of my program which monitors the
> channels on the DAQ board is enlosed in a WHILE loop. The program runs
> so long as the WHILE loop is active. The channel that I am monitoring
> for the signal to start Media Player starts off with a value of 0. At
> some point, the value being recorded changes to 1, after which it
> continues to switch between 0 and 1.
>
> I want the global variable to be modified ONCE only, that it, it
> should start by reading the initial value on the channel (which is 0),
> continue to monitor to it until it changes to 1, and then cease to
> monitor it altogether, leaving it at 1 for the rest of the time the
> program is active.
>
> Does anyone have any suggestions on how to do this?
>
> Thanks.
>
> Pankaj Saxena
Hi Pankaj,
sounds like you need to create a shift register on the edge of the
while loop, pre-initialised with a 0. You can then compare not only
your new value from the DAQ channel, but also the old value. Use an OR
gate between the old value (shift register) and the DAQ channel (don't
worry, it works with integers too - 0 = false, 1 = true), and then
pass the output of this to
your trigger variable, and your shift register on the output side of
the loop.
A better option would be to use a notify synchronisation though. You
could set the Media player section to wait on the notify, and then off
it goes when the DAQ channel goes to the set level. It doesn't matter
if the DAQ channel goes up again, because you're not watching for it
any more.
Hope that helps
Sash