Jump to content

Create array of manually added values


Recommended Posts

Hello everyone,

I'm new to your community, so firstly I'd like to say hello to everyone :)

I guess the topic was repeated several times and I have read many examples, but most of them were concentrated on auto fill of array with random values. I however need to set values into array manually, memorize them, and if possible to go back and make changes in case of a mistake. These values are given from Tasti WB630 keyboard and determine line feed for each of electrical linear drive. In my vision UP / DOWN keys set index number which corresponds to a subsequent piston, LEFT / RIGHT keys set value of feed for currently indexed piston. After setting a correct value for desired piston I hit OK and the value is stored into array. But here my vision ends, because LabVIEW somehow doesn't want to memorize all of the input data except the last one given index and value.The code for now works like this:

Array:

set + OK
[0] 280
[1] 0
[2] 0
[3] 0
[4] 0

set + OK
[0] 0
[1] 50
[2] 0
[3] 0
[4] 0

set + OK
[0] 0
[1] 0
[2] 135
[3] 0
[4] 0

etc.

I'd like to make it work like this:

Array:

set + OK

[0] 280
[1] 0
[2] 0
[3] 0
[4] 0

set + OK
[0] 280
[1] 50
[2] 0
[3] 0
[4] 0

set + OK
[0] 280
[1] 50
[2] 135
[3] 0
[4] 0

etc.

So, can anyone help me out?

EDIT: I've added my source files with code needed for the emulation of Tasti keyboard and my work so far.

Main VI: tasti_emul.vi, SubVI's: Tasti_LR.viTasti_OK2.viTasti_UD.vi

Edited by Zer0
Link to comment

So you can use the initialize array, providing the data type (double) and the maximum size.  Then wire that to a while loop, turning the tunnel into a shift register.  This keeps data between loop iterations.  Wire it to the right, and the next while loop iteration will use that new data on the left.  So now you can use the replace array subset, replacing the index specified and the value.  You might be able to use the iteration terminal (i) of the FOR or WHILE loops if each iteration you replace the next value.

Link to comment

Thank you for your quick reply :)

My previos code looks like this:

post-53810-0-25469400-1438092300.png

And this one works as I desrcibed - it memorizes only the last index and value. Every previos input is nullified. Even if I rewire some connctions to fit your advice, my code still doesn't work:

post-53810-0-67912700-1438092949.png

 

Link to comment

Every time you start the outer while loop, you're going to start with the same initialized array coming into the wire. If you want labview to remember something from one iteration to the next, you need to put a shift register on that loop. The inner while loop does nothing as far as I can tell and probably should be removed.

Link to comment

Yup what he said.  The shift register should be on the first while loop, and remove the inner while loop all together.  You've probably seen these training things before but you should check them out if you haven't already.

 

Learn NI Training Resource Videos

3 Hour LabVIEW Introduction

6 Hour LabVIEW Introduction
Self Paced training for students
Self Paced training beginner to advanced, SSP Required
LabVIEW Wiki on Training

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.