Public Scope and cycle utilization
How public scope channels impact overall cycle utilization and multi master buss load.
Thank you
Paul
Answer
Public scope means that all other channels within the same master module application can read the channel value and status, regardless of the function group these other channel are located in.
(The exception is channels in instances of external functions, these do not see public scope from the main project)
But by using public (and private) scope, you can reduce the usage of FGI channels. Each FGI use a small amount of time to calculate, when you have hundreds of FGI:s that adds up and there is a potential saving.
Also see the new 6.02 feature for propagating function group outputs, can be used to eliminate mid-level calculations channels.
To transfer a channel value and status to an application on another master, you use Master bus APPOUT/APPIN (consuming plenty of bandwith). Or send the value using J1939/Generic CAN.
Display pages and the menu system can read channel values from any application, this is done automatically via the Diagnostics bus. The update rate is limited, but the diagnostics bus can get to a quite high bus utilziation, a good reason to avoid mixing it with too much other traffic.
Public scope should be avoided! It can cause whats called "Critical races" which means you can't see how the calculation order of the different parts of you program where you using the public channel.
Read about it here Race condition
By using FGI and FGO you can easy see the calculation order and take action to avoid race condition.
The new future "Propagate" in 6.02 works great and it will slim down the intermediate channels between two FGs. I used Protected scope with FGIs so now i only have one intermediate channel between two FGs, from one FG 5 branches deep to and other FG 5 branches deep, and still have control of the calculation order.
There are arguments against using public scope in an application, but to say that it could cause a "race condition" is a misunderstanding. The IQAN application is calculated in one single sequence, one function group and channel at the time.
The public scope channel is calculated just like any other channel, when you the application interpreter gets to that point in the application.
Yes, its true but I would say using FGI and FGO will cause awareness off how everything is calculated. Dangerous situation could happen if a state or value lagging one cycle behind and cause oscillations.
One more thing about reverse calculation, in Object List, all you get is a Hint in Project Check about a reverse calculation but no visual notification as channel to channel calculations. Could be something for the future version?
I agree that it is important to be aware of how the order in which channels are calculated. It is good practice to have as few places as possible with inverse calculation order. As the channels are calculated one function group at a time, using more more function groups is usually good practice.
Good point about inverse calculation order in object list. I never use that anymore, for calculations where I want to make use of values from the previous cycle I prefer Qcode with a static variable. We've talked about creating options for some sort of user defined coding guidelines, perhaps it could fit in that feature.
Customer support service by UserEcho
Public scope means that all other channels within the same master module application can read the channel value and status, regardless of the function group these other channel are located in.
(The exception is channels in instances of external functions, these do not see public scope from the main project)
But by using public (and private) scope, you can reduce the usage of FGI channels. Each FGI use a small amount of time to calculate, when you have hundreds of FGI:s that adds up and there is a potential saving.
Also see the new 6.02 feature for propagating function group outputs, can be used to eliminate mid-level calculations channels.
To transfer a channel value and status to an application on another master, you use Master bus APPOUT/APPIN (consuming plenty of bandwith). Or send the value using J1939/Generic CAN.
Display pages and the menu system can read channel values from any application, this is done automatically via the Diagnostics bus. The update rate is limited, but the diagnostics bus can get to a quite high bus utilziation, a good reason to avoid mixing it with too much other traffic.