LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem regarding use of many string controllers

Hi!

 

I have several string controls in my VI that contains sensor names. There will be approx 80 of these string controls.

I have made a VI that solves my problem for 5 sensors, but I now realize that my solution is pretty bad even if it is working, because of the large amount of local variables involved in the program.

 

The user can save the data in the string controllers, and write the data to file. The user can also open string data from old files. The string data from a previously saved file is written to the string controllers by using local variables. 

 

I use "string to byte array" and "build array" to compress the data flow, but I must still use approx 80 local variables in the event structure to update all the string controllers.

 

Is there another way to handle many strings like this?

 

The attachements contains the main vi and two subVIs. The SubVIs are used to save to file and open an existing file.

 

Best regards

___________________________________
Is my avatar the dog from the fraggle rock?
0 Kudos
Message 1 of 13
(2,399 Views)

Hi,

 

If you have more than 80 values then instead of using seperate string controls or indicators for each value, you can use a string array to show all the data. In this way you can avoid use of so many local variables. Use a for loop with auto indexing to extract and insert elements into the array.


Regards,


Nitzz

(Give Kudos to good Answers, Mark it as a solution if your problem is Solved;))

0 Kudos
Message 2 of 13
(2,393 Views)

Thanks for the answer, but I must be able to use separate string controllers. The reason is that the user should be able to write sensor names into these fields. The string controllers will look kind of like a matrix when all the controllers has been created.

 

If I use an array on the frontpanel, it is not very user friendly. Hope you understand what I mean.

___________________________________
Is my avatar the dog from the fraggle rock?
0 Kudos
Message 3 of 13
(2,390 Views)

Hi,

 

I don't see any other solution . May be you can just take a look at the attached vi.


Regards,


Nitzz

(Give kudos to good Answers, Mark it as a solution if your problem is Solved;))

Message 4 of 13
(2,381 Views)

The keyword here is scalability. I would have put a string control into a cluster and created a type def. Then I would have put the type def into a 2D array and put that on the front panel for the user to watch. For editing I would have created a sub-vi and let the user input the names into the array. If you format the type def with the text, color etc, you can create a nice looking user control that will look good inside an array.

 

And since you now got an array, you can easily select how many string controls you want to use, and your program will be scaleable.

Regards,
Even
_________________________________
Certified LabVIEW Associate Developer

Automated Test Developer
Topro AS
Norway
Message 5 of 13
(2,378 Views)

Hi again!

 

I have created a small example for you. It needs alot more, but you can see how type defs work and how to not create too much code. Just run my example to see how the array indicator will look like. Then you can create controls to make the user able to scale how many sensors he/she wants. This can be put in a settings sub-vi. If you make the type def more user friendly it should be not be any problem to handle 80 sensors. If it takes too much screen size, you can use a tab control. Just index the big array so that you can view for example 40 sensors for ech page in the tab. This way the user interface will become easy to use. 

 

P.S and for the editing of sensor names, just create a sub-vi and use the arrayindicator as a control instead. Now the user can input whatever he/she want. Then save close the sub-vi. The array indicator will then update all the sensors without using any variables at all. Just use a shiftregister. You can easily save the array as a binary file for future useage. Load the binary file when the program starts, to continue from last save/close of the program. 

Regards,
Even
_________________________________
Certified LabVIEW Associate Developer

Automated Test Developer
Topro AS
Norway
Download All
Message 6 of 13
(2,369 Views)

Hi again! Thanks for your tips and pointers on how to solve my problem.

 

I have one more question though regarding auto indexing of the arrays. I want the data in the arrays to be updated quite often, so that the data is not set permanently after the auto indexing. As far as I know, the auto indexing can only be done one time though. Do you have a tip regarding this matter? I highly appreciate your answers.

 

A .jpg is added to show the short program code.

 

Best regards

___________________________________
Is my avatar the dog from the fraggle rock?
0 Kudos
Message 7 of 13
(2,339 Views)

The autoindexing of the arrays will be done into and out of your for loop. You will have to run the for loop again to update the arrays. 

Regards,
Even
_________________________________
Certified LabVIEW Associate Developer

Automated Test Developer
Topro AS
Norway
Message 8 of 13
(2,335 Views)

Hi,

 

As Even Deejay has said, you will have to run it multiple times. If you want to update it quite often you can place the for loop inside a While Loop for running it multiple times and then the array will get updated continuously.

 

Regards,

Nitzz

(Give Kudos to good Answers, Mark it as a solution if your problem is Solved;)) 

0 Kudos
Message 9 of 13
(2,332 Views)

This was my initial thought, but when I try to restart the for loop with a surrounding while loop, it will not restart the for loop properly. Can you elaborate further?

___________________________________
Is my avatar the dog from the fraggle rock?
0 Kudos
Message 10 of 13
(2,324 Views)