diff --git a/eeprom_config/config_ft817.yaml b/eeprom_config/config_ft817.yaml new file mode 100644 index 0000000..b335f2a --- /dev/null +++ b/eeprom_config/config_ft817.yaml @@ -0,0 +1,35 @@ +# Values for the cooler of the FT-817 radio. +flags: + USE_DCDC_CONTROL: true + + +config: + # temperature corridor definition + CORRIDOR_MIN_TEMPERATURE: 40.0 + CORRIDOR_MAX_TEMPERATURE: 45.0 + + # The fan is started when temperature rises above this temperature. + FAN_START_TEMPERATURE: 42.0 + + # The fan is stopped when the temperature falls below this point. + FAN_OFF_TEMPERATURE: 30.0 + + # Emergency temperature level. If this is reached, the duty cycle is directly + # set to the maximum to skip a long ramp-up phase. + EMERGENCY_TEMPERATURE: 60.0 + + # The fan PWM duty cycle cannot fall below this limit. It is held until + # temperature falls below the off-temperature. + DUTY_CYCLE_MIN: 30.0 + + # The fan PWM duty cycle cannot go above this limit. Should be set to 100. + DUTY_CYCLE_MAX: 100.0 + + # The fan is always started with this duty cycle. Do not set too low. + DUTY_CYCLE_START: 70.0 + + # gain unit: percent duty cycle change per °C deviation per update cycle (100 ms) + GAIN_T_HIGH_P: 2.000 + GAIN_T_HIGH_I: 0.125 + GAIN_T_LOW_P: 0.000 + GAIN_T_LOW_I: 0.125 diff --git a/eeprom_config/config_to_hex.py b/eeprom_config/config_to_hex.py new file mode 100755 index 0000000..d01001f --- /dev/null +++ b/eeprom_config/config_to_hex.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python3 + +import sys +import struct + +import yaml +from intelhex import IntelHex + + +def as_fxp(v): + return int(v * 2**16 + 0.5) + +BASE_ADDR = 0x08080000 + +FLAG_NAME_TO_BIT_INDEX = { + 'USE_DCDC_CONTROL': 0 + } + +CONFIG_KEY_TO_OFFSET = { + # note: flags are at 0x0000, but not listed here due to special handling. + 'CORRIDOR_MIN_TEMPERATURE': 0x0004, + 'CORRIDOR_MAX_TEMPERATURE': 0x0008, + 'FAN_START_TEMPERATURE': 0x000C, + 'FAN_OFF_TEMPERATURE': 0x0010, + 'EMERGENCY_TEMPERATURE': 0x0014, + 'DUTY_CYCLE_MIN': 0x0018, + 'DUTY_CYCLE_MAX': 0x001C, + 'DUTY_CYCLE_START': 0x0020, + 'GAIN_T_HIGH_P': 0x0024, + 'GAIN_T_HIGH_I': 0x0028, + 'GAIN_T_LOW_P': 0x002C, + 'GAIN_T_LOW_I': 0x0030, + } + + +if __name__ == "__main__": + output = IntelHex() + + if len(sys.argv) < 3: + print(f"usage: {sys.argv[0]} ") + sys.exit(1) + + with open(sys.argv[1], 'r') as configfile: + config = yaml.safe_load(configfile) + + flags = 0 + for key, bitidx in FLAG_NAME_TO_BIT_INDEX.items(): + if config['flags'][key]: + flags |= (1 << bitidx) + + + enc_bytes = struct.pack('