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: 

How to create a start button

Solved!
Go to solution

@rr1024 wrote:

What would be the best way to go about this, should I use an event structure or conditional disable structure or some other method 


Obviously, you had very, very little exposure to LabVIEW and your code is full of rookie mistakes. The problem you are describing is just the tip of the iceberg. Start with a few tutorials. Look at the code examples. Look at the desgn templates that ship with LabVIEW.

 

If you even mention the conditional disable structure in this context, it is obvious you have no idea yet. Don't despair, labview has a quick learning curve and you should be up and running quickly. ...and we are here to help you.

 

Let's look at your code:

 

  1. As a first step, you need to understand dataflow. Your "measure" terminal is read exactly once at the start of the program and then never again. You will not be able to use it to stop the loop, for example. If it should be polled at each iteration, the terminal belongs inside the loop.
  2. Your loop rate is determined by the power of the computer, the speed of the instrument communication and the speed of the file io and thus it is not deterministic. I would strongly recommend to define the loop rate in some way.
  3. Read the help. You don't need to get the time and wire it to the format time function. If you leave it unwired, it uses the current time. same result, half the code!
  4. Your browse option only allows selection of an existing file. Is that really what you want?
  5. Your loop should stop on error, so if the resource is invalid, it won't continue banging its head against the same function and writing an endless stream of meaningless garbage to a file.

As others have said, you need a very simple state machine. Learn about shift registers to maintain state across iterations. Validate all inputs and only enable the start button once the file path and resource has been verified to be good. An event struture have been suggested earlier, however I would strongly recommend not to place interactive loops inside event cases. There are better ways!

 

 

0 Kudos
Message 11 of 14
(1,452 Views)

@RTSLVU wrote:

@RavensFan wrote:

RTSVLU,

 

Did you try running your VI?  It won't work.

 

Your event case is set to lock the front panel until the even completes.  You hit measure and the event case starts and the while loop starts.  The event case won't finish until you stop the while loop by hitting the measure button again.  You can't hit the measure button again because the front panel is locked.

 

A proper state machine would have in intialize, close, and a timeout for the event structure.  No inner while loop in any case of the event structure.


Nope, I did not.

 

Like I said I do not understand the event structure. I think I have used it maybe twice since it was added to LabVIEW. 

 

I know what you are saying about a state machine, 99.999% of my programs are a state machine. But I really did not want to totally rewrite the vi since the whole thign is a kludge to begin with, might as well kludge in an event structure.

 

BUT you are correct this entire vi needs to be re written from the start using a state machine.


While it didn't work I did kind of figure out how their little event state kind of works, so thanks ;-), I'll eventually get around to re-writing the whole thing. For now I'm learning on one of thier example programs and trying to make it do and behave the way I want as a learning excercise.

 

So, while it didn't work, and even the one I created after that didn't exactly the way I wanted, I figured out how to get the user data into the event and start the event. So thanks 

0 Kudos
Message 12 of 14
(1,443 Views)

On a side note, you might want to change your signature so it does not look like it is part of the regular post. Jokes are only funny the first time (or even never!) and your signature makes things very, very repetitive. Please tone it down a bit. Thanks.

0 Kudos
Message 13 of 14
(1,437 Views)

@altenbach wrote:

@rr1024 wrote:

What would be the best way to go about this, should I use an event structure or conditional disable structure or some other method 


Obviously, you had very, very little exposure to LabVIEW and your code is full of rookie mistakes. The problem you are describing is just the tip of the iceberg. Start with a few tutorials. Look at the code examples. Look at the desgn templates that ship with LabVIEW.

 

If you even mention the conditional disable structure in this context, it is obvious you have no idea yet. Don't despair, labview has a quick learning curve and you should be up and running quickly. ...and we are here to help you.

 

Let's look at your code:

 

  1. As a first step, you need to understand dataflow. Your "measure" terminal is read exactly once at the start of the program and then never again. You will not be able to use it to stop the loop, for example. If it should be polled at each iteration, the terminal belongs inside the loop.
  2. Your loop rate is determined by the power of the computer, the speed of the instrument communication and the speed of the file io and thus it is not deterministic. I would strongly recommend to define the loop rate in some way.
  3. Read the help. You don't need to get the time and wire it to the format time function. If you leave it unwired, it uses the current time. same result, half the code!
  4. Your browse option only allows selection of an existing file. Is that really what you want?
  5. Your loop should stop on error, so if the resource is invalid, it won't continue banging its head against the same function and writing an endless stream of meaningless garbage to a file.

As others have said, you need a very simple state machine. Learn about shift registers to maintain state across iterations. Validate all inputs and only enable the start button once the file path and resource has been verified to be good. An event struture have been suggested earlier, however I would strongly recommend not to place interactive loops inside event cases. There are better ways!

 

 


Yes, in labview I'm a rookie considering I just convienced myself I needed to learn this thing a few days ago and FYI this vi is from a NI example code that came with the program and I had th need to do some automatic measurements so I started modifing the Agilent 34401 Read Single Measurement.vi.

 

Is this forum not for help with labview projects? I thought this forum was like stackoverflow for LabView but maybe I"m in the wrong place?

0 Kudos
Message 14 of 14
(1,435 Views)