hamid9543
Active Member
Offline
Posts: 124
Thank You
-Given: 80
-Receive: 7
|
|
« on: January 31, 2013, 11:44:16 11: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, 12:07:34 12:07 by hamid9543 »
|
Logged
|
|
|
|
TucoRamirez
Senior Member
Offline
Posts: 307
Thank You
-Given: 257
-Receive: 115
Tuco ... dead or Alive
|
|
« Reply #1 on: January 31, 2013, 03:36:49 15: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 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, 03:41:57 15:41 by TucoRamirez »
|
Logged
|
Whoever double crosses me and leaves me alive... he understands nothing about Tuco.
|
|
|
robotai
Junior Member
Offline
Posts: 60
Thank You
-Given: 27
-Receive: 23
|
|
« Reply #2 on: February 02, 2013, 04:40:05 16: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
Posts: 124
Thank You
-Given: 80
-Receive: 7
|
|
« Reply #3 on: February 03, 2013, 10:04:54 10: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
Posts: 60
Thank You
-Given: 27
-Receive: 23
|
|
« Reply #4 on: February 03, 2013, 12:36:30 12: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.aspxIf 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
Posts: 124
Thank You
-Given: 80
-Receive: 7
|
|
« Reply #5 on: February 03, 2013, 05:58:19 17:58 » |
|
i read datasheet several times!(again again again....) finally i wrote below code to set new address to EEPROM 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
Posts: 60
Thank You
-Given: 27
-Receive: 23
|
|
« Reply #6 on: February 03, 2013, 09:38:07 21: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
Posts: 307
Thank You
-Given: 257
-Receive: 115
Tuco ... dead or Alive
|
|
« Reply #7 on: February 03, 2013, 10:24:06 22: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
Posts: 124
Thank You
-Given: 80
-Receive: 7
|
|
« Reply #8 on: February 04, 2013, 05:25:43 05: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, 07:55:47 07:55 by hamid9543 »
|
Logged
|
|
|
|
TucoRamirez
Senior Member
Offline
Posts: 307
Thank You
-Given: 257
-Receive: 115
Tuco ... dead or Alive
|
|
« Reply #9 on: February 04, 2013, 08:54:13 08: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
Posts: 124
Thank You
-Given: 80
-Receive: 7
|
|
« Reply #10 on: February 04, 2013, 08:59:05 08:59 » |
|
for erase and set new address 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, 10:18:28 10:18 by hamid9543 »
|
Logged
|
|
|
|
|
|