melexis / mlx90640-library

MLX90640 library functions
Apache License 2.0
241 stars 192 forks source link

Changing I2C Address #29

Closed nlsa closed 4 years ago

nlsa commented 5 years ago

I tried to change the I2C address of my MLX90640 by the following steps, using methods from the mlx90640-library: Addressing the device at 0x33, Write 0x0000 to register 0x240F Sleep 10 ms or longer Write 0xBE32 to register 0x240F Sleep power-off Upon power-on, the device only responds with ACK to I2C address 0x00, returning either 0x008 or 0x009. NACK from all other addresses 0x01 through 0x7F. Repeating the above steps to 0x00 doesn't change anything. Question 1: Have I ruined the device? Question 2: Could someone please provide a working example that changes the I2C address so I don't repeat my mistake on another device? Thank you -

slavysis commented 5 years ago

When you say 'sleep' do you mean just waiting for 10ms without doing anything? Are you powering down the MLX90640 device after you write 0x0000 and before you write the new slave address? Do you read the EERPOM address after writing to it in order to verify that the correct value is written?

Best regards

nlsa commented 5 years ago

Thank you for the quick reply, Slavysis! I stepped through the code in the debugger. The "sleep" period was whatever time it took for the step with my finger. No, I did not power-down after setting it to 0x000... was I supposed to? (I thought that the power-down was only after writing the new valid address). Yes, I did read after writing and it was not what I wrote, first clue that something was wrong. Best, Michael

slavysis commented 5 years ago

Hi,

You should NOT power off the device when the slave address in the EEPROM is 0x00. So what you did seems right. The only issues is that for some reason you were not able to write the new slave address. So when you powered off the device the slave address was 0x00 and that put the device in a special mode. Could you please contact Melexis sales and post a question explaining the issue.

Best regards

nlsa commented 5 years ago

I contacted Melexis with my question, pointing back to this thread. They told me to contact Digi-Key (from whom I purchased the device) about the problem and ask them to contact Melexis on my behalf. Unimpressive customer service, I say.

nlsa commented 5 years ago

Melexis responded directly with a generous offer to replace the device. My faith in their customer service has been redeemed. Thank you!

ackoc23 commented 5 years ago

Where you able to change the I2C address ? How many MLX90640 can you connect together ?

nlsa commented 5 years ago

Hi, I haven’t tried again. Awaiting a couple of new devices. You should be able to configure up to 127 different I2C addresses. I’m a little apprehensive because I thought that I was doing it right when I bricked the first one. Best, Michael

