Proton BASIC Community

Proton (Positron) => Beginners => Topic started by: oguztkn on Sep 20, 2021, 08:33 PM

Title: MLX90614 using problem
Post by: oguztkn on Sep 20, 2021, 08:33 PM
Hi,

I am trying to use the MLX90614 sensor. But I couldn't find any sample project. How are temperature calculations done? Can you help me please.

pic:16f627
Title: Re: MLX90614 using problem
Post by: Yasin on Sep 20, 2021, 09:05 PM
https://wiki.dfrobot.com/IR_Thermometer_Sensor_MLX90614_SKU__SEN0206#Resources (https://wiki.dfrobot.com/IR_Thermometer_Sensor_MLX90614_SKU__SEN0206#Resources)

Have you seen this place?
Title: Re: MLX90614 using problem
Post by: oguztkn on Sep 20, 2021, 09:18 PM
Yes, but I could not do it.

START:

I2CRead SDA, SCL, $B4, $04, [DEGER[0]]
PAUSE 100
I2CRead SDA, SCL, $B4, $05, [DEGER[1]]
PAUSE 100
I2CRead SDA, SCL, $B4, $06, [DEGER[2]]
PAUSE 100
I2CRead SDA, SCL, $B4, $07, [DEGER[3]]
PAUSE 100
I2CRead SDA, SCL, $B4, $08, [DEGER[4]]

tempk = ((DEGER[3] << 8))
tempk=tempk + DEGER[2]
temp = (((tempk * 9)/5) +32);

SEROUT2 PORTB.1,84,[Dec tempk,13,10]


incoming data is inconsistent. 18121,22922,20910,19202, etc.
Title: Re: MLX90614 using problem
Post by: normnet on Sep 21, 2021, 12:49 AM
The SEROUT2 line is tempk in place of temp if that helps at all.

Hopefully you aren't exceeding the variable tempk within the calculation?

Also you shouldn't require parenthesis on both the far left and right of the calculations.
Title: Re: MLX90614 using problem
Post by: normnet on Sep 21, 2021, 01:06 AM
Have you studied SMBus communication with MLX90614 (https://www.melexis.com/en/documents/documentation/application-notes/application-note-mlx90614-smbus-communication)?

Pseudo code example: Reading RAM address 0x07 (Tobj1)
1. Send START bit
2. Send Slave Address (0x00* for example) + Rd\-Wr bit**
3. Send Command (0b000x_xxxx + 0b0000_0111 -> 0b0000_0111)
4. Send Repeated START_bit
5. Send Slave Address + Rd\-Wr bit**
6. Read Data Byte Low (master must send ACK bit)
7. Read Data Byte High (master must send ACK bit)
8. Read PEC (master can send ACK or NACK)
9. Send STOP bit


Title: Re: MLX90614 using problem
Post by: Frizie on Sep 21, 2021, 07:17 AM

SYMBOL MLX_Dta1  = PORTB.0    ;I: Datapin  of the MLX90614
SYMBOL MLX_Clk   = PORTB.1    ;Q: Clockpin of the MLX90614
SYMBOL MLX_Adres = 0          ;Adres of the MLX90614, infra-red (contactless) digital temperature-sensor
SYMBOL MLX_Ta    = $06        ;T-A    Temperature Ambient, internal temperatuur of the sensor
SYMBOL MLX_Tobj1 = $07        ;T-Obj1 Temperature Object, temperature of the object to be measured

DIM Celsius      AS WORD      ;Contains the degrees Celsius, can rise above 255°C, thus WORD!
DIM SensorTemp   AS WORD      ;Measured Kelvin temperature from the MLX90614 temperature sensor

I2CIN MLX_Dta1, MLX_Clk, MLX_Adres, MLX_Tobj1, [SensorTemp.LOWBYTE, SensorTemp.HIGHBYTE]

Celsius = (SensorTemp / 50) - 273     ;Convert measured temperature in Kelvin to Celsius


The example above measures the temperature of the object.
The object to be measured must not be hotter than 380°C.
It is also possible to measure the temperature of the sensor itself (it must not exceed 125 degrees Celsius).
Then fill in:


I2CIN MLX_Dta1, MLX_Clk, MLX_Adres, MLX_Ta, [SensorTemp.LOWBYTE, SensorTemp.HIGHBYTE]


Regards,
Frizie.
Title: Re: MLX90614 using problem
Post by: oguztkn on Sep 21, 2021, 09:21 AM
Quote from: Frizie on Sep 21, 2021, 07:17 AMSYMBOL MLX_Dta1  = PORTB.0    ;I: Datapin  of the MLX90614
SYMBOL MLX_Clk   = PORTB.1    ;Q: Clockpin of the MLX90614
SYMBOL MLX_Adres = 0          ;Adres of the MLX90614, infra-red (contactless) digital temperature-sensor
SYMBOL MLX_Ta    = $06        ;T-A    Temperature Ambient, internal temperatuur of the sensor
SYMBOL MLX_Tobj1 = $07        ;T-Obj1 Temperature Object, temperature of the object to be measured

DIM Celsius      AS WORD      ;Contains the degrees Celsius, can rise above 255°C, thus WORD!
DIM SensorTemp   AS WORD      ;Measured Kelvin temperature from the MLX90614 temperature sensor

I2CIN MLX_Dta1, MLX_Clk, MLX_Adres, MLX_Tobj1, [SensorTemp.LOWBYTE, SensorTemp.HIGHBYTE]

Celsius = (SensorTemp / 50) - 273     ;Convert measured temperature in Kelvin to Celsius


The example above measures the temperature of the object.
The object to be measured must not be hotter than 380°C.
It is also possible to measure the temperature of the sensor itself (it must not exceed 125 degrees Celsius).
Then fill in:


I2CIN MLX_Dta1, MLX_Clk, MLX_Adres, MLX_Ta, [SensorTemp.LOWBYTE, SensorTemp.HIGHBYTE]


Regards,
Frizie.

Thank you for answer. its work. But 34,32,29. i want to appear 33.4, 32.6. How ?
Title: Re: MLX90614 using problem
Post by: flosigud on Sep 21, 2021, 08:38 PM
I would try:

DIM Celsius      AS Float
Title: Re: MLX90614 using problem
Post by: oguztkn on Sep 22, 2021, 06:27 AM
Thank you. it is work. Last questions: How go to sleep this module ?