Constants & Parameters
All constants are defined in apollo.constants and trace directly to the 1965 NAA Telecommunication Systems Study Guide (Course A-624) via the IMPLEMENTATION_SPEC.md section references noted in each table.
from apollo.constants import DOWNLINK_FREQ_HZ, PCM_HIGH_BIT_RATE, SCO_FREQUENCIESRF Carrier Frequencies
Section titled “RF Carrier Frequencies”IMPL_SPEC section 2.1.
| Constant | Value | Unit | Description |
|---|---|---|---|
DOWNLINK_FREQ_HZ | 2,287,500,000 | Hz | Downlink carrier: spacecraft to ground (2287.5 MHz) |
UPLINK_FREQ_HZ | 2,106,406,250 | Hz | Uplink carrier: ground to spacecraft (2106.40625 MHz) |
COHERENT_RATIO | (240, 221) | — | Coherent turnaround ratio: Tx = Rx x 240/221 |
VCO_REFERENCE_HZ | 19,062,500 | Hz | Master oscillator reference (19.0625 MHz) |
Modulation Parameters
Section titled “Modulation Parameters”IMPL_SPEC section 2.3.
| Constant | Value | Unit | Description |
|---|---|---|---|
PM_PEAK_DEVIATION_RAD | 0.133 | rad | Peak phase deviation (7.6 degrees) |
PM_SENSITIVITY_RAD_PER_V | 0.033 | rad/V | PM sensitivity at 1 kHz |
FM_VCO_SENSITIVITY_HZ_PER_V | 1,500,000 | Hz/V | FM VCO sensitivity (1.5 MHz peak / V peak) |
FM_MODULATION_BW_HZ | 1,500,000 | Hz | FM modulation bandwidth (5 Hz to 1.5 MHz) |
Subcarrier Frequencies
Section titled “Subcarrier Frequencies”IMPL_SPEC section 4.2.
Downlink Subcarriers
Section titled “Downlink Subcarriers”| Constant | Value | Unit | Description |
|---|---|---|---|
PCM_SUBCARRIER_HZ | 1,024,000 | Hz | PCM telemetry subcarrier (1.024 MHz, BPSK modulated) |
VOICE_SUBCARRIER_HZ | 1,250,000 | Hz | Voice subcarrier (1.25 MHz, FM modulated) |
EMERGENCY_KEY_HZ | 512,000 | Hz | Emergency keyed carrier (512 kHz) |
PCM Bandpass Filter
Section titled “PCM Bandpass Filter”| Constant | Value | Unit | Description |
|---|---|---|---|
PCM_BPF_LOW_HZ | 949,000 | Hz | Lower edge of PCM bandpass filter |
PCM_BPF_HIGH_HZ | 1,099,000 | Hz | Upper edge of PCM bandpass filter |
PCM_BPF_BW_HZ | 150,000 | Hz | PCM bandpass filter bandwidth (derived: HIGH - LOW) |
Voice Channel
Section titled “Voice Channel”| Constant | Value | Unit | Description |
|---|---|---|---|
VOICE_FM_DEVIATION_HZ | 29,000 | Hz | Voice FM deviation (+/-29 kHz) |
VOICE_AUDIO_LOW_HZ | 300 | Hz | Voice audio passband lower edge |
VOICE_AUDIO_HIGH_HZ | 3,000 | Hz | Voice audio passband upper edge |
Uplink Subcarriers
Section titled “Uplink Subcarriers”IMPL_SPEC section 2.2.
| Constant | Value | Unit | Description |
|---|---|---|---|
UPLINK_VOICE_SUBCARRIER_HZ | 30,000 | Hz | Uplink voice subcarrier (30 kHz FM) |
UPLINK_DATA_SUBCARRIER_HZ | 70,000 | Hz | Uplink data subcarrier (70 kHz FM) |
Master Clock & Timing
Section titled “Master Clock & Timing”IMPL_SPEC section 5.5.
| Constant | Value | Unit | Description |
|---|---|---|---|
MASTER_CLOCK_HZ | 512,000 | Hz | CTE master clock (512 kHz). All timing derived from this |
The master clock divides to produce both bit rates:
- High rate: 512 kHz / 10 = 51.2 kHz
- Low rate: 512 kHz / 320 = 1.6 kHz
PCM Telemetry Parameters
Section titled “PCM Telemetry Parameters”IMPL_SPEC sections 5.1, 5.2.
High Bit Rate
Section titled “High Bit Rate”| Constant | Value | Unit | Description |
|---|---|---|---|
PCM_HIGH_BIT_RATE | 51,200 | bps | High bit rate (51.2 kbps NRZ, MSB first) |
PCM_HIGH_CLOCK_DIVIDER | 10 | — | Master clock divisor: 512 kHz / 10 |
PCM_HIGH_WORD_RATE | 6,400 | words/s | Word rate at high bit rate |
PCM_HIGH_WORDS_PER_FRAME | 128 | words | Words per frame at high rate |
PCM_HIGH_FRAMES_PER_SEC | 50 | fps | Frame rate at high bit rate |
PCM_HIGH_FRAME_PERIOD_US | 19,968 | us | Frame period in microseconds |
Low Bit Rate
Section titled “Low Bit Rate”| Constant | Value | Unit | Description |
|---|---|---|---|
PCM_LOW_BIT_RATE | 1,600 | bps | Low bit rate (1.6 kbps) |
PCM_LOW_CLOCK_DIVIDER | 320 | — | Master clock divisor: 512 kHz / 320 |
PCM_LOW_WORD_RATE | 200 | words/s | Word rate at low bit rate |
PCM_LOW_WORDS_PER_FRAME | 200 | words | Words per frame at low rate |
PCM_LOW_FRAMES_PER_SEC | 1 | fps | Frame rate at low bit rate |
Frame Structure
Section titled “Frame Structure”| Constant | Value | Unit | Description |
|---|---|---|---|
PCM_WORD_LENGTH | 8 | bits | Bits per telemetry word |
PCM_SYNC_WORD_LENGTH | 32 | bits | Sync pattern length (4 words) |
PCM_SYNC_A_LENGTH | 5 | bits | Selectable A field width |
PCM_SYNC_CORE_LENGTH | 15 | bits | Fixed core pattern width (complemented on odd frames) |
PCM_SYNC_B_LENGTH | 6 | bits | Selectable B field width |
PCM_SYNC_FRAME_ID_LENGTH | 6 | bits | Frame ID field width (encodes 1-50) |
Subframe Timing
Section titled “Subframe Timing”| Constant | Value | Unit | Description |
|---|---|---|---|
SUBFRAME_FRAMES | 50 | frames | Frames per subframe (high rate) |
SUBFRAME_PERIOD_S | 1.0 | s | Subframe period |
Default Sync Word Fields
Section titled “Default Sync Word Fields”These are the patchboard-configurable values used as defaults. On real hardware, these were set by wiring jumpers on the PCM encoder.
| Constant | Value (binary) | Value (decimal) | Description |
|---|---|---|---|
DEFAULT_SYNC_A | 10101 | 21 | 5-bit A field |
DEFAULT_SYNC_CORE | 111001101011100 | 29404 | 15-bit fixed core (even-frame value) |
DEFAULT_SYNC_B | 110100 | 52 | 6-bit B field |
A/D Converter (Coder)
Section titled “A/D Converter (Coder)”IMPL_SPEC section 5.3.
| Constant | Value | Unit | Description |
|---|---|---|---|
ADC_BITS | 8 | bits | ADC resolution |
ADC_ZERO_CODE | 1 | — | Code for 0V input (00000001) |
ADC_FULLSCALE_CODE | 254 | — | Code for 4.98V input (11111110) |
ADC_OVERFLOW_CODE | 255 | — | Code for >5V input (11111111) |
ADC_FULLSCALE_VOLTAGE | 4.98 | V | Full-scale input voltage |
ADC_STEP_MV | 19.7 | mV | Voltage per least-significant bit |
ADC_LOW_LEVEL_GAIN | 125 | — | Gain multiplier for low-level inputs (0-40 mV range) |
The conversion formula is:
voltage = (code - 1) * 4.98 / 253For low-level inputs (0-40 mV), the amplifier applies x125 gain before digitization. To recover the actual input voltage, divide by 125.
Subcarrier Oscillators (FM Mode)
Section titled “Subcarrier Oscillators (FM Mode)”IMPL_SPEC section 4.3. These 9 SCO channels are present only in FM downlink mode.
| Constant | Value | Unit | Description |
|---|---|---|---|
SCO_DEVIATION_PERCENT | 7.5 | % | Deviation as percentage of center frequency (+/-) |
SCO_INPUT_RANGE_V | (0.0, 5.0) | V | DC input voltage range |
SCO_OUTPUT_LEVEL_V | 0.707 | V | Peak output level into 5.11 kOhm |
SCO Channel Frequencies
Section titled “SCO Channel Frequencies”SCO_FREQUENCIES is a dict mapping channel number to center frequency:
| SCO Channel | Center Frequency (Hz) | Deviation +/- (Hz) | Low Freq (Hz) | High Freq (Hz) |
|---|---|---|---|---|
| 1 | 14,500 | 1,087.5 | 13,412.5 | 15,587.5 |
| 2 | 22,000 | 1,650.0 | 20,350.0 | 23,650.0 |
| 3 | 30,000 | 2,250.0 | 27,750.0 | 32,250.0 |
| 4 | 40,000 | 3,000.0 | 37,000.0 | 43,000.0 |
| 5 | 52,500 | 3,937.5 | 48,562.5 | 56,437.5 |
| 6 | 70,000 | 5,250.0 | 64,750.0 | 75,250.0 |
| 7 | 95,000 | 7,125.0 | 87,875.0 | 102,125.0 |
| 8 | 125,000 | 9,375.0 | 115,625.0 | 134,375.0 |
| 9 | 165,000 | 12,375.0 | 152,625.0 | 177,375.0 |
All SCOs map 0-5V DC input linearly to the frequency deviation range. 0V corresponds to the low frequency limit, 2.5V to the center, and 5V to the high frequency limit.
Virtual AGC Interface
Section titled “Virtual AGC Interface”IMPL_SPEC section 1.
Connection
Section titled “Connection”| Constant | Value | Unit | Description |
|---|---|---|---|
AGC_PORT_BASE | 19697 | — | TCP port base for yaAGC socket connections |
AGC_MAX_CLIENTS | 10 | — | Maximum concurrent client connections |
AGC I/O Channels
Section titled “AGC I/O Channels”Channels are defined in octal in the original AGC documentation. The constants store decimal equivalents.
| Constant | Octal | Decimal | Description |
|---|---|---|---|
AGC_CH_INLINK | 045 | 37 | Uplink data input (ground to AGC) |
AGC_CH_OUTLINK | 057 | 47 | Downlink data output (AGC to ground) |
AGC_CH_DNTM1 | 034 | 28 | Telemetry word 1 (high byte) |
AGC_CH_DNTM2 | 035 | 29 | Telemetry word 2 (low byte) |
AGC_CH_OUT0 | 010 | 8 | Relay rows |
AGC_CH_DSALMOUT | 011 | 9 | DSKY alarms |
AGC_CH_CHAN13 | 013 | 11 | Radar activity |
AGC_CH_CHAN30 | 030 | 24 | Status/alarm bits |
AGC_CH_CHAN33 | 033 | 27 | AGC warning input |
Telecom Channel Set
Section titled “Telecom Channel Set”AGC_TELECOM_CHANNELS is a frozenset containing the four primary telecom channels used by the bridge filter:
AGC_TELECOM_CHANNELS = frozenset({ AGC_CH_INLINK, # 37 (045 octal) AGC_CH_OUTLINK, # 47 (057 octal) AGC_CH_DNTM1, # 28 (034 octal) AGC_CH_DNTM2, # 29 (035 octal)})Downlink Buffer
Section titled “Downlink Buffer”| Constant | Value | Unit | Description |
|---|---|---|---|
AGC_DOWNLINK_BUFFER_WORDS | 400 | 15-bit words | Size of one complete downlink data snapshot |
Downlink List Type IDs
Section titled “Downlink List Type IDs”From DecodeDigitalDownlink.c in the Virtual AGC project:
| Constant | Value | Description |
|---|---|---|
DL_CM_POWERED_LIST | 0 | CM Powered Flight |
DL_LM_ORBITAL_MANEUVERS | 1 | LM Orbital Maneuvers |
DL_CM_COAST_ALIGN | 2 | CM Coast/Alignment |
DL_LM_COAST_ALIGN | 3 | LM Coast/Alignment |
DL_LM_DESCENT_ASCENT | 7 | LM Descent/Ascent |
DL_LM_LUNAR_SURFACE_ALIGN | 8 | LM Lunar Surface Alignment |
DL_CM_ENTRY_UPDATE | 9 | CM Entry Update |
Uplink Modulation Parameters
Section titled “Uplink Modulation Parameters”IMPL_SPEC section 2.2. These parameters define the uplink RF modulation characteristics — the signal path from ground station to spacecraft.
| Constant | Value | Unit | Description |
|---|---|---|---|
UPLINK_PM_DEVIATION_RAD | 1.0 | rad | Peak PM deviation (57.3 degrees — much stronger than downlink’s 0.133 rad) |
UPLINK_DATA_BIT_RATE | 2,000 | bps | Uplink command data rate (2 kbps NRZ) |
UPLINK_DATA_FM_DEVIATION_HZ | 4,000 | Hz | FM deviation on the 70 kHz data subcarrier (±4 kHz) |
UPLINK_VOICE_FM_DEVIATION_HZ | 7,500 | Hz | FM deviation on the 30 kHz voice subcarrier (±7.5 kHz) |
UPLINK_WORD_BITS | 15 | bits | AGC word width (matches AGC 15-bit architecture) |
UPLINK_INTER_WORD_GAP | 3 | bit periods | Zero-bit gap between serialized words (UPRUPT timing margin) |
PRN Ranging
Section titled “PRN Ranging”Ken Shirriff’s research and NASA documentation. The ranging system measures Earth-Moon distance by correlating a pseudo-random noise (PRN) code.
Chip Rate & Code Length
Section titled “Chip Rate & Code Length”| Constant | Value | Unit | Description |
|---|---|---|---|
RANGING_CHIP_RATE_HZ | 993,963 | chip/s | PRN chip rate (~994 kchip/s) |
RANGING_CODE_LENGTH | 5,456,682 | chips | Full code period: 2 × 11 × 31 × 63 × 127 |
SPEED_OF_LIGHT_M_S | 299,792,458 | m/s | Used for delay-to-range conversion |
Component Code Lengths
Section titled “Component Code Lengths”The PRN code is built from five component codes combined with majority-vote logic:
| Constant | Value | Description |
|---|---|---|
RANGING_CL_LENGTH | 2 | Clock component (alternating 0/1) |
RANGING_X_LENGTH | 11 | X code (custom feedback logic) |
RANGING_A_LENGTH | 31 | A code (5-bit LFSR) |
RANGING_B_LENGTH | 63 | B code (6-bit LFSR) |
RANGING_C_LENGTH | 127 | C code (7-bit LFSR) |
LFSR Generator Parameters
Section titled “LFSR Generator Parameters”Initial states and feedback tap positions for each linear feedback shift register:
| Constant | Value | Description |
|---|---|---|
RANGING_X_INIT | 22 (0b10110) | X code initial register state |
RANGING_A_INIT | 0x1F (all ones) | A code initial state (5-bit) |
RANGING_B_INIT | 0x3F (all ones) | B code initial state (6-bit) |
RANGING_C_INIT | 0x7F (all ones) | C code initial state (7-bit) |
RANGING_A_TAPS | (2, 0) | A LFSR feedback: x⁵ + x² + 1 |
RANGING_B_TAPS | (1, 0) | B LFSR feedback: x⁶ + x + 1 |
RANGING_C_TAPS | (1, 0) | C LFSR feedback: x⁷ + x + 1 |
Range Resolution
Section titled “Range Resolution”At ~994 kchip/s, one chip ≈ 1.006 μs. For two-way ranging:
range_resolution ≈ c / (2 × chip_rate) ≈ 150.8 m per chipThe full code period covers approximately 5.49 seconds of round-trip delay, equivalent to ~822,600 km one-way range — more than enough for Earth-Moon distance (~384,400 km).
Recommended Sample Rates
Section titled “Recommended Sample Rates”| Constant | Value | Unit | Description |
|---|---|---|---|
SAMPLE_RATE_BASEBAND | 5,120,000 | Hz | Baseband rate: 10x master clock (5.12 MHz) |
SAMPLE_RATE_RF | 10,240,000 | Hz | RF rate: 20x master clock (10.24 MHz) |
Both rates are integer multiples of the 512 kHz master clock, ensuring clean relationships with all PCM timing.
Receiver PLL Parameters
Section titled “Receiver PLL Parameters”IMPL_SPEC section 2.2.
| Constant | Value | Unit | Description |
|---|---|---|---|
RX_PLL_BW_HZ | 318 | Hz | PLL bandwidth at threshold |
RX_STATIC_PHASE_ERROR_DEG | 6.0 | degrees | Maximum static phase error |
RX_AGC_RANGE_DB | 80 | dB | AGC dynamic range (-132 to -52 dBm) |
RX_AGC_TIME_CONSTANT_S | 5.7 | s | AGC time constant |
RX_THRESHOLD_DBM | -132.5 | dBm | Receiver sensitivity threshold |
Transmitter Parameters
Section titled “Transmitter Parameters”IMPL_SPEC section 2.3 and 3.1.
| Constant | Value | Unit | Description |
|---|---|---|---|
TX_POWER_MW | 300 | mW | Transmitter power (250-400 mW typical) |
TX_IMPEDANCE_OHM | 50 | Ohm | Output impedance |
Traveling Wave Tube (TWT) Amplifier
Section titled “Traveling Wave Tube (TWT) Amplifier”| Constant | Value | Unit | Description |
|---|---|---|---|
TWT_LOW_POWER_W | 5 | W | TWT low power mode |
TWT_HIGH_POWER_W | 20 | W | TWT high power mode |
TWT_WARMUP_S | 90 | s | TWT warmup time |