LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I read elements in four arrays and store in variables?

Solved!
Go to solution

Greetings,

 

I have 4 arrays that I will read to control an autonomous robot vehicle as instructions.

 

I need to be able to read the first elements in each array and store in 4 separate variables (direction, speed, angle, distance). Then wait until that first instruction has been executed. Then I move on to the second elements in each array. I will repeat this until I have gone through all the elements. I am struggling to figure out how to do this?

 

Please note:

-The number of elements in the arrays are always the same, although the number of elements vary because the can be less instructions or more.

 

 

For example a complete instruction takes 1st element from array 1, array 2, array 3 and array 4 and this builds up something like: Forward, 10, 20, Left. This then will result in the robot moving Forward at a speed of 10 for a distance of 20 and then make a left turn. Once thats done then it takes the  2nd elements and so on.

 

Please find attached my VI that reads a text file and creates the 4 arrays.

 

Thank you. 

0 Kudos
Message 1 of 7
(3,240 Views)

Hi Stan,

 

I need to be able to read the first elements in each array and store in 4 separate variables (direction, speed, angle, distance).

Well, right now you read a 2D array and get it's first 4 columns in seperate indicators…

 

LabVIEW doesn't use "variables" in the same way as text-based programming languages, values are stored in wires and shift registers. When you have problems understanding this you should take the (free) beginner courses offered by NI…

 

I am struggling to figure out how to do this?

Learn about using "auto indexing" with loops. It will make your live easier - and solve your current problem too!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(3,218 Views)

Hi GerdW,

 

Firstly, I would like to thank you for your time replying to me.

 

Unfortunately, I don't think you understood my question.

 

Kind regards,

0 Kudos
Message 3 of 7
(3,210 Views)

Hi Stan,

 

Unfortunately, I don't think you understood my question.

I think I understood your question very well.

I even think I gave you the correct answer.

 

When you still think, that's not the case: Explain your problem with more details and examples…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 7
(3,204 Views)
Solution
Accepted by topic author stanm13

stanm13 wrote:  Unfortunately, I don't think you understood my question.

Then I would say either a) you don't understand the answer or b) you did not explain it well enough.

 

To perform each element in an array, using a FOR loop with autoindexing inputs is the way to go.


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 5 of 7
(3,193 Views)

Thank GerdW.

 

I know where I was going wrong now.

 

Kind regards,

0 Kudos
Message 6 of 7
(3,180 Views)

Thank you crossrulz.

 

It was a mixture of both.

 

Kind regards,

0 Kudos
Message 7 of 7
(3,178 Views)