Add additional rungs and edit variable assignments

Use the following steps to add rung 2 and rung 3 by copying rung 0 and rung 1, edit the variable assignments, and then build the Traffic_Light UDFB.
An error icon error icon next to a variable name indicates:
  • A variable name must be assigned.
  • A constant value must be entered.
  • A data type mismatch.
Prerequisites
To add additional rungs and edit variable assignments
  1. Duplicate rung 0 and rung 1 by doing the following:
    1. Select the first rung.
    2. Select the second rung while selecting the
      Ctrl
      key.
    3. Right-click any rung, and then select
      Copy
      .
    4. Right-click rung 1, and then select
      Paste
      .
    You can also use the shortcut key to copy and paste rungs.
  2. In rung 2, assign the variable
    TON_3
    to the TON.
  3. In rung 3, assign the variable
    TON_4
    to the TON.
  4. In rung 2 and rung 3, do the following:
    1. Change each EW variable to the NS variable.
    2. Change each NS variable to the EW variable.
    3. (optional) Enter rung comments.
    4. Verify that rung 2 and rung 3 look similar to the following example:
      Traffic Light project - Rung 3 and 4
  5. Add rung 4 to the end.
    The logic is:
    When the program is first downloaded to the controller and run, none of the traffic lights are initially turned on. This last rung checks for the condition (all traffic lights are off), and turns on the North-South red traffic lights and the East-West green traffic lights.
  6. (optional) Double-click rung 4, select
    Add rung comment
    , and then enter:
    To initialize the program after the initial download, if all the lights are turned off, turn on the North-South red lights and the East-West green lights.
  7. Add the following ladder diagram elements to rung 4 in the order listed from left to right. Use
    Toolbox
    to add reverse contact elements according to the following table:
    Ladder diagram elements on rung 4
    LD Element
    Position
    Name
    XIO
    1 (far left)
    NS_RED_LIGHTS
    XIO
    2
    NS_YELLOW_LIGHTS
    XIO
    3
    NS_GREEN_LIGHTS
    XIO
    4
    EW_RED_LIGHTS
    XIO
    5
    EW_YELLOW_LIGHTS
    XIO
    6 (far right)
    EW_GREEN_LIGHTS
  8. Add two OTOs in parallel to turn on the NS_RED_LIGHTS and the EW_GREEN_LIGHTS variables.
    The entire user-defined function block program looks similar to the following image:
    How the Traffic Light project looks like
  9. Build the project by doing one of the following:
    • From the menu bar, select
      Device
      Build
      .
    • Right-click the controller, and then select
      Build
      .
  10. In
    Output
    , view the build result.
  11. (optional) Fix any errors, and then build the project again.
  12. Save the project by doing one of the following:
    • From the menu bar, select save button.
    • From the
      File
      menu, select
      Save
      .
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal