Source: Signals Digital and Analog
Analog Signals
- Vary continuously in time and amplitude — infinite possible values between min and max
- Examples: temperature, sound, joystick position (potentiometer), AC wall voltage (−120 V to +120 V)
- Graph: smooth and continuous curve
Digital Signals
- Discrete — only two states: high (1) or low (0)
- High voltage depends on power source: 3.3 V circuit → 3.3 V high; 5 V circuit → 5 V high
- Ground is always 0 V
- Graph: square wave
Analog to Digital Conversion (ADC)
An ADC reads an analog signal and generates a digital representation.
No native ADC on Raspberry Pi / reTerminal — requires external ADC (e.g. Grove Base Hat with 12-bit ADC).
Sampling
Sampling = reading the analog signal at regular time intervals.
| Term | Formula | Description |
|---|---|---|
| Sampling period (T) | T = 1 / fs | Time between samples (seconds) |
| Sampling frequency (fs) | fs = 1 / T | Samples per second (Hz) |
Examples:
- T = 0.5 s → fs = 1/0.5 = 2 Hz
- fs = 2000 Hz → T = 1/2000 = 0.0005 s (0.5 ms)
Higher sample rate = more accurate digital representation.
Bit Resolution
The number of bits determines how many distinct values the ADC can produce:
| Bits (n) | Distinct values (2^n) |
|---|---|
| 1 | 2 |
| 3 | 8 |
| 8 | 256 |
| 12 | 4096 |
| 16 | 65536 |
Grove Base Hat ADC: 12-bit → 4096 distinct values
Encoding (Voltage → Binary)
- Identify min/max input voltage (e.g. −1 V to +1 V = 2 V range)
- Identify distinct binary values (e.g. 3-bit = 8 values: 000 to 111)
- Voltage increment per step = voltage_range / distinct_values = 2/8 = 0.25 V per step
- Map each measured voltage to the nearest binary value
Bitrate
bitrate (bits/sec) = sampling_frequency × bits_per_sample
Example: fs = 2000 Hz, 3-bit resolution → bitrate = 2000 × 3 = 6000 bits/sec
Digital Simulating Analog (PWM)
PWM uses rapid switching (discrete high/low) to simulate analog levels — e.g. LED dimming, servo positioning. See PWM concept.
See Also
- ADC concept
- Signals and ADC topic
- Serial Protocols topic (PWM)