-
Notifications
You must be signed in to change notification settings - Fork 189
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
All values from the EEPROM are "FFFF", excepted for the first that is "00BF" #104
Comments
Hi, |
Hi, thanks a lot for the answer!!
I tried to do what you say, having also seen it in the "main" of one of the
posts here on github, but it still doesn't work. What i explained at the
beginning of this posts happens during debugging, while during the "run" i
get problems before getting the data back from the EEPROM. In particular,
the set refresh rate and resolutions functions return values such as
-1(NACK), -2 ("the data is not the intended one" what does it means?) or
1(what does it means?). During debugging, the same functions return
correctly 0.
I'm using the mbed online platforms, could there be any problems related to
this?
Il Lun 24 Apr 2023, 08:41 Slaveyko ***@***.***> ha scritto:
… Hi,
The code should not hang, unless there is something awfully wrong with the
memory allocation and you somehow mess-up the stack. I would suggest that
you start by fixing the communication and getting proper data.
You are using the SW I2C lib and this one requires that you trim the SCL
frequency.
The I2C speed when reading the EEPROM should be no more than 400KHz, So
you should do something like:
MLX90640_I2CFreqSet(400000);
status=MLX90640_DumpEE(slaveAddress, pEE);
MLX90640_I2CFreqSet(1000000);
—
Reply to this email directly, view it on GitHub
<#104 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A7KZOWV7GYQZNBWDBZB2MSTXCYN75ANCNFSM6AAAAAAXHFUTZY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Hi, -2 means that the value written via I2C in a register is not the one that you wanted to write. Best regards |
Hi, |
Hi, Best regards |
Hi, #include <MLX90640_I2C_Driver.h> void ExtractVDDParameters(uint16_t *eeData, paramsMLX90640 *mlx90640); int MLX90640_DumpEE(uint8_t slaveAddr, uint16_t *eeData) int MLX90640_CheckInterrupt(uint8_t slaveAddr) void MLX90640_StartMeasurement(uint8_t slaveAddr, uint8_t subPage) int MLX90640_GetData(uint8_t slaveAddr, uint16_t *frameData)
} int MLX90640_InterpolateOutliers(uint16_t *frameData, uint16_t *eepromData)
} int MLX90640_GetFrameData(uint8_t slaveAddr, uint16_t *frameData)
#ifdef DEBUG
#ifdef DEBUG
#ifdef DEBUG
} int MLX90640_ExtractParameters(uint16_t *eeData, paramsMLX90640 *mlx90640)
} //------------------------------------------------------------------------------ int MLX90640_SetResolution(uint8_t slaveAddr, uint8_t resolution)
} //------------------------------------------------------------------------------ int MLX90640_GetCurResolution(uint8_t slaveAddr)
} //------------------------------------------------------------------------------ int MLX90640_SetRefreshRate(uint8_t slaveAddr, uint8_t refreshRate)
} //------------------------------------------------------------------------------ int MLX90640_GetRefreshRate(uint8_t slaveAddr)
} //------------------------------------------------------------------------------ int MLX90640_SetInterleavedMode(uint8_t slaveAddr)
} //------------------------------------------------------------------------------ int MLX90640_SetChessMode(uint8_t slaveAddr)
} //------------------------------------------------------------------------------ int MLX90640_GetCurMode(uint8_t slaveAddr)
} //------------------------------------------------------------------------------ int MLX90640_SetDeviceMode(uint8_t slaveAddr, uint8_t deviceMode)
} //------------------------------------------------------------------------------ int MLX90640_SetSubPageRepeat(uint8_t slaveAddr, uint8_t subPageRepeat)
} //------------------------------------------------------------------------------ int MLX90640_SetSubPage(uint8_t slaveAddr, uint8_t subPage)
} //------------------------------------------------------------------------------ void MLX90640_CalculateTo(uint16_t *frameData, const paramsMLX90640 *params, float emissivity, float tr, float *result)
//------------------------- Gain calculation -----------------------------------
//------------------------- To calculation -------------------------------------
} //------------------------------------------------------------------------------ void MLX90640_GetImage(uint16_t *frameData, paramsMLX90640 *params, float *result)
//------------------------- Gain calculation -----------------------------------
//------------------------- Image calculation -------------------------------------
} //------------------------------------------------------------------------------ float MLX90640_GetVdd(uint16_t *frameData, const paramsMLX90640 *params)
} //------------------------------------------------------------------------------ float MLX90640_GetTa(uint16_t *frameData, const paramsMLX90640 *params)
} //------------------------------------------------------------------------------ int MLX90640_GetSubPageNumber(uint16_t *frameData) } //------------------------------------------------------------------------------
} //------------------------------------------------------------------------------ void ExtractVDDParameters(uint16_t *eeData, paramsMLX90640 *mlx90640)
} //------------------------------------------------------------------------------ void ExtractPTATParameters(uint16_t *eeData, paramsMLX90640 *mlx90640)
} //------------------------------------------------------------------------------ void ExtractGainParameters(uint16_t *eeData, paramsMLX90640 *mlx90640)
} //------------------------------------------------------------------------------ void ExtractTgcParameters(uint16_t *eeData, paramsMLX90640 *mlx90640)
} //------------------------------------------------------------------------------ void ExtractResolutionParameters(uint16_t *eeData, paramsMLX90640 *mlx90640)
} //------------------------------------------------------------------------------ void ExtractKsTaParameters(uint16_t *eeData, paramsMLX90640 *mlx90640)
} //------------------------------------------------------------------------------ void ExtractKsToParameters(uint16_t *eeData, paramsMLX90640 *mlx90640)
} //------------------------------------------------------------------------------ void ExtractAlphaParameters(uint16_t *eeData, paramsMLX90640 *mlx90640)
} //------------------------------------------------------------------------------ void ExtractOffsetParameters(uint16_t *eeData, paramsMLX90640 *mlx90640)
} //------------------------------------------------------------------------------ void ExtractKtaPixelParameters(uint16_t *eeData, paramsMLX90640 *mlx90640)
} //------------------------------------------------------------------------------ void ExtractKvPixelParameters(uint16_t *eeData, paramsMLX90640 *mlx90640)
} //------------------------------------------------------------------------------ void ExtractCPParameters(uint16_t *eeData, paramsMLX90640 *mlx90640)
} //------------------------------------------------------------------------------ void ExtractCILCParameters(uint16_t *eeData, paramsMLX90640 *mlx90640)
} //------------------------------------------------------------------------------ int ExtractDeviatingPixels(uint16_t *eeData, paramsMLX90640 *mlx90640)
} //------------------------------------------------------------------------------ int CheckAdjacentPixels(uint16_t pix1, uint16_t pix2)
} //------------------------------------------------------------------------------ float GetMedian(float *values, int n)
} //------------------------------------------------------------------------------ int IsPixelBad(uint16_t pixel,paramsMLX90640 *params)
} //------------------------------------------------------------------------------ This is "MLX90640_API.h": #include <stdint.h> #define MLX90640_NO_ERROR 0 #define BIT_MASK(x) (1UL << (x)) #define MLX90640_EEPROM_START_ADDRESS 0x2400 #define MLX90640_CTRL_REG 0x800D #define MLX90640_MS_BYTE_SHIFT 8 #define POW2(x) pow(2, (double)x) #define SCALEALPHA 0.000001 typedef struct
#endif This is "MLX90640_I2C_Driver.h": #ifndef MLX90640_I2C_Driver_H #include <stdint.h> |
The most stranger thing is that during debugging i have correctly 0 from the calibration functions, but during the run returns other values. Could you explain why? I'm sorry for the many questions and thank you a lot for the help. |
What do you mean when you say 'debugging'? Is it step-ing through the code? If you do not have an oscilloscope To trim the clock frequency, you could connect the SCL to an GPIO of the MCU and measure the frequency while running I2C communication. |
Hi,
Thanks for the answer. Yes, i mean that when i run the code in debug mode
(step-ing through the code) the calibration's functions return correctly 0;
but if i don't run it in debug mode, they're turn -1.
Il Mer 26 Apr 2023, 08:12 Slaveyko ***@***.***> ha scritto:
… What do you mean when you say 'debugging'? Is it step-ing through the code?
My guess would be that there is something wrong with the timings.
—
Reply to this email directly, view it on GitHub
<#104 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A7KZOWVTZ6ALLWCFRXMT3SLXDC4E7ANCNFSM6AAAAAAXHFUTZY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Since you are using the SW I2C and you are stepping through it this stretches the timings and the communication is good. In normal mode the SCL is too fast and the device returns NACK. Modify the void Wait(int freqCnt) function to get the proper I2C timings. The easiest would be to use an oscilloscope in order to trim the frequency. As you do not have one, you could use the MCU to measure the frequency. This would require you to connect the SCL output to an input of the MCU and measure the frequency when you send/receive data via I2C. |
I tried to use the oscilloscope but i can't see any waveform with the file i uploaded here. But using this code: #include "mbed.h" Serial pc(USBTX, USBRX); int main() {
} i get these two waves: the first refers to the SCL pin and the second to the SDA pin. Going back to the main project, i have another question. When i run the code in debug mode, as mentioned above, the calibration functions correctly return 0, but the "MLX90640_ExtractParameters(pEE, &mlx90640)" functions seems to crash. Is it always due to timing? Thank you so much for your availability and help, any suggestion on what i could do is always welcome. |
This is using the hardware I2C of the MCU, and you were trying to use the SW I2C driver. Make sure that your configuration is correct. If you want to use the HW I2C module of the MCU you should use the "MLX640_I2C_Driver.cpp" and implement the i2c read/write functions accordingly. You should definitely first make sure that your communication is working. Now that you have an oscilloscope, this should be a rather straight forward thing to do. |
Hi, i'm using the MLX90640 thermal camera on mbed on the STM32F429-Disc. The main function is as follows:
#include "mbed.h"
#include <MLX90640_I2C_Driver.h>
#include <MLX90640_API.h>
#define FRAMES_NUM 15
#define TA_SHIFT 8
Serial pc(USBTX, USBRX);// tx, rx, Virtual serial port over USB
DigitalOut greenLED(LED1);
void PrintRawData(uint16_t *p);
int main()
{
uint8_t printme=1;
pc.baud(115200);
greenLED = !greenLED;
MLX90640_I2CFreqSet(1000000);
}
void PrintRawData(uint16_t *p)
{
for(int i=0; i<832; i++) {
pc.printf("%04X,",*p++);
}
pc.printf("\r\n");
}
I added to the project the files "MLX90640_API.h", "MLX90640_API.cpp", "MLX90640_I2C_Driver.h", and "MLX640_SWI2C_Driver.cpp" provided by you. When I try to debug the code, it seems to hang when I call the function "MLX90640_ExtractParameters(pEE, &mlx90640)", so I thought the problem was in the parameter "pEE", which is the EEPROM data, and which actually turns out to be incorrect. Is it possible that the code hangs when I call the function "MLX90640_ExtractParameters(pEE, &mlx90640)" due to incorrect EEPROM data?
The text was updated successfully, but these errors were encountered: