LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

optimization of code replacing constant with timer

@yamada do think i could work with semaphores to avoid race conditions?

i am not (yet) familiar with "state machine" architecture in this case but i read a bit about semaphores.

maybe you are so kind to give me some examples.

the other stuff i could manage and it seems to work properly. i still stuck in the race conditions. any help appericated

0 Kudos
Message 11 of 38
(316 Views)

@Herrmann-s wrote:

@yamada do think i could work with semaphores to avoid race conditions?

i am not (yet) familiar with "state machine" architecture in this case but i read a bit about semaphores.

maybe you are so kind to give me some examples.

the other stuff i could manage and it seems to work properly. i still stuck in the race conditions. any help appericated


To guarantee that Loesen is updated before being read (which i assume is what you're trying to do), just use the wire. The wire is the variable, not the indicator. The indicator is just to inform the user of something (or send out data if a sub-vi).

So instead of those two Local variables, just wire the inital time-wire through to those cases. The indicator can stay, but it's not used for data that way and Flow Control forces the first Read time before the time calculations.

 

Semaphore will just make things harder for you. 🙂

 

Simple demonstration of Race Condition:

Yamaeda_0-1715677456024.png

 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 12 of 38
(301 Views)

you mean i should just use the wires instead of using the local variables (see attached picture)????? if so ....i am the worlds dumbest galah! 

0 Kudos
Message 13 of 38
(296 Views)

Hi Herrmann,

 

From what I could understand, you should do something like this :

 

PinguX_0-1715682695434.png

 

As "Loesen_1" seem to be a time reference, you have to store it in a feedback node (or a shift register).

Message 14 of 38
(274 Views)

@Herrmann-s wrote:

you mean i should just use the wires instead of using the local variables (see attached picture)????? if so ....i am the worlds dumbest galah! 


Yes, just wire to target. 🙂 You have to handle the False case in the 1st Case, probably a Feedback node would suffice. That's just one Race condition, but it will reduce points of error.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 15 of 38
(269 Views)

@PinguX wrote:

 

PinguX_0-1715682695434.png

 

Oh, i didn't think about that, but the first part is just an Elapsed time-block with Set Reference wired to Reset.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 16 of 38
(268 Views)

i'll give it a try thank you so much guys!

any further ideas etc are very welcome. i am trying my best to understand LV and i need to "sync" my brain a little bit.

thats why i am highly interested in your opinions and different approach. that helps me a lot!

0 Kudos
Message 17 of 38
(263 Views)

hi pungux, one last question for today (even if i blame myself) 😉

i am a bit confused atm about "set reference?"

it is pretty hot in my office and maybe my brain is not working correctly anymore. what reference should i put there? 

0 Kudos
Message 18 of 38
(248 Views)

The "Set Reference?" boolean is the one at the top-left of your previous screenshot :

 

PinguX_1-1715689248906.png

 

That structure in the corner can be replaced by Select and Feedback nodes.

 

 

Another quick advice : avoid "Insert into array" in a loop with Shift Register, the auto-indexing option is by far better (for memory and time execution).

PinguX_2-1715689705705.png

 

EDIT : Case structure accept multiple type (boolean, numeric, string) for case selector.

So instead of placing condition before the structure, you can make it the other way :

PinguX_0-1715690498065.png

(cf. "201020_Def2Ring.vi")

 

 

Message 19 of 38
(242 Views)

and again thank you very much! thats really wonderful support! i am implementing it and give it a try!

0 Kudos
Message 20 of 38
(212 Views)