Switch connected to MCP23008 of Controller 2 powers off my Zynthian

Hi dear Jofemodo! As you requested, I post here my problem building a Zynthian box! (and I am the first to use new forum…wooooww!! :wink:)
I’m Marco, the technical responsible of Garretlabs, the italian blog of open source ideas (http://garretlabs.wordpress.com).
I really love your project, since I build diy synthesizers…and I play them in my musical projects.

So… I’m building one Zynthian box starting from scratch. I used a Raspi 3 rev.B, the Hifi Berry and I built on myself the flat cable, the two controller boards and the 2in1 board (using prototype boards).

All seems to work correctly (except audio and midi, which I not test yet): display, rotary encoders and switches for the two controllers directly connected to Raspi GPIOs. Also switch (connected to X07) of MCP23008 used by first controller seems to work . But… when I press the SW2 of the second controller connected to X08 of MCP23008 the Zynthian have some strange behavior (the majority of times the display turns to
black…and I think the Zynthian is powered off). It seems that I2C connection with MCP23008 works, because at start I saw the waveforms on pins 1 and 2, and the its pins 16 and 17 are correctly high (in order to detect when the switch is pressed, that is the signal turns to low).

I used the old image of Zynthian operating system and also the new one (sonar) for my tests (I noticed that the new one inverted my encoders direction…so I inverted the cables ), both downloaded took from Torrent.

I also tested the MCP23008 on a solderless breadboard with the standard connections for this chip (I2C on pins 1/2, +5V on pins 18/6, GND on pins 9/3/4/5, and then pin 17 for X08 and pin 16 for X07) connected with the Raspi pins on flat cable.

I also obviously exchanged the two controllers, they seem both ok.

Always the same situation: when I click on switch not directly connected to GPIO on the second controller (which is passing from MCP23008) … the Zynthian powers off.
The problem to me seems tied to the Raspi pins used for the second controllers.

Do you have an idea of the problem? Anyone encountered it?
Or do you have any suggestion in order to investigate which is the problem?
For example, is there the possibility to attach a connection via SSH to open a shell? And the GPIO library displays some debug message on the shell?

Thank you very much for your project, which is beatiful and great!
And thank you very much for your support!
Sincerely,
Marco

Just a little update of my investigation.
I connected the Raspi via lan to my computer (using ssh -l pi 192.168.0.10) then I explored the folders.
In the folder /zynthian/zyncoder I found the executable zyncoder_test (which I imagine it’s useful to test the switches/encoder library)
So I executed with sudo ./zyncoder_test. The following mask appeared (and continuously refreshed):
SW0 = 0
ZC0 = 64
SW1 = 0
ZC1 = 64
SW2 = 0
ZC2 = 64
SW3 = 0
ZC3 = 64

I saw that rotating upper encoder of first controller the value of ZC0 was changed, and for the lower encoder the ZC1 values was changed. Regarding the upper encoder of second controller, it is tied to value of ZC2 and the lower to ZC3. All seems good for encoders.

Regarding the switches: clicking the upper encoder of first controller (which I connected to X07 of MCP23008), SW2 value changes, with a very great value.
It seems that sometimes (after several continuous clicks), together also SW1 changes with SW2 value (could it be an overflow of value stored in SW2? I ask this because in this moment the SW1 is not pressed…it could be also a bug of the zyncoder_test program, at visualization level).
Clicking the lower encoder (directily connected to GPIO) always SW1 value changes, with a more little value than SW2.
Clicking the lower encoder of second encoder (directly connected to GPIOs) alway the SW3 value changes, with values similar to SW1.
But… clicking the upper encoder of second controller (connected to X08) the shell exits after the following errors:

Cannot read socket fd = 7 err = Success
CheckRes error
JackSocketClientChannel read fail
Connection to 192.168.0.10 closed by remote host.
Connection to 192.168.0.10 closed.

It seems that the two switches connected to MCP23008 have some problem (And from this experiment the SW0 seems that it never changes).

Do you have any suggestion?
Thank you very much for support!!
Marco

PS: for this problem I never entere in the page in which the snapshot can be saved (click of third pot).

Hello i am Fabrizio from Italy too…i am not a musician but only a electronic technician with music passion…
I realize the Zhinthian and i think that your problems is some error in assembly
I suggest you to control all the system step by step with this link
http://wiki.zynthian.org/index.php/Build_a_Zynthian_Prototype-3

Pay attention to the photo and the indication of pin 1 of the cables

Fabrizio

1 Like

Thank you very much Fabrizio!
It’s a pleasure to encounter italians in the open source electronic world!
I’m from Florence, where are you from?

I wil double check the cables, but I’m pretty sure that I connected the pins of 2in1 board to the right places in the GPIOs of Raspi, since MCP23008 seems well powered and I see on the oscilloscope the SDA/SCL waveforms on pins 1/2 of the component .
Do you used a Raspberry Pi 2 or 3? I’m using a Pi 3.

…To me the problems seems tied to a sort of overflow of the vector used to store the value of detected pressed button…:unamused:
In the afternoon I will publish some other more detailed test (with screeshots) that I executed yesteday night, in which I saw that only buttons connected to X07 and X08 seems to have problems, and the click of these buttons seems “dirty” also the values of switches directly connected to GPIOs.
I saw that from this “dirty” error derives the power off of my Zynthian: because the software detects a “dirty” long click of the fourth encoder (which correctly commands the power off, following the modes transition diagram) from the click of the third encoder.

Thank you again Fabrizio, tonight I will a new check of all connections (because trust is good, double check is better!):slight_smile:.
Marco

Ok i am from 50 km away of Turin …i use raspi2 but is the same…there are also other friends Italians …if you like send me your phone number for whatsapp contact…

1 Like

Well, as promised… I investigated a little more during these nights… :unamused:
But I found a solution (I hope) :grinning:
I entered in the shell via ethernet and I studied the code used to start all the services connected to zynthian features.
So, I stopped the zynthian with sudo /etc/config/init.d zynthian stop and then I restarted with sudo /etc/config/init.d zynthian start
In this way I had on the shell all the “printf” used for debug.
From the messages on the shell I verified that pressing the switches connected to X07 and X08 often produced a sort of “ghost second click” on the other switches. Especially, the power off of my Zynthian derived from a “Looooong click” of the SW3 (directly connected to GPIO) when I pressed for a short time the SW2 (connected to X08). The “Looooong click” on SW3 correctly powers off the Zynthian (as reported in the modes diagram). Mhhhh… very strange.
I also verified with the oscilloscope that the clicks on the buttons connected to X07 and X08 didn’t generate some “spurious” click on the switches connected directly to GPIOs.
But at the same time I see that high level of X07 and X08 is 5V, and the two switches connected directly to Raspi GPIOs have the high level at 3.3V.
It’s obvious, but I didn’t think to this…:disappointed:
So I tried to power the MCP23008 at 3.3V (instead of 5V, I little modified my 2in1 board), and the high level of X07 and X08 was reported to 3.3V as the other two switches.
Well, with this mod all the switches seemed to work correctly. I done several tests… and I found no more problem, without any spurious clicks.

The problem could be tied to the fact that since I2C of Raspi should work at 3.3V (connected at pins 1/2 of the MCP23008) but the MCP23008 is powered with 5V…
So, this misalignement of voltages of MCP23008 could generate some noise on the Raspi internal bus?:confused: It should be investigated at lower level…

In any case, I think it could be better to insert a level shifter if we want to power the MCP23008 with 5V , but I also think that MCP23008 can be surely powered at 3.3V without worries (following the datasheet, at 3.3V the I2C of MCP23008 can work at 400Khz, which is sufficient of our purposes).
Do you have some comment on this workaround?
I’m totally wrong on my analysis?
…Thank you for your suggestions!

Hi @marcolastri,

I have two Zynthians running with 5V for the MCP23008. After some smaller problems (the problem is mostly located directly before the screen :slight_smile:) it works.

Do you have tried to run the MCP at 3.3V? Maybe it is a problem with the capacitors for the buttons?

I just have not much time because I am going on holiday the next days. If it is not fixed until end of my holiday I can try to look at this with my BitScope.

Sorry - currently not much help from me… :frowning:

Regards, Holger

1 Like

Hi Holger!
I tried to use 3.3V for MCP and with this mod, all seems to work correctly.:slight_smile:
Regarding the capacitors,it could be… I used the same capacitor used for the switches connected to GPIOs (ceramic capacitor 100nF). I will try to add some other cap in parallel in order to have a smooth behaviour.

Thank you very much for your suggestion…and have good holiday!:slight_smile: (I also I’m on holidays in the next days…I will restart the project on last days of August…:swimmer:).

Ciao!
Marco

Hi @marcolastri!

In first place, congratulations for your success in building a Zynthian Box from scratch!! You are a brave warrior! :wink: We will be waiting for some photos or videos when it’s ready!!

Regarding your problem …
I’ve been using 5V for the MCP23008 with no related problems until know. I’ve sent several kits with the 2in1 PCB, that uses 5V for the MCP and, as much as i know, it works for everybody too. In the beginning, i doubted, but i try and as it worked, i start to use 5V because the I2C frequency is greater with it.

It’s very strange that it doesn’t work for you with 5V … anyway, let me know any advance in the understanding of this problem. If needed, i could change the voltage in the next PCB revision, or perhaps, add some advice for “from scratch” builders.

1 Like

Hi,

The physical I2C lines are open-drain. This means that the Pi pulls them up to 3.3 volt and the MCP pulls them low when communicating. So 5V from MCP never reaches the pi and the communication is safe, even then there is a voltage difference between host and slave. So although running the MCP at 3.3V seems to solve marcolastri’s problem, it should not matter…
I run several Pi’s with a MCP23017 powering the MCP at 5 volt, even driving a (5v) LCD-display from the MCP (Adafruit-like I2C CharLCDDisplay). On this display I do NOT use caps on the switches and it always works flawless. So could the debouncingcaps be the culprit?

Cheers,
Kees

1 Like

Hi @jofemodo!
Thank you for your congrats… effectively I am a little brave (but only on electronics… :wink: ).
I love difficult goals!
I used all breadboards (no PCB! ) for controllers and 2in1 board so my experiment has been very adventurous! :slight_smile:
And…yesterday night I connected my MIDI master keyboard and I obtained my first notes from the Zynthain synth!!!:grinning::grinning::grinning::grinning::grinning::grinning:
I think tonight I will publish some photo of my current setup (now it is naked, because my father is the responsible for Garretlabs synths boxes ;-)… he is a retired mechanical technician, so now he is on holiday at the sea! :swimmer: …and I have a real envy for him!:wink:).

