12-06-2018 08:47 AM
Attached an example using variant attributes - You could easily replace the variant with an array, and replace the 'ID' with an index. (Pass an index of -1 to an a new item, or add a new state for add new item).
If you would always read and write all the values at once, replace the number with a cluster.
12-06-2018 08:48 AM - edited 12-06-2018 08:51 AM
@govindsankar wrote:
In my original code, I am using cluster. I have 24 inputs, i group them into 8 clusters having 3 inputs each, so I have 8 inputs. In this program, I just used 8 numeric to show everyone how I am doing the program to correct my mistake.
So use an array of clusters. Each cluster consisting of the 3 inputs.
12-06-2018 09:01 AM
You can ofcourse also break up the FGV.
/Y
12-06-2018 09:22 AM
12-06-2018 08:47 AM
Attached an example using variant attributes - You could easily replace the variant with an array, and replace the 'ID' with an index. (Pass an index of -1 to an a new item, or add a new state for add new item).
If you would always read and write all the values at once, replace the number with a cluster.
Thank you very much, this was what I want, how to set index to an FGV. Thank you very much.
12-06-2018 09:29 AM
If all you are doing is a Get/Set, then you might as well just use a normal Global Variable. But changing to the Variant Attributes where you also have a lookup makes the FGV setup necessary. Even then, you could use a Data Value Reference and get a little more performance out.
12-06-2018 10:18 AM
12-06-2018 09:22 AM
12-06-2018 08:47 AM
Attached an example using variant attributes - You could easily replace the variant with an array, and replace the 'ID' with an index. (Pass an index of -1 to an a new item, or add a new state for add new item).
If you would always read and write all the values at once, replace the number with a cluster.
Thank you very much. Instead of having 8 inputs to 1 fgv. now i have 1 fgv with the input and then 8 copies of the same fgv with different ids. That is what I actually wanted, since I was unable to do that, I thought I will put all inputs into 1 fgv. These 8 inputs are from 8 motors, so I can name each copy of my fgv as motor1, motor2 etc. Thank u very much, I have been trying to do this for over 2 weeks.
12-06-2018 10:24 AM
@crossrulz wrote:
If all you are doing is a Get/Set, then you might as well just use a normal Global Variable. But changing to the Variant Attributes where you also have a lookup makes the FGV setup necessary. Even then, you could use a Data Value Reference and get a little more performance out.
How would using a DVR improve performance? Or do you mean just passing the variant around by reference instead of using the FGV?
12-06-2018 10:43 AM
@paul.r wrote:
Or do you mean just passing the variant around by reference instead of using the FGV?
Yes. For more details: A Look At Race Conditions
12-07-2018 09:33 AM - edited 12-07-2018 09:34 AM
paul.r ACTIVE PARTICIPANT
12-06-2018 08:47 AM
Attached an example using variant attributes - You could easily replace the variant with an array, and replace the 'ID' with an index. (Pass an index of -1 to an a new item, or add a new state for add new item).
If you would always read and write all the values at once, replace the number with a cluster.
I have a new problem. I did the same thing , creating an fgv with , init,set and get as the states and used set variant attribute and get variant attribute inside the set and get methods. But here the value passed into the fgv is an array. Now when I run the program, the first time I set and then try to get, I get the exact values. Second time onwards I am not getting new values, even though I changed the values in the input, the output is showing the same values of the first time. I tried running in highlight execution mode, then I found it goes properly to both set and get states, but the value coming out from the get state is the value I set during the first time. I have attached the program. Please tell me what is the problem.
12-07-2018 09:58 AM
Your calling VI doesnt make much sense and is likely the source of your issues - the uninitialized 'state' shift register is going to give different results depending on when you stop the VI.
A few tips - make the FGV itself private, and create wrappers for the different functions. This makes it much easier to see where the various states are being called, rather than having to search through every instance to find the particular uses you are interested in. Also, why are you turning the array into a cluster? Just put it into the look up table as an array.