Skip to content

Commit

Permalink
Add new commands for configuring thermistor parameters:
Browse files Browse the repository at this point in the history
CONFigure:SENSORx:BETAcoeff
CONFigure:SENSORx:BETAcoeff?
CONFigure:SENSORx:THERmistor
CONFigure:SENSORx:THERmistor?
CONFigure:SENSORx:TEMPNominal
CONFigure:SENSORx:TEMPNominal?
  • Loading branch information
tjko committed Mar 19, 2022
1 parent 03d3ac6 commit 4a17329
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 4 deletions.
68 changes: 68 additions & 0 deletions commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ Fanpico supports following commands:
* [CONFigure:SENSORx:TEMPCoeff?](#configuresensorxtempcoeff-1)
* [CONFigure:SENSORx:TEMPMap](#configuresensorxtempmap)
* [CONFigure:SENSORx:TEMPMap?](#configuresensorxtempmap-1)
* [CONFigure:SENSORx:BETAcoeff](#configuresensorxbetacoeff)
* [CONFigure:SENSORx:BETAcoeff?](#configuresensorxbetacoeff-1)
* [CONFigure:SENSORx:THERmistor](#configuresensorxthermistor)
* [CONFigure:SENSORx:THERmistor?](#configuresensorxthermistor-1)
* [CONFigure:SENSORx:TEMPNominal](#configuresensorxtempnominal)
* [CONFigure:SENSORx:TEMPNominal?](#configuresensorxtempnominal-1)
* [MEASure:Read?](#measureread)
* [MEASure:FANx?](#measurefanx)
* [MEASure:FANx:Read?](#measurefanxread)
Expand Down Expand Up @@ -641,6 +647,68 @@ CONF:SENSOR1:TEMPMAP?
20,0,50,10000
```

#### CONFigure:SENSORx:BETAcoeff
Set beta coefficient of thermistor used to measure temperatur.
Typically thermistor beta coefficient is in the range 3000-4000.

Default: 3950

For example:
```
CONF:SENSOR1:BETA 3950
```

#### CONFigure:SENSORx:BETAcoeff?
Get the configured beta coefficient of the thermistor used to measure temperature.

For example:
```
CONF:SENSOR1:BETA?
3950
```

#### CONFigure:SENSORx:THERmistor
Set thermistor nominal resistance at nominal (room) temperature.
Typically this is either 10000 (for 10k thermistors) or 100000 (for 100k thermistors).

Default: 10000

For example: configure 100k thermistor
```
CONF:SENSOR1:THER 100000
```

#### CONFigure:SENSORx:THERmistor?
Get the thermistor nominal resistance at nominal (room) temperature.

For example:
```
CONF:SENSOR1:THER?
100000
```

#### CONFigure:SENSORx:TEMPNominal
Set nominal temperature of the thermistor (in C).
Typically nominal temperature is around room temperature.

Default: 25.0

For example:
```
CONF:SENSOR1:TEMPN 25.0
```

#### CONFigure:SENSORx:TEMPNominal?
Get nominal temperature of the thermistor (in C).

For example:
```
CONF:SENSOR1:TEMPN?
25.0
```



### MEASure Commands
These commands are for reading (measuring) the current input/output values on Fan and Motherboard Fan ports.

Expand Down
86 changes: 82 additions & 4 deletions src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,81 @@ int cmd_sensor_temp_coef(const char *cmd, const char *args, int query, char *pre
return 0;
}

int cmd_sensor_temp_nominal(const char *cmd, const char *args, int query, char *prev_cmd)
{
int sensor;
float val;

sensor = atoi(&prev_cmd[6]) - 1;
if (sensor >= 0 && sensor < SENSOR_MAX_COUNT) {
if (query) {
printf("%.1f\n", conf->sensors[sensor].temp_nominal);
} else {
val = atof(args);
if (val >= -50.0 && val <= 100.0) {
debug(1, "sensor%d: change temp nominal %.1fC --> %.1fC\n",
sensor + 1, conf->sensors[sensor].temp_nominal,
val);
conf->sensors[sensor].temp_nominal = val;
} else {
debug(1, "sensor%d: invalid temp nominal: %f\n",
sensor + 1, val);
}
}
}
return 0;
}

int cmd_sensor_ther_nominal(const char *cmd, const char *args, int query, char *prev_cmd)
{
int sensor;
float val;

sensor = atoi(&prev_cmd[6]) - 1;
if (sensor >= 0 && sensor < SENSOR_MAX_COUNT) {
if (query) {
printf("%.0f\n", conf->sensors[sensor].thermistor_nominal);
} else {
val = atof(args);
if (val > 0.0) {
debug(1, "sensor%d: change thermistor nominal %.0f ohm --> %.0f ohm\n",
sensor + 1, conf->sensors[sensor].thermistor_nominal,
val);
conf->sensors[sensor].thermistor_nominal = val;
} else {
debug(1, "sensor%d: invalid thermistor nominal: %f\n",
sensor + 1, val);
}
}
}
return 0;
}

int cmd_sensor_beta_coef(const char *cmd, const char *args, int query, char *prev_cmd)
{
int sensor;
float val;

sensor = atoi(&prev_cmd[6]) - 1;
if (sensor >= 0 && sensor < SENSOR_MAX_COUNT) {
if (query) {
printf("%.0f\n", conf->sensors[sensor].beta_coefficient);
} else {
val = atof(args);
if (val > 0.0) {
debug(1, "sensor%d: change thermistor beta coefficient %.0f --> %.0f\n",
sensor + 1, conf->sensors[sensor].beta_coefficient,
val);
conf->sensors[sensor].beta_coefficient = val;
} else {
debug(1, "sensor%d: invalid thermistor beta coefficient: %f\n",
sensor + 1, val);
}
}
}
return 0;
}

int cmd_sensor_temp_map(const char *cmd, const char *args, int query, char *prev_cmd)
{
int sensor, i, count;
Expand Down Expand Up @@ -965,10 +1040,13 @@ struct cmd_t mbfan_c_commands[] = {
};

struct cmd_t sensor_c_commands[] = {
{ "NAME", 4, NULL, cmd_sensor_name },
{ "TEMPOffset", 5, NULL, cmd_sensor_temp_offset },
{ "TEMPCoeff", 5, NULL, cmd_sensor_temp_coef },
{ "TEMPMap", 5, NULL, cmd_sensor_temp_map },
{ "NAME", 4, NULL, cmd_sensor_name },
{ "TEMPOffset", 5, NULL, cmd_sensor_temp_offset },
{ "TEMPCoeff", 5, NULL, cmd_sensor_temp_coef },
{ "TEMPMap", 5, NULL, cmd_sensor_temp_map },
{ "TEMPNominal", 5, NULL, cmd_sensor_temp_nominal },
{ "THERmistor", 4, NULL, cmd_sensor_ther_nominal },
{ "BETAcoeff", 4, NULL, cmd_sensor_beta_coef },
{ 0, 0, 0, 0 }
};

Expand Down

0 comments on commit 4a17329

Please sign in to comment.