Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQ outputs not updating with MATLAB script

Hello,

I have a Matlab script that adjusts the range and offset voltage of my
DAQ board for optimal signal capture...  Sometimes it works, and
sometimes it doesn't.  Most recently, it doesn't, and nothing has been
changed in the matlab code or the vi.  Since this isn't an easily
repeatable error, it is proving difficult to debug.  It seems that the
vi just stops listening to Matlab, and restarting Labview or the
computer doesn't help.

I have a uesr input box where the user can put in an initial guess at
the range and offset.  These are branched to inputs into the Matlab
script, which should then take over and adjust the values according to
its rules.  It has done this successfully on many occasions.  The
output from the Matlab script is linked as an input to a local
variable.

Also since the last time it worked, sometimes it does change the range
value, but of channel ao1 rather than ao0 as it is supposed to.

All the hardware seems to be fine, as in a separate vi (without hte
matlab script) all values can be changed manually -- it's just when the
matlab script is incorporated that things go wacky.

If anyone can help me figure this out, I'd greatly appreciate it.
Thank you for your time.
0 Kudos
Message 1 of 6
(2,897 Views)

Hello ssingh,

Does the range output of the Matlab script sometimes give the incorrect value, or is it giving the correct value, and the DAQ driver is not changing the range?  I notice that you mention the use of a local variable.  Is it possible that the range value of the local variable is being read by the DAQ driver before it is written to by the Matlab script?  If you do not have an order of execution to your program, it may sometimes execute faster than others resulting in a not easily reproducible behavior (called a race condition) in your code tied to the fact that the local variable is being read before it is written.

If you do not think that this is the case, please post the minimum amount of your code that you see this problem with, so that we can take a look at it.

Regards,
Laura

0 Kudos
Message 2 of 6
(2,885 Views)
how can i post my labview vi?

i can't post the whole program, but i have an excerpt i can show you without giving away any secrets.  can i email it to you?
0 Kudos
Message 3 of 6
(2,878 Views)

Hello ssingh,

When you reply to the message, there is an attachment option at the bottom of the screen.  You could post a screenshot of just the pertinent area for us to look at.

Regards,
Laura

0 Kudos
Message 4 of 6
(2,866 Views)
ah, sorry i missed that before --

here is the screen shot.  let me know if you have any questions...
0 Kudos
Message 5 of 6
(2,864 Views)

Hello ssingh,

I do think that you have a race condition in your code.  You have a local variable called "input cluster" that may not be updated with your newly calculated values before it is read into your DAQmx code.  You need to have an order of execution defined so that this does not happen.  You can do so a number of ways, the best way is to hardwire the output of the MATLAB node to the input of your DAQmx code.  So, the input cluster control would be in the input to the MATLAB node, and then the output of the node would be hardwired to the unbundle by name.

Hope this helps,
Laura

0 Kudos
Message 6 of 6
(2,837 Views)