Wiki source code of Patune utilty - fine tuning of PA
Last modified by UT2UK on 2026/03/02 10:55
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
![]() |
1.1 | 1 | The **patune** utility is an interactive console program for calibrating and configuring the parameters of the Power Amplifier (PA) in the Ermak TT transceiver. The program provides bias control of the amplifier, stage current calibration, monitoring, and cooling system configuration. |
| 2 | |||
| 3 | ## Purpose of the Utility | ||
| 4 | |||
| 5 | The program is designed for engineers and technicians for: | ||
| 6 | * Automatic calibration of driver and output stage bias | ||
| 7 | * Setting target idle currents for each stage | ||
| 8 | * Monitoring the current status of the power amplifier | ||
| 9 | * Managing thermal compensation | ||
| 10 | * Configuring alarm parameters (temperature and current alarms) | ||
| 11 | * Setting up the fan control table (cooling) | ||
| 12 | * Saving configuration to non-volatile memory (NVMEM) | ||
| 13 | |||
| 14 | ### Operating Modes | ||
| 15 | |||
| 16 | The utility is organized as a hierarchical menu system: | ||
| 17 | |||
![]() |
2.1 | 18 | ``` |
| 19 | Main menu | ||
| 20 | ├── View information | ||
| 21 | │ ├── Print PA info (status) | ||
| 22 | │ ├── Print PA config (configuration) | ||
| 23 | │ ├── Print PA bias table (bias table) | ||
| 24 | │ └── Print total current (current consumption) | ||
| 25 | ├── Edit bias table | ||
| 26 | │ ├── Print PA bias table | ||
| 27 | │ ├── Reset all bias to defaults | ||
| 28 | │ ├── Enter driver stage current | ||
| 29 | │ ├── Enter output stage current | ||
| 30 | │ ├── Autotune DAC bias for driver stage | ||
| 31 | │ ├── Autotune DAC bias for output stage | ||
| 32 | │ ├── Enter driver stage thermo compensation | ||
| 33 | │ └── Enter output stage thermo compensation | ||
| 34 | ├── Edit PA configuration | ||
| 35 | │ ├── Print PA config | ||
| 36 | │ ├── Edit max temperature ALARM | ||
| 37 | │ ├── Edit restore temperature ALARM | ||
| 38 | │ ├── Edit max driver current | ||
| 39 | │ ├── Edit max output stage current | ||
| 40 | │ └── Fan Table Editor | ||
| 41 | │ ├── Print fan lookup table | ||
| 42 | │ ├── Reset fan table to defaults | ||
| 43 | │ └── Edit entries 0-7 | ||
| 44 | ├── Quick commands | ||
| 45 | │ ├── Bias switch ON | ||
| 46 | │ ├── Bias switch OFF | ||
| 47 | │ ├── Reset overcurrent | ||
| 48 | │ └── Write all settings | ||
| 49 | ``` | ||
| 50 | |||
![]() |
1.1 | 51 | ## Command Line Parameters |
| 52 | |||
| 53 | The utility does not accept command line parameters. All control is performed through the interactive console menu. | ||
| 54 | |||
| 55 | ### Starting the Program | ||
| 56 | |||
![]() |
2.1 | 57 | ```bash |
| 58 | patune | ||
| 59 | ``` | ||
| 60 | |||
![]() |
1.1 | 61 | At startup the program: |
| 62 | 1. Connects to PA Manager | ||
| 63 | 1. Requests the current PA configuration | ||
| 64 | 1. Requests the current bias table | ||
| 65 | 1. Displays the main menu | ||
| 66 | 1. Waits for user input | ||
| 67 | |||
| 68 | ## Input Format | ||
| 69 | |||
| 70 | ### User Input | ||
| 71 | |||
| 72 | #### Numeric Input | ||
| 73 | |||
| 74 | When a numeric value is requested, the program expects: | ||
| 75 | * A positive integer within the specified range | ||
![]() |
2.1 | 76 | * Or the `q` character to cancel the operation |
| 77 | * Or `q` and Enter to exit | ||
![]() |
1.1 | 78 | |
| 79 | Example of entering a current value: | ||
| 80 | |||
![]() |
2.1 | 81 | ```bash |
| 82 | Enter driver stage current, mA (1-1000), press 'q' to cancel: 600 | ||
| 83 | ``` | ||
| 84 | |||
![]() |
1.1 | 85 | **Validation:** |
| 86 | * The value must be within the range [min, max] | ||
| 87 | * If a value outside the range is entered, the program will display an error and repeat the prompt | ||
| 88 | * Maximum 1 attempt per second (1 sec delay) | ||
| 89 | |||
| 90 | #### Signed Numeric Values | ||
| 91 | |||
| 92 | Signed values are used for thermal compensation: | ||
| 93 | |||
![]() |
2.1 | 94 | ```bash |
| 95 | Enter driver stage thermo compensation, C/dac (-100 - 100), press 'q' to cancel: -5 | ||
| 96 | ``` | ||
| 97 | |||
![]() |
1.1 | 98 | **Valid value ranges:** |
| 99 | * Thermal compensation: -100 to +100 DAC/°C | ||
| 100 | * Temperature: -40 to 126 °C | ||
| 101 | * Fan speed: 0 to 100 % | ||
| 102 | |||
| 103 | #### Cancelling an Operation | ||
| 104 | |||
![]() |
2.1 | 105 | Press `q` at any input prompt to cancel the current operation without saving. |
![]() |
1.1 | 106 | |
| 107 | ### Menu Navigation | ||
| 108 | |||
![]() |
2.1 | 109 | * Digits `0-9` to select a menu item |
![]() |
1.1 | 110 | * Enter to confirm |
![]() |
2.1 | 111 | * `q` to return to the previous menu |
![]() |
1.1 | 112 | |
| 113 | ## Output Format | ||
| 114 | |||
| 115 | ### PA Status | ||
| 116 | |||
![]() |
2.1 | 117 | ```bash |
| 118 | Print PA info. | ||
| 119 | Heat temp: 75C | ||
| 120 | Int temp: 65C | ||
| 121 | VSWR alarm : 0 | ||
| 122 | Extra current alarm : 0 | ||
| 123 | Temperature alarm : 0 | ||
| 124 | Bias enable: 1 | ||
| 125 | Bus voltage: 48mV | ||
| 126 | Output stage current: 1050mA | ||
| 127 | Driver stage current: 620mA | ||
| 128 | Output bias: 2450/2460mV | ||
| 129 | Driver bias: 1850/1855mV | ||
| 130 | Fan speed: 45 | ||
| 131 | ``` | ||
![]() |
1.1 | 132 | |
![]() |
2.1 | 133 | | Field | Description | Unit | |
| 134 | | -------------------- | -------------------------------------------- | ------ | | ||
| 135 | | Heat temp | Heatsink temperature | °C | | ||
| 136 | | Int temp | Internal temperature | °C | | ||
| 137 | | VSWR alarm | VSWR alarm flag | 0/1 | | ||
| 138 | | Extra current alarm | Overcurrent alarm flag | 0/1 | | ||
| 139 | | Temperature alarm | Temperature alarm flag | 0/1 | | ||
| 140 | | Bias enable | Bias enable status | 0/1 | | ||
| 141 | | Bus voltage | Supply voltage | mV | | ||
| 142 | | Output stage current | Output stage current | mA | | ||
| 143 | | Driver stage current | Driver current | mA | | ||
| 144 | | Output bias | Output bias voltage (channel 0/1) | mV | | ||
| 145 | | Driver bias | Driver bias voltage (channel 0/1) | mV | | ||
| 146 | | Fan speed | Fan speed | % | | ||
| 147 | |||
![]() |
1.1 | 148 | ### PA Configuration |
| 149 | |||
![]() |
2.1 | 150 | ```bash |
| 151 | Print PA config. | ||
| 152 | High limit temp: 80C | ||
| 153 | Low limit temp: 75C | ||
| 154 | Max driver current: 1200mA | ||
| 155 | Max output current: 2000mA | ||
| 156 | ``` | ||
![]() |
1.1 | 157 | |
![]() |
2.1 | 158 | | Field | Description | Default value | |
| 159 | | ------------------ | --------------------------------------------- | ------------- | | ||
| 160 | | High limit temp | Maximum temperature (alarm) | 80°C | | ||
| 161 | | Low limit temp | Minimum temperature (restore) | 75°C | | ||
| 162 | | Max driver current | Max driver current (alarm threshold) | 1200mA | | ||
| 163 | | Max output current | Max output current (alarm threshold) | 2000mA | | ||
| 164 | |||
![]() |
1.1 | 165 | ### Bias Table |
| 166 | |||
![]() |
2.1 | 167 | ```bash |
| 168 | Bias DAC output 0: 2450 | ||
| 169 | Bias DAC output 1: 2460 | ||
| 170 | Bias DAC driver 0: 1850 | ||
| 171 | Bias DAC driver 1: 1855 | ||
| 172 | Target driver current,mA: 600 | ||
| 173 | Target output current,mA: 1000 | ||
| 174 | Driver thermo compensation,dac/C: -2 | ||
| 175 | Output thermo compensation,dac/C: -3 | ||
| 176 | Temprature of calibration,C: 25 | ||
| 177 | ``` | ||
![]() |
1.1 | 178 | |
![]() |
2.1 | 179 | | Field | Description | Range | |
| 180 | | -------------------------- | --------------------------------------------------- | ------------------- | | ||
| 181 | | Bias DAC output [0/1] | DAC bias value for output channels 0 and 1 | 0-4095 | | ||
| 182 | | Bias DAC driver [0/1] | DAC bias value for driver channels 0 and 1 | 0-4096 | | ||
| 183 | | Target driver current | Target idle current for driver stage | 1-1000 mA | | ||
| 184 | | Target output current | Target idle current for output stage | 1-2000 mA | | ||
| 185 | | Driver thermo compensation | Driver thermal compensation | -100 to +100 DAC/°C | | ||
| 186 | | Output thermo compensation | Output thermal compensation | -100 to +100 DAC/°C | | ||
| 187 | | Temperature of calibration | Temperature at which calibration was performed | °C | | ||
| 188 | |||
![]() |
1.1 | 189 | ### Fan Control Table |
| 190 | |||
![]() |
2.1 | 191 | ```bash |
| 192 | Index | Temperature (°C) | Fan Speed (%) | ||
| 193 | ------|------------------|--------------- | ||
| 194 | 0 | 10 | 0% | ||
| 195 | 1 | 20 | 7% | ||
| 196 | 2 | 35 | 31% | ||
| 197 | 3 | 40 | 63% | ||
| 198 | 4 | 50 | 79% | ||
| 199 | 5 | 60 | 100% | ||
| 200 | 6 | 70 | 100% | ||
| 201 | 7 | 126 | 100% | ||
| 202 | ``` | ||
| 203 | |||
![]() |
1.1 | 204 | The table contains 8 interpolation points. Each row contains: |
| 205 | * **Index**: sequence number (0-7) | ||
| 206 | * **Temperature**: threshold temperature in °C | ||
| 207 | * **Fan Speed**: fan speed in % | ||
| 208 | |||
| 209 | Speed is calculated by interpolating between points based on the current temperature. | ||
| 210 | |||
| 211 | ### Calibration Progress | ||
| 212 | |||
| 213 | During automatic calibration a progress bar is displayed: | ||
| 214 | |||
![]() |
2.1 | 215 | ```bash |
| 216 | Tuning Driver Channel 0 | ||
| 217 | Target Current: 600mA | ||
| 218 | DAC: 1800/4095 [***** ] 12% | Current: 150mA/600mA [**** ] 25% | ||
| 219 | ``` | ||
| 220 | |||
![]() |
1.1 | 221 | Components: |
| 222 | * **DAC**: current DAC value and maximum | ||
| 223 | * First progress bar: DAC progress (yellow) | ||
| 224 | * **Current**: current measured current and target current | ||
| 225 | * Second progress bar: progress toward target current (green) | ||
| 226 | |||
| 227 | ### Error Messages | ||
| 228 | |||
![]() |
2.1 | 229 | ```bash |
| 230 | Set bias ON ERROR | ||
| 231 | Get driver current ERROR | ||
| 232 | Request PA config ERROR | ||
| 233 | Connect/Disconnect loading ERROR | ||
| 234 | Unable to tune bias for Driver channel 0 | ||
| 235 | ``` | ||
| 236 | |||
![]() |
1.1 | 237 | An error message in red indicates a communication failure with PA Manager or an unexpected state. |
| 238 | |||
| 239 | ### Success Messages | ||
| 240 | |||
![]() |
2.1 | 241 | ```bash |
| 242 | ✓ Finished OK | ||
| 243 | Channel: 0 | ||
| 244 | Final DAC Value: 1850 | ||
| 245 | Final Current: 600mA | ||
| 246 | Bias switched ON. | ||
| 247 | New settings were recorder to NVMEM - OK. | ||
| 248 | Overcurrent flag reseted OK. | ||
| 249 | ``` | ||
| 250 | |||
![]() |
1.1 | 251 | Successful operations are displayed in yellow. |
| 252 | |||
| 253 | ## Usage Examples | ||
| 254 | |||
| 255 | ### Example 1: Checking Amplifier Status | ||
| 256 | |||
![]() |
2.1 | 257 | ```bash |
| 258 | $ patune | ||
| 259 | ************************************************************ | ||
| 260 | | Power amplifier service utility version 1.2 | | ||
| 261 | ************************************************************ | ||
| 262 | [Main menu] | ||
| 263 | 0 - Print PA info. | ||
| 264 | 1 - Print PA config. | ||
| 265 | 2 - Print PA bias table. | ||
| 266 | 3 - [Edit bias table] | ||
| 267 | 4 - [Edit PA configs] | ||
| 268 | 5 - [Edit fan table] | ||
| 269 | 6 - Bias switch ON. | ||
| 270 | 7 - Bias switch OFF. | ||
| 271 | 8 - Reset overcurrent. | ||
| 272 | 9 - Write all settings. | ||
| 273 | q - Quit | ||
| 274 | Enter your choice: 0 | ||
| 275 | Print PA info. | ||
| 276 | Heat temp: 45C | ||
| 277 | Int temp: 38C | ||
| 278 | VSWR alarm : 0 | ||
| 279 | Extra current alarm : 0 | ||
| 280 | Temperature alarm : 0 | ||
| 281 | Bias enable: 1 | ||
| 282 | Bus voltage: 48mV | ||
| 283 | Output stage current: 1050mA | ||
| 284 | Driver stage current: 620mA | ||
| 285 | Output bias: 2450/2460mV | ||
| 286 | Driver bias: 1850/1855mV | ||
| 287 | Fan speed: 35 | ||
| 288 | ``` | ||
| 289 | |||
![]() |
1.1 | 290 | ### Example 2: Setting Target Driver Current |
| 291 | |||
![]() |
2.1 | 292 | ```bash |
| 293 | Enter your choice: 3 | ||
| 294 | [Bias table editor] | ||
| 295 | 0 - Print PA bias table. | ||
| 296 | 1 - Reset all bias to default value. | ||
| 297 | 2 - Enter driver stage current. | ||
| 298 | 3 - Enter output stage current. | ||
| 299 | 4 - Autotune DAC bias for driver stage. | ||
| 300 | 5 - Autotune DAC bias for output stage. | ||
| 301 | 6 - Print power consumption for all stages. | ||
| 302 | 7 - Enter driver stage thermo compensation. | ||
| 303 | 8 - Enter output stage thermo compensation. | ||
| 304 | q - Quit | ||
| 305 | Enter your choice: 2 | ||
| 306 | Enter driver stage current, mA (1-1000), press 'q' to cancel: 650 | ||
| 307 | ``` | ||
| 308 | |||
![]() |
1.1 | 309 | ### Example 3: Automatic Driver Calibration |
| 310 | |||
![]() |
2.1 | 311 | ```bash |
| 312 | Enter your choice: 4 | ||
| 313 | Tuning Driver Channel 1 | ||
| 314 | Target Current: 600mA | ||
| 315 | DAC: 800/4096 [** ] 19% | Current: 0mA/600mA [ ] 0% | ||
| 316 | DAC: 1200/4096 [**** ] 29% | Current: 100mA/600mA [***** ] 16% | ||
| 317 | DAC: 1500/4096 [**** ] 36% | Current: 250mA/600mA [******* ] 41% | ||
| 318 | DAC: 1700/4096 [***** ] 41% | Current: 450mA/600mA [***** *** ] 75% | ||
| 319 | DAC: 1750/4096 [***** ] 42% | Current: 590mA/600mA [***** **** ] 98% | ||
| 320 | DAC: 1751/4096 [***** ] 42% | Current: 600mA/600mA [***** ***** ] 100% | ||
| 321 | ✓ Finished OK | ||
| 322 | Channel: 1 | ||
| 323 | Final DAC Value: 1751 | ||
| 324 | Final Current: 600mA | ||
| 325 | ``` | ||
| 326 | |||
![]() |
1.1 | 327 | ### Example 4: Editing a Fan Table Entry |
| 328 | |||
![]() |
2.1 | 329 | ```bash |
| 330 | Enter your choice: 5 | ||
| 331 | [Fan Table Editor] | ||
| 332 | 0 - Print fan lookup table. | ||
| 333 | 1 - Reset fan table to defaults. | ||
| 334 | 2 - Edit entry 0 (10°C / 0%). | ||
| 335 | 3 - Edit entry 1 (20°C / 7%). | ||
| 336 | ... | ||
| 337 | Enter your choice: 3 | ||
| 338 | Edit Fan Table Entry 2 | ||
| 339 | Current settings: | ||
| 340 | Temperature: 35°C | ||
| 341 | Fan Speed: 31% | ||
| 342 | Enter new temperature (C) (-40 - 126), press 'q' to cancel: 30 | ||
| 343 | Enter new fan speed (0-100%) (0-100), press 'q' to cancel: 25 | ||
| 344 | Entry 2 updated: | ||
| 345 | Temperature: 30°C | ||
| 346 | Fan Speed: 25% | ||
| 347 | ``` | ||
| 348 | |||
![]() |
1.1 | 349 | ### Example 5: Saving Configuration |
| 350 | |||
![]() |
2.1 | 351 | ```bash |
| 352 | Enter your choice: 9 | ||
| 353 | New settings were recorder to NVMEM - OK. | ||
| 354 | ``` | ||
| 355 | |||
![]() |
1.1 | 356 | ## Error Diagnostics |
| 357 | |||
| 358 | ### Calibration Error | ||
| 359 | |||
| 360 | **Message:** | ||
| 361 | |||
![]() |
2.1 | 362 | ```bash |
| 363 | ✗ Unable to tune bias for Driver channel 0 | ||
| 364 | ``` | ||
| 365 | |||
![]() |
1.1 | 366 | **Causes:** |
| 367 | * Amplifier is not functioning | ||
| 368 | * No power supply to the stage | ||
| 369 | * Current sensor is faulty | ||
| 370 | * Bias circuit is incorrectly configured | ||
| 371 | |||
| 372 | **Solution:** | ||
| 373 | 1. Check PA power supply | ||
| 374 | 1. Check load connectors | ||
| 375 | 1. Make sure bias can be adjusted | ||
| 376 | 1. Check the DAC coefficient value | ||
| 377 | |||
| 378 | ### Configuration Write Error | ||
| 379 | |||
| 380 | **Message:** | ||
| 381 | |||
![]() |
2.1 | 382 | ```bash |
| 383 | Write config ERROR | ||
| 384 | ``` | ||
| 385 | |||
![]() |
1.1 | 386 | **Causes:** |
| 387 | * NVMEM is full | ||
| 388 | * Hardware write error | ||
| 389 | * Loss of connection with PA Manager | ||
| 390 | |||
| 391 | **Solution:** | ||
| 392 | 1. Repeat the write operation | ||
| 393 | 1. Try resetting the configuration: "Reset all bias to default value" | ||
| 394 | 1. Reboot and try again | ||
| 395 | |||
| 396 | ## Practical Application Scenarios | ||
| 397 | |||
| 398 | ### Scenario 1: Initial Setup of a New Amplifier | ||
| 399 | |||
![]() |
2.1 | 400 | ``` |
| 401 | Step 1: Check status | ||
| 402 | - Select "Print PA info" | ||
| 403 | - Make sure the sensors are working | ||
| 404 | Step 2: Set target currents | ||
| 405 | - Select "Edit bias table" → "Enter driver stage current" | ||
| 406 | - Enter 600 mA (typical value) | ||
| 407 | - Select "Enter output stage current" | ||
| 408 | - Enter 1000 mA (typical value) | ||
| 409 | Step 3: Automatic calibration | ||
| 410 | - Select "Autotune DAC bias for driver stage" | ||
| 411 | - Wait for completion (both channels sequentially) | ||
| 412 | - Select "Autotune DAC bias for output stage" | ||
| 413 | - Wait for completion | ||
| 414 | Step 4: Verify results | ||
| 415 | - Select "Print PA info" | ||
| 416 | - Make sure currents are within target values | ||
| 417 | Step 5: Save | ||
| 418 | - Select "Write all settings" | ||
| 419 | ``` | ||
| 420 | |||
![]() |
1.1 | 421 | ### Scenario 2: Fan Control Setup |
| 422 | |||
![]() |
2.1 | 423 | ```bash |
| 424 | Step 1: View current table | ||
| 425 | - Select "Edit fan table" → "Print fan lookup table" | ||
| 426 | Step 2: Edit interpolation points | ||
| 427 | - For each entry: | ||
| 428 | - Select "Edit entry N" | ||
| 429 | - Set the trigger temperature | ||
| 430 | - Set fan speed in % | ||
| 431 | Step 3: Save | ||
| 432 | - Select "Write all settings" | ||
| 433 | Example table for cold climate: | ||
| 434 | Entry 0: 15°C / 0% | ||
| 435 | Entry 1: 25°C / 10% | ||
| 436 | Entry 2: 40°C / 30% | ||
| 437 | Entry 3: 50°C / 60% | ||
| 438 | Entry 4: 60°C / 80% | ||
| 439 | Entry 5: 70°C /100% | ||
| 440 | Entry 6: 80°C /100% | ||
| 441 | Entry 7: 126°C /100% | ||
| 442 | ``` | ||
| 443 | |||
![]() |
1.1 | 444 | ### Scenario 3: Maintenance and Diagnostics |
| 445 | |||
![]() |
2.1 | 446 | ``` |
| 447 | Step 1: Check configuration integrity | ||
| 448 | - Select "Print PA bias table" | ||
| 449 | - Make sure all values are within acceptable limits | ||
| 450 | - Select "Print PA config" | ||
| 451 | Step 2: Check current consumption | ||
| 452 | - Select "Print power consumption for all stages" | ||
| 453 | - Compare with expected values | ||
| 454 | Step 3: Test the amplifier | ||
| 455 | - Select "Bias switch ON" | ||
| 456 | - Check "Print PA info" | ||
| 457 | - Make sure all alarms are in zero state | ||
| 458 | - Select "Bias switch OFF" | ||
| 459 | Step 4: Reset alarm (if required) | ||
| 460 | - Select "Reset overcurrent" | ||
| 461 | ``` | ||
| 462 | |||
![]() |
1.1 | 463 | ## Limitations and Implementation Notes |
| 464 | |||
| 465 | ### Parameter Limits | ||
| 466 | |||
![]() |
2.1 | 467 | | Parameter | Minimum | Maximum | Note | |
| 468 | | ---------------------------------- | ------- | ------------------------------ | --------------------- | | ||
| 469 | | Driver current | 1 mA | 1000 mA | Target value | | ||
| 470 | | Output current | 1 mA | 2000 mA | Target value | | ||
| 471 | | Max alarm current (driver) | - | 6000 mA | Threshold value | | ||
| 472 | | Max alarm current (output) | - | 26000 mA | Threshold value | | ||
| 473 | | Heatsink temperature | -40°C | 126°C | Sensor range | | ||
| 474 | | Maximum alarm temperature | - | 80°C | Limited | | ||
| 475 | | Bias DAC | 0 | 4095 (output) / 4096 (driver) | 12-bit resolution | | ||
| 476 | | Thermal compensation | -100 | +100 | DAC/°C | | ||
| 477 | | Fan speed | 0% | 100% | Corresponds to DAC 0-63 | | ||
![]() |
1.1 | 478 | |
| 479 | **Utility version:** 1.2 |
