Right now I’m doing as follow:
uint8_t ManualFlow = 40; // 0 -> 255 Unsigned Char
uint24_t ME; // 0 -> 16777215 Unsigned Short Long
ME = (uint24_t) ManualFlow*10; // Have to make this hack otherwise malfunction in calculation
ME /= 6;
ME *= (80 - 60);
ME /= 100;
ME *= 414;
The end result:
40*10 = 400
400/6 = 66
66*20 = 1320
1320/100 = 13
13*414 = 5382
What I would Love is similar to this:
4/60 = 0,0667 * 20 * 4188 * 0,998 = 5576 (more accurate).
How can I do this more accurate without using floats or doubles, and most important
not increase my code size too much.
Kind Regards
Sonite
conclusion:
My initial code had not so good accuracy and was “this big”.
By doing this below I increased the code with “38 byte” and gained better accuracy
The best accuracy I got by doing fixed-point but it increased the code to much “1148 bytes ->
Hope it can help some one else!
Kind Regards
Sonite