Skip to content

Commit

Permalink
EMC2101 should read internal temp if BM1366
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamin-wilson committed Sep 6, 2023
1 parent d4affd7 commit ef71810
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 8 deletions.
11 changes: 9 additions & 2 deletions main/EMC2101.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ uint16_t EMC2101_get_fan_speed(void)
return RPM;
}

float EMC2101_get_chip_temp(void)
float EMC2101_get_external_temp(void)
{
uint8_t temp_msb, temp_lsb;
uint16_t reading;
Expand All @@ -83,4 +83,11 @@ float EMC2101_get_chip_temp(void)
reading >>= 5;

return (float)reading / 8.0;
}
}

uint8_t EMC2101_get_internal_temp(void)
{
uint8_t temp;
ESP_ERROR_CHECK(register_read(EMC2101_INTERNAL_TEMP, &temp, 1));
return temp;
}
4 changes: 2 additions & 2 deletions main/EMC2101.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ void EMC2101_set_fan_speed(float);
// void EMC2101_read(void);
uint16_t EMC2101_get_fan_speed(void);
void EMC2101_init(void);
float EMC2101_get_chip_temp(void);

float EMC2101_get_external_temp(void);
uint8_t EMC2101_get_internal_temp(void);
#endif /* EMC2101_H_ */
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ <h2>Power</h2>
<td>{{info.fanSpeed}} <small>RPM</small></td>

</tr>
<tr>
<td>Chip Temperature:</td>
<td>{{info.temp}} <small>C</small></td>

</tr>
</table>

</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AfterViewChecked, Component, ElementRef, ViewChild } from '@angular/core';
import { ToastrService } from 'ngx-toastr';
import { interval, Observable, shareReplay, switchMap } from 'rxjs';
import { interval, Observable, shareReplay, startWith, switchMap } from 'rxjs';
import { LoadingService } from 'src/app/services/loading.service';
import { SystemService } from 'src/app/services/system.service';
import { WebsocketService } from 'src/app/services/web-socket.service';
Expand All @@ -25,6 +25,7 @@ export class HomeComponent implements AfterViewChecked {
) {

this.info$ = interval(3000).pipe(
startWith(() => this.systemService.getInfo()),
switchMap(() => {
return this.systemService.getInfo()
}),
Expand Down
1 change: 1 addition & 0 deletions main/http_server/axe-os/src/app/services/system.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class SystemService {
"voltage": 5208.75,
"current": 2237.5,
"fanSpeed": 82,
"temp": 60,
"hashRate": 0,
"bestDiff": "0",
"freeHeap": 200504,
Expand Down
1 change: 1 addition & 0 deletions main/http_server/axe-os/src/models/ISystemInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface ISystemInfo {
voltage: number,
current: number,
fanSpeed: number,
temp: number,
hashRate: number,
bestDiff: string,
freeHeap: number,
Expand Down
2 changes: 2 additions & 0 deletions main/http_server/http_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,10 @@ static esp_err_t GET_system_info(httpd_req_t *req)
cJSON_AddNumberToObject(root, "voltage", GLOBAL_STATE->POWER_MANAGEMENT_MODULE.voltage);
cJSON_AddNumberToObject(root, "current", GLOBAL_STATE->POWER_MANAGEMENT_MODULE.current);
cJSON_AddNumberToObject(root, "fanSpeed", GLOBAL_STATE->POWER_MANAGEMENT_MODULE.fan_speed);
cJSON_AddNumberToObject(root, "temp", GLOBAL_STATE->POWER_MANAGEMENT_MODULE.chip_temp);
cJSON_AddNumberToObject(root, "hashRate", GLOBAL_STATE->SYSTEM_MODULE.current_hashrate);
cJSON_AddStringToObject(root, "bestDiff", GLOBAL_STATE->SYSTEM_MODULE.best_diff_string);

cJSON_AddNumberToObject(root, "freeHeap", esp_get_free_heap_size());
cJSON_AddNumberToObject(root, "coreVoltage", ADC_get_vcore());
cJSON_AddStringToObject(root, "ssid", ssid);
Expand Down
6 changes: 4 additions & 2 deletions main/tasks/power_management_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void POWER_MANAGEMENT_task(void *pvParameters)
while (1)
{

if (read_power)
if (read_power == true)
{
power_management->voltage = INA260_read_voltage();
power_management->power = INA260_read_power() / 1000;
Expand All @@ -57,7 +57,7 @@ void POWER_MANAGEMENT_task(void *pvParameters)
if (strcmp(ASIC_MODEL, "BM1397") == 0)
{

power_management->chip_temp = EMC2101_get_chip_temp();
power_management->chip_temp = EMC2101_get_external_temp();

// Voltage
// We'll throttle between 4.9v and 3.5v
Expand Down Expand Up @@ -125,6 +125,8 @@ void POWER_MANAGEMENT_task(void *pvParameters)
}
else if (strcmp(ASIC_MODEL, "BM1366") == 0)
{
power_management->chip_temp = EMC2101_get_internal_temp() + 5;

if (power_management->fan_speed < 10)
{
ESP_LOGE(TAG, "Detected fan speed too slow, setting vCore to 0");
Expand Down
2 changes: 1 addition & 1 deletion sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ CONFIG_PARTITION_TABLE_OFFSET=0x8000
CONFIG_PARTITION_TABLE_MD5=y
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y
CONFIG_ESPTOOLPY_FLASHSIZE="8MB"
CONFIG_ESP_MAXIMUM_RETRY=3
CONFIG_ESP_MAXIMUM_RETRY=5
CONFIG_HTTPD_WS_SUPPORT=y
CONFIG_SPIFFS_OBJ_NAME_LEN=64

0 comments on commit ef71810

Please sign in to comment.