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: 

Element insertion in Arrays

Solved!
Go to solution

I am new to LabVIEW, I go through certain LabVIEW online free tutorials and videos. I am trying to to do, in front panel user tell the dimensions of the array, then he inserts each element one by one and program should wait for user next value, to doing so I used two far loops to cater row and column and while loop to wait for user values.
Problem is it just get one value from me and then program stops and shows the array with only last index number new element. I hope I explained my problem well.
I am sorry, if I am in the wrong section.it's my first time to ask for help in the online community, looking for the best response. I have attached my LabVIEW file.

0 Kudos
Message 1 of 10
(3,033 Views)
Solution
Accepted by topic author Moonnight786

Hi Moonnight,

 

wh do you need all this stuff to fill a 2D array with user input?

Use autoindexing!

check.png

(You should rethink the inner while loop: it might be annoying not being able to input the same number for the next element…)

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 10
(3,027 Views)
Solution
Accepted by topic author Moonnight786

@Moonnight786 wrote:

I am sorry, if I am in the wrong section.it's my first time to ask for help in the online community, looking for the best response. I have attached my LabVIEW file.


This is exactly the right place, BTW.

 

The problem get's easier when you get to know (and properly use) the event structure.

 

To get to understand data flow, try the execution highlight. That will probably show you why the program stops and only returns one element.

0 Kudos
Message 3 of 10
(3,003 Views)

Thank you so much for the reply, I am a new user to LabVIEW, just messing with it to learn it. can you give me some basic tasks to do in LabVIEW, that would help me to establish my experience within LabVIEW environment? 

0 Kudos
Message 4 of 10
(2,981 Views)

Hi Moonnight,

 

something like this? Or the "Concepts" section in the LabVIEW help?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 10
(2,972 Views)

Of course if you want to see the array as it is buidling up, its terminal needs to be inside the loop and updated with each iteration. That's also where a shift register comes in to hold the data across iterations.

 

Here is a very simple draft that shows you how to interactively fill an array inside a loop. Note that one FOR loop is sufficient, no need for Aztec pyramids of loops. 😄

 

FillArray.png

 

To adapt your code you would add your inner polling loop. Personally, I would probably use a dequeue in this loop and use a separate loop with an event structure to enqueue a new value (and spin that loop to add an element). Then you also need to decide how to proceed once the array is filled, etc. A good playing field to learn 😄

 

 

Message 6 of 10
(2,953 Views)

Hello GerdW,


Thank you for your time, something like this also means to me a lot, and I tried to find "concepts" section in LabVIEW help I could not find it. 

I am a 3rd year mechatronics engineering student, I read about LabVIEW unique features and NI hardware quite popular in the market, so I want to learn it and also I wish to do my final year project based on LabVIEW. so any help to improve my skill willbe highly appriciated. As a beginner felt it is quite complicated than other programming environments.
Regards 
Moonnight,

0 Kudos
Message 7 of 10
(2,933 Views)

hi,

0 Kudos
Message 8 of 10
(2,931 Views)

Hi Moonnight,

 

see this

 

As a beginner felt it is quite complicated than other programming environments.

The main and biggest difference is the DATAFLOW concept: you don't use "variables", you use wires!

(Well, if you would program for PLCs (graphically) or with Simulink then the difference is not as big.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 9 of 10
(2,918 Views)

wrote:

As a beginner felt it is quite complicated than other programming environments.


It's only difficult when you look for similarities to those other environments (NXG looks more like VS BTW). For most people, LabVIEW will be a lot easier to start with compared to e.g. C++. But for most C++ programmers, LabVIEW is difficult. Letting go all those rules (and learning others) is not easy.

 

You'll have to learn to relax and go with the wire flow...

Message 10 of 10
(2,908 Views)