Zyncoder_test : not winning

Right … I am trying to slowly, step by step build up a custom zynthian box. Currently I have:

  1. RBPi5 - 4GB
  2. TouchScreen (BIQU BTT HDMI5) - BIGTREETECH HDMI5 / HDMI7 – Biqu Equipment
  3. Waveshare MCP23017 IO Expansion Board (for testing purposes) - https://www.waveshare.com/wiki/MCP23017_IO_Expansion_Board
  4. 1 pushbutton rotary encoder (for testing purposes) - (https://handsontec.com/index.php/product/ky040-rotary-encoder-module-for-arduinoraspberry/)

I’ve compiled zyncoder_test, after uncommenting the following section in the main function of the zyncoder_test.c file, and adding one or two more debugging fprintf statements to verify hardware pins.

		for (i=0;i<num_zynpots;i++) {
			int32_t val = get_value_zynpot(i);
			if (val!=0) {
				printf("PT-%d = %d\n", i, val);
			}

And. Here is the ouput. Basically, no output. :slight_smile:

(venv) root@zynthian:/zynthian/zyncoder# systemctl stop zynthian
(venv) root@zynthian:/zynthian/zyncoder# ./build/zyncoder_test
Starting ZynCore...
ZynCore: Configured 4 x Logical Zynswitches...
ZynCore->setup_zynmcp23017(0, ...): setting up I2C device at [i2caddr=20, intA=16, intB=26]
ZynCore->gpiod_line_register_callback(): Registered callback on pin 16
ZynCore->gpiod_line_register_callback(): Registered callback on pin 26
ZynCore: Setting-up 4 x Physical Zynswitches...
ZynCore: Setting-up zyncoder in pins (102, 101)...
ZynCore: Setting-up zyncoder in pins (105, 104)...
ZynCore: Setting-up zyncoder in pins (110, 109)...
ZynCore: Setting-up zyncoder in pins (113, 112)...
ZynCore: Setting-up 4 x Zynpots (zyncoders)...
ZynCore->gpiod_start_callbacks: Callback thread created successfully
number of zynpots... 4
Testing switches & rotaries...

physical wiring:

MCP23107 -> PI5 (Physical Header)
=================================
VCC      -> pin 1 (3v3)
GND      -> pin 9 (GND)
SDA      -> pin 3 (GPIO2 / SDA)
SCL      -> pin 5 (GPIO3 / SCL)
INTA     -> pin 16 (GPIO23 / WiringPi4)  -> 10k pullup resistor to VCC
INTB     -> pin 26 (GPIO7 / WiringPi11)  -> 10k pullup resistor to VCC
A0       -> n.c.
A1       -> n.c.
A2       -> n.c.

ENCODER -> MCP23107
===================
GND   -> GND
SW_A  -> GND
SW_B  -> PA0
ENC_A -> PA1
ENC_B -> PA2

I’ve verified 3.3v on ENC_A, ENC_B, and SW_B.

I’m at a loss as to where I’ve gone wrong. Any thoughts?

Start with the select encoder switch and trace the switching action right to the pins of the 23017.
I’ve not tried a 23017 with a Pi5 but I’ve had it flying on all other Pi’s. Normally it turns out to be a hardware issue. And that can boil down to the test gear you have available. Just because a software instant declares an interrupt pin doesn’t confirm it’s actually ever received one. And do this with a switch not an encoder because encoders have differing types especially if mounted on a PCB…and.

Looking at the encoder you have pointed to, it’s not the type that is usually used with zynthians.

The zynth assumes that both the direction pins and the encoder centre switch are pulled high on the chip when unused and pulled low by the contact being made. The ones you show adhere more to the Kh004 subsystem which generally works by supplying a positive voltage on switch activation…

Apologies if this is all blindingly obvious, it’s sometimes difficult to know how much people know. IT’s a real pleasure opening up a new area of knowledge for someone especially if they have been pushed here by their own enthusiasm.

Keep at it. We nromally get there.

4 Likes

Thanks for this. Right, yes, I see that the encoder board additionally pulls A+B high. So that could be a problem. I have some of these : PEC11R-4015F-S0024 BOURNS - Encoder: incremental | THT; 24imp/revol; two phase A and B; 5VDC | TME - Electronic components … I guess they’ll be better. I’ll have to make up a protoboard for them. Here’s hoping that’s the issue.

hi infinitymodular
I can’t describe in words my suffering until I got these KY-040 to work somehow. First of all, I had to grab a soldering iron and get rid of the pull-up SMD resistors R1-R3. Now, following the advice on the forum, I’m going to solder the capacitors.

I’ve decided the shortcut is longer than the path… so I’m doing this now:



as per the schematic and pcb layout

2 Likes

And… one step closer… a working test panel… now to connect to the MCP23107 and hope for the best.


OK … all connected… and still not working. :frowning:


![Screenshot 2024-10-16 at 17.57.01|656x500](upload://5Ft7BFxZyMUdr27nLIarcWeLmPu.png

I’m not sure which wiring layout I should select… but I’ve chosen MCP23017 Encoders…

I’ve assumed that mcp-pins following the logic that:

100 – 107 = PA0 – PA7
108 – 115 = PB0 – PB7

I’ve double checked MCP address = 0x20 and it’s VCC, GND, SDA, SCL and INT pins are correct.

What am I missing?


Is the MPC being detected by zynthian? It should show in the Hardware section of webconf console (main page). You can also run i2cdetect -y 1 to show the detected device addresses.

image

funny you should ask… :slight_smile: I just spotted that and it’s showing up as 0x27 … so I changed the address. And things are happening now with the encoders and buttons :slight_smile: YAY!!!

now I need to check the manual to see if the behaviour is correct.

3 Likes

I had the first encoder switch/enca swapped around… It’s totally working now… Thanks for the assistance everyone! I’m so chuffed with this now … it’s a whole new world… Soon the pushbutton’s should arrive, and then I can start down the road of adding those…

1 Like

Puts a rook on standby…

2 Likes