Hi,
I'm rather new to LV, and while I'm experimenting and developing with a FP RT system, I'm stuck now.
We're doing frequency measurements with a counter module (cFP-CTR-502), and in this context I need an algoritm that goes like this:
A variable (I'll call it Divisor) has a value of 1 for starters and depending on the value of another variable (let's call it Count), the divisor should be multiplied, or divided by a value:
count < 1000 => Divisor *3
count < 500 => Divisor *6
count < 250 => Divisor *9
Count >16000 => Divisor *9
Count >8000 => Divisor *6
Count >5300 => Divisor *3
Count between 1000 and 5300 => no alteration of Divisor.
I tried to write code in a formula node(dlr==Divisor and Cnt==Count):
float32 dlr=1;
while (dlr<6250)
{
if(cnt<250)
dlr=dlr*9;
else if (cnt<500)
dlr=dlr*6;
else if (cnt<1000)
dlr=dlr*3;
else if (cnt>5300)
dlr=dlr/3;
else if (cnt>8000)
dlr=dlr/6;
else if (cnt>16000)
dlr=dlr/9;
}
But this has two main problems:
-All of my CPU time is taken (alltough it's in a while loop with a 'Wait untill next ms multiple')
-'dlr' is allways reset to a value of 1, while it should be a more dynamic number
Can Anyone give me a hint on how I should work this out ?
thx