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: 

Alternative to event structures?

Hi Anna,

 

Please post your code so we can take a look at it.

Also, if you are looking for examples, you might want to try the NI Example Finder: with LabVIEW open, go to HELP>Find Examples.... Make sure to select "Include ni.com examples"

You also might have some luck checking out NI Developer Zone.

Regards,
Claire Reid
National Instruments
0 Kudos
Message 11 of 27
(1,338 Views)

Hi Anna,

 

You might also want to check out one of our online LabVIEW Introduction Courses. We have a Three-Hour and a Six-Hour course. You would only need to go through one of the two, as the Three-Hour is included in the Six-Hour.

Regards,
Claire Reid
National Instruments
0 Kudos
Message 12 of 27
(1,315 Views)
Noooo!!! Don't abandon me, veterans!  I'm sorry about the delay in posting my code.  I've been caught up with all the trivial things that get in the way of me improving my labview; like school and tests.  If anyone has a few minutes to glance at my code, and give me some feedback, I would REALLY appreciate it. I've already tried to incorporate your suggestions as well as I can for now.  (I should have posted the whole code before, you might be heartened at the progress).
 My main two concerns now are 1) improving my code, and 2) restructuring things in an event-case-like system so that the user can change a setting and the program will detect the change and execute the appropriate code (send a VISA message to the hardware for that particular setting).  This would replace the true/false case structures which are in place now, where the user has to change the setting and then press "set."  "Test.vi" is just an example of my understanding of how to poll the FP for a change in an array.  Is this the best way to do it? The attached picture I found from a book by David Rutter in google books.. It shows how to cluster FP booleans and detect a change.  Is there an equivalent way to cluster FP arrays and detect a change (and know which array that change came from)? Or do I just have to have 20 separate comparisons?   I know you guys are busy, but I don't need you to do it for me.. Just give me some ideas and I can try to implement them!  Thanks in advance.  PS. I know the FP is kind of confusing, I'm going to change that when I settle on a final UI approach.
 
 In response to Altenbach:
    * If you are really serious about LabVIEW programming, you should probably upgrade to LabVIEW full
at one time. Smiley Happy


I agree! But I'm kind of a "go-fer" right now.. I have to work with the tools that I'm given.  Maybe my
boss will have a generous day and decide to buy an upgrade!
(Also; I want to learn to write good LabVIEW code, but I'm a physics undergrad, so I will probably  never
get much more in-depth than what is required for the experiment.)

    * You make some serious "beginner mistakes" and use way too many local variables and value property
nodes. You seems to use them like old fashioned "variables" of text based code. For example you get the
loop iteration into a terminal, then read from the local variable of the loop iteration indicator and
compare it with zero. All you need is wire [i] to the case structure and make one case "0" and the other
the default. 90% less code!


Done- thanks for the suggestion!

    * A local variable just points to the terminal, so for example in the image below you don't need to
read from the local variable if the terminal is right there! Just bvranch the wire (see image). This also
eliminates the race conditions (see below).


Thanks for pointing this out.  Looking at it again, I can't remember how it ever made sense to me the way
I had it.  I've tried to improve this- however the program requires a lot of resetting the controls and indicators
(e.g. to set the default, to set parameters from a file, to read the settings from the hardware and initialize
at the beginning) so I'm not sure how to go about getting rid of the remaining local variables.


    * In addition, you might get serious race conditions, because LabVIEW does not guarantee that the local
variable is only read after the new value is written to the terminal. Most likely, a stale value is read
first and placed into the value property. LabVIEW does not execute left-to-right. Order is determined by
dataflow, and if dataflow is broken due to the absense of wires, execution order is unpredictable.


Again, I'd LIKE a predictable execution order! But I'm still a little stumped about the best way to reset the
controls and indicators..

    * Value property nodes are several orders of magnitude less efficient than wires or local varaibles.
If possible, use wires, else local variables.

