Star-delta starter using timers in PLC Programming - Time & Space Complexity
We want to understand how the time it takes for a star-delta starter program to run changes as we adjust timer settings.
Specifically, how does the program's execution scale with the timer delays involved?
Analyze the time complexity of the following star-delta starter PLC code using timers.
// Star-delta starter sequence using timers
IF StartButton THEN
StarCoil := TRUE;
TimerStar(IN:=StarCoil, PT:=T#5s);
IF TimerStar.Q THEN
StarCoil := FALSE;
DeltaCoil := TRUE;
TimerDelta(IN:=DeltaCoil, PT:=T#3s);
END_IF;
IF TimerDelta.Q THEN
DeltaCoil := FALSE;
END_IF;
END_IF;
This code controls motor starting by first energizing the star coil for 5 seconds, then switching to the delta coil for 3 seconds using timers.
Look for loops or repeated checks in the code.
- Primary operation: The program continuously checks timer states each scan cycle.
- How many times: The timer checks happen every scan while the start button is pressed and timers are running.
The program runs in a loop, checking timers each scan. The total time depends on timer durations.
| Timer Duration (seconds) | Approx. Scan Checks |
|---|---|
| 5 + 3 = 8 | About 8 seconds worth of scans |
| 10 + 6 = 16 | About 16 seconds worth of scans |
| 50 + 30 = 80 | About 80 seconds worth of scans |
Pattern observation: The number of timer checks grows linearly with the total timer duration set.
Time Complexity: O(n)
This means the program's running time grows linearly with the total timer duration set in the star-delta sequence.
[X] Wrong: "The timers cause the program to run in constant time regardless of duration."
[OK] Correct: The PLC scans repeatedly check timer states, so longer timer durations mean more scan cycles and more operations.
Understanding how timer delays affect program execution helps you design efficient control logic and explain timing behavior clearly in real projects.
What if we added a loop to repeat the star-delta sequence multiple times? How would the time complexity change?
Practice
Solution
Step 1: Understand star-delta starter function
The star-delta starter reduces starting current by initially connecting the motor in star mode, then switching to delta mode.Step 2: Role of timers in this process
Timers control how long the motor stays in star mode before switching to delta mode to ensure smooth transition and reduce electrical stress.Final Answer:
To control the time the motor stays connected in star and delta modes -> Option AQuick Check:
Timers control connection time = A [OK]
- Thinking timers increase motor speed
- Confusing timers with direction control
- Assuming timers measure temperature
Solution
Step 1: Identify correct timer syntax in PLC
In IEC 61131-3 standard, TON timers are declared with input IN, preset time PT, and output Q using := and => operators.Step 2: Compare options
TON Timer1 (IN:=Start, PT:=T#5s, Q=>Done) uses correct syntax: TON Timer1 (IN:=Start, PT:=T#5s, Q=>Done). Others have syntax errors or incorrect format.Final Answer:
TON Timer1 (IN:=Start, PT:=T#5s, Q=>Done) -> Option BQuick Check:
Correct IEC timer syntax = B [OK]
- Using incorrect assignment operators
- Missing time format T#5s
- Adding semicolons inside declarations
IF Start THEN
TimerStar(IN:=TRUE, PT:=T#10s);
IF TimerStar.Q THEN
TimerDelta(IN:=TRUE, PT:=T#5s);
END_IF
END_IFWhat is the output state of TimerDelta.Q after 12 seconds of Start being TRUE?
Solution
Step 1: Analyze TimerStar behavior
TimerStar starts when Start is TRUE and runs for 10 seconds. After 10 seconds, TimerStar.Q becomes TRUE.Step 2: Analyze TimerDelta behavior after TimerStar.Q
Once TimerStar.Q is TRUE (after 10s), TimerDelta starts and runs for 5 seconds. At 12 seconds, TimerDelta has been running for 2 seconds, so TimerDelta.Q is still FALSE. But the code only sets TimerDelta.IN to TRUE when TimerStar.Q is TRUE, so TimerDelta is active.Step 3: Re-examine timing
At 12 seconds, TimerDelta has been running for 2 seconds (less than 5s), so TimerDelta.Q is FALSE.Final Answer:
FALSE -> Option DQuick Check:
TimerDelta.Q after 2s < 5s = FALSE [OK]
- Assuming TimerDelta.Q is TRUE immediately
- Ignoring timer preset times
- Confusing timer input IN with output Q
IF Start THEN
TimerStar(IN:=Start, PT:=T#10s);
IF TimerStar.Q THEN
TimerDelta(IN:=Start, PT:=T#5s);
END_IF
END_IFWhat is the main problem?
Solution
Step 1: Check TimerStar input
TimerStar.IN is correctly tied to Start, so it runs when Start is TRUE.Step 2: Check TimerDelta input
TimerDelta.IN is tied to Start, not TimerStar.Q. This means TimerDelta starts immediately with Start, not after TimerStar.Q becomes TRUE.Step 3: Identify the problem
TimerDelta should start only after TimerStar.Q is TRUE to ensure star mode completes before delta starts. Current code starts TimerDelta too early.Final Answer:
TimerDelta never starts because IN is tied to Start, not TimerStar.Q -> Option AQuick Check:
TimerDelta.IN must depend on TimerStar.Q [OK]
- Linking TimerDelta.IN directly to Start
- Ignoring timer sequence dependencies
- Not resetting timers properly
Solution
Step 1: Understand star-delta timing sequence
The motor must start in star mode for 8 seconds, then switch to delta mode for 10 seconds, then stop.Step 2: Analyze options
Start triggers TimerStar (8s), when TimerStar.Q is TRUE start TimerDelta (10s), when TimerDelta.Q is TRUE stop motor correctly sequences timers: TimerStar runs first, then TimerDelta starts after TimerStar.Q is TRUE, then motor stops after TimerDelta.Q is TRUE.Step 3: Eliminate incorrect options
Start triggers TimerDelta (10s), when TimerDelta.Q is TRUE start TimerStar (8s), then stop motor reverses sequence, Start triggers both TimerStar and TimerDelta simultaneously, motor stops after 18s runs timers simultaneously (wrong), Start triggers TimerStar (8s), motor stops immediately after TimerStar.Q is TRUE stops motor too early.Final Answer:
Start triggers TimerStar (8s), when TimerStar.Q is TRUE start TimerDelta (10s), when TimerDelta.Q is TRUE stop motor -> Option CQuick Check:
Sequential timers for star then delta = C [OK]
- Starting timers simultaneously
- Reversing star and delta order
- Stopping motor too early
Ready to prove it?
Pass the test and this pattern moves unknown
