In the industrial world, data is just as important as logic. Managers need to know how many parts were produced, how many cycles a machine has completed, and when it’s time for maintenance.
In this lesson, we will implement the CTU (Count Up) block to track a proximity sensor and display that live data on the HMI screen we built in Lesson 3.
🔢 Step 1: The CTU (Count Up) Block
The CTU block is the industry standard for tracking events. It has three primary pins:
- CU (Count Up): Every time this signal goes from False to True, the count increases by 1.
- R (Reset): When this signal is True, the count returns to 0.
- PV (Preset Value): A limit you set (e.g., 100 parts).
- Q (Output): Turns ON when the count reaches the Preset Value.
- CV (Current Value): The actual number of counts recorded.
🛠️ Step 2: Wiring the Production Counter
- The Trigger: Drag Input I1 onto your canvas. This represents your physical proximity sensor on a conveyor belt.
- The Logic: Drag a CTU block from the Counters folder in the Library. Connect I1 to the CU pin.
- The Reset: Drag Input I2 onto the canvas. Connect it to the R (Reset) pin. This allows an operator to clear the count manually.
- The Limit: Click the CTU block. In the Properties pane, set the PV to
10. This tells the logic that our production “batch” is 10 units.
🖥️ Step 3: Displaying Data on the LCD
We want the operator to see the count without needing a laptop.
- Go to the Display tab.
- Drag an Integer Value element onto the screen.
- Go back to the Circuit Program tab. You will see a new input pin on your “Screen” block.
🧪 Step 4: Testing the Logic
- Enter Simulation Mode.
- Click I1 multiple times. You will see the count increase on the screen preview.
- Once the count reaches 10, the Q output of the CTU block will turn red. (You could wire this to a “Batch Complete” light on Output Q3).
- Click I2 to watch the count reset to zero instantly.
💡B2B Pro-Tip: Maintenance Alerts
Professional integrators use counters for Predictive Maintenance. By setting a counter to 10,000 cycles and wiring the output to a “SERVICE REQUIRED” message on the HMI, you ensure the machine is maintained before it breaks. This is a high-value feature you can sell to B2B clients.