From: ackoc23 notifications@github.com Sent: Wednesday, April 3, 2019 2:31 PM To: melexis/mlx90640-library mlx90640-library@noreply.github.com Cc: Owen, Michael Michael.Owen@saabusa.com; State change state_change@noreply.github.com Subject: Re: [melexis/mlx90640-library] Changing I2C Address (#29)

Where you able to change the I2C address ? How many MLX90640 can you connect together ?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/melexis/mlx90640-library/issues/29#issuecomment-479607190, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALLgn8DCiKZfbxDhH3b20U_Twv5vFMq8ks5vdPNqgaJpZM4bmpW4.

This message is intended only for the addressee and may contain information that is company confidential or privileged. Any technical data in this message may be exported only in accordance with the U.S. International Traffic in Arms Regulations (22 CFR Parts 120-130) or the Export Administration Regulations (15 CFR Parts 730-774). Unauthorized use is strictly prohibited and may be unlawful. If you are not the intended recipient, or the person responsible for delivering to the intended recipient, you should not read, copy, disclose or otherwise use this message. If you have received this email in error, please delete it, and advise the sender immediately.

ackoc23 commented 5 years ago

Do you know if there's any arduino example sketch on how to change the I2C address ?

nlsa commented 5 years ago

Hi, Google found a couple of discussions but not complete source code. https://forum.arduino.cc/index.php?topic=570057.0 https://discourse.processing.org/t/how-to-change-i2c-address-of-mlx90640-32x24-thermal-camera-sensor/6238 I am not using Arduino so I can’t help, sorry MRO

From: ackoc23 notifications@github.com Sent: Thursday, April 4, 2019 10:00 AM To: melexis/mlx90640-library mlx90640-library@noreply.github.com Cc: Owen, Michael Michael.Owen@saabusa.com; State change state_change@noreply.github.com Subject: Re: [melexis/mlx90640-library] Changing I2C Address (#29)

Do you know if there's any arduino example sketch on how to change the I2C address ?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/melexis/mlx90640-library/issues/29#issuecomment-479909046, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALLgnzwbV37w8p7xceJLJCjH5GvbAF4Cks5vdgV1gaJpZM4bmpW4.

This message is intended only for the addressee and may contain information that is company confidential or privileged. Any technical data in this message may be exported only in accordance with the U.S. International Traffic in Arms Regulations (22 CFR Parts 120-130) or the Export Administration Regulations (15 CFR Parts 730-774). Unauthorized use is strictly prohibited and may be unlawful. If you are not the intended recipient, or the person responsible for delivering to the intended recipient, you should not read, copy, disclose or otherwise use this message. If you have received this email in error, please delete it, and advise the sender immediately.

nlsa commented 5 years ago

I succeeded in changing the address using the steps listed above. The C# .NetMF code is below. I stepped through it in the Visual Studio debugger so that I could confirm each step. public ChangeAddress() { using (OutputPort i2cPort = new OutputPort(Pins.GPIO_PIN_SDA, true)) // Toggles SDA. This is necessary on Netduino Plus 2 { // to wake up I2C. I don't know why. i2cPort.Write(false); Thread.Sleep(100); } Netduino.Foundation.Communications.I2CBus _I2C; _I2C = new Netduino.Foundation.Communications.I2CBus(0x33, 400); // configure I2C UInt16 Result = _I2C.ReadUShort(0x240F, Netduino.Foundation.Communications.ByteOrder.BigEndian); // should be 0xBE33 (original address is 0x33) _I2C.WriteUShort(0x240F, 0, Netduino.Foundation.Communications.ByteOrder.BigEndian); // erase register Thread.Sleep(10); Result = _I2C.ReadUShort(0x240F, Netduino.Foundation.Communications.ByteOrder.BigEndian); // should be zero _I2C.WriteUShort(0x240F, 0xBE32, Netduino.Foundation.Communications.ByteOrder.BigEndian); // write new address, 0x32 Thread.Sleep(10); Result = _I2C.ReadUShort(0x240F, Netduino.Foundation.Communications.ByteOrder.BigEndian); // should be 0xBE32 }

AKremor commented 5 years ago

Hi,

You should NOT power off the device when the slave address in the EEPROM is 0x00. So what you did seems right. The only issues is that for some reason you were not able to write the new slave address. So when you powered off the device the slave address was 0x00 and that put the device in a special mode. Could you please contact Melexis sales and post a question explaining the issue.

Best regards

Hi @slavysis,

What is the sensor doing in the 'special mode' that it enters when power cycled with address 0x00 set? Is there a way the user can return the sensor to normal operations if it enters the special mode, or is the sensor permanently unusable?

Thanks, Anthony

slavysis commented 5 years ago

Hi, Unfortunately, there is no way the user can bring the sensor back to normal operation.

Best regards

p4twu commented 5 years ago

Hi,

It's working now. Please see the update below.

I'm also trying to change the i2c address of my MLX90640 in order to connect more than one device.

If I run my little program setaddr.cpp (link to old revision deleted) the address gets changed, but it reverts back to the default address 0x33 after disconnecting and reconnecting the device to power.

Please note, that I changed the address at two locations (EEPROM 0x240F and register 0x8010).

Output:

Value of I2C device 0x33 at EEPROM address 0x240f: 0xbe33 Value of I2C device 0x33 at register address 0x8010: 0xbe33 Writing value 0xbe32 to EEPROM address 0x240f. New value successfully written to EEPROM at address 0x240f. Device is still accessible at address 0x33. Writing value 0xbe32 to I2C device 0x33 and register address 0x8010. New value successfully written to register address 0x8010. I2C device addressed successfully at i2c address 0x32. Value at EEPROM address 0x240f: 0xbe32 Value at register address 0x8010: 0xbe32 Please reboot the device (disconnect from power and connect to power).

Output of running i2cdetect -y 1:

0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- 32 -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --

After POR: 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- 33 -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --

Can anyone help?

Update

The trick was to erase the EEPROM first instead of overwrite the address with a new one. I updated the program accordingly. You can find the new revsion of setaddr.cpp here. Suggestions and comments welcome.

Thank you! Patrick