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: 

Short run time

Solved!
Go to solution

Hi all,

 

I have wrote and modified this code. There's no error in the code, but I am having hard time of fixing the run time. It runs only up to maximum of 350 iteration. I wanted to run until I receive a true value; before it gets there it just says PASS which is my true value. But the computation is not true. Below is an attachment of my code. If you have any idea how to fix this please make suggestion.

 

Thank you in advance

0 Kudos
Message 1 of 7
(2,664 Views)

Suggestions:

 

1.) Get rid of the sequences and use a state machine architecture

2.) Wire the error in/out clusters to shift registers in your loop.

3.) If the computation is not correct,but you are getting a true then you logic is somehow flawed.  Can you explain how the computation is supposed to work?

>

"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
0 Kudos
Message 2 of 7
(2,659 Views)

Why do you keep configuring your serial port on closing it?  Initialize it once before your main loop and close it once after the main loop.  Everything inside of the main loop should be reads and writes.

 

Also, for your stop logic, use the In Range and Coerce function.  It'll save you some room and help avoid stupid logic errors.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 7
(2,650 Views)

I went ahead and cleaned up your code so that there is only 1 error path, removed locals, only close the serial port once, and (best of all) removed the sequence structures.  Yes, the VI looks long, but that's fine.  I would highly recommend making subVIs for each of your tasks (what you used to have as sequence steps).  See if this works for you.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 7
(2,645 Views)

The code you wrote doesn't work because the write visa out is not connected to anything; and the Visa Read gives error -1073807253. And I used case structure because I wanted the program to compute by precedence.

0 Kudos
Message 5 of 7
(2,617 Views)
Solution
Accepted by topic author gltfrs

Ha, silly me.  I forgot to wire up a few of the VISA Resources to the next function.  If you fix those up, it should work fine.  You don't need the sequence structures because the data flow will take care of the order for you.  That's why the error cluster and VISA Resource should be propagated to each function.  The only time you need the sequence structure is for the waits, since there's no error input for them.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 7
(2,613 Views)

Your code didn't really worked for me. But I modified the code and your suggestions were very helpful.

 

Thank you

0 Kudos
Message 7 of 7
(2,584 Views)