LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

optimization of code replacing constant with timer

hello, i am a beginner and i have the offer to optimize a little code snip. not sure if thats possible with distance but  i'll give it a try.on thepicture you can see that there is a constant 10 and in this area i think all the magic is done (not sure). 

my problem is that this vi prgram produces some hickups and i think it is related to the mentioned area.

maybe someone could "see" the problem.

my idea was to replace seomhow the hole part related to this constant with a some sort of timer so that everything which uses this code snip are useing this exacty timing. sorry for my terrible english and also for my silly question. maybe it is not possible to answer this question without any further information. i am a bit desperate and frustrated atm sorry

0 Kudos
Message 1 of 38
(464 Views)

Hi Herrmann,

 


@Herrmann-s wrote:

i am a beginner 


As can be seen in the image you have attached!

 


@Herrmann-s wrote:

on thepicture you can see that there is a constant 10 and in this area i think all the magic is done (not sure). 

my problem is that this vi prgram produces some hickups and i think it is related to the mentioned area.

maybe someone could "see" the problem.


There are a lot of problems visible in your image:

  • no style guide applied, like left-to-right wiring
  • usage of local variables, so race conditions are possible
  • lots of terminals with no label visible: you may hide the label on the frontpanel but never delete/hide it in the blockdiagram!
  • lots of coercion dots
  • comparision of floats for equality
  • Rube-Goldberg constructs like NOT functions that can be replaced by inversion dots at the CompoundArithmetic function

And no, this image does not help to solve your problem with your code!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 38
(454 Views)

thanks Gerd. your hints are good first start for me to work through the code. they are disastrous but very welcome. i am willing to learn an giving my best!

0 Kudos
Message 3 of 38
(427 Views)

What type of hicups? Plase attach the .vi in an older LV version (file -> save for previous, 2017 or 2019 should work fine)

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 38
(414 Views)

you dont want to see this 😄

(it is not a work of mine. i am the one who should clean it).

 

i am not sure how i should describe hiccups. it is some sort of a time sync problem of some loops. some are running faster than others and as i wrote in my first post - my guess is - that the magic is in the constants (10) being used which should act as a quick and dirty workaround. my idea is to replace these constants to use some sort of a timer to avoid the "overtaking" of some of the loops. if one is slower the faster one should wait etc. but i could be wrong 🙂

any suggestion welcome and i am learing by doing becuase i am totally lost because nobody in my vicinity could help.

i zipped it there are some subvis

0 Kudos
Message 5 of 38
(405 Views)

Hi Herrmann,

 


@Herrmann-s wrote:

you dont want to see this


You are right!

 

See this:

Both codes do the same, but yours is pure Rube-Goldberg!

 

Please cleanup your VIs, create more (reasonable) subVIs and attach again…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 38
(396 Views)

If you want several loops at the same speed they should be the same loop so all go by the slowest.

 

There's lots of improvements you can do (and that i recommend) to make it easier to read and manage. One simple thing is this:

Yamaeda_0-1715169950683.png

 

Many things can and should be placed in loops instead of done multiple times.

Yamaeda_1-1715170795606.png

 

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 38
(352 Views)

Some of your error could be du Race Conditions, your code can't guarantee in which order things execute. If you start with some clean up your problems might disappear or atleast it should be consistant enough to actually fix. I suggest a State machine design.

Yamaeda_0-1715171319344.png

 

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 8 of 38
(346 Views)

Sry for my late reply we had a public holiday.

many thanks guys for your wonderful help.

that improves my learning curve extremly. sometimesi could find a starting point and thats very frustrating.

i am working on to understand your code snips and thats really a fantastic starting point to me. 

0 Kudos
Message 9 of 38
(272 Views)

I stuck a little with these race conditions. I read a bit about it but i am not sure if i understand it correctly. I am fiddeling a little bit around atm with my wrong "construction" how to port it into correct code.

0 Kudos
Message 10 of 38
(248 Views)