Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Current »


A function block sub-schema is a standalone schema that can execute as part of another schema. The sub-schema is itself a collection interconnected functional operators with defined inputs and outputs. It allows you to create your own custom operator, as you can specify its input/output signature (quantity/type) as well as its functional behavior (I/O mapping).

Sub-schemas are stored as distinct .scm files. They are standalone schemas that can be referenced again and again by other schema documents. A Function Block Sub-Schema operator serves as the graphical representation of a sub-schema document. The operator resides within the parent schema that uses the sub-schema document---the operator references the sub-schema (akin to a function call in a textual programming language).

For example, the schema diagram of Figure 5.9a contains a single Function Block Sub-Schema operator with four analog inputs and one analog output. The operator references the sub-schema document of Figure 5.9b which computes the root mean square (RMS) of its inputs and applies the result to its output (i.e., it computes the square root of the sum of the squares of the inputs).

Each input pin in the parent schema's Function Block Sub-Schema operator graphic corresponds to a like-named Float Variable operator in the sub-schema. For instance, the input labeled "fInputA" in the sub-schema graphic corresponds to the variable named "fInputA". So when the sub-schema computes, the variable named "fInputA" takes on the value applied to the Function Block Sub-Schema operator input pin labeled "fInputA".

The RMS sub-schema itself contains four Function Block Sub-Schema operators. Each sub-schema operator computes the square of its input signal as shown in Figure 5.9c: Although the operator labels are different (i.e., "A * A", "B * B", "C * C", and "D * D"), they all reference the same sub-schema document named "Square.scm" (Figure 5.9c).



(a)


(b)

(c)
Figure 5.9. (a) Sample schema with function block sub-schema.

(b) sub-schema document referenced by function block sub-schema operator in (a).

(c) sub-schema document referenced by function block sub-schema operators in (b).

A Function Block Sub-Schema operator must be linked to or associated with a schema (.scm) file that contains the desired functional behavior. In the example of Figure 5.9, the sub-schema operator labeled "Root Mean Square" in Figure (A) is linked to the RootMeanSquare.scm schema of Figure B, and the four sub-schema operators in Figure (B) are individually linked to the Square.scm schema of Figure (C). Each sub-schema operator in Figure (B) represents a distinct instance of the Square.scm schema.


Unlike most operators, the Function Block Sub-Schema is not configured through a property sheet. Instead, its configuration is defined by attributes of the linked schema file (e.g., quantity and type of I/O) and through a drop-down menu. This drop-down menu is accessed by right-clicking on the operator icon graphic. It contains commands to manage the operator's link to a schema file. For instance, to link an existing schema file to the operator, select the Link Existing Schema item, and use the File Open dialog to select the desired file.


The schema link is stored as a relative file path to the parent schema. The link can be manually edited by selecting the Edit Schema Link item from the drop-down menu. This command is useful if the schema file is renamed or moved to a different directory outside of the Design Pad G4 environment. The schema link can be removed altogether by selecting the Unlink Schema item from the drop-down menu.


Once a schema file is associated with a Function Block Sub-Schema operator, the file can be opened by double-clicking the left mouse button on the sub-schema graphic. The file can also be opened by selecting the Open Linked Schema item from the drop-down menu.


As indicated above, the operator's input and output pins correspond to like-named Variable operators in the linked sub-schema file. The input-pin type (e.g., analog or digital) must also correspond to the data-type of the Variable operator (e.g., Float or Boolean). Variables in the sub-schema file that are to serve as sub-schema inputs or sub-schema outputs must be explicitly identified as such. This is done within the Sub-Schema Setup dialog---to view the dialog select the Sub-Schema Setup item from the Schema menu. The dialog box (shown in Figure 5.10) contains a list control (top left quadrant) and two list-boxes (top right quadrant) that identify sub-schema inputs and outputs. The list control on the left contains all sub-schema file Variable operators of Local scope (only variables with local scope can serve as sub-schema I/O). The two list-boxes on the right contain the subset of variables that are to serve as I/O. The ordering of the variables in the list-boxes corresponds to the ordering of the I/O pins in the sub-schema operator graphic. To change the pin order, simply drag the variable name from one position in the list-box to another. To identify a variable as a sub-schema input or output, select "YES" in the combo-box in the appropriate column and then click the Update button. (The changes are then reflected in the list-boxes on the right.)


Figure 5.10. Sub-Schema Setup Dialog


Function Block Sub-Schema operators can be configured to execute conditionally or periodically. (This is defined in the When to Compute group control located in the lower left quadrant of the Sub-Schema Setup dialog). The Enable On combo determines when the underlying sub-schema file is to execute. If set to Always Enabled, the sub-schema will execute periodically, with a user-defined updated rate (the Periodic Compute Time).


The sub-schema can be configured to execute at the same frequency as its parent schema executes or at a different user-specified frequency. Sub-schemas cannot execute more frequently than their parent schemas. If the user-defined periodic compute time for the sub-schema is less than the periodic compute time of the parent schema, the sub-schema will execute whenever the parent schema executes.


When the Enable On property is set for conditional execution the operator will include a digital input pin that dictates when the underlying sub-schema file is to execute. If set to Rising Edge, the sub-schema will execute at the instant that the digital input switches from LOW to HIGH. If set to Falling Edge, the sub-schema will execute at the instant that the digital input switches from HIGH to LOW. If set to Active High or Active Low, the sub-schema will execute whenever the input is HIGH or LOW, respectively.

  • No labels