Please help me understand how to use I2c with Smbus alerts - Page 1
Forum section: electronics / projects

author: kraal
author_rank: Newbie
timestamp: November 28, 2020, 10:55:09 am
content: Hello,I'm planning to use a LTC2943 battery gauge in one of my projects with a raspberry Pi. However I never used the I2c nor SMBus protocols so I have some questions and your help would be greatly appreciated.What I understand is that LTC2943 is a slave only device, that it has an hardcoded ID, that it is able to raise SMBus alerts and that it has registers to "program" the thresholds for these alerts.I plan to use this IC as follows:Board with LTC2943 -> ESD protection -> output connector -> cable -> Raspi input connector (probably USB) -> linux -> monitoring appThere will be no other i2c slave on the board. My questions are:do I need a physical I2c/SMBus master on the board or will it be "provided" by the raspberry pi ?do I need to pull up the lines or is it done on the raspberry side ?do I need a microcontroller on the board or can I interact with the IC programmatically from monitoring app ?i2C protocol uses 2-lines, how do I use the SMBus alert pin of the LTC2943 ? is it a 3d line to be handled separately ?As the ID of the IC is hardcoded, how do I handle a situation where i have multiple boards to monitor (featuring the same IC) to avoid "collisions" ?Thanks a lot for your help ! If you have links to good documentation (something like i2C and SMBus alerts for dummies) and best practices please share it with me ! :-)Greetings from Switzerland.Michel

author: RoGeorge
author_rank: Super Contributor
timestamp: November 28, 2020, 11:51:08 am
content: What is drawn as a μP in the datasheet is in fact the Raspberry Pi (RPi) from your project.https://www.analog.com/media/en/technical-documentation/data-sheets/2943fa.pdfCommunication between RPi and LTC2943 is made by separate wires (not USB) between the RPi connector and the LTC2943.1. RPi has I2C pins on its connector, and it can act as an I2C master.2. You need to pull up the end of the I2C wires in one place only, with a resistors for each wire (near the LTC2943 chip side).3. No other microcontroller needed, RPi can talk I2C with the LTC2943 directly.4. You need to read the datasheet anyway, even if some parts of it doesn't make sense at first.https://www.analog.com/media/en/technical-documentation/data-sheets/2943fa.pdfIn page 6 it is explain what the ALCC pin is forQuoteSo, you can either use the ALCC pin wired to the RPi (at some RPi GPIO - the pin will go low, or 0, when an alert event happens), to inform RPi about the alert, or you can poll the internal registers of the LTC2943 without adding an extra "Alert" wire.http://smbus.org/specs/SMBus_3_1_20180319.pdfsearch for "ALERT" inside the SMB document.5. Use another I2C master (and other I2C wires, too).

author: kraal
author_rank: Newbie
timestamp: November 28, 2020, 05:21:34 pm
content: Hello,First of all, thank you for your answer.Quote from: RoGeorge on November 28, 2020, 11:51:08 amI read the datasheet, but some parts were not clear to me, especially in a raspberry pi context. Hence my questions.Quote from: RoGeorge on November 28, 2020, 11:51:08 amOk, thanks, found the corresponding GPIOs when enabling I2C.Quote from: RoGeorge on November 28, 2020, 11:51:08 amGreatQuote from: RoGeorge on November 28, 2020, 11:51:08 amOk, so I understand that they are not pulled "by default" on the raspberry side.Quote from: RoGeorge on November 28, 2020, 11:51:08 amGreat again.Quote from: RoGeorge on November 28, 2020, 11:51:08 amThank you for the link, I'll read it. For now, my understanding is that there is no "default" GPIO for the alert signal, I have to choose one. Am I correct ?Quote from: RoGeorge on November 28, 2020, 11:51:08 amCan you please clarify this one ? I'm not sure to understand your answer.Do you mean that I need to "proxy" the communication between each IC and the raspberry pi to have them have a unique ID (and answer to it) ?Again thanks a lot and best regards,Michel

author: RoGeorge
author_rank: Super Contributor
timestamp: November 28, 2020, 10:29:22 pm
content: 4. Yes, most probably there isn't any dedicated Alarm GPIO pin on the RPi side. It might be only if there is a SMB driver for RPi that has the SMB alert functionality implemented, IDK, never looked for that.5. Since the address of the LTC2943 is fixed, you can not put more than one LTC2943 on the same I2C bus. However, you can use another separate I2C bus (2 or 3 more wires) for a second LTC2943. If there are no more I2C peripherals available on the RPi, you'll need to use normal GPIO pins and find (or write yourself) a driver for a software I2C peripheral that can emulate an I2C controller using ordinary GPIO pins.

author: Renate
author_rank: Super Contributor
timestamp: November 29, 2020, 07:56:34 pm
content: I'm not saying that this is relevant, but if you are using old RPi or old software or if it becomes an issue,a heads up on i2c-bcm2708 and I²C repeated starts.