Activity 1.2.5 — Analog Random Number Generator Design¶
Learning Objectives¶
By the end of this lesson, students will be able to:
- Explain how analog circuits can generate unpredictable electrical signals
- Design an analog RNG circuit using a 555 timer and comparator
- Apply the design process to create and test an analog circuit
- Integrate analog and digital subsystems into a complete system
Vocabulary¶
Vocabulary (click to expand)
| Term | Definition |
|---|---|
| 555 Timer | An integrated circuit that generates precise timing signals and oscillations |
| Oscillator | A circuit that produces a repeating electronic signal (waveform) |
| Capacitor | An electronic component that stores electrical energy in an electric field |
| Comparator | A circuit that compares two input voltages and outputs a digital signal |
| Threshold | A predetermined voltage level that triggers a change in circuit behavior |
| Clock Signal | A periodic digital signal used to synchronize circuit operations |
| Jitter | Unpredictable, rapid variations in a signal timing or voltage |
Part 1: The RNG Design Challenge¶
What makes a number "random"? In digital systems, we work with predictable signals—every calculation follows rules, every output can be predicted if you know the inputs. But what if you need something truly unpredictable?
This is the design challenge: create a circuit that outputs a random value.
Why Random Numbers Matter¶
Random number generators (RNGs) are essential in: - Video games and simulations - Cryptography and security systems - Scientific sampling and experiments - Lotteries and gambling devices - Noise generation for audio/video
The Analog Approach¶
In the analog world, randomness comes from physical phenomena that are difficult to predict: - Thermal noise in resistors - Radioactive decay timing - Atmospheric static - Capacitor discharge timing
For our design, we will use a 555 timer oscillator combined with capacitor charging/discharging to create an unpredictable analog voltage that can be converted to a digital output.
Practice Problem — Understanding Analog Randomness¶
If a capacitor takes exactly 2.3 seconds to discharge through a resistor, what makes the timing "random" when we use this in an RNG?
Think about what external factors might affect the discharge time. Consider temperature, component tolerances, and the exact moment we start measuring.
Show Solution
The "randomness" comes from:
1. EXTERNAL FACTORS (environmental):
- Temperature changes affect resistance and capacitance
- Humidity affects circuit characteristics
- Electromagnetic interference adds noise
2. HUMAN FACTOR:
- The exact moment a person presses a button varies
- Human reaction times are inconsistent (~200-300ms with ~50ms variance)
3. COMPONENT TOLERANCES:
- Capacitors typically have 10-20% tolerance
- Resistors typically have 5-10% tolerance
- These variations add up to unpredictable timing
The circuit is NOT truly random (it's deterministic), but it produces
unpredictable results because we cannot control all the variables.
This is called "pseudorandom" - unpredictable in practice, but
following deterministic rules.
Part 2: Designing the Analog RNG¶
Block Diagram¶
┌─────────────────────────────────────────────────────────────┐
│ ANALOG RNG SYSTEM │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────┐ ┌──────────────┐ ┌─────────────────┐ │
│ │ 555 │───▶│ ANALOG │───▶│ DIGITAL │ │
│ │ TIMER │ │ SECTION │ │ OUTPUT │ │
│ │(Oscillator)│ │(Capacitor) │ │ (LED/Display) │ │
│ └──────────┘ └──────────────┘ └─────────────────┘ │
│ │
│ Generates Creates Converts to │
│ timing pulses unpredictable discrete states │
│ voltage │
└─────────────────────────────────────────────────────────────┘
Circuit Components¶
| Component | Part Number | Purpose |
|---|---|---|
| 555 Timer | NE555 | Generates clock pulses at ~1kHz |
| Capacitor | 10µF | Creates variable time constant |
| Resistor | 10kΩ | Controls discharge rate |
| Comparator | LM393 | Converts analog voltage to digital output |
| LED | Standard | Visual output indicator |
Design Process Review¶
Remember our engineering design process:
┌─────────────────────────────────────────────────────────────┐
│ ENGINEERING DESIGN PROCESS │
├─────────────────────────────────────────────────────────────┤
│ │
│ 1. DEFINE THE PROBLEM │
│ ↓ │
│ 2. RESEARCH │
│ ↓ │
│ 3. DESIGN (CDS - Conceptual Design Sketch) │
│ ↓ │
│ 4. SIMULATE │
│ ↓ │
│ 5. BUILD (DMS - Detailed Manufacturing Spec) │
│ ↓ │
│ 6. TEST │
│ ↓ │
│ 7. DOCUMENT │
│ │
└─────────────────────────────────────────────────────────────┘
Part 3: The 555 Timer as an Oscillator¶
How the 555 Timer Works¶
The 555 timer can operate in different modes. In astable mode, it continuously produces a square wave without needing a trigger input. This makes it perfect for our RNG clock.
Astable Mode Configuration¶
┌───────────────┐
VCC ───┤ 8 │
│ 555 │
│ │
GND ───┤ 1 │
│ │
┌────┤ 4 (RESET) │
│ │ │
│ └───────┬───────┘
│ │
10kΩ 10µF
│ │
│ │
└────┬───────┘
│
└─── Pin 2 & 6 (Threshold/Trigger)
Output: Pin 3
Timing Calculations¶
The 555 astable frequency depends on the resistor and capacitor values:
High Time (TH): 0.693 × R × C
Low Time (TL): 0.693 × R × C
Period (T): 0.693 × R × C × 2
Frequency (f): 1.443 ÷ (R × C)
Practice Problem — Calculate Oscillator Frequency¶
Calculate the output frequency if R = 10kΩ and C = 10µF.
Show Solution
Part 4: Creating the Random Output¶
The Comparator Stage¶
The unpredictable voltage from the capacitor is fed into a comparator. The comparator compares this voltage against a reference threshold:
Analog Input ┌────────────┐ Digital Output
(0V to VCC) ────▶│ ├───▶ L (voltage < threshold)
│ COMPARATOR │
Reference ──────▶│ │ H (voltage ≥ threshold)
(½ VCC) └────────────┘
Why This Creates Randomness¶
The capacitor voltage follows an exponential curve during charge/discharge:
Voltage
│
VCC│ ●
│ ●
│ ●
VCC/2├──────●────────────── Threshold
│ ●
│●
│________________________
0 Time (τ) →
The exact voltage at any moment depends on: - Where we are in the charge/discharge cycle - Environmental factors affecting component values - The precise timing of user input
Part 5: Building and Testing¶
MultiSim/PLTW S7 Schematic Design¶
When creating your schematic in MultiSim or PLTW S7:
- Place components from the component library
- Connect wires using proper wire routing
- Add labels for signal names and test points
- Include virtual instruments (oscilloscope, multimeter)
- Add title block with your name, date, and project title
Breadboard Prototyping¶
Follow these guidelines for building your circuit:
| Step | Action | Why It Matters |
|---|---|---|
| 1 | Power off | Prevents component damage |
| 2 | Check components | Verify values before placing |
| 3 | Build systematically | Follow signal flow left-to-right |
| 4 | Check connections | Ensure all pins are connected |
| 5 | Power on slowly | Watch for smoke or heat |
| 6 | Test incrementally | Verify each section works |
Testing Procedure¶
- Visual Inspection: Check for loose wires, backwards components
- Power Check: Verify voltage levels with multimeter
- Oscillator Test: Confirm 555 output with oscilloscope
- Comparator Test: Verify output changes with input voltage
- Full System Test: Run multiple trials, record results
Measurement Recording¶
┌─────────────────────────────────────────────────────────────┐
│ RNG TEST DATA SHEET │
├─────────────────────────────────────────────────────────────┤
│ Date: _____________ Tester: _____________________________ │
│ │
│ Component Voltage Measurements: │
│ ┌──────────────────┬─────────────┬─────────────┐ │
│ │ Measurement │ Expected │ Actual │ │
│ ├──────────────────┼─────────────┼─────────────┤ │
│ │ 555 VCC │ 5.0V │ _____ V │ │
│ │ Capacitor Max │ ~3.3V │ _____ V │ │
│ │ Capacitor Min │ ~1.7V │ _____ V │ │
│ │ Comparator Ref │ 2.5V │ _____ V │ │
│ └──────────────────┴─────────────┴─────────────┘ │
│ │
│ Output Observations (circle one): │
│ LED blinks consistently? YES / NO │
│ Output appears random? YES / NO │
│ Results are unpredictable? YES / NO │
│ │
└─────────────────────────────────────────────────────────────┘
Part 6: System Integration¶
Integrating Analog and Digital Sections¶
The complete RNG system combines:
| Section | Components | Function |
|---|---|---|
| Clock Generation | 555 Timer | Creates timing pulses |
| Analog Randomness | Capacitor, Resistor | Unpredictable voltage |
| Signal Conversion | Comparator | Analog to digital |
| Output Stage | LED, Counter | Display results |
Block Level Integration¶
┌──────────────────────────────────────────────────────────────┐
│ COMPLETE RNG SYSTEM │
├──────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────┐ ┌───────────┐ ┌────────────┐ ┌─────────┐ │
│ │ 555 │──▶│ ANALOG │──▶│ COMPARATOR │──▶│ COUNTER │ │
│ │ Timer │ │ SECTION │ │ │ │ & DISP │ │
│ │ (Clock) │ │ (Random) │ │ (ADC) │ │ │ │
│ └─────────┘ └───────────┘ └────────────┘ └─────────┘ │
│ │
│ Stable Physical Converts Counts & │
│ timing chaos to digital displays │
│ │
└──────────────────────────────────────────────────────────────┘
Summary¶
Key takeaways from this lesson:
- Analog circuits can generate unpredictable (pseudorandom) outputs through physical phenomena
- The 555 timer in astable mode produces continuous clock pulses used for timing
- Capacitor charge/discharge creates variable voltages affected by many factors
- Comparators convert analog voltages to discrete digital signals
- The design process (Define → Research → Design → Simulate → Build → Test → Document) guides engineering work
- System integration combines multiple subsystems into a complete functional device
- Testing and measurement verify that designs meet specifications
Key Reminders¶
- Always power off before building or modifying circuits
- Use the engineering design process for all projects
- Document your work completely—sketches, schematics, and test data
- Analog randomness is actually deterministic—it only appears random due to complexity
- The 555 timer is a versatile IC with many applications beyond this lesson
- Proper measurement technique is essential for debugging circuits
Custom activity — adapted from PLTW Digital Electronics