03-24-2010 05:57 PM
Im trying to build a VI that will alllow a lobster with a magnet on its back to trigger a heater to turn on when a field of appropriate magnitude is detected. When a field is detected the sensor DAq outputs a voltage which will eventually turn the heater on in some as of yet undetermined way. Anyway, the important thing is that the sensor DAQ is able to output the voltage. The magnetic sensor component of the VI works fine but i am having difficulty in making it so that the voltage output ceases after a certain period of time (6 secs in attached VI), and then is able to be turned back on by magnetic stimulation after more time has elapsed (18sec). However, i keep getting "error code 2008 occured at DAQ mx read" shortly after 18 seconds has elapsed.
note this VI is far from finished, for my purposes i am assuming that when the VI begins to run the lobster has just activated the heater, thus the heater times starts just as the VI begins running. If anyone knows how to make it so that i can initiate the elapsed timer VI when the magnetic threshold is reached, that would be helpful as well...
Thank you
03-25-2010 08:37 PM
Hello llehctim,
The error you mention crops up when a task has been closed and then later the task is referenced again. I noticed that you have repeat set to off in the Express VI where you have your AI inputs coming from. I would guess that the code is automatically closing your DAQ reference and when you have it in a loop to be called again, it throws the error.
I will also caution you to place constants on your conditional terminal (the terminal that determines when you stop your loop). This means that once you start your code that you are using the big red abort button. This is like stopping your car with a brick wall. Yes, you can do it, but it doesn't take the proper steps to release resources and can leave hardware or any other references in a bad state. Use a stop button instead so that you properly close your DAQ tasks. This could also be why you might see weird errors.
As far as time tracking goes, functional global variables are the most efficient manner of programming this. As this is a slightly advanced coding concept, you can also use the "Elapsed Time VI" which is another express VI. Feel free to post back if you would like some more help or guidance.