Thanks for the suggestion- I've changed all the value nodes to local variables.

    * Make a state machine instead of a code worm that is 10 screens wide. Code should fit on one monitor
screen.


I'm a little stumped about how to implement this.  With an event structure, I can see just having every
control on the FP be another case.  Without event structures, the most obvious method to me was (as I
have it) multiple true/false case structures. Which I know isn't ideal.

Also, thank you Gabriel for your encouragement! And thanks Claire for the examples suggestion.  I've been
able to utilize the examples fairly well to self-teach and get where I am (i.e., the very basics, then
how to use VISA and programming structures, etc).  The problem I'm running into now is finding examples
of how respond to FP activity without event structures.  
Download All
0 Kudos
Message 13 of 27
(1,295 Views)
Message Edited by fsustudent on 10-22-2008 01:51 PM
0 Kudos
Message 14 of 27
(1,295 Views)

If you are a student at Florida State University (fsu, of course there are a few others with that acronym), you should find out if there is a campus license available. There are some great LabVIEW programmers there, so you might try to contact one of them for options. Also see if there are local user groups.

 

If you are a student and want to explore full LabVIEW for your own studies (not work related), you might want to look into the student edition.

 

(Sorry, I currently have limited internet access because of ISP problems. I am not sure when I will have time to deal with all this in more details.)

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

Hello everyone,

 

I think my problem is related to the present topic.

 

Context : I am using an Envent Structure to change tab while VI is running by pushing a button; It works perfectly when the VI is located on my computer. But as soon as I target the same VI in a PXI controler (via ethernet connection) the Envent Structure doesn't respond. I already know the problem : the event structure only works with interaction on Front Panel and while targeted PXI doesn't have front panel, there is no interaction (the issue is explained here).

 

Question : Is there any way to replace Event Structure properly ?

 

Thank you.

 

Regards.

 

BlockDiagram.png

FrontPanel.png

 

 

 

0 Kudos
Message 16 of 27
(795 Views)

@Mars13 wrote:

Question : Is there any way to replace Event Structure properly ?

 


Yes.

0 Kudos
Message 17 of 27
(784 Views)

@Mars13 wrote:

Context : I am using an Envent Structure to change tab while VI is running by pushing a button; It works perfectly when the VI is located on my computer. But as soon as I target the same VI in a PXI controler (via ethernet connection) the Envent Structure doesn't respond. I already know the problem : the event structure only works with interaction on Front Panel and while targeted PXI doesn't have front panel, there is no interaction (the issue is explained here).


So you have an embedded PXI controller (I assume RT).  So why does it matter what the tab value is?  You need to stop thinking about GUI responses and start thinking about what signals the Queued Message Handler to do something.  I recommend making use the the Simple TCP Messaging (STM) library.  You need to have an application on your main PC that communicates with the PXI controller over the TCP connection.  From the TCP commands, the PXI can then do what it needs to.


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 18 of 27
(774 Views)

Hi altenbach,

 

Thank you for your reply.

 

You mean "Yes" there is a way to replace Event Structure or "yes" there is no way...?

 

I was just wondering if an alternative existed before the implementation of Event Structure in LV  (version 6.1) ?

 

Regards

 

Mars.

 

 

0 Kudos
Message 19 of 27
(764 Views)

Thank you for your reply cfossrulz.

 

I am not sure I completly understood.

 

I am already communicating using IP adress. But each time I use board in the PXI, labview need to load VI into the PXI controler before running.

 

As far as possible, I just want to use PXI boards (via PXI controler) like any GPIB or USB instrument from my PC without loading VI into PXI controler. And I also want (if possible) to keep my GUI (Front panel ?) as it is. Do you think it's possible using TCP messaging as you suggested ?

 

At that stage, I don't want to use RT option but just using PXI like it was an instrument. I'll see RT implementation later.

 

I don't know If I express this properly because most part of the time I am using labview for basic purpose (+ my english is far from perfect)...

 

Regards.

 

 

0 Kudos
Message 20 of 27
(746 Views)