jamesdanielv / thermal_cam_mlx90640

same as thermal cam project but with mlx90640 sensor
16 stars 3 forks source link

getting the data from the MLX90640 line by line #7

Closed vangalvin closed 4 years ago

vangalvin commented 4 years ago

I am working on a project that uses a 48 MHz ARM® Cortex® M0+ MCU, 128KB FLASH, 16KB SRAM the reason I had to go with this is that the unit has an integrated LoRa radio, is low power and several other features.its actually a CubeCell from heltech.

Do you know if there is a way to extract the data line by line in to an array? All i really need to do is look at the pixel values and do a comparison with a set level to see if there is a hot spot in the image.

If one or more pixels are above a set threshold then an alert is triggered via the LoRa.

jamesdanielv commented 4 years ago

if using my version just do this float temp=Readmlx90640To(x+y*32) ;

or if using res doubler then

float temp=DoubleResolutionValue(x,y);

both call a sub function that reads the cell. it also caches cells nearby so reading them is almost instantaneous after first read.however there is overhead as the data is converted into actual values in degrees C. this will be even faster when i eventually get to upload code.

just be sure to scan from left to right and from top to bottom for cache to work properly. if out of order pixel locations a cache mis occurs at it reloads all data.

if you want to do the data line by line manually loading the array is fine, as the data is cached from the sensor already.

if all you want is direct access to the memory for the data, and you have the ram, in Z_MemManagment.h, change new_method to false, and look at mlx90640To[x] with 768 values.

i would suggest that the new_method be false and save memory; and just create a 128 byte array that is 32 floats something like this; i haven't tested it but you get the idea. float myarray[32];//set up array float lineNumber=0;//0 to 24 how it is set is up to you

//load array; for (int rasterline=0;rasterline<32;rasterline++ ){

//Readmlx90640To(x+y32) ; myarray[ rasterline]= Readmlx90640To(rasterline+lineNumber32) ;

}

vangalvin commented 4 years ago

Thank you for the quick response. Yes the ASR605x only has 16Kb so handling 768 values is not going to work sadly. It also looks like there may be a few other issues mostly around library compatibility. I tried the getEepromDump and ended up with the following errors.

`In file included from G:\Arduino\thermal_cammlx90640-master\Updates\getEEpromDump\getEEpromDump\getEEpromDump.ino:21:0:

sketch\MLX90640_SimpleDriver.h: In function 'int MLX90640_I2CWrite(uint8_t, unsigned int, uint16_t)':

MLX90640_SimpleDriver.h:40:67: error: expression list treated as compound expression in initializer [-fpermissive]

int MLX90640_I2CRead(_deviceAddress, writeAddress, 1, &dataCheck); ^

MLX90640_SimpleDriver.h:40:67: error: invalid conversion from 'uint16_t {aka short unsigned int}' to 'int' [-fpermissive]

In file included from G:\Arduino\thermal_cammlx90640-master\Updates\getEEpromDump\getEEpromDump\getEEpromDump.ino:20:0:

C:\Arduino15\packages\CubeCell\hardware\CubeCell\0.0.4/cores/asr650x/Wire/Wire.h: In function 'int MLX90640_I2CRead(uint8_t, unsigned int, unsigned int, uint16_t*)':

C:\Arduino15\packages\CubeCell\hardware\CubeCell\0.0.4/cores/asr650x/Wire/Wire.h:113:13: note: candidate 1: uint8_t TwoWire::requestFrom(int, int)

 uint8_t requestFrom(int address, int size);
         ^

C:\Arduino15\packages\CubeCell\hardware\CubeCell\0.0.4/cores/asr650x/Wire/Wire.h:111:13: note: candidate 2: uint8_t TwoWire::requestFrom(uint8_t, uint8_t)

 uint8_t requestFrom(uint8_t address, uint8_t size);
         ^`
jamesdanielv commented 4 years ago

let me look a little more. it seems like the code for cubecell that translated Arduino memory sizes is not defining the correct bit width. the wire.h library for Arduino is standard for example.

the errors are not allowing a memory type, i can mod that to a true cast method. it should be compiled to same machine code as it is now just some more wording in higher level C+

the memory errors are likely because cubecell does not understand the memory sizes. i don't yet know if that is something i can fix, or if it needs to be addressed with their interpreter.

jamesdanielv commented 4 years ago

i looked at the code and compiled it successfully to teensy_lc arm, and arm cortex using arduino ide 1.8.9. i think it is the library for the cube cell. i would try defining bytes as uint8_t and int as int_16, and unsigned as uint16_t this might help your issues. since i can not repeat the error i will close this.