Its important that you know the difference between the two. Example 1: Coils[0] := Coils[0] OR (Buttons[0] AND Sensors[0] > 6); In this case the statements will be evaluated every scan and result in either true or false for Coils[0]. Example 2: IF NOT Coils[0] AND Buttons[0] AND (Sensors[0] > 6) THEN Coils[0] := TRUE; END_IF In this example Coils[0] will latch the result in a true evaluation, if you want it to behave the same way as example 1 then you need to do it like example 3 below: IF NOT Coils[0]...
One thing you could do is create an object with the variable as field with a function and procedure to get the variable (read) and set the variable (write). These are then called from your program and the vizualization.
What you want is to use the CFC language instead of FB.
That calculation will not work the way you expect it to. If PumpFillSpeed is limitied to 0-50 then the only whole number would be 50/50 = 1 everything else is 0.0-0.9999... and since you are using word and integer only 50 would work since there is no representation for mantissa in integer values. Declare a temporary real variable and do the calculation and then do a REAL_TO_WORD in the DRV2Speed assignment.
You need to change it in the "var" section at the top. Ex: "y1 AT %IX0.5 : bool = 0;" -> "y1 AT %QX0.5 : bool = 0;"
It looks like you are trying to write (assign) to inputs (%IX0.x) instead of outputs (%QX0.x).
Use VAR_OUTPUT for pins on the right side or VAR_INOUT for pins on the left side. i cant see any other way.
I miss understood the question. How do you imagine the FBs being reusable if you have hard coded global variables in them? Somehow you need to pass the variables to the FB. I suppose you could pass pointers as inputs to the blocks and modify the dereferenced pointer inside the function block but i cant see the gain in that.