User avatar
noudio
Posts: 8
Joined: Sun Mar 03, 2013 7:41 am
Location: Nijmegen, the Netherlands

I2C interface on other pins...

Sun Mar 03, 2013 1:15 pm

How difficult is it to get the i2c driver working on other pins (than the ones that are normally used for i2c0 and i2c1), lets say to introduce a 'third' bus i2c2 that uses gpio's of my own choice?

My problem is this: I do not want to change my board, to remove resistors, since i still do want to use the regular i2c for communicating with 'normal' i2c devices, like an arduino.

I'm trying to get the lego mindstorm ultrasonic sensor to work on a pi.
However, the folks at lego for sure have a different opinions about i2c: their speed is low (9600 Bd), their pull-up's are very high (82k), but what really sucks is that there is a 4k7 ohm in series on the outputs of these sensors. So they are not exactly 'open drain' outputs anymore (which means the sensor is only able to pull the lines down to a level (4k7/(1k8+4k7))vcc (2.4v = still recognized as 'high')

i looked for possible solutions:
- a level converter that also isolates the i2c busses with respect to impedance, for example with the
TXS0102, but no: all these converters physically connect the busses via a switch (fet) during their 'low state' which means that the sensor's 4k7 will still (not!) pulldown the pi's 1k8....

- So without doubt: to get it working on a pi requires that you use the i2c-termination of the sensor, (82k up + 4k7 in series), which means: either removal of raspi's resistors or to use other pins...

Software solutions: Write own code, or 'changing the used GPIO's' of the kernel module?
Can anybody advise me?
Noudio

rj999
Posts: 31
Joined: Wed Feb 01, 2012 12:22 pm

Re: I2C interface on other pins...

Sun Mar 03, 2013 4:23 pm

Doesn't the P82B715 do what you want? Excluding buss speed issues...

pgman
Posts: 22
Joined: Sun Jan 06, 2013 8:34 pm

Re: I2C interface on other pins...

Sun Mar 03, 2013 4:48 pm

How about using an Arduino Nano or atmega328 with bootloader connected via serial or SPI to the Pi. Then use the Arduino/atmega I2C bus to talk to the Lego. You can get an atmega328 kit with bootloader for less than £5/$8.

All you would need to do then is write a bit of code on the arduino to talk to the Lego and then send the data back to the Pi when you ask for it over serial or SPI.

fanoush
Posts: 461
Joined: Mon Feb 27, 2012 2:37 pm

Re: I2C interface on other pins...

Sun Mar 03, 2013 5:48 pm

pgman wrote:Then use the Arduino/atmega I2C bus to talk to the Lego. You can get an atmega328 kit with bootloader for less than £5/$8.
Or you can use PICAXE chip, they start below £2 and you just need two resistorts and RS-232 serial cable to program it in BASIC http://www.picaxe.com/Hardware/PICAXE-Chips/

User avatar
noudio
Posts: 8
Joined: Sun Mar 03, 2013 7:41 am
Location: Nijmegen, the Netherlands

Re: I2C interface on other pins...

Sun Mar 03, 2013 10:26 pm

Thanks guys,

About the P82B715: for sure that already looked more promising than the things I googled together! And speed is certainly no problem, lego designed their i2c for 9600Baud (?they misused a uart?)

Thanks to the current gain of this device, a pull-up on the other side can be seen 10 times as high. So 1k8 will be seen as 18k. Actually it is even better, since one must take the 3,3v of the pi and the 5v of the sensor into account. For the same current through the 1k8 pi pullup, this pullup counts as a 5v/3.3v *1k8 = 2k7 pullup if it was hung up on the 5v rail instead of the 3.3V. In other words: it is 2K7 which is seen in parallel with the 82k from the sensors point of view (which does 5v).

With the P82B715 it would thus 'see' 27k in par with 82k: so that's 20k3. So now it pulls-down to 4k7/(4k7+20k3)*5V == 0.94V, is that a reliable logic low? hmmmm, that 4k7 really sucks doesnt it?

Transferring the problem to an arduino or atmega is another good idea. I was planning to attach an arduino anyway on the thing. Only now i don't have that yet, and i was looking for a quick and dirty solution for the sensor alone. But maybe I should spent time on that direction, an be more patient with the sensor. (i think then i still would connect the arduino via i2c to the pi, and write a proprietary 'other pins i2c' on the arduino to attach the lego. on arduino this seems more easier to me than on the pi. You guess i'm also more familiar with i2c than with the other interfaces.)

But still I hope that someone gives me a hint if i2c on other pins of pi is reasonable...
Noudio

Return to “Interfacing (DSI, CSI, I2C, etc.)”