Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 10, 2016, 11:42:20 11:42


Login with username, password and session length


Pages: [1]
Print
Author Topic: mlx90614  (Read 3276 times)
0 Members and 1 Guest are viewing this topic.
hamid9543
Active Member
***
Offline Offline

Posts: 120

Thank You
-Given: 45
-Receive: 3


« on: January 31, 2013, 12:44:16 12:44 »

hi to all
i want config mlx90614 in pwm mode:
1)how programing mlx90614 in first program(via I2c or no?)?
2)how write data on eeprom mlx90614 for config pwm mode?
hardware:pic16f877a
software:ccs compailer
« Last Edit: January 31, 2013, 01:07:34 13:07 by hamid9543 » Logged
TucoRamirez
Senior Member
****
Offline Offline

Posts: 277

Thank You
-Given: 197
-Receive: 95


Tuco ... dead or Alive


« Reply #1 on: January 31, 2013, 04:36:49 16:36 »

i have a similar problem but while calibrating the temp in function of the distance ... i  dont know how to compensate it correctly.

for example for reading temperature i use
Code:
unsigned int Read_temp(unsigned char com)
{
  unsigned int SensorRaw;
  Soft_I2C1_Start();// issue I2C start signal
  Soft_I2C1_Write(0x00);// send address (device address + W)
  Soft_I2C1_Write(com);// send command
  Soft_I2C1_Start();// issue I2C signal repeated start
  Soft_I2C1_Write(0x01);// send address (device address + R)
  SensorLow = Soft_I2C1_Read(1);// Read temp. low byte (acknowledge)
  SensorHigh = Soft_I2C1_Read(1);// Read temp. high byte (acknowledge)
  PEC = Soft_I2C1_Read(1);// Read PEC (not used) (acknowledge)
  Soft_I2C1_Stop();// issue I2C stop signal
  SensorRaw = SensorLow + (SensorHigh << 8);// Build temp. word
  return SensorRaw;
}


and the smbus routines i use are on my post about the electronic compass (i mean the i2c @ 100KHz)


http://www.sonsivri.to/forum/index.php?topic=50278.0
« Last Edit: January 31, 2013, 04:41:57 16:41 by TucoRamirez » Logged

Whoever double crosses me and leaves me alive... he understands nothing about Tuco.
robotai
Junior Member
**
Offline Offline

Posts: 60

Thank You
-Given: 27
-Receive: 23


« Reply #2 on: February 02, 2013, 05:40:05 17:40 »

The PWM mode is rely on EEPROM configuration while mlx90614 is default on SMbus mode. So it needs to use I2C to switch mode. Once mode switched, later power on will keep on the mode without need to do it again.

To switch to PWM mode. The command 0x22 should be sent to write to EEPROM PWMCTRL word. Set bit 1 to 1 will turn it on. Bits 9 to 15 is used to configure PWM period.
Logged
hamid9543
Active Member
***
Offline Offline

Posts: 120

Thank You
-Given: 45
-Receive: 3


« Reply #3 on: February 03, 2013, 11:04:54 11:04 »

very very thx!
i search for commend but no find!
1)can you help me for  find all commend for mlx90614?
2)how write code to EEPROM PWMCTRL please explain or write flochart or sample code?(very important)
3)how change address EEPROM?
Logged
robotai
Junior Member
**
Offline Offline

Posts: 60

Thank You
-Given: 27
-Receive: 23


« Reply #4 on: February 03, 2013, 01:36:30 13:36 »

The datasheet below includes everything for the commands. Although it only support just simply read and write to EEPROM and RAM.

http://www.melexis.com/Asset/IR-sensor-thermometer-MLX90614-Datasheet-DownloadLink-5152.aspx

If you are familier about I2C programming, this information should be enough. If not, I do suggest to learn it first. Section 8.2 to 8.4 describes all information what you need.
Use I2C library to send start, command, data, and finally stop command. Above TucoRamirez's example would be a good example.
Logged
hamid9543
Active Member
***
Offline Offline

Posts: 120

Thank You
-Given: 45
-Receive: 3


« Reply #5 on: February 03, 2013, 06:58:19 18:58 »

i read datasheet several times!(again again again....)
finally i wrote below code to set new address to EEPROM
Code:
      i2c_start ();       
      i2c_write (0x2E);       
      i2c_write (0x00);         
      i2c_write (0x00);
      i2c_write (0x6F);     
      i2c_stop ();
 
      delay_ms(10);
     
      i2c_start ();       
      i2c_write (0x2E);     
      i2c_write (0x5B);       
      i2c_write (0x00);
      i2c_write (0xF4);     
      i2c_stop ();
but it  dos not work !! and no change default address(5A)  happened.



Logged
robotai
Junior Member
**
Offline Offline

