01-25-2011 01:45 PM
Hello,
I am running an experiment using a potentiostat and a hotplate and a timeout error appears at random times. For instance, the programs will run properly sometimes but other times (most of the time) the error will appear within 15 min or 45 min and so on of the experiment. I'm not sure why. I have attached the VI's below.
The error for the hotplate always occurs at the second VISA read after the visa write of "FEA2 0000 00A2" and the error for the potentiostat occurs at the VISA Read after the VISA wirte of "READI"
Thanks
01-25-2011 02:31 PM
Your code looks very problematic and is also overly complicated.
A quick glance at potentiostat (I haven't looked at the other program):
This entire thing is too linear. Are you restarting after each experiment or are you using continuous run button?
The greedy loop for setup on the left needs a wait. Once that loop finishes, you are writing to the VISA in three different places at once, probably in random or even interlaced order. (In the top loop, in the bottom loop, and at the very bottom.) Shouldn't there be some order? Shouldn't the lower while loop be a FOR loop? You know the number of iteration before it starts, right.
What is the purpose of the big case structure? The false case can never execute anyway, so remove the structure.
I would suggest you design it as a state machine. Most of your globals cound be replaced by shift registers or wires.
01-25-2011 10:13 PM
A problem in the potentiostat stat VI is the parallel loops with VISA Writes to the same resource. You simply cannot do that. You have no way of knowing the order of the Writes and Reads.
There are other strange pieces of code in the other VI. Why would you have a for loop that iterates once? Your hex-num and num-hex subVIs are a testament to Rube Goldberg. All you need is a single typecast in both of them.
01-26-2011 01:03 AM - edited 01-26-2011 01:04 AM
Looking at the hotplate VI, I agree with Dennis that there are serious problems too. You probably should start with a few simple tutorials about datatypes, flat data, etc. Programming like you currently do will only end in grief and countless wasted hours.
For example, let's have a quick look at the while loop on the left. If you make the controls the correct representation (U16, I think), none of the conversions are needed. All that gymnastics to hex and back is not needed. (As Dennis mentioned, a simple typcast would suffice!) There are also serious flaws in the code, for example try a "Stirring" setting of 672 and look at the string output!).
Here's your code to generate the two strings from the two controls:
And here's a 2 minute rewrite, done properly. Except for the few cases where your code is broken, they produce the same output. 😉 As you can see, none of your subVIs are needed. (There are many other simple ways to do all this)
All the rest of your code could be cleand up similarly. You have 90% too much code!!!
01-26-2011 01:31 AM - edited 01-26-2011 01:37 AM
See also this discussion in the Rube Goldberg thread.
Let us know if you need further help to fix your code, here's a general plan:
01-26-2011 10:54 AM
Thank you so much for your help! I was left these programs and am also a beginner in labVIEW so i'm currently learning how to use this program. Are there any quick ways to learn labVIEW? (to construct/fix this program).
01-26-2011 11:35 AM
Other than taking the LabVIEW courses, no. Even then it will give you most of the basics, but not experience. There are examples (some better than others) in the LabVIEW Help, and there are LabVIEW tutorials. Also the book "LabVIEW for Everyone" by Jeffery Travis and Jim Kring is a good starting point.
Also, asking questions here, particularly if you post your attempts. can be very educational.
Welcome to "the club" of LabVIEW programmers!
01-31-2011 12:22 PM
Hello,
I was wondering what was wrong with my program and if anybody could help me out again. I realize the program writes to one visa read but i'm not sure how to fix this. Also after the last visa read, is the code that follows correct?
01-31-2011 12:39 PM - edited 01-31-2011 12:44 PM
There are still many things wrong with your program.
01-31-2011 01:31 PM
Why do you write to Visa, read it back (atleast partly) and throw away the result? That's just a bad way to empty the buffer.
/Y