Close

reduced math time down further by about 50,000 microseconds on uno

A project log for mlx90640 sensor works w 800 bytes

Everywhere i read people are excited to get mlx90640 working. here are examples using arduino w 800bytes ram, and 1k with calibrated DEG C

jamesdanielvjamesdanielv 09/09/2019 at 07:110 Comments

shaved another 50,000 microseconds off of math time for arduino 328p chip. it does however use 4 more bytes. as it requires another float to store the fractional result

i recently posted a a project about different optimization techniques here

https://hackaday.io/project/167533-math-optimizations-with-specific-tasks-and-ranges

one of my guide rules was whenever possible fractionally multiply instead of divide.

i have broken down the math to its basics, so i can simplify and cache.

i have determined that the first sub_calc_To (my version of the math) still eats up 500,000 microseconds time to process. 

this is how the code looks after it has been modified to be simpler

and here is how it looks now with a time savings of 50,000 microseconds

there are some notes and references to the data in the comments. this is more for me.

any way the division has been cached, and the result turned into a fraction, and applied two times.

notice the above version divides twice. the version below divides 1 time. division is at minimum 4 times slower and in many cases a lot longer. multiplication even with floats is faster. this is because even the most basic cpus contain logic for multiplication usually just an extended length register. division is harder beast to incorporate hardware for, so it is done in software very slowly. 

removing the division to speed things up. we still need to do it once however. now i just need to check to see if this value happens more than one time! i have noticed that the time it takes to solve increases when more heat is on the cells. i'll look into it more.....

Discussions