LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

loop counter variable

it is possible to change the input using loop counter variable of loop ??

0 Kudos
Message 1 of 11
(1,750 Views)

Hi 123,

 


@newmemeber123 wrote:

it is possible to change the input using loop counter variable of loop ??


Yes.

 

Spoiler
Maybe you should provide more/detailed information on what you actually want to achieve. An example VI might help too…
Best regards,
GerdW


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

im attaching it and the  subvis contains same visa read and write operation which is in the for loop same as channel 0 for 1 and 2 as shown in the measurement. i want to get a rid of subvis and i want to use loop counter variable to select the channel one after another. dont want to use other two read and write operation. is its possible ?

 

thanks 

 

0 Kudos
Message 3 of 11
(1,736 Views)

@newmemeber123 wrote:

i want to get a rid of subvis

 


There is a lot of duplicated code. You should see if you can make a subvi that you can re-use multiple times.

What is the difference between the sub-vis and what stays the same?

 

Then you can use something like this and you dont need the channel index at all:

 

LLindenbauer_0-1662025048941.png

 

 

It is a bit confusing what you are trying to do.

Message 4 of 11
(1,713 Views)

im attaching the vi in here.. the structure before  case i cant change it because its channel selection command  cases. there are three inputs for every channel which comes out of case so any how i want to get rid of last two read and write FOR loops and for that i want to use loop counter variable as a channel selector input one after another. 

 

waiting for ideas and suggestions thank you..  

0 Kudos
Message 5 of 11
(1,688 Views)

Yes i tried to use only one sub VI the problem is if i use visa read and write 3 times for three channels the im not having the same speed as im hoping because three visa read and write operation  so i want to use only one visa read and write for all three channels so i can get better speed. so im thinking to use loop counter as channel selector or to give input one after another but im not getting how. I will explain the situation again.. i have channel selectors commands as you can see case number 7 or in every case. so now im using three for loops and three visa read and write for every channel.. is it possible to replace three for loops with one and have same operation so i can get better speed.. if you have any questions i will explain you..

thanks in advance  

0 Kudos
Message 6 of 11
(1,607 Views)

Sorry, I cannot open LV2021 VIs. From the screenshot, there are subVIs involved in this. You will probably have to send them, too.

 

Your speed issues probably come from sending a lot of empty strings and waiting for the communication timeout. The solution would be to not send empty strings.

 

The code looks like you first enter the loop and then try to figure your way out by trying every exit. I think it is possible to know the route beforehand, like this:

 

LLindenbauer_3-1662552858641.png

 

This way, If a channel is not used, you are not writing to the line and waiting for a reply (that will not come).

0 Kudos
Message 7 of 11
(1,558 Views)

Thanks for suggestions and reply.. Now i converted it to previous version. you can check the vi now. removed subvis and made it more readable. as you can see the in the vi im using 3 for loops and 3 read and write operations for three channels. if im running only one with with same string commands then the speed is fine with single read and write if i run channel one and two then it will become slow then if i run channel 1,2 and three it become more slow. can you tell me solution for this? can i use single visa read and write operation for  all three channels using loop counter so channels can be select one after another? i think im  i will use only one visa read write for all three channels then speed will be improved because if i run it for one channel it is working so fast. check the case structure as well where im selecting the channel.

 

0 Kudos
Message 8 of 11
(1,543 Views)

Hi new,

 


@newmemeber123 wrote:

made it more readable.


No, you still forgot to use AutoCleanup (ctrl-U)…

 


@newmemeber123 wrote:

as you can see the in the vi im using 3 for loops and 3 read and write operations for three channels. if im running only one with with same string commands then the speed is fine with single read and write if i run channel one and two then it will become slow then if i run channel 1,2 and three it become more slow. can you tell me solution for this?


When you send more commands to your device then it has to handle more work and so I expect it to iterate slower…

 

Why do you need 3 FOR loops to handle 3 arrays of strings? Why not build just one array of strings and use only one FOR loop?

Do you really need only the result of the last command for each FOR loop?

Why do you even call those FOR loops with arrays of 3 empty strings? Does your device expect empty command messages???

 


@newmemeber123 wrote:

can i use single visa read and write operation for  all three channels using loop counter so channels can be select one after another? i think im  i will use only one visa read write for all three channels then speed will be improved because if i run it for one channel it is working so fast. check the case structure as well where im selecting the channel.


Yes, you can.

You just need to iumplement the communication protocol of your device correctly - as has been told to you several times before!

 

Btw. 128kbaud is a rather uncommon transmission speed for serial communication…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 11
(1,531 Views)

1, i have added the two cleaned up vi.

2, yes thats the reason its slow.. so i looking can i select the channel one after another

3, i did now understand how i can do one for loop and one  array of string.. can you show me example so i can understand it in better way.

4, yes, i need the result of last command for every for loop.

5, no my device dose not need any empty string.. how can i improve it i mean case structure and how can i remove empty strings?

 

thanks 

0 Kudos
Message 10 of 11
(1,496 Views)