LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Retain values of variable-Persistent

Solved!
Go to solution

Dear all,

I am on the verge of creating a fuzzy random coefficeint (FRC) for an adaptive controller in LabVIEW. The original design is made in MATLAB/SIMULINK and I am trying to translate functions in LabVIEW for my own design. 
The MATLAB function is then called in Simulink and outputs results. What I am stuck with is how PERSISTENT is maintained in LabVIEW. Consider following script:

 

e=[0.2 0.3];

current_error=e(1);
simulation_time=e(2);



persistent count;
persistent previous_error;



if isempty(count)
count=0;
end

 

if isempty(previous_error)
previous_error=0;
end



count=count+1;

control_activity=(current_error+previous_error)/count;

previous_error=current_error+previous_error;

 

The above script keeps the values of persistent variables (count,previous_error) intact whenever this function is called in Simulink. But in LabVIEW how it is done?
I will probably call the same function made in LabVIEW in some main loop. Am I supposed to use shift registers to pass values between iterations?

Will it serve the purpose of variable persistency? 

There is a same post of same problem in this forum but the guy over there wants to keep values intact when the VI is run. I, on the ther hand, want to keep my values in a jar whenever my function is called in a loop. 

HELP!!

Regards.


0 Kudos
Message 1 of 2
(3,343 Views)
Solution
Accepted by topic author NapDynamite

@NapDynamite wrote:

The above script keeps the values of persistent variables (count,previous_error) intact whenever this function is called in Simulink. But in LabVIEW how it is done?
I will probably call the same function made in LabVIEW in some main loop. Am I supposed to use shift registers to pass values between iterations?

Will it serve the purpose of variable persistency?


Yes, use shift registers


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 2
(3,332 Views)