07-11-2008 05:48 PM
07-11-2008 08:51 PM
You have serious problems understanding dataflow.
Your problem is that the while loop for your digital write is dependent on the completion of the first while loop. Your first while loop runs continuously until the comparison becomes false (because you have a run while true condition for that loop). Only then does the boolean value of false exit the loop and the 2nd while loop can begin.
In your Bakeout module VI, you have false going into the loop. (It can never be True because if it was, the first while loop would still be running and the boolean coming out of the loop wouldn't be there yet.) So the digital write in the True case doesn't occur, the boolean is still false, and the 2nd while loop exits after the one iteation.
In your Bakeout control VI, you have a different situation. You still have a false going into the 2nd loop. The while loop begins its first iteration. Because i=0 (true) is ORed with the false, the True case will execute and the digital write will put out the false. Because there is no error to stop the 2nd loop, it will iterate again. Now I=0 is false ORed with the that came in from the 1st loop. The false case will execute, nothing happens, there is no error and the loop won't stop because it only stops on an error. You are now stuck in an endless while loop executing as fast as the processor will allow it.
What I believe you want is two independent while loops. You can't pass that boolean by wire. You will either need to use a local variable or a notifier to get the value from one loop to the other. Also, in the Bakeout control version, you will need some other alternative to stop that while loop besides just an error condition. Otherwise those loops will continue to be endless, and your master while loop will never get past the initial iteration and you would still need to abort the VI to stop.
07-14-2008 02:54 PM
07-14-2008 02:55 PM
07-14-2008 03:47 PM
07-15-2008 01:23 PM
07-15-2008 03:22 PM
In your topmost DAQmx read, you are comparing the # of samples available with the min number of samples to read and taking the maximum of those 2. Okay. But why are you feeding it into the timeout connector of the DAQmx read?
(Slide your close file function outside the while loop. Right now you see it has a shadow. That means it is not a part of the loop, but happens to be overlapping it.)
07-15-2008 04:57 PM
07-16-2008 04:37 PM
07-16-2008 10:03 PM - edited 07-16-2008 10:09 PM
Your code needs a lot of work and has major architecture problems. I am reattaching the VI with notes scattered throughout the diagram marking as many trouble spots as I see.
1. First you use too many local variables and in ways that would lead to race conditions.
2. You will have endless while loops. If a local variable is true (e.g. Thermo X on?) the loop will run endlessly as the local variable will never go false. The only place that variable gets updated is a piece of code outside the loop and that won't get calculated again until all the nested case structures end and the outer while loop ends. On/Off Master has the same problem. If true, the loops will run forever.
3. I believe this specific error is occurring because you have 3 sample clocks with finite sample of 1000 being created at the beginning. If these clocks all get generated at the same time (as I believe they will), they conflict with each other. Also there is a sample clock with continuous samples at the beginning of code. I don't know how many sample clocks you can create at once.
4. Since you are primarily using lower level DAQmx functions, there is no need for the DAQ assistants at the beginning of the code. They really aren't doing anything but defining the channel. Just use constants for the appropriate channels fed into the lower level DAQ functions.
5. You duplicate a lot of code between true and false cases with very few differences. So you wind up with 4 times as much code as you need.
6. You have 3 loops that all do the same thing, just on different channels. These could all be subVI's. So now your are 12 times as much code as you need. I think this is why your VI is so large at 626 kB for something that should be rather simple.
7. What you really need is a producer/consumer architecture with state machines. Put all of your DAQ functions in a single loop. The 3 4 analog inputs should be merged into a single task. I would write their values to the indicators, or better yet use an Action Engine to store their latest readings. Other parts of code can use the action engine to read the latest value. Keep your decision code in separate while loops. Keep your data logging in a separate loop, you can pass what you want to write to file through a queue.
I would recommend you take a few steps back and get things working with 1 analog input first. Then add the data logging functions. Then expand your code to work with 3 channels instead of just one.