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: 

Is it possible to change indicator/control depending on enum?

Solved!
Go to solution

(Channeling my inner C.A.)

 



@jdepypere wrote:

Here's the current code, in a case. In the top while loop there is also the 'virtual' option, where nothing happens.

Capture.PNG

 

Here's another sot of the bottom while, where the 'reset' and 'start' buttons are used.

Capture2.PNG

 

Oh, and the red boxes are drivers to use the DAQ, they initialize, read/write and close the connection.


The code above makes very little sense.  In the first picture the flat sequence structure in completely un-needed and does nothing useful to the code execution.  So, why is it there?  Yes, I really want to understand why you chose to place it and help you understand LabVIEW and dataflow.  The bottom loop appears to be something that looks like it wants to be a state machine but is a proverbial "Re-invented Wheel" with a poor understanding of "Round" (use the example finder and read about state machines)  After reading up on State Machines take a look at Queued Message Handelers (Example: Producer Consumer (events)") and you will avoid some potential race-conditions.

"Should be" isn't "Is" -Jay
0 Kudos
Message 11 of 21
(1,249 Views)

Well this is done analog to an example of my teacher, so I would assume it was done correct... Wasn't sure why he used a flat sequence either, but assumed it wouldn't hurt the program to be sure the connections would be opened before something could perhaps get written.

 

As for the FSM, it is meant to be a FSM indeed, and it is again done the same way as an example we got from our teacher. I'll give it another look though, thanks.

Message 12 of 21
(1,243 Views)

@jdepypere wrote:

 

As for the FSM, it is meant to be a FSM indeed, and it is again done the same way as an example we got from our teacher. I'll give it another look though, thanks.


That begs the question- At what institution are you enrolled?  (I Almost dangled a particple there) Smiley Very Happy

 

<side note>

the classic joke goes"

American studying an Oxford: Excuse me, where is the library at?

Oxford Prossessor: Here, at Oxford, we do not end our sentances with a preposition.

American studying an Oxford: OK, where is the library at jacka$$?

 


"Should be" isn't "Is" -Jay
0 Kudos
Message 13 of 21
(1,236 Views)

I dare not answer that question 🙂

 

We just have to build a rather simple FSM, no rocket science involved, and we didn't get any LabView lessons.

 

I would say the flat sequence is there so that the while loops don't start reading/writing values to the DAQ even though the ports haven't been initialized yet, thus preventing a first falsified loop, no?

 

As far as the FSM itself goes, I can't really find any 'state machines' in the example finder that resemble anything like we saw in class. I've only got this one 'decent' (yet apparantly not decent) example to make a robot.

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

jdepypere wrote:

I would say the flat sequence is there so that the while loops don't start reading/writing values to the DAQ even though the ports haven't been initialized yet, thus preventing a first falsified loop, no?


Since there is a wired data dependecy, the loop cannot start until the initialization has finished. No need for a sequence. That is the power and magic of datafow!

0 Kudos
Message 15 of 21
(1,218 Views)

Oh, I was not aware of that. Has this been in all versions of LV?

 

It's just weird that my teacher would do stuff this 'wrong'.

0 Kudos
Message 16 of 21
(1,214 Views)

jdepypere wrote:

It's just weird that my teacher would do stuff this 'wrong'.


It is one of the central features of dataflow and has always existed.

 

It is not fundamentally wrong to add extra sequence structures, it does not break the code or change functionality. (90% of all beginners code posted here in the forums shows excessive and unnecessary use of sequence structures.

 

Some people, especially those trained in German bureaucracy, like things well organized and compartmentalized, otherwise they get lost if there is too much free spirited, free-form code without clear boundaries. 😄

Message 17 of 21
(1,211 Views)

To get back to this - I must've been a little distracted in class, on the slide it sais the flat sequence is purely for clarity.

 

No notes on the FSM though 😛

0 Kudos
Message 18 of 21
(1,193 Views)

The sequence structure has an important function in cases where execution order matters, but dataflow is insufficient to determine execution order. Only overuse is bad. 🙂

 

Often, the loss of data dependencies due to overuse of local variables requires more sequences to reestablish proper function. There are always better ways!

0 Kudos
Message 19 of 21
(1,188 Views)

Now that I'm at asking simple questions - say I have a led and I need to set/get the values in multiple places. Is it advised to use solely local variables from the led, thus leaving the original led linked to nothing in the diagram, or is it better to always have the original led linked up somewhere as well? Or does it not matter and is the second method better for cleaner code? I presume it doesn't really matter, and that setting the LED var instantly updates all the local variables (thus no race-conditions occuring), but ofcourse I'm not sure...

0 Kudos
Message 20 of 21
(1,139 Views)