08-01-2006 03:55 PM
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.
08-02-2006 02:07 PM
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
08-03-2006 05:02 PM
08-04-2006 02:19 PM
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
08-04-2006 02:31 PM
08-07-2006 01:34 PM
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