Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimize floating point operations #212

Open
charlespax opened this issue Apr 12, 2016 · 5 comments
Open

Minimize floating point operations #212

charlespax opened this issue Apr 12, 2016 · 5 comments
Milestone

Comments

@charlespax
Copy link
Member

There are many bast ten floating point operations. If possible, let's make things base 16 and use bit shift math. This should save a bunch of flash space since the floating point library is pretty big.

@charlespax charlespax added this to the Milestone 6 milestone Apr 12, 2016
@charlespax charlespax mentioned this issue Apr 12, 2016
10 tasks
@protological
Copy link
Collaborator

I've looked at the t400 code and I think the floating point operations can be replaced with int16 values. The int16 would have a range of -35535 to 35535, if the values were stored as base 10 with a resolution of 1/10th degree the supported range would be -3553.5C to 3553.5C. The base 10 division and modulo operations would be must faster and take less code space than the floating point.

@protological
Copy link
Collaborator

protological commented Jul 12, 2016

I think I need some more information on the temperature vs microvolt lookup in the code. I see the following functions, where did they come from? If we can eliminate some of these floating point operations the code will be smaller and faster

From GetJunctionVoltage():
i = jTemp/10 + 27;
jVoltage = valueLow - TK_OFFSET + (jTemp - (i*10-270)) * (valueHigh - valueLow)/10;

From GetTypKTemp():
LookedupValue = ((float)-270 + (i)*10) + ((10 *(float)(microVolts - valueLow)) / ((float)(valueHigh - valueLow)));

@charlespax
Copy link
Member Author

@protological Can this be closed now that #220 is merged?

@protological
Copy link
Collaborator

Not all the float operations have been removed. The mentioned algorithms use floating point values. Maybe we need to keep some floats

@charlespax charlespax modified the milestone: Milestone 6 Jul 30, 2016
@charlespax charlespax changed the title Remove all floating point operations Minimize floating point operations Jul 30, 2016
@charlespax charlespax added this to the Milestone 6 milestone Jul 30, 2016
@protological
Copy link
Collaborator

I've managed to reduce the floating point math quite a bit, however there are still a few hold outs

t400.ino
void readTemperatures(): lines 271-284

functions.c
int32_t celcius_to_microvolts(float celcius): Argument is float and then converted to uint8_t
int16_t microvolts_to_celcius(int32_t microVolts): line 517, 525

If we can get some details on the math in these functions I might be able to translate them to integer math operations

@charlespax charlespax modified the milestones: Ice box, Milestone 6 Jul 31, 2016
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

No branches or pull requests

2 participants