I2C pullups

Discussion related to "under the hood" OpenMV topics.
OutoftheBOTS
Posts: 88
Joined: Tue May 29, 2018 4:15 am

I2C pullups

Postby OutoftheBOTS » Mon Jun 11, 2018 6:24 am

Ok all the Dev boards that I have used have had internal pullups on the I2C lines (usually on the chip that drives them so it can be driven by software)

I just measured the voltage on the I2C pins when I ran a script that created a I2C bus and the I2C lines stayed low, I assume this means there isn't any internal pullups on the OpenMV board and for I2C they have to be connected externally???
User avatar
kwagyeman
Posts: 2407
Joined: Sun May 24, 2015 2:10 pm

Re: I2C pullups

Postby kwagyeman » Mon Jun 11, 2018 11:34 am

You have to enable pull ups on the pins using the PIN object. There aren't any pull ups externally. This is because the STM32 chips can pull pins high and low.
Nyamekye,
OutoftheBOTS
Posts: 88
Joined: Tue May 29, 2018 4:15 am

Re: I2C pullups

Postby OutoftheBOTS » Mon Jun 11, 2018 5:08 pm

Just so I understand everything properly.

In your example i2c_control1.py you use the code

Code: Select all

from pyb import I2C

i2c = I2C(2, I2C.MASTER) # The i2c bus must always be 2.
mem = i2c.mem_read(256, 0x50, 0) # The eeprom slave address is 0x50.
But nowhere do you use the Pin class to set the SDA and SCL lines as pullups. R you relying on external pullsups pullups??

I asked on the official MicroPython forum about the I2C pullups for the pyboard and they said they are not done by the software but rather the pyboard has external pullups on the PCB. This is different to all the other ports of micropython that I have used where there isn't any external pullups and they are done in software automatically by the machine.I2C class.

If your using the official micro-python port without any modification to the pyb.I2C class or machine.I2C class or any external pullups on the PCB then this means the user will have ensure that there is pullups on the other device.
User avatar
kwagyeman
Posts: 2407
Joined: Sun May 24, 2015 2:10 pm

Re: I2C pullups

Postby kwagyeman » Mon Jun 11, 2018 5:13 pm

That code does not turn pull ups on. On our I2C boards we add pull ups. On the camera we don't. If you'd like to turn pull ups on in software then make a pin object and set pull ups on when you make it. The pin object will modify some regs in hardware that I2C will just silently benefit from. It won't disable them.
Nyamekye,
OutoftheBOTS
Posts: 88
Joined: Tue May 29, 2018 4:15 am

Re: I2C pullups

Postby OutoftheBOTS » Mon Jun 11, 2018 5:31 pm

Thank you :)

I want to add my own pullups anyway as want to use 82K pullups instead of 10K.

But now I know the difference in running my MicroPython script on OpenMV compared to other boards running MicroPython. For OpemMv you have to change your script to add turning on pullups or use external pullups :)
OutoftheBOTS
Posts: 88
Joined: Tue May 29, 2018 4:15 am

Re: I2C pullups

Postby OutoftheBOTS » Mon Jun 11, 2018 5:59 pm

Maybe you need to add the I2C class docs http://docs.openmv.io/library/pyb.I2C.html that no pullups are provided on the OpenMV cam and users need make sure there is pullups on any I2C devices they connect to the bus.
User avatar
kwagyeman
Posts: 2407
Joined: Sun May 24, 2015 2:10 pm

Re: I2C pullups

Postby kwagyeman » Mon Jun 11, 2018 6:10 pm

Send a github PR?

We need the documentation help.
Nyamekye,
OutoftheBOTS
Posts: 88
Joined: Tue May 29, 2018 4:15 am

Re: I2C pullups

Postby OutoftheBOTS » Mon Jun 11, 2018 6:31 pm

Ok I will see if I can do my very first ever PR on github :)

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 7 guests