[Igor] has an AS5600 magnetic rotary encoder chip on a breakout board. Normally, you’d think that was an easy device to work with since it has an I2C interface. But [Igor] wanted to do it the hard way. What’s the hard way? By hand. He directly manipulates the clock and data lines using some push buttons. You can see how it goes in the video below.
This is possible because the controlling device — in this case [Igor] — gets to set the clock rate, and there’s no reason it has to be regular. We have to admit that it never occurred to us to do this, but we have written “bit banged” I2C-like code before.
The practical value of this isn’t clear, but we were still impressed. Certainly, if you had to write code or build hardware to operate the protocol, this would tell you quickly if you understood the fundamentals. We wonder if his next trick will be RS232 via Morse code key.
If you want a deep dive into the world of I2C, we can help with that. This reminded us of the old “paperclip computer book” that showed how to make your own computer with oatmeal boxes and paperclips. You just had to do the work of the CPU yourself.
If he wanted to do it the hard way. Where is the 555 ic to debounce the buttons? Or is that the stupid way ?
i’m not gonna look up the transition time spec for i2c, or actually trace out the circuit…but i would be inclined to try a capacitor for debouncing and there are capacitors in the photo sooo :)
I think this was why I’d wondered about (but never actually tried) creating something like this. Add in a microcontroller acting like a logic analyser and a small OLED to show you the data, and it becomes a neat little learning tool.
Also, do we really need a reason? It’s fun!
It was a great way to troubleshoot bad I2C docs back in the 90s when neither myself or my employer could afford a good enough logic analyzer or digital scope.
Won’t work for TIA-232 because that needs a better than 10% steady clock.
does the clock have to be fast, or just steady? you could play along with a metronome just like a drummer :)
TIA-232 (named RS, recommended standard, before the 1990s) requires fairly fast and steady timing. Even 75 bps, let alone modern 115200 bps, would be impossible to do by hand with better than 10% accuracy.
Raises the important question how many songs have secret messages hidden in I2C bit banged with the drum and hi hat?
reminds me of the Emo Philps bit about how some nearby roofers kept calling him a paranoid freak… in morse code.
This is mostly idle curiosity; but it would be interesting to know if (and if so what, whether more or less randomly scattered, certain vendors, or certain sorts of peripherals) some I2C devices misbehave when the clock is sufficiently slow or irregular. In theory it isn’t forbidden; but it wouldn’t be the biggest surprise if some devices are really SMBus at heart and just claim I2C because somebody gave going under 10KHz a quick go and it seemed OK.
i have this problem. these chips can be burned with custom settings, but only once. the intent is that you use i2c to set it up on a test fixture, burn the settings, then you can have it spew pwm over the desired range and resolution. i suppose this can reduce latency or increase sample rate if you use it as intended. there is no facility to change i2c address so if you want to use multiple (for example a joystick project im working on) and dont want to permanently burn the fuses, you would use a multiplexer or a micro with multiple i2c channels. but thats not always available.
there are other sensors though. i found a 14-bit part with an spi interface (as5048) and a12 bit part that offers a wide array of interfaces (MT6701). the as5600 does have the advantage of being cheap as a breakout board though, so im probibly just going to burn them.
I have done this with some SPI devices. One button that toggles just the clock, another that toggles both clock and data. There was an LED on the MISO that latched the data on the trailing edge of the clock, too, so you could read the output of the device. I probably have the schematic sketch somewhere I’ll never find it. It was simple, though, but did use a 555 to drive the LED, so maybe that’s cheating.
I did mine to experiment with a poorly documented chip that I had trouble getting the SPI on my STM32 nucleo board reading data from. Turned out there was a 12 clock turnaround after the command byte was clocked out on MOSI before the data started on MISO. The weird device was given to me to evaluate and had been fabricated as a freebie in a multi-project wafer, just to fill in the blank spots. He had 2 weeks to tape out the design, and messed something up.
I did this back in the day when I worked at NXP. It was just a demo to show how easy I2C is to the FAEs and sales. Just a simple I2C GPIO and a couple of LEDs with two pushbuttons. Easy peasy.