LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Remove Elements of Array

Solved!
Go to solution

Hi, I have an small issue. I am running a programme where each time, lets say 01:00:00 it needs to enter in a loop , execute it and get out and keep moving until the next iteration. But due to the density of the programme and the specifications of the computer, the time changes sometimes every second and other times every two seconds. In order to enter in the loop for each time I have one array so I have a function that gives me back the position of the time in the array and I can use it inside the loop for operations. So the problem is sometimes the time is changing every 2 seconds and that doesnt allow me to enter in the right position of the array. I cant change it to minutes, since the time needed for the operations inside the loop is too small, so I will get out and  It could enter again in the same position that we have already carried out. I wonder if there is any way of removing a position we have already use from one array or any other way you think about doing this. thanks

 

labview.png

0 Kudos
Message 1 of 15
(3,159 Views)

Hi Lorquino,

 

it is most often a bad idea to attach just an image and no real code.

It is also a bad idea not to cleanup your code before attaching even just images of it!

 

That being said:

Instead of searching for exactly the same data in your array (using Search1DArray) you should use Threshold1DArray with real timestamps in your array constant!

 

Btw. why do you need so many functions (and block diagram space) just to convert a number into a string containing a timestamp? Why not use FormatIntoString with a format of "%<%H:%M:%S>T" ???

Best regards,
GerdW


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

GerdW has suggested some ways to technically achieve your outcome. You should look into these as they are very good ideas. You could simply put a wait until next multiple to get your program to operate every minute instead.

 

I will suggest that a higher level design approach could be taken to address this problem. Your problem is that your program is sufficiently complicated that you cant guarantee that it is able to check the time every second. You likely have one large while loop that tries to do everything every loop. In reality the different parts of your program can run at different rates, but your design does not allow for this! You should try to separate the parts of the program into independant modules that can operate independantly.

 

I would make a module that periodically checks if time has passed and create an instruction for another module to take the action. This decouples the check from the action. The frequency of the check will define the responsiveness; if you want the action to occur within a second then check every second. This will make your system much more parallel and help your system being more responsive.

 

Look into the Queued Message Handler template that uses producer-consumer to decouple instructions from carrying out actions. A state machine could also achieve this depending on the other things you need your program to do.

CLA - Kudos is how we show our appreciation for comments that helped us!
0 Kudos
Message 3 of 15
(3,132 Views)

Hi, here you have the file, answering to your second question, I use that structure to convert the timestamp to that is in seconds to a string that shows the time to compare it to the array positions... 

I dont understand If i use the threhold function, what type of data should I incluse in the array ? can I type timestamp data ? Could you explain a little bit more please ? thanks

0 Kudos
Message 4 of 15
(3,112 Views)

Hi, here you have the file, answering to your second question, I use that structure to convert the timestamp to that is in seconds to a string that shows the time to compare it to the array positions... 

I dont understand If i use the threhold function, what type of data should I incluse in the array ? can I type timestamp data ? Could you explain a little bit more please ? thanks

Download All
0 Kudos
Message 5 of 15
(3,111 Views)

is there just anyway of desactivating the position of the array that we used previously ? 

0 Kudos
Message 6 of 15
(3,100 Views)

Hi Lorquino,

 

simplify your VI:

check.png

I set "segundos transcurridos…" to a different display mode…

 

Did you notice Max' answer?

He's right in suggesting to start at the "algorithm design" stage and not with focusing on implementation problems!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 15
(3,099 Views)

Hi , I am so sorry but I do not understand what the threshold element  is doing, I have even reproduced your VI. 
I just need to get the row of the array and introduce it to a loop(case structure) where I will use that row to get the values of another array and work with those values carrying out complex operations with sensors. If the time I am looking for it hasnt come yet I just introduce -1 that is value the 1DsearchArray gives me to that case structure, but it will be empty for that option so it will immediatly get out and keep searching in the string array. All this is running in 1 second time, but my problem is  sometimes the timing changes 2sec rather than 1sec i guess due to my computer so it jumps that row of the array since it does not have that temporary instant. So I am thinking of change the array to minutes rather to seconds and remove the positition I already found to avoid enter again there if I get out of the loop and I am still at the same minute but I am not sure how to delete that array position.  I really apology but I do not understand your VI,since it seems its not getting me back the row of the array. I am so bad at explaining my own stuff. I believe i need to programme all this in this way because i need to be getting values from the sensors while Im searching for the right row of the arrray and while Im inside the loop. I would really appreacite it something related to this information, or explainging why your solution can help me. 

0 Kudos
Message 8 of 15
(3,084 Views)

Hi Lorquino,

 

I do not understand what the threshold element is doing, I have even reproduced your VI.

Did you read the LabVIEW help for Treshold1DArray?

Btw. it gives you a (fractional) index into your array.

 

I just need to get the row of the array

This is what you get from my example…

Best regards,
GerdW


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

Please correct me If I am wrong, with your example I get a fractional number, that number is not any index ? I mean i need to get index 0 , when the time shows 00:01:00 , not before and not after , and i need to get index 1 when the time shows 00:02:00 , not before and not after, your example gives us values in increment when you are close to the point ,  Im not sure about its accuracy whats the name of the block i32 you placed on your schematic ? Furthermore your programme it work in a sequencial way but mine you didnt need to have all the index in order.

I am not sure either how works with the values I got , I had one case structure to introduce the differents rows or -1 that it willl not do anything,if I have fractional values , may i ask you again how i know when i have to select each row of the the next array.

I want just ask politely if there is any way of desactivated a previous position that we have already used or  maybe a way of gettig through your proposal the value of the index in entire way. thanks . I really appreacite it your help.  

0 Kudos
Message 10 of 15
(3,065 Views)