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: 

for loop

hai friends,

 

i am a beginer in the labview, i need a suggestion HOW TO GET A VALUE OUT FROM A FOR LOOP during the operation(runtime). 

 

what VI should perform:

1. As shown in the VI the module one generates an array which contains the number of channels selected (booleans enabled).

2. the module 2 & 3 have some data put in the arrays which has to be sent accordingly. [ module 2 is for differant tests & module 3 differant freq values ]

3. During the operation for each channel(i.e., selected from module 1) it should select one test and accordingly it should select the frequencies.

 

In the below attached vi the operation is being done, but the value that has to be sent is inside the for loop and i am unable to use that value during the operation.

 

element , element 2 and element 3 are the variables from which the data should be taken.

i have tried using with local variables, property nodes and shift registers. but the result is negative.

 

here the final array is the data that i have to send through serial port.

 

Please suggest me a appropiate solution.

thanks in advance

0 Kudos
Message 1 of 7
(2,910 Views)

Your code show a complete lack of understanding of LabVIEW dataflow and I would recommend to start with some tutorials and look at the shipping examples.  ...then design a proper state machine.

 

Some of the problems:

  • What's the point of the event structure? Looks like a one-shot deal. (are you using "continuous run" mode???)
  • Your Vi is full of race conditions due to the overuse of local variables. All your independent code fragments will start executing in parallel and there is no guarantee that indicators get  expected values before the local variables of these same indicators receive valid data. (look at the "final array", its value gets calculated way before any of the local variables have been written to.)
  • Maybe you should combine some of the FOR loops.

What is the program supposed to do?

 

0 Kudos
Message 2 of 7
(2,897 Views)

yes. i'm using it in continuous run mode.

program flow has to be as following:

channel selection(select the channelsusing booleans) ==>> then for each channel it has to perform each test(module 2 means send 17,33,49,65,81) ==>> then for each test it has to send 1-11 values.

 

if channel 1 & 2 are selected then:

 

for channel 1
1 17 1

1 17 2

.

.

.

.

.

1 17 11

1 33 1

1 33 2

.

.

.

1 33 11

1 49 1

.

.

.

1 49 11

 

like wise it has to send the data serially to controller for each channel all tests and 1-11 values.

 

i hope you have got some idea about what i am saying.

 

thanks

 

0 Kudos
Message 3 of 7
(2,886 Views)

You need to go back and learn LabVIEW before you begin tackling problems like this.

0 Kudos
Message 4 of 7
(2,844 Views)

Go read this, especially the links at the end which point to tutorials on LabVIEW.  It is nice to have a "reasonable problem" in mind when starting to learn a programming language, but you really do need to start with the basics.  In the case of LabVIEW, that means the concept of Data Flow ...

 

Bob Schor

0 Kudos
Message 5 of 7
(2,823 Views)

Oops, I screwed up the link.  Here's another try -- just in case I blow it again, it is Hooovahh's Unofficial Guide to Forum Etiquette, which includes a set of links to (free) training material.

 

http://forums.ni.com/t5/Feedback-on-NI-Discussion-Forums/Unofficial-Forum-Rules-and-Guidelines/m-p/3...

 

BS

0 Kudos
Message 6 of 7
(2,818 Views)

@Bob_Schor wrote:

Oops, I screwed up the link.  Here's another try -- just in case I blow it again, it is Hooovahh's Unofficial Guide to Forum Etiquette, which includes a set of links to (free) training material.


Here's the more controlled document over in the NI Communities: https://decibel.ni.com/content/docs/DOC-40451


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
0 Kudos
Message 7 of 7
(2,804 Views)