LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Local Variables in State machines

I have been reading the posts that came up when I searched for the subject topic. Well let me thank Tbob and Shan for thier excellent samples  of using  of  clustered locals for data handling inside of a State machine.

Having started with LabVIEW two years back I  now have  commissioned four major  projects  where  the  SM architecture is used for machine control and  Loacl variables are used  for  data  handling between cases.

Today I am happy that  there  is  an elegant alternative  as suggested  with Local clusters and a single SR.  Good. But what about the projects already commissioned ? To decide whether to recode them, I need to know this :

- Each SM uses something like 150 to 200 local variables (Please don't laugh!)
- Taking the case of one particular indicator called "R.ANGLE" it has  in a total of  9 local variables in various SM cases.

Question is :

When I run the SM, does LV create  copies in memory  for 9  numbers of  R.ANGLE  indicators or  a copy for  only the variable that is currently being updated in a SM case ?  And discard it when I jump to the next  case ?

( The above SM is inside of a 50ms timed loop and till date running with no problems - atleast memory related )

Thanks for any insight.

Raghunathan
Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 6
(2,581 Views)

Since LV does not know which copies of a local may need to be read some time in the future, the new value is written to ALL of the copies of the local.

So if you write to a idicator and thera are 9 local copies of that indicator, then the data is also written to the 9 "read local"s.

I hope I upderstood your Q.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 6
(2,570 Views)
Hello Ben,

Yes you understood my query very well.

If that is the case, then I think I have created quite a lousy code ? Assuming that there are about 150 local variables and 5 instances of each, then when I launch the application, automatically 5 x  150 = 750 copies are loaded in memory ?? Sounds very depressing  if you ask me.

And I also suppose that the 750  copies remain in memory till the application is closed.

Kindly confirm if my understanding is correct.

Thanks

Raghunathan

Message Edited by Raghunathan on 04-14-2006 10:56 AM

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 3 of 6
(2,558 Views)

You are correct.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 6
(2,549 Views)


Raghunathan wrote:
[...]

Today I am happy that  there  is  an elegant alternative  as suggested  with Local clusters and a single SR.  Good. But what about the projects already commissioned ? To decide whether to recode them, I need to know this :

[...]


Now, after Bens answers, if you start to rewrite your code ....

If you use one SR (I prefer at least two, I like to keep the error cluster separate)  another helping hint:

Use a type definition for your cluster, so in best case, you will only need to edit every subvi once.


 

Message Edited by Henrik Volkers on 04-18-2006 10:22 AM

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 5 of 6
(2,512 Views)
Hello Henrik,

That was a valid point about  segregating the clusters and using a type definition. It will defenitley help in code maintainability.

Thanks for  your kind tips and greetings from India.

Raghunathan
Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 6 of 6
(2,499 Views)