|
| 1 | +# Autotune and Presets Documentation |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +The ESP miner implements two complementary systems for power management optimization: |
| 6 | + |
| 7 | +1. **Presets System**: Pre-configured settings for different performance profiles |
| 8 | +2. **Autotuning Logic**: Dynamic adjustment of mining parameters based on real-time conditions |
| 9 | + |
| 10 | +## Presets System |
| 11 | + |
| 12 | +### Device Model Support |
| 13 | + |
| 14 | +The presets system supports four device models, each with tailored configurations: |
| 15 | + |
| 16 | +- **DEVICE_MAX**: 1x BM1397 Asic from the S17 series |
| 17 | +- **DEVICE_ULTRA**: 1x BM1366 Asic from S19XP |
| 18 | +- **DEVICE_SUPRA**: 1x BM1368 Asic from S21 |
| 19 | +- **DEVICE_GAMMA**: 1x BM1370 Asic from S21 Pro |
| 20 | + |
| 21 | +### Preset Profiles |
| 22 | + |
| 23 | +Each device model supports three preset profiles: |
| 24 | + |
| 25 | +#### Quiet Mode |
| 26 | +- **Purpose**: Low power consumption and noise |
| 27 | +- **Characteristics**: Conservative voltage and frequency settings |
| 28 | +- **Use Case**: Home mining, noise-sensitive environments |
| 29 | + |
| 30 | +#### Balanced Mode |
| 31 | +- **Purpose**: Optimal performance-to-efficiency ratio |
| 32 | +- **Characteristics**: Moderate voltage and frequency settings |
| 33 | +- **Use Case**: General purpose mining |
| 34 | + |
| 35 | +#### Turbo Mode |
| 36 | +- **Purpose**: Maximum performance |
| 37 | +- **Characteristics**: High voltage and frequency settings |
| 38 | +- **Use Case**: Maximum hashrate scenarios |
| 39 | + |
| 40 | +### Preset Configuration Examples |
| 41 | + |
| 42 | +| Device Model | Profile | Voltage (mV) | Frequency (MHz) | Fan Speed (%) | |
| 43 | +|--------------|---------|--------------|-----------------|---------------| |
| 44 | +| DEVICE_MAX | quiet | 1100 | 450 | 50 | |
| 45 | +| DEVICE_MAX | balanced| 1200 | 550 | 65 | |
| 46 | +| DEVICE_MAX | turbo | 1400 | 750 | 100 | |
| 47 | +| DEVICE_ULTRA | quiet | 1130 | 420 | 25 | |
| 48 | +| DEVICE_ULTRA | balanced| 1190 | 490 | 35 | |
| 49 | +| DEVICE_ULTRA | turbo | 1250 | 625 | 95 | |
| 50 | + |
| 51 | +### Preset Application Process |
| 52 | + |
| 53 | +When a preset is applied: |
| 54 | + |
| 55 | +1. **Safety First**: Fan speed is temporarily set to 100% for safety |
| 56 | +2. **Parameter Setting**: Voltage, frequency, and fan speed are configured |
| 57 | +3. **NVS Storage**: Settings are persisted to non-volatile storage |
| 58 | +4. **Autotune Enable**: Autotune flag is activated |
| 59 | +5. **Logging**: Configuration change is logged to database |
| 60 | + |
| 61 | +### NVS Configuration Keys |
| 62 | + |
| 63 | +- `NVS_CONFIG_ASIC_VOLTAGE`: Core voltage in millivolts |
| 64 | +- `NVS_CONFIG_ASIC_FREQ`: ASIC frequency in MHz |
| 65 | +- `NVS_CONFIG_FAN_SPEED`: Fan speed percentage |
| 66 | +- `NVS_CONFIG_AUTOTUNE_PRESET`: Applied preset name |
| 67 | +- `NVS_CONFIG_AUTOTUNE_FLAG`: Autotune enable/disable flag |
| 68 | +- `NVS_CONFIG_AUTO_FAN_SPEED`: Automatic fan control flag |
| 69 | + |
| 70 | +## Autotuning Logic |
| 71 | + |
| 72 | +### Purpose |
| 73 | + |
| 74 | +The autotuning system dynamically adjusts mining parameters to: |
| 75 | +- Maintain optimal operating temperature (60°C target) |
| 76 | +- Maximize hashrate within power and thermal limits |
| 77 | +- Prevent overheating and hardware damage |
| 78 | +- Optimize performance-per-watt efficiency |
| 79 | + |
| 80 | +### Key Parameters |
| 81 | + |
| 82 | +#### Target Values |
| 83 | +- **Target Temperature**: 60°C (optimal ASIC operating temperature) |
| 84 | +- **Temperature Tolerance**: ±2°C around target |
| 85 | +- **Hashrate Target**: Calculated based on frequency and core count |
| 86 | + |
| 87 | +#### Safety Limits |
| 88 | +- **Maximum Power**: Device-specific power limit |
| 89 | +- **Maximum Voltage**: Device-specific voltage limit |
| 90 | +- **Maximum Frequency**: Device-specific frequency limit |
| 91 | +- **Thermal Limits**: 75°C throttle, 90°C emergency shutdown |
| 92 | + |
| 93 | +### Timing Mechanism |
| 94 | + |
| 95 | +#### Warmup Period |
| 96 | +- **Duration**: 15 minutes (900 seconds) from startup |
| 97 | +- **Purpose**: Allow system to reach thermal equilibrium |
| 98 | +- **Behavior**: No adjustments during warmup if temperature < target |
| 99 | + |
| 100 | +#### Adjustment Intervals |
| 101 | +- **Normal Operation**: 5 minutes (300 seconds) when temp ≤ 68°C |
| 102 | +- **High Temperature**: 5 seconds when temp > 68°C |
| 103 | +- **Purpose**: Faster response during thermal stress |
| 104 | + |
| 105 | +### Temperature-Based Adjustments |
| 106 | + |
| 107 | +#### Temperature Within Target Range (-2°C to +2°C) |
| 108 | +**Condition**: Temperature is 58°C - 62°C |
| 109 | + |
| 110 | +**Action**: Hashrate optimization |
| 111 | +- If hashrate < 80% of target: Increase voltage by 10mV |
| 112 | +- If hashrate ≥ 80% of target: No adjustment needed |
| 113 | + |
| 114 | +#### Temperature Below Target (< -2°C) |
| 115 | +**Condition**: Temperature < 58°C |
| 116 | + |
| 117 | +**Actions**: Performance increase |
| 118 | +- Increase frequency by 2% (if within limits) |
| 119 | +- Increase voltage by 0.2% (if within limits) |
| 120 | +- Check power consumption limits before adjustment |
| 121 | + |
| 122 | +**Safety Checks**: |
| 123 | +- Frequency must be below maximum frequency limit |
| 124 | +- Power consumption must be below maximum power limit |
| 125 | +- Voltage must be below maximum voltage limit |
| 126 | + |
| 127 | +#### Temperature Above Target (> +2°C) |
| 128 | +**Condition**: Temperature > 62°C |
| 129 | + |
| 130 | +**Actions**: Performance reduction |
| 131 | +- Decrease frequency by 2% |
| 132 | +- Decrease voltage by 0.2% |
| 133 | + |
| 134 | +**Purpose**: Reduce heat generation to bring temperature back to target |
| 135 | + |
| 136 | +### Safety and Monitoring |
| 137 | + |
| 138 | +#### Prerequisites for Autotune Operation |
| 139 | +- Temperature sensor must be initialized (temp ≠ 255) |
| 140 | +- Hashrate must be > 0 (system actively mining) |
| 141 | +- Autotune flag must be enabled in NVS configuration |
| 142 | + |
| 143 | +#### Overheat Protection |
| 144 | +- **Throttle Temperature**: 75°C - Triggers Overheat Mode |
| 145 | +- **VR Temperature Limit**: 105°C throttle, 145°C maximum |
| 146 | +- **Actions**: Fan to 100%, voltage/frequency reduction, system shutdown if needed |
| 147 | + |
| 148 | +#### Data Logging |
| 149 | +All autotune adjustments are logged to the database with: |
| 150 | +- Timestamp and event type |
| 151 | +- Current and target values |
| 152 | +- Adjustment reasons and amounts |
| 153 | +- System state information |
| 154 | + |
| 155 | +### Algorithm Flow |
| 156 | + |
| 157 | +``` |
| 158 | +1. Check Prerequisites |
| 159 | + ├── Autotune enabled? |
| 160 | + ├── Valid temperature reading? |
| 161 | + ├── Hashrate > 0? |
| 162 | + └── Outside warmup period? |
| 163 | +
|
| 164 | +2. Timing Check |
| 165 | + ├── Sufficient time elapsed since last adjustment? |
| 166 | + └── Use appropriate interval (normal vs high temp) |
| 167 | +
|
| 168 | +3. Temperature Analysis |
| 169 | + ├── Calculate temperature difference from target (60°C) |
| 170 | + └── Determine adjustment strategy |
| 171 | +
|
| 172 | +4. Parameter Adjustment |
| 173 | + ├── Within target range → Optimize hashrate |
| 174 | + ├── Below target → Increase performance |
| 175 | + └── Above target → Decrease performance |
| 176 | +
|
| 177 | +5. Safety Validation |
| 178 | + ├── Check power limits |
| 179 | + ├── Check voltage limits |
| 180 | + ├── Check frequency limits |
| 181 | + └── Apply changes if safe |
| 182 | +
|
| 183 | +6. Logging and Monitoring |
| 184 | + ├── Log adjustment to database |
| 185 | + ├── Update NVS configuration |
| 186 | + └── Monitor for next cycle |
| 187 | +``` |
| 188 | + |
| 189 | +### Integration with Hardware Control |
| 190 | + |
| 191 | +#### Voltage Control |
| 192 | +- **Module**: VCORE (TPS546 voltage regulator) |
| 193 | +- **Range**: Device-specific minimum to maximum voltage |
| 194 | +- **Precision**: 1mV increments |
| 195 | +- **Response Time**: Immediate |
| 196 | + |
| 197 | +#### Frequency Control |
| 198 | +- **Module**: BM1397 ASIC frequency control |
| 199 | +- **Range**: 50 MHz to device maximum |
| 200 | +- **Precision**: 1 MHz increments |
| 201 | +- **Response Time**: Requires frequency transition process |
| 202 | + |
| 203 | +#### Temperature Monitoring |
| 204 | +- **Sensor**: EMC2101 temperature controller |
| 205 | +- **ASIC Temperature**: External sensor reading |
| 206 | +- **VR Temperature**: TPS546 internal temperature |
| 207 | +- **Update Rate**: Every 2 seconds (POLL_RATE) |
| 208 | + |
| 209 | +### Performance Optimization Features |
| 210 | + |
| 211 | +#### Adaptive Learning |
| 212 | +- System learns optimal settings through operation |
| 213 | +- Adjustments become more refined over time |
| 214 | +- Historical performance data influences decisions |
| 215 | + |
| 216 | +#### Power Efficiency |
| 217 | +- Monitors power consumption vs hashrate |
| 218 | +- Optimizes for maximum GH/s per watt |
| 219 | +- Prevents power limit violations |
| 220 | + |
| 221 | +#### Thermal Management |
| 222 | +- Proactive temperature control |
| 223 | +- Coordinated fan speed adjustment |
| 224 | +- Prevents thermal damage to components |
| 225 | + |
| 226 | +## Configuration and Usage |
| 227 | + |
| 228 | +### Enabling Autotune |
| 229 | +```c |
| 230 | +nvs_config_set_u16(NVS_CONFIG_AUTOTUNE_FLAG, 1); // Enable |
| 231 | +nvs_config_set_u16(NVS_CONFIG_AUTOTUNE_FLAG, 0); // Disable |
| 232 | +``` |
| 233 | +
|
| 234 | +### Applying Presets |
| 235 | +```c |
| 236 | +// Apply preset by name |
| 237 | +apply_preset(DEVICE_MAX, "balanced"); |
| 238 | +apply_preset(DEVICE_ULTRA, "turbo"); |
| 239 | +apply_preset(DEVICE_SUPRA, "quiet"); |
| 240 | +``` |
| 241 | + |
| 242 | +### Manual Override |
| 243 | +Individual parameters can be manually set to override autotune: |
| 244 | +```c |
| 245 | +nvs_config_set_u16(NVS_CONFIG_ASIC_VOLTAGE, 1200); // Set voltage |
| 246 | +nvs_config_set_u16(NVS_CONFIG_ASIC_FREQ, 600); // Set frequency |
| 247 | +nvs_config_set_u16(NVS_CONFIG_AUTO_FAN_SPEED, 0); // Disable auto fan |
| 248 | +``` |
| 249 | +
|
| 250 | +## Best Practices |
| 251 | +
|
| 252 | +### Recommended Usage |
| 253 | +1. **Initial Setup**: Start with "balanced" preset for your device model |
| 254 | +2. **Break-in Period**: Allow 24-48 hours for thermal stabilization |
| 255 | +3. **Environment Consideration**: Adjust for ambient temperature and ventilation |
| 256 | +4. **Monitoring**: Watch logs for adjustment patterns and stability |
| 257 | +
|
| 258 | +### Troubleshooting |
| 259 | +- **Frequent Adjustments**: Check ambient temperature and cooling |
| 260 | +- **Poor Hashrate**: Verify power supply capacity and connections |
| 261 | +- **Overheating**: Improve ventilation or reduce ambient temperature |
| 262 | +- **Instability**: Consider using "quiet" preset for more conservative operation |
| 263 | +
|
| 264 | +### Safety Considerations |
| 265 | +- Never disable overheat protection |
| 266 | +- Ensure adequate power supply capacity |
| 267 | +- Monitor system logs regularly |
| 268 | +- Maintain proper ventilation and cooling |
0 commit comments