Posts: 60

Thank You
-Given: 27
-Receive: 23


« Reply #6 on: February 03, 2013, 10:38:07 22:38 »

I think you misunderstand the data sheet.

To change the slave address, you should follow steps to send below bytes.

1. Send default slave address (0x5a), or simply send (0x00) as described in section 8.4.1 if only this device is connected on the bus.
2. Send command (0x2e) to choose write to EEPROM to change slave address.
3. Send LSB (0x5b) as your new slave address.
4. Send MSB (0x00).
5. Send PEC or directly stop to finish it.

Hope this help.
Logged
TucoRamirez
Senior Member
****
Offline Offline

Posts: 277

Thank You
-Given: 197
-Receive: 95


Tuco ... dead or Alive


« Reply #7 on: February 03, 2013, 11:24:06 23:24 »

Pseudo code example: Reading EEPROM address 0x0E (SMBus Address)
1. Send START bit
2. Send Slave Address (0x00* for example) + Rd\-Wr bit**
3. Send Command (0b001x_xxxx + 0b0000_1110 -> 0b0010_1110)
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


Pseudo code example:
An Erasing of the EEPROM address 0x0E (SMBus Address)
1. Send START bit
2. Send Slave Address (0x00* for example) + Rd\-Wr bit**
3. Send Command (0b001x_xxxx + 0b0000_1110 -> 0b0010_1110)
4. Send Low data 0x00
5. Send High data 0x00
6. Send PEC 0x6F
7. Send STOP bit
8. Wait 5ms (this time is need the cell to be erased)
A writing of 0x5A in EEPROM address 0x0E (SMBus Address )
1. Send START bit
2. Send Slave Address (0x00* for example) + Rd\-Wr bit**
3. Send Command (0b001x_xxxx + 0b0000_1110 -> 0b0010_1110)
4. Send Low Byte 0x5A
5. Send High Byte 0x00 (the high byte of the EEPROM address 0x0E has no meaning)
6. Send PEC 0xE1
7. Send STOP bit
8. Wait 5ms (this time is need the cell to be written)
9. Turn off/Turn on module power supply to reset MLX90614 (After this MLX90614 will
respond to the new slave address 0x5A)


Logged

Whoever double crosses me and leaves me alive... he understands nothing about Tuco.
hamid9543
Active Member
***
Offline Offline

Posts: 120

Thank You
-Given: 45
-Receive: 3


« Reply #8 on: February 04, 2013, 06:25:43 06:25 »

your former guidance was very very  useful.
i have driven ds1307 and 2404 but i can not understand the mining of calculating COMMAND and PEC value exactly.
i am able to drive 3 sensor in i2c state(by the information in application note) i would be pleasure if explain
for me how i can calculate COMMAND and PEC value .
please give me an example.
« Last Edit: February 04, 2013, 08:55:47 08:55 by hamid9543 » Logged
TucoRamirez
Senior Member
****
Offline Offline

Posts: 277

Thank You
-Given: 197
-Receive: 95


Tuco ... dead or Alive


« Reply #9 on: February 04, 2013, 09:54:13 09:54 »

show at least some code ^^ :p
Logged

Whoever double crosses me and leaves me alive... he understands nothing about Tuco.
hamid9543
Active Member
***
Offline Offline

Posts: 120

Thank You
-Given: 45
-Receive: 3


« Reply #10 on: February 04, 2013, 09:59:05 09:59 »

for erase and set new address
Code:
 i2c_start ();
      i2c_write (0x00);    
      i2c_write (0x2E);      
      i2c_write (0x00);        
      i2c_write (0x00);
      i2c_write (0x6F);      
      i2c_stop ();
 
      delay_ms(10);
      
      i2c_start ();
      i2c_write (0x00);      
      i2c_write (0x2E);    
      i2c_write (0x5B);      
      i2c_write (0x00);
      i2c_write (0xF4);  
      i2c_stop (); 
work very good but i do not understant how calculate command and pec?
« Last Edit: February 04, 2013, 11:18:28 11:18 by hamid9543 » Logged
robotai
Junior Member
**
Offline Offline

Posts: 60

Thank You
-Given: 27
-Receive: 23


« Reply #11 on: February 05, 2013, 09:30:29 09:30 »

The PEC is CRC-8. For the mathematics  information refer to
http://en.wikipedia.org/wiki/Cyclic_redundancy_check

To find the online calculation, below link is provided by SMBus organization,
http://smbus.org/faq/crc8Applet.htm

There is an application note provided by Melexis which include fully implementation sample and library for mlx90614 through SMBus
http://www.melexis.com/Assets/MLX90614-SMBus-implementation-in-PIC-MCU-5229.aspx

This should be helpful for you.
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC