LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using timer to index values out of csv file

Is this the way to do it?

 

Earlier I was using time interval in which the main loop is running to index the elements. 

Download All
0 Kudos
Message 1 of 5
(953 Views)

Hi girish,

 


@girish_jadhav wrote:

Is this the way to do it?


Does it give you the expected results? When the answer is "Yes!, then you can go this way…

Which way do you want to go? There is no explanation or documentation in your code (or your message), so how should we know that?

 

Other remarks:

That VI is overly complicated! Whenever you need to duplicate code you should think about using arrays and (autoindexing FOR) loops!

The VI would take about 20% of block diagram space…

 

Two simple changes reduces the code by ~20 operations:

 

  • Your CSV file contains columns of timestamps: you cannot convert them using a StringToFloat function!
  • As your (orange) wires are connected to dedicated global variables you should not use controls to set the index values: there should be constants…
  • As you seem use all those timers to measure different elapsed times without resetting them you could go with just one ElapsedTime and some Q&R (quotient&remainder) functions…

Did I mention the code is way to complicated?

 

Best regards,
GerdW


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

Hello GerdW,

 

Sorry that I didn't provide more information. 


@GerdW wrote:

Hi girish,

 


@girish_jadhav wrote:

Is this the way to do it?


Does it give you the expected results? When the answer is "Yes!, then you can go this way…

Which way do you want to go? There is no explanation or documentation in your code (or your message), so how should we know that?

 

Other remarks:

That VI is overly complicated! Whenever you need to duplicate code you should think about using arrays and (autoindexing FOR) loops!

The VI would take about 20% of block diagram space…

 

Two simple changes reduces the code by ~20 operations:


 

I am lost as to how to use autoindexing for-loop in my vi. And don't understand why you used Array Subset outside of while loop!

 

  • Your CSV file contains columns of timestamps: you cannot convert them using a StringToFloat function!

 

I want to read 10 setpoint columns from the csv file (the one I attached is incomplete). Time interval columns are not necessary for me in the LabVIEW so I have not indexed those columns. 

 


  • As your (orange) wires are connected to dedicated global variables you should not use controls to set the index values: there should be constants…

You are right. I will change this. 

 

Best Regards, 

Girish


 

0 Kudos
Message 3 of 5
(858 Views)

Hi Girish,

 


@girish_jadhav wrote:

And don't understand why you used Array Subset outside of while loop!


I used the ArraySubset before the loop because you always index column 1 from your file data. You only need to do that once!

(You also can move the StringToFloat function before the loop: you also need to convert to float just once before the loop!)

 


@girish_jadhav wrote:

I am lost as to how to use autoindexing for-loop in my vi.


You are basically doing the same operations (index data from a 2D array, calculate an elapsed time, creating display data) 10 times in your code. You should use arrays and (autoindexing) FOR loops to implement those operations only once…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 5
(853 Views)

Hi GerdW, 

 


@GerdW wrote:

Hi Girish,

 


@girish_jadhav wrote:

And don't understand why you used Array Subset outside of while loop!


I used the ArraySubset before the loop because you always index column 1 from your file data. You only need to do that once!

(You also can move the StringToFloat function before the loop: you also need to convert to float just once before the loop!)

 



I did that to remove the header. 



You are basically doing the same operations (index data from a 2D array, calculate an elapsed time, creating display data) 10 times in your code. You should use arrays and (autoindexing) FOR loops to implement those operations only once…


auto-index.png

Is this what you meant? I get the 2D matrix in the loop, but I am unable to index the values. I tried it with elapsed timer to try and index values at 10s interval but it didn't work. I only read zeroes. 

 

How can I use Q&R operation here to index all the 10 values?

 

Best Regards, 

Girish

0 Kudos
Message 5 of 5
(844 Views)