Skip to content

Add heater control parameters to TunerStudio#32

Merged
dron0gus merged 1 commit into
dron0gus:masterfrom
xtitoris:heater-config-ts-merge
Jan 30, 2026
Merged

Add heater control parameters to TunerStudio#32
dron0gus merged 1 commit into
dron0gus:masterfrom
xtitoris:heater-config-ts-merge

Conversation

@xtitoris

Copy link
Copy Markdown

Moved some heater parameters into config memory.
Specifically

  • HeaterSupplyOffVoltage
  • HeaterSupplyOnVoltage
  • PreheatTimeSec

This way the board could be configured to work independently of the ECU, so that

  • Heater only turns on when alternator produces high enough voltage (as an indirect measurement of when engine is running), by setting HeaterSupplyOnVoltage higher than ~13.5V
  • And/or increasing PreheatTimeSec to 5-10 minutes to allow engine to warm up a bit, and water condensation to evaporate.

To conserve the precious RAM, ScaledValue struct is introduces, that allows seamlessly mapping int/uint values.
This way values could be mapped to integers, scaling them both up and down.

  • Fractional point values, like 12.5 could be mapped to 125 in memory, if more precision is needed.
  • Precision can be sacrificed to fit larger values into smaller types. E.g. values from 0 to 1275 can be fitted into uint8_t using steps of 5.

Added unit tests for ScaledValue, so that it definitely fits into its storage type
And unit tests for Configuration, to make sure changes to config structure would be backward-compatible with existing units.

@dron0gus

dron0gus commented Jan 30, 2026

Copy link
Copy Markdown
Owner

Why new class FixedPoint? Why not ScaledChannel?
Does it worth to store PreheatTimeSec in uint8_t with 5 scale? To save 1 byte?

@dron0gus dron0gus merged commit 7ccfdd8 into dron0gus:master Jan 30, 2026
7 checks passed
@xtitoris

xtitoris commented Jan 30, 2026

Copy link
Copy Markdown
Author

Does it worth to store PreheatTimeSec in uint8_t with 5 scale? To save 1 byte?

Well, if we decide to make more timeouts user-configurable, like HEATER_WARMUP_TIMEOUT, HEATER_DIDNOTHEAT_RETRY_TIMEOUT, and others, or add HEATER_FAST_HEATING_THRESHOLD_T to the config, none of which require single digit precision, it would run away quick, with one byte wasted for each of these values.

@xtitoris

Copy link
Copy Markdown
Author

I've also played around with making these values variable bit-width, so that we could store, for example, three uint16_t : 10 values in two bytes, but TunerStudio does not support that.

@xtitoris xtitoris deleted the heater-config-ts-merge branch February 9, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants