Cookies are not enabled on your browser.
To learn more: https://www.automationdirect.com/clickplcs?utm_source=MnR8e-cZLUs&utm_medium=VideoTeamDescription
(VID-CL-0081)
Is your PLC scan time creeping up? A giant "Main" program can lead to watchdog timeouts and sluggish machine responses. In this tutorial, we show you how to organize your logic using the three distinct program types in CLICK PLCs to keep your code lean, fast, and professional.
What we cover:
Main Program: The "heartbeat" of your logic—learn what stays here and what needs to move.
Subroutines: How to create modular building blocks for reusable code like pump sequences or alarm handlers.
Interrupt Programs: Your "emergency response team"—how to handle high-speed encoder pulses and PID loops that can't wait for a full scan.
Best Practices: Why CLICK doesn't allow "nesting" and how to manage memory status when jumping between programs.
Stop fighting with long scan times. Master the structure of your CLICK PLC today!
CLICK PLC Hardware: https://www.automationdirect.com/clickplcs?utm_source=MnR8e-cZLUs&utm_medium=VideoTeamDescription
FREE CLICK Programming Software: https://www.automationdirect.com/support/software-downloads
Free PLC Training: https://www.automationdirect.com/programmable-logic-controllers/plc-training
Online Support Page: https://community.automationdirect.com/s/contactsupport?utm_source=MnR8e-cZLUs&utm_medium=VideoTeamDescription
**Please check our website for our most up-to-date product pricing and availability.
#PLC #ClickPLC #PLCTutorial #Automation #LadderLogic #ScanTime #Subroutine #Interrupt #PLCProgramming #AutomationDirect
Watchdog timer alarms? Scan time overruns? Your PLC scan time may be creeping up because every piece of logic—timers, math, sequences, everything—is crammed into one giant Main Program. That exact frustration is what the Click PLC’s program structure was built to eliminate. By dividing your ladder logic into three distinct types—Main Program, Subroutine Programs, and Interrupt Programs—you gain the power to keep scan times short, code organized, responses lightning-fast, and troubleshooting straightforward. Let’s walk through what each type does, how they interact, and when to reach for each one so you can build more reliable, easier-to-maintain automation. The Main Program is the heartbeat of your application. Every scan cycle, the PLC reads inputs, executes the Main Program rung by rung, updates outputs, and repeats. This is where your core machine control lives: start/stop sequences, monitoring sensors, driving actuators, running most timers and counters. Starting from the top, it executes sequentially down the ladder—unless sidetracked by a subroutine or interrupt program—and it ends with an END instruction to close the scan. Use the Main Program for the everyday logic that must happen on every cycle—but keep it lean. A bloated Main Program slows everything down. Subroutine Programs are your modular building blocks. You can create hundreds of named subroutines, depending on the total program size and step count. They only run when explicitly called with a CALL instruction from the Main Program. When called, the PLC jumps to the subroutine, executes every rung until it hits a RETURN (which you must include), then returns exactly to the instruction after the CALL. Subroutines shine for reusable code: a common pump startup sequence, an alarm handler, a recipe calculation, or any block you want to call from multiple places. They make your Main Program shorter, cleaner, and faster to scan while keeping logic organized and easy to maintain. A couple of things to keep in mind: If a sub is not called on any given scan, the bit memory and data registers within the sub will maintain their status from the last time the sub was called—unless changed in the Main, of course. Also, in the Click, no nesting of subs is possible. In other words, you can’t CALL from within a subroutine. Interrupt Programs are your emergency-response team. Up to 12 on standard CPUs, 8 on analog models, or up to 32 on Click Plus. They trigger on specific events—rising or falling edges on high-speed inputs, or timed intervals you define (every 10 ms, every 3 seconds, etc.). When the trigger fires, the PLC immediately pauses the current scan, executes the interrupt program to completion, hits RETURN, and resumes exactly where it left off. Interrupts cannot call subroutines and do not use END. Reserve them for anything that absolutely cannot wait for the next full scan: counting fast encoder pulses without missing counts, updating a PID loop on a precise schedule, or reacting instantly to a crucial limit switch. Put it all together like this: build your foundation in the Main Program, break out reusable or conditional logic into Subroutines, and protect time-sensitive tasks with Interrupts. That separation keeps scans quick, code readable, and your machine responsive. Open the free CLICK software, experiment with these program types, and check the built-in help. Better yet, visit AutomationDirect.com to find out about free PLC training. Click here to see more videos about our Click line of PLCs. Click here to check out our webstore and free PLC training. Click here to subscribe to our YouTube channel and keep up to date on all new products and news from AutomationDirect.
Safe &
Secure
Voted #1 mid-sized employer in Atlanta
Check out our
job openings