Regarding my problem, I think the frequency for I2C at 3.3V could be sufficent…but I will do some experiment with the caps on the switches since I am convinced that the problem is tied to another thing, also if using 3.3V on MCP is a good workaround for me. I used the classic 104 ceramic caps to connect the ground…but following also thesuggestion by Kees, I will try to play with them.
Thank you again for your suggestion and again for your congratulations!
In the next days I will put some more detailed comment for “from scratch” builders.
I have also some idea about the software… :wink:
Cheers!!

Hi @Keeze101 (Kees).
I know that Raspi should not be involved by the 5V propagation from MCP. For this reason I will investigate again (I want always arrive to the real target).
Thank you for your interesting suggestion: I will try to play with the caps (for the first test I will bypass them).
I will report here my results…so keep in touch!
Thank you again!
Cheers,
Marco

While the 5V is not directly connected to the GPIO perhaps the MCP is having a problem with the SDA or SCK only going to 3.3V ( and extra noise on proto board, GND issue)? The level should be within the chip’s threshold but if the GND is bouncing from noise, could be a problem.
Yogi

@yogi,
I double checked the proto board… I’m pretty sure that the ground is ok.
But regarding the noise…it could be an issue, also if the cables number is very low.
I could try to rearrange the cables in order to have a minor interference…but prior I could try to reproduce also the circuit of controllers on a solderless breadboard, since I already verified that the 2in1 on a solderless breadboard have the same problem.
Or…in September I will produce some pcb to try the most clean solution…
Thank you very much for your suggestion!

Problem solved following the solution suggested by @Keeze101! :grinning:
Well, I simply connected directly the pin of switches which use MCP to the MCP pins and the other pin to ground.
In other words, I removed the connection to ground of the pin of swithces connected to MCP via the 104 capacitors, and also powered the MCP23008 using 5V as initially foreseen.
With this configuration all works very well!
Thank you very much to all…I’ m publishing the first photos of my Zynthian in “success cases”.:confetti_ball::tada:

Yea \o/ glad you got it working!

Great to hear that this solved your problem! Just got my 23008’s and coming weekend about to prototype my Zythian:)

Cheers,
Kees

1 Like