mirror of
https://github.com/skot/ESP-Miner.git
synced 2025-04-10 04:49:16 +02:00
automatic fan speed control
This commit is contained in:
parent
e5009e14ab
commit
fc0e49e5d5
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -1,6 +1,6 @@
|
||||
{
|
||||
"idf.flashType": "UART",
|
||||
"idf.portWin": "COM11",
|
||||
"idf.portWin": "COM30",
|
||||
"idf.adapterTargetName": "esp32s3",
|
||||
"idf.openOcdConfigs": [
|
||||
"interface/ftdi/esp32_devkitj_v1.cfg",
|
||||
|
@ -11,4 +11,7 @@ asicvoltage,data,u16,1320
|
||||
asicmodel,data,string,BM1366
|
||||
devicemodel,data,string,ultra
|
||||
boardversion,data,string,0.11
|
||||
flipscreen,data,u16,1
|
||||
flipscreen,data,u16,1
|
||||
invertfanpolarity,data,u16,1
|
||||
autofanspeed,data,u16,1
|
||||
fanspeed,data,u16,100
|
BIN
esp-miner-factory-v2.0.1.bin
Normal file
BIN
esp-miner-factory-v2.0.1.bin
Normal file
Binary file not shown.
@ -38,6 +38,30 @@
|
||||
#define EMC2101_FAN_RPM_NUMERATOR 5400000 ///< Conversion unit to convert LSBs to fan RPM
|
||||
#define _TEMP_LSB 0.125 ///< single bit value for internal temperature readings
|
||||
|
||||
#define FAN_LOOKUP_TABLE_T1 0x50
|
||||
#define FAN_LOOKUP_TABLE_S1 0x51
|
||||
|
||||
#define FAN_LOOKUP_TABLE_T2 0x52
|
||||
#define FAN_LOOKUP_TABLE_S2 0x53
|
||||
|
||||
#define FAN_LOOKUP_TABLE_T3 0x54
|
||||
#define FAN_LOOKUP_TABLE_S3 0x55
|
||||
|
||||
#define FAN_LOOKUP_TABLE_T4 0x56
|
||||
#define FAN_LOOKUP_TABLE_S4 0x57
|
||||
|
||||
#define FAN_LOOKUP_TABLE_T5 0x58
|
||||
#define FAN_LOOKUP_TABLE_S5 0x59
|
||||
|
||||
#define FAN_LOOKUP_TABLE_T6 0x5A
|
||||
#define FAN_LOOKUP_TABLE_S6 0x5B
|
||||
|
||||
#define FAN_LOOKUP_TABLE_T7 0x5C
|
||||
#define FAN_LOOKUP_TABLE_S7 0x5D
|
||||
|
||||
#define FAN_LOOKUP_TABLE_T8 0x5E
|
||||
#define FAN_LOOKUP_TABLE_S8 0x5F
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
|
@ -104,15 +104,24 @@
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label>Invert Fan Polarity</label>
|
||||
<input formControlName="invertfanpolarity" type="checkbox">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Fan Speed {{form.controls['fanspeed'].value}}% <b *ngIf="form.controls['fanspeed'].value < 33"
|
||||
style="color:red">Danger: Could Cause Overheating</b> <b
|
||||
*ngIf="form.controls['fanspeed'].value == 100" style="color: #F2A900">S19 Simulator</b></label>
|
||||
<label>Automatic Fan Control</label>
|
||||
<input formControlName="autofanspeed" type="checkbox">
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label>Fan Speed {{form.controls['fanspeed'].value}}% <span
|
||||
*ngIf="form.controls['autofanspeed'].value == true">(disabled, automatic) </span> <b
|
||||
*ngIf="form.controls['fanspeed'].value < 33" style="color:red">Danger: Could Cause
|
||||
Overheating</b> <b *ngIf="form.controls['fanspeed'].value == 100" style="color: #F2A900">S19
|
||||
Simulator</b></label>
|
||||
<input formControlName="fanspeed" type="range" [min]="0" [max]="100">
|
||||
</div>
|
||||
|
||||
|
@ -2,6 +2,7 @@ import { HttpErrorResponse, HttpEventType } from '@angular/common/http';
|
||||
import { Component } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { ToastrService } from 'ngx-toastr';
|
||||
import { startWith } from 'rxjs';
|
||||
import { LoadingService } from 'src/app/services/loading.service';
|
||||
import { SystemService } from 'src/app/services/system.service';
|
||||
import { eASICModel } from 'src/models/enum/eASICModel';
|
||||
@ -48,10 +49,22 @@ export class EditComponent {
|
||||
wifiPass: [info.wifiPass, [Validators.required]],
|
||||
coreVoltage: [info.coreVoltage, [Validators.required]],
|
||||
frequency: [info.frequency, [Validators.required]],
|
||||
invertfanpolarity: [info.invertfanpolarity, [Validators.required]],
|
||||
autofanspeed: [info.autofanspeed == 1, [Validators.required]],
|
||||
invertfanpolarity: [info.invertfanpolarity == 1, [Validators.required]],
|
||||
fanspeed: [info.fanspeed, [Validators.required]],
|
||||
});
|
||||
|
||||
this.form.controls['autofanspeed'].valueChanges.pipe(
|
||||
startWith(this.form.controls['autofanspeed'].value)
|
||||
).subscribe(autofanspeed => {
|
||||
if (autofanspeed) {
|
||||
this.form.controls['fanspeed'].disable();
|
||||
} else {
|
||||
this.form.controls['fanspeed'].enable();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
private checkDevTools = () => {
|
||||
if (
|
||||
@ -66,7 +79,7 @@ export class EditComponent {
|
||||
|
||||
public updateSystem() {
|
||||
|
||||
const form = this.form.value;
|
||||
const form = this.form.getRawValue();
|
||||
|
||||
form.frequency = parseInt(form.frequency);
|
||||
form.coreVoltage = parseInt(form.coreVoltage);
|
||||
@ -75,6 +88,7 @@ export class EditComponent {
|
||||
form.flipscreen = form.flipscreen == true ? 1 : 0;
|
||||
form.invertscreen = form.invertscreen == true ? 1 : 0;
|
||||
form.invertfanpolarity = form.invertfanpolarity == true ? 1 : 0;
|
||||
form.autofanspeed = form.autofanspeed == true ? 1 : 0;
|
||||
|
||||
this.systemService.updateSystem(form)
|
||||
.pipe(this.loadingService.lockUIUntilComplete())
|
||||
|
@ -45,6 +45,7 @@ export class SystemService {
|
||||
flipscreen: 1,
|
||||
invertscreen: 0,
|
||||
invertfanpolarity: 1,
|
||||
autofanspeed: 1,
|
||||
fanspeed: 100
|
||||
}
|
||||
).pipe(delay(1000));
|
||||
|
@ -26,5 +26,6 @@ export interface ISystemInfo {
|
||||
frequency: number,
|
||||
version: string,
|
||||
invertfanpolarity: number,
|
||||
autofanspeed: number,
|
||||
fanspeed: number,
|
||||
}
|
@ -208,6 +208,7 @@ static esp_err_t PATCH_update_settings(httpd_req_t * req)
|
||||
uint16_t invert_screen = cJSON_GetObjectItem(root, "invertscreen")->valueint;
|
||||
|
||||
uint16_t invert_fan_polarity = cJSON_GetObjectItem(root, "invertfanpolarity")->valueint;
|
||||
uint16_t auto_fan_speed = cJSON_GetObjectItem(root, "autofanspeed")->valueint;
|
||||
uint16_t fan_speed = cJSON_GetObjectItem(root, "fanspeed")->valueint;
|
||||
|
||||
nvs_config_set_string(NVS_CONFIG_STRATUM_URL, stratumURL);
|
||||
@ -219,8 +220,8 @@ static esp_err_t PATCH_update_settings(httpd_req_t * req)
|
||||
nvs_config_set_u16(NVS_CONFIG_ASIC_FREQ, frequency);
|
||||
nvs_config_set_u16(NVS_CONFIG_FLIP_SCREEN, flip_screen);
|
||||
nvs_config_set_u16(NVS_CONFIG_INVERT_SCREEN, invert_screen);
|
||||
nvs_config_set_u16(NVS_CONFIG_INVERT_FAN_POLARITY, invert_screen);
|
||||
nvs_config_set_u16(NVS_CONFIG_INVERT_FAN_POLARITY, invert_fan_polarity);
|
||||
nvs_config_set_u16(NVS_CONFIG_AUTO_FAN_SPEED, auto_fan_speed);
|
||||
nvs_config_set_u16(NVS_CONFIG_FAN_SPEED, fan_speed);
|
||||
|
||||
cJSON_Delete(root);
|
||||
@ -281,6 +282,7 @@ static esp_err_t GET_system_info(httpd_req_t * req)
|
||||
cJSON_AddNumberToObject(root, "invertscreen", nvs_config_get_u16(NVS_CONFIG_INVERT_SCREEN, 0));
|
||||
|
||||
cJSON_AddNumberToObject(root, "invertfanpolarity", nvs_config_get_u16(NVS_CONFIG_INVERT_FAN_POLARITY, 1));
|
||||
cJSON_AddNumberToObject(root, "autofanspeed", nvs_config_get_u16(NVS_CONFIG_AUTO_FAN_SPEED, 1));
|
||||
cJSON_AddNumberToObject(root, "fanspeed", nvs_config_get_u16(NVS_CONFIG_FAN_SPEED, 100));
|
||||
|
||||
free(ssid);
|
||||
|
@ -17,6 +17,7 @@
|
||||
#define NVS_CONFIG_FLIP_SCREEN "flipscreen"
|
||||
#define NVS_CONFIG_INVERT_SCREEN "invertscreen"
|
||||
#define NVS_CONFIG_INVERT_FAN_POLARITY "invertfanpolarity"
|
||||
#define NVS_CONFIG_AUTO_FAN_SPEED "autofanspeed"
|
||||
#define NVS_CONFIG_FAN_SPEED "fanspeed"
|
||||
#define NVS_CONFIG_BEST_DIFF "bestdiff"
|
||||
|
||||
|
@ -76,10 +76,8 @@ static void _init_system(GlobalState * global_state, SystemModule * module)
|
||||
// DS4432U tests
|
||||
DS4432U_set_vcore(nvs_config_get_u16(NVS_CONFIG_ASIC_VOLTAGE, CONFIG_ASIC_VOLTAGE) / 1000.0);
|
||||
|
||||
// Fan Tests
|
||||
EMC2101_init(nvs_config_get_u16(NVS_CONFIG_INVERT_FAN_POLARITY, 1));
|
||||
|
||||
EMC2101_set_fan_speed((float) nvs_config_get_u16(NVS_CONFIG_FAN_SPEED, 100) / 100);
|
||||
EMC2101_set_fan_speed(1);
|
||||
|
||||
vTaskDelay(500 / portTICK_PERIOD_MS);
|
||||
|
||||
@ -277,7 +275,7 @@ static void _check_for_best_diff(SystemModule * module, double diff, uint32_t nb
|
||||
uint64_t old = module->best_nonce_diff;
|
||||
module->best_nonce_diff = diff;
|
||||
// only write to flash if new > old
|
||||
if(module->best_nonce_diff > old) {
|
||||
if (module->best_nonce_diff > old) {
|
||||
nvs_config_set_u64(NVS_CONFIG_BEST_DIFF, module->best_nonce_diff);
|
||||
}
|
||||
// make the best_nonce_diff into a string
|
||||
|
@ -48,7 +48,9 @@ void POWER_MANAGEMENT_task(void * pvParameters)
|
||||
|
||||
uint16_t frequency_target = nvs_config_get_u16(NVS_CONFIG_ASIC_FREQ, CONFIG_ASIC_FREQUENCY);
|
||||
|
||||
vTaskDelay(2000);
|
||||
uint16_t auto_fan_speed = nvs_config_get_u16(NVS_CONFIG_AUTO_FAN_SPEED, 1);
|
||||
|
||||
vTaskDelay(3000 / portTICK_PERIOD_MS);
|
||||
|
||||
while (1) {
|
||||
|
||||
@ -124,12 +126,38 @@ void POWER_MANAGEMENT_task(void * pvParameters)
|
||||
ESP_LOGE(TAG, "OVERHEAT");
|
||||
nvs_config_set_u16(NVS_CONFIG_ASIC_VOLTAGE, 990);
|
||||
nvs_config_set_u16(NVS_CONFIG_ASIC_FREQ, 50);
|
||||
nvs_config_set_u16(NVS_CONFIG_FAN_SPEED, 100);
|
||||
nvs_config_set_u16(NVS_CONFIG_AUTO_FAN_SPEED, 0);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
if (auto_fan_speed == 1) {
|
||||
automatic_fan_speed(power_management->chip_temp);
|
||||
} else {
|
||||
EMC2101_set_fan_speed((float) nvs_config_get_u16(NVS_CONFIG_FAN_SPEED, 100) / 100);
|
||||
}
|
||||
// ESP_LOGI(TAG, "target %f, Freq %f, Volt %f, Power %f", target_frequency, power_management->frequency_value,
|
||||
// power_management->voltage, power_management->power);
|
||||
vTaskDelay(POLL_RATE / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
|
||||
// all values input below 60 result in 38 but increases exponentially such that an input of 70 results in 100
|
||||
static void automatic_fan_speed(float chip_temp)
|
||||
{
|
||||
double result = 0.0;
|
||||
double min_temp = 50.0;
|
||||
|
||||
if (chip_temp < min_temp) {
|
||||
result = 25;
|
||||
} else if (chip_temp >= THROTTLE_TEMP) {
|
||||
result = 100;
|
||||
} else {
|
||||
double range = THROTTLE_TEMP - min_temp;
|
||||
result = ((chip_temp - min_temp) / range) * 100;
|
||||
}
|
||||
|
||||
ESP_LOGE(TAG, "Result %f", result);
|
||||
EMC2101_set_fan_speed((float) result / 100);
|
||||
}
|
@ -3,15 +3,16 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t fan_speed;
|
||||
float chip_temp;
|
||||
float voltage;
|
||||
float frequency_multiplier;
|
||||
float frequency_value;
|
||||
float power;
|
||||
float current;
|
||||
uint16_t fan_speed;
|
||||
float chip_temp;
|
||||
float voltage;
|
||||
float frequency_multiplier;
|
||||
float frequency_value;
|
||||
float power;
|
||||
float current;
|
||||
} PowerManagementModule;
|
||||
|
||||
void POWER_MANAGEMENT_task(void *pvParameters);
|
||||
static void automatic_fan_speed(float chip_temp);
|
||||
void POWER_MANAGEMENT_task(void * pvParameters);
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user