diff --git a/docs/src/content/docs/reference/constants.mdx b/docs/src/content/docs/reference/constants.mdx index 67f19f3..de639f9 100644 --- a/docs/src/content/docs/reference/constants.mdx +++ b/docs/src/content/docs/reference/constants.mdx @@ -267,6 +267,79 @@ From `DecodeDigitalDownlink.c` in the [Virtual AGC project](https://github.com/v --- +## 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 + +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 + +| 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 + +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 + +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 + +At ~994 kchip/s, one chip ≈ 1.006 μs. For two-way ranging: + +``` +range_resolution ≈ c / (2 × chip_rate) ≈ 150.8 m per chip +``` + +The 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 | Constant | Value | Unit | Description |