Jump to content

Storing in a 1D Array


Recommended Posts

Hello,

Before asking my actual question I would like to make a couple of comments.

1. This is truly a beginners question. I tried googling for help with arrays as well as the ni.com website for examples, but couldn't find anything.

2. I searched in this forum, but most of the questions here are far more advanced and difficult than what I am asking.

I am university student working abroad at a university in Germany for an 8 month coop term. I am writing this program to automate one of our experiments. [Note: not really relevant to the question, just explaining the program quickly -- most welcome to skip this part]. After entering the values on the front panel (most of this information is just used in the header) the program will set the voltage on the pulsar and then read two voltages across the laser from an oscilliscope). The voltages will be saved to an ascii file with the comment file.

My problem (at the moment) is storing the values from the front panel in an array.

The program starts and the for loop initializes running through the case structure which holds various variables.

The values will be concatenated into a string and then stored in an array <-- problem is here.

Do I have to create a local variable that points to my array for the input?

I hope my question/problem was described adequately.

I feel so embarrassed asking this, but I am stuck. :unsure:

Thanks in advance for any tips,

Philip

Download File:post-5846-1155294692.llb

Link to comment

Do I have to create a local variable that points to my array for the input?

Hi Philip,

you can create a "sequence local" (right click on the sequence) and with this you can use the data in a following sequence.

have a nice weekend

Ulrich

Do I have to create a local variable that points to my array for the input?

Hi Philip,

you can create a "sequence local" (right click on the sequence) and with this you can use the data in a following sequence.

have a nice weekend

Ulrich

I forgot one thing: Wire the case output directly to the sequence local. The foor loop output will automatically create an array.

(you also can disable the indexing if you don't need it)

see you

Ulrich

Link to comment

Don't worry about asking questions here. LabView can be confusing at first.

Instead of using the "Insert Into Array" block, you just need to wire the output of the case structure to the array. When you bring a wire out of a For Loop it automatically becomes an array, shown by the square box I indicated in the picture.

post-858-1155300082.jpg?width=400

Link to comment

Hi Philip,

don't hesitate to ask. There are no stupid questions, just stupid answers.

I meant the same thing as ooth.

forgot one thing: Wire the case output directly to the sequence local. The foor loop output will automatically create an array.

(you also can disable the indexing if you don't need it)

Then wire this output to your sequence local and after you measured the voltages save both to an ASCII File.

I attached your main.vi where you can see it. I also made some other changes. I hope they are helpful for you.

your welcome

Ulrich

Download File:post-3940-1155305739.vi

Link to comment
  • 1 month later...

First, I would like to thank Ulrich and ooth. Their suggestions here really helped throughout the rest of my program. I had most of the programming working, but I wanted to make some changes to it to make the code easier to look at.

One addition was the a subvi to create the file name based on input from the user. The properties from the laser (which were being cycled through in that while loop) make up the name.

The way I used to do it was just take the properties out from the loop and add underscores in the main program. This works, but it looks ugly and can hard to follow. I tried to clean it up and make it easier in case someone later wants to add other properties to the filename.

The problem now is that the subvi filename.vi starts without any of the variables waiting outside. I thought in Labview that nothing could run until all of the information was ready? Now, I know I asked a question, but I think it has to do with the fact that I disabled indexing. However, when I enable indexing, I get an error that the type cast is wrong because from the loop it needs an array and the subvi is an element.

Any suggestions on a fix.

Thanks

Philip

Download File:post-5846-1159259916.vi

post-5846-1159259927.jpg?width=400

Link to comment
The problem now is that the subvi filename.vi starts without any of the variables waiting outside.

Hello Phillip,

If you use execution highlighitn on that section (set a breakpoint on the '16' constant) you would see what happens.

The output of the for loop only uses the values from the last iteration, in this case nothing! So the VI waits on termination of the for loop but starts with empty inputs! (See: the knowledge base)

To have such a setup I recoment a cluster with all the information, with a shift register you can update the contents of the cluster and feed this one to you filename.vi

For instance:

post-2399-1159263604.png?width=400

Ton

Link to comment

Hello Ton.

Thanks for your reply. At first I tried to apply what you said in my program and got lost. Then I went back to your display picture and tried to set that up.

I do have a question about your block diagram though.

How did you get your cluster to have the type display "Status 2"? Mine will only display abc or I32 for example (see my block diagram).

Thanks,

Philip

post-5846-1159269732.jpg?width=400

Link to comment

Try using the "Unbundle By Name" / "Bundle By Name" instead of the Bundle/Unbundle.

With Bundle/Unbundle the cluster order is important, and the terminals will change if you add new elements to the cluster.

The "By Name" primitives doesn't care about cluster order or if you add new elements, as long as the referenced name still exist in the cluster.

/J

Hello Ton.

Thanks for your reply. At first I tried to apply what you said in my program and got lost. Then I went back to your display picture and tried to set that up.

I do have a question about your block diagram though.

How did you get your cluster to have the type display "Status 2"? Mine will only display abc or I32 for example (see my block diagram).

Thanks,

Philip

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.