Previous PageNext Page

COUNTERS

CTD- Down Counter
The CTD function is a programmable down counter. A true on CD will cause the counter to decrement by one. Once the counter (CV) equals zero, the Q output will be true. A true on LD will cause the counter to load the PV as the current (CV) count and reset the Q output. The down counter triggers on a false to true transition on the CD input.
  1. We will now use the CTD in a ladder diagram.
  2. Place EZ LADDER® in the Edit mode (if in the Monitor mode).
  3. Using the Insert Function drop down menu on the tool bar, select CTD or use the CTD button on the tool bar.
  4. Place the cursor on Rung 4 near the center of the ladder diagram workspace and left-click to place the object. The Function Block properties dialog box will appear. Keep the name CTD1 and leave the description blank (The name field allows you to set any name for the function while the description allows you to set a text description of what the function is used for). Click OK. The CTD1 is now placed on rung 4.
  5. Select the DIRECT CONTACT button from the tool bar.
  6. Place the cursor on Rung 4 near the left power rail and left-click to place the contact. The Contact properties dialog box will appear. Using the drop down menu in the dialog box, selct GPI2 and click OK. This finishes the placement of the contact that is tied directly to hardware input GPI2 (also named GPI2).
  7. With the DIRECT CONTACT still selected, place the cursor on Rung 5 near the left power rail and left-click to place the contact. The Contact properties dialog box will appear. Using the drop down menu in the dialog box, selct GPI3 and click OK. This finishes the placement of the contact that is tied directly to hardware input GPI3 (also named GPI3).
  8. Select the DIRECT COIL button from the tool bar.
  9. Place the cursor on Rung 4 near the right power rail and left-click to place the coil. The Coil properties dialog box will appear. Using the drop down menu in the dialog box, selct GPO1 and click OK. This finishes the placement of the contact that is tied directly to hardware output GPO1 (also named GPO1).
  10. Select the HORIZONTAL LINK tool.
  11. Draw a link from the right side of the GPI2 contact to the CD of CTD1.
  12. Draw a link from the right side of the GPI3 contact to the LD of CTD1.
  13. Draw a link from the Q output of CTD1 to the left side of the GPO1 coil.
  14. We now need to insert variables to give the CTD1 setpoints. Select the INST VARS button from the tool bar.
  15. Place the cursor on Rung 6 just left of the PV (preset value) input on CTD1. Left-click to insert the variable. The Variables dialog box will appear (the only tab available will be the INTEGER tab) since this is connecting to a counter.
  16. Click the ADD button to add a new variable. The Add variable dialog box will appear. Type CNTB for the Name, select INTERNAL as the variable type an enter 10 for the DEFAULT VALUE then click OK. This sets the variable connected to the counter's preset value to 10.
  17. With the INST VARS button still selected, place the cursor on Rung 6 just right of the CV (current value) output on CTD1. Left-click to insert the variable. The Variables dialog box will appear (the only tab available will be the INTEGER tab) since this is connecting to a counter.
  18. Click the ADD button to add a new variable. The Add variable dialog box will appear. Type CVal2 for the Name, select INTERNAL as the variable type an leave the DEFAULT VALUE blank, then click OK. This sets the variable connected to the counter's current value to this variable (which can be used to view the current counter value when running the program on the target).
  19. Save the ladder diagram from the File menu and selecting SAVE. It is a good idea to periodically save your ladder diagram when developing it.
  20. Compile the target using the COMPILE button from the tool bar. Ensure that the compile is successful and there are no errors. If there are errors they must be corrected. Your ladder diagram should look similar to this:


  21. We are now ready to run the program on the target. Switch to the Monitor mode by clicking the MON button from the tool bar.
  22. Connect to the target, by selecting the CONNECT button from the tool bar. If a different program is running, just click OK.
  23. Download the ladder diagram to the target by selecting the DOWNLOAD button from the tool bar. If successful, the ladder diagram is now operating on the target. It should look similar to:


  24. Notice GPO1 is true and the CVal2 is zero when the program starts executing. You will need to "load" the CTD before it can be used.
  25. Momentarily close the switch connected to Input3 (LD counter input). GPI3 momentarily is true causing power flow.This will cause the counter to "load" the preset value of 10 as well as setting GPO1 to false.
  26. Momentarilly close the switch that is connected to Input 2 on the Development Board. GPI2 momentarily turns red indicating power flow and the CVal2 variable is now decremented (provided GPI3 is open). For each momentary closure of the GPI2 input, the counter value decreases. When the counter value CVal2 is equal to zero, then GPO1 will turn red indicating power flow and the actual output will also be true.

You have completed the CTD exercise.

  Previous PageNext Page