melexis / mlx90640-library

MLX90640 library functions
Apache License 2.0
239 stars 189 forks source link

MLX90640_CalculateTo takes too long and prevents reading faster than 1Hz #65

Open r0486441 opened 4 years ago

r0486441 commented 4 years ago

Hello,

I've been doing a project with the mlx90640 using an arduino nano 33 iot. I've noticed that refresh rates up to 1Hz work properly but starting from 2Hz, it tops of at 1.25Hz, whatever higher frequency I take.

When doing some debugging, I noticed that there was 2 times a delay of 377ms when calling MLX90640_CalculateTo and more specifically in the To calculation (in MLX90640_API.cpp).

Is there a way to increase the speed of this function? I'm trying to understand what it does and there are a lot of sqrt and pow calculations to be done, which can take a while on such a lightweight microcontroller, but I'm not really sure what can be adjusted to increase this speed. Can someone help me?

Thanks in advance!

rtubio commented 4 years ago

I have the same issue. I have timed my code with C++ chrono library and it takes around 600 ms to execute the following calls:

MLX90640_GetFrameData(MLX_I2C_ADDR, frame); MLX90640_InterpolateOutliers(frame, eeMLX90640); ta = MLX90640_GetTa(frame, &mlx90640); MLX90640_CalculateTo(frame, &mlx90640, e, ta, frameTo);