LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

optimization of code replacing constant with timer

Flattening the code linked to that "10" constant, it gives this :

PinguX_0-1715949286314.png

By simplifying it, we obtain the following :

PinguX_1-1715949384365.png

 

The boolean in output is True 1 out of N iterations of the While Loop, depending of the TC/TUC input.

Increasing the "10" will lower the frequency, decreasing the "10" will higher the frequency.

 

My guess is your colleague wanted a way to "double" the While Loop : some actions are done at full speed, some others are at lower speed (1/N).

0 Kudos
Message 31 of 38
(508 Views)

he showed me something but we were too busy with other things today and i wasnt able to catch him before his china trip. but what i can definitely say is that he used  "time count" like on the picture i posted. but i dont understand the idea of it atm i need more skills. you guys gave me some homework and i am diligently reading.

the event case is pretty interesting and i ve never used it like that. it seems to be a mighty tool and i had no idea how useful it is. 

 

but thats a little snip of all i can remember. the clock here is for sure the rest is incomplete. maybe it makes some sort of sense for you to implement this code somehow instead of the "10"


2024.jpg

0 Kudos
Message 32 of 38
(491 Views)

puh i stuck totally 😞

i guess i ll never be able to catch it. really frustrating.

0 Kudos
Message 33 of 38
(466 Views)

Take a look at some NI exercices : https://learn-cf.ni.com/custed/Certification/Prep%20Material/CLD/cld_success_package.zip

 

The third can be suitable for your case.

0 Kudos
Message 34 of 38
(451 Views)

thank you ...reading 🙂

0 Kudos
Message 35 of 38
(448 Views)

I built some array to "log" or better visualize the timing of the loop and there are some inconsistency. not sure if the inaccuracy of the loop affects the constant 10 but is it possible to prevent this behavior with a simple code which is connected to the loop?

also i implemented a method to measure the time (hopefully corretly). maybe you could stablilize or force the timing for the loop to make the 10 constant unnecessary?

 

(there are 2 loops. while and for loop)  ?2024-05-22 08_06_55-Pressure.jpg2024-05-22 09_47_53Latencies.jpg

0 Kudos
Message 36 of 38
(420 Views)

As the "10" constant is linked to the iteration terminal "i", the inconsistency of the execution time of the While loop therefore will affects frequency of actions after the "10".

 

There are multiple ways to control frequency of a While loop, here are some of them.

PinguX_0-1716367671287.png

The best solution is the one that fully meets your needs. Perhaps neither of the previous two answers it and you have to create your own.

 

Note that you should create FGV to manage time. Perhaps you've seen this concept in the NI exercises I sent out.

 

About the measurement of time, your method is good. Just consider rotating the array the other direction (-1) and using right encoding (U32).

PinguX_1-1716368143117.png

 

0 Kudos
Message 37 of 38
(410 Views)

thank you pinguX. yes i read the FGV thing. i'll have to study it a little bit mote to understand how i could use the code. i have the problem to simulate my code.

i  have to connect it to the hardware. i wasnt able to simulate it with MAX or anything else.

0 Kudos
Message 38 of 38
(400 Views)