LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a start button

Solved!
Go to solution

When ever I run this VI and the VISA resource is not set correctly it automatically throws and error

"Error -1073807346 occurred at VISA Open in Agilent 34401.lvlib:Initialize.vi->34401A DMM Monitor.vi"

 

My intent of the "Measure" Button is to use it as a "Start Button" so it doesn't throw the error as soon as a user runs the program when he/she has not even had an oppertunity to select a file or VISA resourse and at the same time I'd like to enable the while loop.

 

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

0 Kudos
Message 1 of 14
(8,220 Views)

Hi rr,

 

an event structure will be nice as it avoid polling UI elements…

 

I also recommend to integrate some error handling so you can catch errors like the one you just received!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 14
(8,215 Views)

I'm not sure how this event structure works I added an event but how do I tie the measure button into is so the program starts when the user hits measure?

0 Kudos
Message 3 of 14
(8,187 Views)

@rr1024 wrote:

I'm not sure how this event structure works I added an event but how do I tie the measure button into is so the program starts when the user hits measure?


Please go through state machine architecture and how to handle events

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 4 of 14
(8,158 Views)

@PalanivelThiruvenkadam wrote:

@rr1024 wrote:

I'm not sure how this event structure works I added an event but how do I tie the measure button into is so the program starts when the user hits measure?


Please go through state machine architecture and how to handle events


Fortunately I already know how a statemachine works and have years of creating them in C, C++, PHP, VBA, # ... languages and the examples on NI's website suck, do little more than show you the graphic with an explanation of what it does and no real step by step use.

 

From NI's silly examples I tried the following which doesn't do anything...lol

0 Kudos
Message 5 of 14
(8,132 Views)

If you already know how a state machine works with other languages, then why are you asking us? It's pretty easy to see how it works just on the examples. Have you even used the Tutorials to help guide you?

0 Kudos
Message 6 of 14
(8,129 Views)
Solution
Accepted by rr1024

I am kind of old school and do not find much use for event structures but.... give this a try.

 

evnt.png

 

I am sure somene here that actually understand event based programming could do better.

 

Oh BTW: The timeout case is empty

========================
=== Engineer Ambiguously ===
========================
Message 7 of 14
(8,125 Views)
Knowing how to do something in some other language often means little in LabVIEW. Every language (human or computer) is different, with different assumptions and often very different approaches to how ideas and concepts should be expressed. Two recommendations:

1. Forget as quickly as possible what you know about text based languages -- it will seldom be helpful.

2. To get one take on how to build a proper LabVIEW state machine, check out this post and the one following:

http://www.notatamelion.com/2015/02/23/building-a-proper-labview-state-machine-design-pattern-pt-1/

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 8 of 14
(8,120 Views)

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.

0 Kudos
Message 9 of 14
(8,107 Views)

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

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 10 of 14
(8,098 Views)