en:pfw:linear-conversion
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
en:pfw:linear-conversion [2025-02-11 23:19] – created albert | en:pfw:linear-conversion [2025-02-12 12:36] (current) – albert | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | A very simple method (no floating point, no algebraic formulas) for | + | ===== Simple linear conversion ===== |
+ | A very simple method (no floating point, no algebraic formulas) for | ||
| | ||
- | --- Example 1, temperature | + | === Example 1, temperature |
Two points are given: Sensor output 400 and 1200 correspond | Two points are given: Sensor output 400 and 1200 correspond | ||
- | to 10 and 36.3 degrees Celsius respectively. | + | to 10 and 36.3 degrees Celsius respectively.\\ |
To get rid of floating point, we calculate Celsius in tenths of degrees: | To get rid of floating point, we calculate Celsius in tenths of degrees: | ||
- | Sensor | + | |
- | 400 100 | + | |
- | | + | 1200 363 |
- | | + | (800) |
- | Take: | + | Let's take: |
- | | + | SensorZ |
- | | + | CelsiusZ |
- | | + | SensorDist |
- | | + | CelsiusDist = distance between the two Celsius values (263) |
- | The conversion | + | Then the conversion looks like this: |
: > | : > | ||
Line 28: | Line 28: | ||
: >CELSIUS ( sensor -- celsius ) 400 - 263 800 */ 100 + ; | : >CELSIUS ( sensor -- celsius ) 400 - 263 800 */ 100 + ; | ||
- | --------------------------------------------------------- | + | |
Line 34: | Line 34: | ||
| | ||
- | --- Example 2 --- | + | === Example 2 === |
- | Sensor | + | |
- | 400 363 | + | |
- | | + | 1200 100 |
- | | + | (800) |
+ | The forth definition: | ||
: >CELSIUS ( sensor -- celsius ) 400 - 263 800 */ NEGATE 363 + ; | : >CELSIUS ( sensor -- celsius ) 400 - 263 800 */ NEGATE 363 + ; | ||
- | ---------------------------------------------------------------- | + | |
( an,jan2025) | ( an,jan2025) | ||
en/pfw/linear-conversion.1739312350.txt.gz · Last modified: 2025-02-11 23:19 by albert