shanteacontrols / OpenDeck

Software and hardware platform for simpler building of MIDI controllers.
https://shanteacontrols.com
Apache License 2.0
618 stars 53 forks source link

RPI Pico W + 4067 multiplexer #176

Closed walrusmustgo closed 1 year ago

walrusmustgo commented 1 year ago

Hello! First of all, i'd like to thank you for this wonderful project! It kickstarted my entry to the vast electronic world! ^^

With that being said, i'm a noob, just started fiddling with electronics. Now,i've got an issue with using multiplexers with the rpi pico w board. If i connect a single potentiometer to the ADC input of the Pico, everything is working correctly, but if i build a new firmware, with multiplexers enabled, i get really hectic behaviour once the pot gets under a certain threshold, as you can see here:

https://user-images.githubusercontent.com/57779757/200574837-562322bb-f68f-431c-b88c-73aa296cf710.mp4

My board is setup correctly ( as far as i'm aware ):

image

This is the build config: image

Upon measuring voltages, the pot sends good values to the multiplexer, but on the z0 pin, the voltages are much smaller ( 3.3V on the channel pin, ~0.8V on the signal pin ).

As i've said, i'm a noob, so i might be missing something fundamental/obvious! :)

Thanks again for this beautiful piece of software, and your hard work!

Regards, Marko.

PS. The breadboard image configuration is just one of many combinations i've tried. I've tried to fill all 16 channels with potentiometers as well, tried only using channel 0, only channel 16 etc. The behaviour is quite erratic, sometimes nothing gets picked up on channel 1, but gets picked up on channel 16. If i enable every channel, this jumping from channel to channel happens on all of them.

paradajz commented 1 year ago

Can you post your entire config file?

walrusmustgo commented 1 year ago
---
  mcu: "rp2040"
  usb: true
  uart:
    dinMIDI:
      pins:
        rx:
          port: "0"
          index: 1
        tx:
          port: "0"
          index: 0
    touchscreen:
      pins:
        rx:
          port: "0"
          index: 5
        tx:
          port: "0"
          index: 4
      components: 64
  i2c:
    display:
      pins:
        sda:
          port: "0"
          index: 16
        scl:
          port: "0"
          index: 17
  buttons:
    type: "native"
    extPullups: false
    pins:
    -
      port: "0"
      index: 2
    -
      port: "0"
      index: 3
    -
      port: "0"
      index: 6
    -
      port: "0"
      index: 7
    -
      port: "0"
      index: 8
    -
      port: "0"
      index: 9
    -
      port: "0"
      index: 10
    -
      port: "0"
      index: 11
    -
      port: "0"
      index: 12
    -
      port: "0"
      index: 13
  analog:
    type: "4067"
    inputVoltage: "3.3"
    multiplexers: 1
    pins:
      s0:
        port: "0"
        index: 18
      s1:
        port: "0"
        index: 19
      s2:
        port: "0"
        index: 20
      s3:
        port: "0"
        index: 21
      z0:
        port: "0"
        index: 26
  leds:
    external:
      type: "native"
      pins:
      -
        port: "0"
        index: 14
      -
        port: "0"
        index: 15
      -
        port: "0"
        index: 22
      -
        port: "0"
        index: 21
      -
        port: "0"
        index: 20
      -
        port: "0"
        index: 19
      -
        port: "0"
        index: 18

Here it is! :)

paradajz commented 1 year ago

You are sharing the pins between LEDs and multiplexers: pins 18, 19, 20 and 21 are defined both for LEDs and multiplexers. Remove the LED ones.

walrusmustgo commented 1 year ago

Oh my........ Thanks! I'm an idiot :)

It's getting better, but there's still some weird stuff happening: 1) If i turn channel 1 knob, i'm getting the correct channel readings ( channel 0 ), but the values are clamped to a really small value ( 27 - 32 ), and if i turn the channel 16 knob, i'm getting both channel 1 and channel 16 readings, with the same clamped values... The pots are 10K by the way, don't know if that matters :)

https://user-images.githubusercontent.com/57779757/200581767-7e440441-9656-4546-a45e-e9de3a9ed15b.mp4

paradajz commented 1 year ago

Did you run make clean after you've changed the config file?

walrusmustgo commented 1 year ago

Tried it now, rebuilt, but the problem still persists :(

Do i have to play around with ADC offset by any chance?

paradajz commented 1 year ago

Do i have to play around with ADC offset by any chance?

No. Running the 4067 mux on that same ADC pin on my test setup works fine. My board is standard Pico, though, not the W version, so I'm not sure. Double check your mux wiring, maybe there's a loose contact somewhere.

walrusmustgo commented 1 year ago

Hmm, i'll try to reconnect everything and let you know. :) I'll also see if i can get ahold of a normal Pico board, the Pico W had some small firmware changes afaik, that might cause the issue (although, if i'm not mistaken, it's just some small internal tweaks).

I'll keep you posted once i test with new connections,and a Pico board. :) Thanks a lot!

paradajz commented 1 year ago

You should also tie any unconnected mux pins to GND - floating pins cause noise.

walrusmustgo commented 1 year ago

I've reconnected everything again with new cables, tried a different potentiometer, and connected all of the unused pins to the GND. The only thing that changed was that the clamped value vas lowered ( 25 - 30 )...

I'll try with a regular Pico board tonight, and i'll keep you posted :)

paradajz commented 1 year ago

Please also verify that you are on latest commit on master. After that, to rule out issues with the mux, disconnect Sx and common/signal/Z pins from Pico, tie all Sx pins to GND, and then measure the voltage on the signal pin when the pot on mux channel 0 is turned all the way left and right (so the voltage readouts should be 0V and 3.3V, respectively).

walrusmustgo commented 1 year ago

Alrighty! 1) The commit is latest, just tried cloning the repo again, did a git pull, no changes. Built again, the same issue. 2) I've tried 3 MUX boards with the method you've suggested, all mux boards display correct values (0V - ~3.3V)

I'm more and more starting to believe that it's the Pico W issue to be honest, I've tried building with different pins, some things have definitely changed for the Pico W board: image

I'll know more tonight, if it's a Pico W issue, than i'll see if i can pinpoint the problem, and i'll let you know if i've fixed it! And i'll let you know if regular Pico is working correctly :)

By the way, i've changed my config to use 6, 7, 8, 9 ( and removed them from the button control list :) ) pins respectively for the control pins, because looking at the pinout, nothing has changed in that regard on the Pico W.