Add a user-defined function block to a ladder program
Use the steps to add the user-defined function block Traffic_Controller_FB to the Traffic_Light_Control Program Organization Unit (POU).
Prerequisites
To add a user-defined function block to a ladder program
- InProject Organizer, expandPrograms, and then double-clickTraffic_Light_Controlto open the program.
- FromToolbox, locate and dragTraffic_Controller_FBto rung 0.
- Right-click the box besideTraffic_Controller_FB, and then selectNew variable.
- InNew variable, enter the variable nameTraffic_Controller_FB_1, and then selectCreate.
- In thePropertiespane, turn onEN/ENOforTraffic_Controller_FB.
- Save the project by doing one of the following:
- From the menu bar, select
.
- From theFilemenu, selectSave.
The first function block input that connects directly to the ladder rung is the function block enable (EN) bit. The remaining four function block inputs are "real-world" inputs that indicate whether a car is waiting at a red light in any of the four possible directions: North, South, East, or West. These inputs get mapped to four Boolean input variables that are local to the function block: N_CAR_SENSOR, S_CAR_SENSOR, E_CAR_SENSOR, and W_CAR_SENSOR. You must assign four L70E controller inputs to these function block inputs.To see the full names and data types of the variables that are associated with these inputs and outputs, hover over the instruction block to display a tooltip:
Provide Feedback