• We had to restore from a backup today after a failed software update. Backup was from 0000 EDT and restored it at 0800 EDT so we lost about 8hrs. Today is 07/20/2024. More info here.

Linux to I2C?

CptKrf

New Member
Joined
Dec 6, 2022
Messages
24
Reaction score
22
Credits
364
Has anyone had any luck connecting an I2C device to Linux? Not talking about a Raspberry PI. That is very easy since I2C support is built in. Unfortunately, the PI is somewhat short on horsepower.

With an old (Very old) pc with a parallel printer port it is no problem, since the legacy port is just a GPIO that can be read and written straight to the metal. Unfortunately, those hard addressed ports are long gone from any motherboard in the last 15 or so years. There are PCI-e parallel port cards available, but while they might work, the documentation is nil and the supposed Linux drivers are just boilerplate crap. Have yet to find one that even compiles, let alone work. And without documentation on the card, writing a driver is almost impossible.

Amazon has small USB to I2C devices that are cheap, but most of them are slave devices - i.e., going the wrong way, allowing the connection of USB to an I2C master, rather than the other way around. There are a couple that seem to be USB Master to Slave I2C, but again, lousy or no documentation and drivers that are phony, calling for libraries that don't exist in Google search or in any of the Distro sources.

All I need are three pins to the outside. Or two if one of them is bi-directional.

For now, I use dedicated Arduinos with a self-built shield to make the interface, but I continue my search for a native solution.

Anybody?
 


Got it. Finally found a parallel card that acts like the old motherboard ports. From Amazon, SIIG Legacy and Beyond Series 1 Port Single Parallel PCIe Card. Interestingly, it has the same A99*** chip as four others that I tested, but they will not respond to any of my probings. But, problem fixed.
 
Now in production, so to speak. Or rather, everything works so I can get to programming anything on the I2C chain. It took a considerable amount of research and time with a logic analyzer, but I have an interface from an ordinary parallel port to a single or multiple I2C chain. It only takes one TTL chip, a 74ls09. It could be done with just three signal diodes, but the TTL has much more drive and is less prone to glitches. With the single chip, it can access 8 modules of 8 bits with only two wires, for a total of 64 input/outputs total. But, if a TCA9548A multiplexer is added (Amazon, 10 for $12) you get 8 chains of 8, to get 512 IO lines.

And since the TCA9548A also has a 3 bit address, you could add seven more and have a ridiculous count of 4096 IO lines. Connected with just 2 wires.

I am using the only PC that I have that has a PCI bus - a 2008 Mac Pro cheesegrater with Debian, which is way overpowered for my bench projects, but works much faster than a PI4, instantly turning on 144 leds from a database where the PI takes approximately forever to load an sqlite database and over three seconds for every pass on the leds. And the Mac can be used for the programming in real time, where the PI was a real drag - literally.

I wrote the I2C driver in Perl as I developed the interface, intending to replace it with a C version for "production", but even using the scripting language, it is far faster than needed so I just left it.

If anybody is interested, I can give specifics.
 

Members online


Top