LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Highlight Execution

Please post your most recent code.

0 Kudos
Message 11 of 27
(1,690 Views)

here's the most recent vi

0 Kudos
Message 12 of 27
(1,689 Views)

Well, you have a number of problems with that VI.

  1. The VISA functions should not be in that first loop. All you're accomplishing is opening new sessions every 2 seconds. Place those VIs outside the while loop. You can keep the VISA resource name control inside the loop and tunnel it out so that data dependency will make sure the VISA functions don't execute until the loop is done.
  2. The VISA Open is not necessary.
  3. Instead of polling in the while loop, waiting for the user to press OK, use an event structure. If there's no change in the controls why do you need to recalculate the values every 2 seconds?
  4. I have no idea what you're doing with those global variables. It appears that you are trying to create a state machine in the second part. That's the wrong way to do it. Please look at the KnowledgeBase article on state machines: Application Design Patterns: State Machines
  5. The case structure around the right-hand while loop is irrelevant. There is no way this can be false. The first loop will not stop until the OK is pressed, and at that point the value of the wire is true. This will always be the case.
  6. By definition, if you run a loop until the iteration is some fixed value, then you actually have a for-loop. Thus, your right-hand part of the code should be a for-loop, with N = "Total Intervals".
  7. When RunVar = 0 you are running a for-loop. The delay is after the VISA Read. The delay should be between the VISA Write and the VISA Read. Instead of using a for-loop to do something like that, just string the functions in series using the Time Delay VI (see attached figure).
  8. The issue with the delay being in the wrong place also occurs when RunVar = 1 and 2.
  9. You should be using a shift register to pass the error around the loop. Otherwise it will get cleared with each iteration.
Message 13 of 27
(1,679 Views)

Your wait will occure after the read due to LV optimization, what you need to do is place a single frame Sequence which contains the wait in between write and read.

Now you'll write and read during the same microsecond before the VISA buffer is even filled (thus you get 0 read) and then wait 2 sec.

 

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 14 of 27
(1,659 Views)

@Yamaeda wrote:

Your wait will occure after the read due to LV optimization, what you need to do is place a single frame Sequence which contains the wait in between write and read.

Now you'll write and read during the same microsecond before the VISA buffer is even filled (thus you get 0 read) and then wait 2 sec.

 

/Y


Y,

 

Where do you see this in the latest code that was posted?

0 Kudos
Message 15 of 27
(1,649 Views)

 


@Yamaeda wrote:

Your wait will occure after the read due to LV optimization,


???? Smiley Surprised

 

0 Kudos
Message 16 of 27
(1,637 Views)

So I got the program to run smoothly, except for one problem. The hot plate turns off between readings now and i'm not sure how to fix this? is it because i removed the while loop so it isn't polling anymore? 

thanks!!

0 Kudos
Message 17 of 27
(1,622 Views)

forgot to post the new vi, sorry lol. 

here it is

0 Kudos
Message 18 of 27
(1,621 Views)

nevermind, it's because i have the for loop instead of the globals, 

i was just wondering though if there was another way i could do this without using globals? would i use an enum instead?

0 Kudos
Message 19 of 27
(1,605 Views)

I would highly recommend you look at examples using state machinies. Your code is very difficult to read as well as it is extremely inflexible. What you have essentially written is a series of flat sequence structures disguised as For loops. You generally place the event structure inside a while loop so it can catch more than a single event. If you use a state machine you could would be able to have a more flexible implementation of your application, it would be MUCH easier to understand, you could catch and handle errors when/if they occur and benefit from using shift registers to pass data between the states (i.e, replace the use of globals).



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 20 of 27
(1,590 Views)