From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Runs perfectly, then fails.

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

0 Kudos
Message 1 of 13
(3,908 Views)

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.

0 Kudos
Message 2 of 13
(3,889 Views)

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.

Message 3 of 13
(3,854 Views)

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!!!

 

 

0 Kudos
Message 4 of 13
(3,836 Views)

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:

 

 

  • Use a proper state machine as toplevel VI.
  • Don't use loops that spin like crazy doing nothing. For example the strings only need to be regenerated if the inputs change, and not millions of times per second.
  • Use shift registers instead of the globals.
  • Rewrite all formatting, scanning and other hex gymnastics in a style as above. The target is to distill it down to 10% of the current code complexity. Should be easily possible.
  • Eliminate all code that is useless!

 

0 Kudos
Message 5 of 13
(3,821 Views)

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). 

0 Kudos
Message 6 of 13
(3,782 Views)

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!

 

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



Message 7 of 13
(3,772 Views)

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? 

0 Kudos
Message 8 of 13
(3,705 Views)

There are still many things wrong with your program.

 

 

  • Your two controls are still DBL. Change the representation to U16 as instructed! (orange terminal=bad!)
  • You still have a polling loop that consumes 100% CPU of one core.
  • You still have useless loops.
  • You still uses while loops as FOR loops
  • In the upper small while loop you open visa twice, but never close it.
  • The way you are converting the read string makes no sense at all. You need to reverse the operation (split, calculate checksum, verify checksum, etc). How does the received string look like?
  • ....etc. etc.
Why don't you start out with a few simple LabVIEW tutorials. You should not program in LabVIEW unless you have some basic understanding of it. Just programming like a wild boar in a vegetable garding is a huge waste of time!

 

 

0 Kudos
Message 9 of 13
(3,693 Views)

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

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 13
(3,680 Views)