Clock-Driven Crossing Lights
Railroad crossing lights using clock and NOT gate. Learn about timing circuits and alternating outputs. Introduction to sequential timing.
배울 내용
- Drive a sequential pattern with a clock signal.
- Use a toggle flip-flop to alternate between two states.
- Connect Q and ¬Q outputs to drive complementary output lights.
- Recognize that the output frequency is half the clock frequency.
- Understand the simplest pattern of synchronous sequential logic.
작동 원리
A clock-driven crossing lights circuit demonstrates how a clock signal can drive a simple alternating output sequence. The classic application: railroad crossing lights that alternate between two LEDs while a train approaches.
The core mechanism is a clock + flip-flop in toggle mode: each clock edge flips a stored bit, and the bit (and its complement) drive two output lights. Result: lights alternate at half the clock frequency.
For a more dramatic effect, two flip-flops in toggle mode produce a 4-state sequence; combinational logic on the two outputs decodes which lights to illuminate at each phase. With four states you can do pattern A-B-A-B (alternation) or A-AB-B-AB (four phases), depending on how the outputs are decoded.
This is the simplest possible synchronous sequential circuit — state changes only on clock edges, the state determines the output, and the output is observable as a deterministic time-varying pattern. It's the seed of finite-state machines and clocked control logic.
단계별로 시도해 보세요
위 임베드에서 입력을 설정한 후, 예상 결과를 읽고 직접 확인하세요.
- 1Clock = running at 1 Hz예상:
Lights alternate at 0.5 Hz관찰 포인트: The two lights swap on every clock edge — one on, one off. Each light's frequency is half the clock's. - 2Clock = stopped예상:
Lights frozen관찰 포인트: Stop the clock — pattern freezes wherever it is. Sequential circuits need a clock to evolve. - 3Clock = running at 10 Hz예상:
Faster alternation, 5 Hz visible관찰 포인트: Increase the clock frequency — the lights blink faster. The relationship is exactly clock_freq / 2. - 4Clock = single edge예상:
Lights swap once관찰 포인트: A single clock pulse produces a single state transition. Sequential logic responds to edges, not levels.
사용된 구성 요소
실제 응용 사례
Real railroad crossing lights. Modern crossings use microcontroller-driven LED arrays, but the alternating-light behaviour is exactly what this circuit demonstrates.
Construction-site warning lights. Yellow flashers on barriers alternate at a fixed rate — same clock-divided toggle pattern.
Heartbeat / activity LEDs. A microcontroller's activity LED blinks at a fixed rate to confirm the system is alive — implemented as a counter divided down to a slow clock.
PWM-driven LED brightness. A clock divides the system clock down to a PWM frequency that controls duty cycle for analog-style brightness — same clock-divider principle.
Synchronous traffic light controllers. Real traffic lights use FSMs clocked at 1 Hz or so; the alternating crossing-light pattern is a one-state FSM specialization.
자주 묻는 질문
Why do the lights alternate instead of both flashing on and off together?
Because one is driven by Q and the other by ¬Q (the complement). When Q toggles, Q goes 0→1 while ¬Q goes 1→0 — the lights swap.
How would I make the pattern slower?
Either reduce the clock frequency, or add more divide-by-2 stages (more T flip-flops in series) to divide the clock further. Cascading 4 flip-flops gives clock/16; cascading 6 gives clock/64.
Could I make a 3-light pattern?
Yes — use a 2-bit counter (two T flip-flops) and decode the 4 states with combinational logic to drive 3 lights in a pattern like A-AB-B-AB. Or 3 lights in a circle with a 3-state FSM.
How is this different from a standard counter?
It's a 1-bit counter (one toggle flip-flop). A wider counter has more bits and counts higher; this one toggles between two states only. The principles (clock-driven state transitions) are identical.
What if the clock has glitches?
Each glitch could cause an extra toggle. Real designs use clean clock generators and sometimes add Schmitt-trigger inputs to filter noise. In a simulator, you can assume the clock is glitch-free.