fillalph Posted August 11, 2006 Report Share Posted August 11, 2006 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. Thanks in advance for any tips, Philip Download File:post-5846-1155294692.llb Quote Link to comment
Ulrich Posted August 11, 2006 Report Share Posted August 11, 2006 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 Quote Link to comment
fillalph Posted August 11, 2006 Author Report Share Posted August 11, 2006 Hello Ulrich, Thanks for your quick reply. I am not entirely sure how to implement your idea so I made a small vi trying to sort it out, but didn't quite get it. Again, I attached what I got from your message. If you could quickly clarify that, it would be greatly appreciated. Thanks for taking the time to help a beginner. Philip Download File:post-5846-1155299563.vi Quote Link to comment
ooth Posted August 11, 2006 Report Share Posted August 11, 2006 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. Quote Link to comment
fillalph Posted August 11, 2006 Author Report Share Posted August 11, 2006 ooth: Thank you. That was what I was looking for. Simple implementation. Ulrich: Even though ooth's way works, I would still (if you have more time) like to try and get your example working since there is always more than one way to do something. Thank you, Philip Quote Link to comment
Ulrich Posted August 11, 2006 Report Share Posted August 11, 2006 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 Quote Link to comment
fillalph Posted August 16, 2006 Author Report Share Posted August 16, 2006 Hello, I just would like to say thanks to the people that read the thread and to Ulrich and ooth for their replies. Greatly appreciated. Philip EDIT: Any chance Ulrich that you could save the file you posted in version 7.0? I would like to see the other changes you made. Thanks. Quote Link to comment
Ulrich Posted August 16, 2006 Report Share Posted August 16, 2006 EDIT: Any chance Ulrich that you could save the file you posted in version 7.0? I would like to see the other changes you made. Thanks. Hi Philip, here it is in LV7.0. I hope you can open it. have a nice day Ulrich Download File:post-3940-1155724397.vi Quote Link to comment
fillalph Posted August 16, 2006 Author Report Share Posted August 16, 2006 Hello Ulrich, Thanks for taking the time to convert to version 7.0 and for taking the time to go through my program and making those corrections and adjustments. Truly appreciated. Philip Quote Link to comment
fillalph Posted September 26, 2006 Author Report Share Posted September 26, 2006 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 Quote Link to comment
Ton Plomp Posted September 26, 2006 Report Share Posted September 26, 2006 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: Ton Quote Link to comment
fillalph Posted September 26, 2006 Author Report Share Posted September 26, 2006 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 Quote Link to comment
Mellroth Posted September 26, 2006 Report Share Posted September 26, 2006 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 Quote Link to comment
fillalph Posted October 4, 2006 Author Report Share Posted October 4, 2006 Hello. Sorry tcplomp and JFM. My programming got put on hold while I was busy growing and taking measurements. I just wanted to say thank you. Your solution worked fine. I had to create a "dummy" cluster to use in the for loop since not every iteration passed information. Thank you Philip Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.