Create a user-defined function block and variables
Use the steps to create a user-defined function block (UDFB), and then add input and output variables. The UDFB is created using the ladder diagram programming language.
To create a user-defined function block and variables
- InProject Organizer, expandAssets.
- Right-clickUser-Defined Function Blocks, and then selectNew user-defined function block.
- InNew user-defined function block, enter the UDFB nameTraffic_Controller_FB, selectLadder Diagramfrom theTypelist, and then selectCreate.
- InProject Organizer, expandTraffic_Controller_FB, and then double-clickLocal Variables.
- In the local variable grid, add the following variables:
- Four input variables to represent a car sensor in each of the four positions in the intersection (N, S, E, W).
- Six output variables to represent red, yellow, and green traffic lights in each of two directions (NS, EW).
VariablesNameData TypeDirectionAttributeN_CAR_SENSORBOOLVarInputReadS_CAR_SENSORBOOLVarInputReadW_CAR_SENSORBOOLVarInputReadE_CAR_SENSORBOOLVarInputReadNS_GREEN_LIGHTSBOOLVarOutputRead/WriteNS_YELLOW_LIGHTSBOOLVarOutputRead/WriteNS_RED_LIGHTSBOOLVarOutputRead/WriteEW_RED_LIGHTSBOOLVarOutputRead/WriteEW_YELLOW_LIGHTSBOOLVarOutputRead/WriteEW_GREEN_LIGHTSBOOLVarOutputRead/WriteTON_1TONVarRead/WriteTON_2TONVarRead/WriteTON_3TONVarRead/WriteTON_4TONVarRead/Write - Save the project by doing one of the following:
- From the menu bar, select
.
- From theFilemenu, selectSave.
Provide Feedback