GPIO Dilemma, MUX or I2C


#1

Lots of scattered unresolved post on this over the years, can someone help me make a decision?
I want to build an enclosure with at least one OLED, 12-16 LED backed switches and then some knobs... I really want to do everything from the axoloti itself and avoid a separate Arduino or MIDI based solution...
Seems I should be able to accomplish this with some combination of I2C and MUX chips...
CD74HC4067 or https://www.sparkfun.com/products/9056
MCP23017 or https://www.sparkfun.com/products/13601

It seems to me I could have 2 OLED Displays and 6 MCP23017s for a total of 196 GPIOs, but at what cost?
Also, I dont want to do that, just saying its possible :slight_smile:
So, are there i2c objects? how do i do this?


SPI/I2C OLED display
#2

You can run everything off the same i2c bus- that is the one that is already on the IO pins.

The gpio expander you reference is the sx1509 (not the mcp23017).
I wrote a driver for it. My driver is mostly about key scanning, but it's better than starting from scratch. https://github.com/deadsy/axo/tree/master/work/objects/sx1509
btw - you can have up to 4 on the same bus (4 x 16 gpio lines)

OLED display: last time I looked at the driver for it there were some issues with i2c bus sharing.
Those are fixable - maybe Mr. @SmashedTransistors will revise it. :slight_smile:

So, are there i2c objects? how do i do this?

I don't think you can with the existing i2c objects/drivers. The OLED driver needs to play well with others and you need an gpio expander driver object that has the sort of interface you are after. But it's very do-able.


#3

Note that the tiar/HW/OLED objects has very limited functionalities, they are good as little oscilloscopes and "parameter reminders".

In fact, I have no idea how to do that. I will need some help :wink:
Maybe it is a good idea to start a new thread about "tips and good practices for I2C objects".


#4

yup, I only need the OLEDs to remind me what my knobs do...
So is there an issue with I2C bus sharing?


#5

@SmashedTransistors

Maybe it is a good idea to start a new thread about "tips and good practices for I2C objects".

Ok. I'll write up some stuff and explain myself.


#6

Thanks !! There is a lot of interesting I2C devices out there that can be used for music applications.


#7

Yeah, it feels really really silly to add another device to send signals to the axoloti it can generate itself


#8

If you make a Arduino device with buttons, breath control and other sensors you benefit from existing drivers. On the Arduino, you have MIDI drivers that allow to transform your device into a MIDI device so that it can be used with the Axoloti and other MIDI instruments and devices.
I think that when you have a lot of sensors/buttons it is the way to go.


#9

Thanks for the new post @deadsy :smiley:
I see i have some revisions to make!

I will make a revised version for the OLED next month (i won't have much "Axoloti time" since then but it is on the top of my todo list).


[EDIT 24 oct 18]
Big thanks for your tutorial and examples @deadsy !

I added tiar/HW/OLED128x64nice which "plays the game" more nicely.
It needs a gpio/i2c/config to work
In the help patch OLED128x64nice.axh I use two instances of the OLED128x64nice object to address two OLED displays (which was not possible with the former object).

I do not have other i2c devices to test how "nicer" this OLED object his.
[EDIT 29 oct]
Update for the new OLED128x64nice object:

  • mode2 is full height scope mode
  • can draw horizontal bar graphs (see help patch tiar/HW/bar.axh), useful for displaying envelopes and lfos.
    [EDIT 30 oct]
    added bardbl object that allows up to 8 bargraphs per OLED display (see help patch tiar/HW/bar.axh)

#10

It would be great if somebody can connect a I2C device and an OLED to check that my revision work :slight_smile: So that I can correct it if there are some issues.


#11

Ill order some MCP23017 chips and get started here soon... thanks for the effort...


#12

can I do audio in/out over I2C with a MCP23017?


#13

I don't think so.
I never experimented with the MCP23017 and I do not know if you have means to synchronize the converter with the audio rate of the axoloti.


#14

could I use an ad/da with one of the new I/O ports?


#15

Short answer: No. i2c is too slow for audio at reasonable sample rates.

Long answer: At a 400 kHz i2c clock rate with say 10 bit times per byte you could maybe get 20,000, 16-bit samples/sec across an i2c link, but nobody sane does this. Also - manipulating the GPIO lines of the mcp23017 is not going to make things any faster.