12-03-2018 08:14 AM
I need to use mutiple functional global variables in the same VI. So is there a way to label each fgv, so that i set the value of 1 fgv at one place and get it another place, then in the same vi, use another fgv in parallel where i set different values and get these different values at another place. How can I achieve this, that is same FGV running parallel with different values.
12-03-2018 08:23 AM
How do you want to identify the different variables? Will they all be of the same data type? There is a current value table library that may give you want you want, see the link below. You could also design a simpler one yourself, using a variant attribute table.
12-03-2018 08:28 AM
yeah the 3 values are velocity, acceleration and direction of motor. So I need to have mutiple motors in the same VI, but Iam using a FGV that inputs 3 values velocity, direction and acceleration and also the string value for the case structure. 2 cases, set value and get value. This fgv has 3 outputs also velocity, acceleration and direction. Since there are mutilple motors I need to set for motor 1 velocity, acceleration and direction in the fgv and then get it somewhere else. Under motor1 then there will be motor2 with different values to velocity, acceleration and direction. But unless I am able to label the fgv as 1 and 2, I will be writing different values to the same fgv.
12-03-2018 08:35 AM
Use one FGV for all motors, but have the data stored as an array. One of the inputs will be a motor number that will index out what set of data you are reading, or tell the FGV which element of the array is to be modified when writing data to it.
As long as the FGV does not take a long time to do what it needs to (and Get/Set FGV's never do), you should not see any problem with using that one FGV in numerous places.
12-03-2018 09:13 AM
@RavensFan wrote:
Use one FGV for all motors, but have the data stored as an array. One of the inputs will be a motor number that will index out what set of data you are reading, or tell the FGV which element of the array is to be modified when writing data to it.
As long as the FGV does not take a long time to do what it needs to (and Get/Set FGV's never do), you should not see any problem with using that one FGV in numerous places.
Or, use LVOOP. This is a perfect example of using classes. Define a motor class and then create an instance of the class for each motor. Then the data for each motor is contained in that instance and you minimize the chance of changing a motor's values inadvertently via a FGV.
12-05-2018 03:49 AM
I am trying to use the array method as RavensFan said. But I want in a way the number of motors are unknown, so that every time I add a new motor, I want to add the values to the existing array, that is increment the array automatically. I am trying to figure out how. Kindly do help me. Thanking You.
12-05-2018 04:14 AM - edited 12-05-2018 04:15 AM
Then your FGV need an "Add motor" function that adds to the array (and effectively turns it into an AE if you wan't to be technical).
/Y