cross-posted from: https://lemmy.world/post/37481146

I'm making a custom keyboard with a Raspberry Pi Pico as the MCU, and i don't understand what all the different pins are for and how they should be wired up to my key matrix and trackpoint.

My current understanding is that GPIO are normal pins that can be wired to the rows and columns, but what of VBUS, VSYS, 3V3, and all the others that aren't just GPIO or GND? And how should the ground pins be used here?

The schematic currently doesn't include the trackpoint because i'm planning to hand wire it and the MCU to the PCB, so i can put them under the PCB in the case and i don't have to try to fit them onto the board. Is there a better way to connect these that won't require adding a bunch of space to the board to fit the MCU?

no comments (yet)

sorted by: hot top controversial new old
there doesn't seem to be anything here
10 comments in c/mechanicalkeyboards@lemmy.ml view that post
[–] 9 points 1 year ago* (last edited 1 year ago) (2 children)

So there is a LOT to cover on this, but I'm going to try and keep it to simple overviews.

  • VBUS is the voltage supplied to the device (like 5V from USB)
  • VSYS is the systems voltage that can be supplied from the device to the things its connecting to (like keys)
  • GPIO standards for General Purpose Input / Output, or an uncommitted digital signal pin that can be controlled by the device. It can act as an input or as an output. In a keyboard's case, this would be predominantly inputs for the keys themselves. If you have RGB LEDs, these would be outputs.
  • ADC VREF is the Analog to Digital Converter Reference Voltage, which is the maximum voltage an ADC can measure and convert to a digital value.
  • 3V3 is 3.3V out
  • 3V3_EN controls the power to the voltage regulator, which lets you shut off the 3.3V supply coming from 3V3
  • RUN is the pin used to start, stop, or reset the microcontroller.
  • AGND is the analog ground, a dedicated ground for the ADC. Its separate from the digital ground (GND) to prevent noise from interfering with analog signals. It eventually connects to the power supply ground though.

Edited to add: You'll use GND (ground) shared for all of these keys.

  • source
  • hideshow 2 child comments
  • [–] 4 points 1 year ago*
    • Create ground plane - 1 entire layer for ground. You'll just use via to connect them

    • read the data sheet it'll explain what each pin does. Most of the times single pin can act as multiple things and you need to set certain bit to use certain functions.

    • for layout fan out from MCU and then on 1 layer try to be horizontal and on another vertical.

    • when it comes to crowded board vias are both your friends and enemies so use them wisely.

    • make sure the track length, spacing between track and a via, diameter of via, etc. Are within spec for your manufacturer.

    • check if any pins are differential pair. If so again adjust your software settings. I think vBUS is a for maybe usb but check datasheet.

    You may also want to check out Robert Feranec's YouTube channel he has some really good videos. Even one on full end to end keyboard design https://www.youtube.com/playlist?list=PLXvLToQzgzdftro2qK5In8p6ExsDFdpzw

  • source
  • [–] 3 points 1 year ago* (4 children)

    You can put the MCU and other circuitry on the underside, but perhaps use at least a 3-layer PCB so you can run an internal ground plane under the power components.

    Is this keyboard a one-off or are you doing production runs? Try to keep all the SMD components on the same side if you can.

    If you're using the pico rather than a bare RP2040, you'll have a much harder time putting anything on the underside though.

  • source
  • hideshow 4 child comments
  • [–] [S] 1 point 1 year ago* (last edited 1 year ago) (3 children)

    It's a one off, just for me to use. The case i just finished designing has room for the Pico, trackpoint, and wires to those under where the PCB will go.

    How does the ground plane usually work on keyboards with only 2 layers? Would it be enough to just connect everything to a ground pin instead of paying for a third layer?

  • source
  • parent
  • hideshow 3 child comments
  • [–] 1 point 1 year ago (2 children)

    If you can reasonably have the entire bottom layer be connected to ground without the top layer being too crowded, 2 layers could work.

    Wires to the underside components? Can you solder them to thru-holes on the underside of the PCB instead?

  • source
  • parent
  • hideshow 2 child comments
  • [–] [S] 2 points 1 year ago* (last edited 1 year ago) (1 child)

    Not without moving some switches to fit the trackpoint and diodes to fit the Pico. But how hard can hand wiring that one part be⸮

    I'm still not clear on how the ground should work. Is it enough to just wire every row to a ground pin as well as a normal input pin?

  • source
  • parent
  • hideshow 1 child comment
  • [–] 2 points 1 year ago

    I was halfway through a message about return path impedance, but remembered the pico is a carrier board with its ground built in it's USB connector, and the switches are hardly going to care.

    My bad, you'll be fine 👍

  • source
  • parent
  • [–] 1 point 1 year ago* (last edited 1 year ago)

    VBUS, VSYS, 3V3 - it is all power pins.

    As I understand by reading in the datasheet there are 3 ways to power the Pico board:

    -USB Micro-B port

    -VBUS Pin

    -VSYS Pin

    ============================

    VBUS - can be used for output

    VSYS - can be used for output

    3v3 - output power 3.3v

    GND - ground

    From datsasheet:

    "VBUS is the micro-USB input voltage, connected to micro-USB port pin 1. This is nominally 5V (or 0V if the USB is not connected or not powered). VSYS is the main system input voltage, which can vary in the allowed range 1.8V to 5.5V, and is used by the on-board SMPS to generate the 3.3V for the RP2040 and its GPIO. 3V3_EN connects to the on-board SMPS enable pin, and is pulled high (to VSYS) via a 100kΩ resistor. To disable the 3.3V (which also de-powers the RP2040), short this pin low. 3V3 is the main 3.3V supply to RP2040 and its I/O, generated by the on-board SMPS. This pin can be used to power external circuitry (maximum output current will depend on RP2040 load and VSYS voltage, it is recommended to keep the load on this pin less than 300mA)

    ADC_VREF is the ADC power supply (and reference) voltage, and is generated on Pico by filtering the 3.3V supply. This pin can be used with an external reference if better ADC performance is required. AGND is the ground reference for GPIO26-29, there is a separate analog ground plane running under these signals and terminating at this pin. If the ADC is not used or ADC performance is not critical, this pin can be connected to digital ground. RUN is the RP2040 enable pin, and has an internal (on-chip) pull-up resistor to 3.3V of about ~50kΩ. To reset RP2040, short this pin low."

    But I'm not proffessional with microcontrollers.

  • source
  • 4 comments in c/mechanical_keyboards@programming.dev view that post
    [–] 5 points 1 year ago

    Have a look at the Pinout guides, and you should get in the habit of reading datasheets. They usually will have reference designs for the power delivery (pins like vcc, vsys, etc). Also most gpio pins will have multiple functions depending on the use case, and some pins may have more or different features. Sounds like with your particular setup, you'll just need basic digital pins, but if you wanted to add features like RGB backlights or an analog input of some kind like for volume control, you may need to take advantage of either a high speed data pin (for the LEDs) or an ADC pin for the analog sensing.

    https://datasheets.raspberrypi.com/pico/Pico-R3-A4-Pinout.pdf

    https://datasheets.raspberrypi.com/pico/pico-datasheet.pdf

  • source
  • [–] 3 points 1 year ago

    3V3 is the 3.3V supply. The others are going to be power supplies for other things that you don't need to worry about. E.g. VBUS might be the 5V USB (actually I checked and it is; VSYS seems to be the input voltage).

    For simple switches the only pins you need are 3V3, GPIOs and ground. Leave everything else disconnected.

  • source
  • [–] 2 points 1 year ago* (1 child)

    I'm no electrical engineer, but I have made a bunch of boards with Pi Picos and done a couple of PCB designs of questionable but usable quality. My second one mounts the Pico dev board directly to my PCB. The first one needed a ribbon cable that was then split to reach the MCU.

    Somebody on the .ml thread has already gone over the basics of what the pins all do. For the main matrix of the keyboard, you don't need anything except GPIO, not even Ground. Each row gets a GPIO pin, and each column gets a GPIO pin. The firmware -- KMK, QMK, ZMK, etc. -- will handle it from there. It should even automatically treat the pico's combo pins as digital GPIO due to your specifying them in the code. I haven't looked at the pinout of the various trackpoint modules that are out there, but you'll probably need either 5v or 3.3v power, a ground, and 2-4 GPIO pins.

    If you're getting a PCB fabricated and want to keep your options open on sourcing various modules (or not using them at all), then I think you're on the right track with hand-wiring it. I'm a big proponent of making something that will work and that you understand, and growing from there, rather than trying to make your first PCB all things it might ever need to be and getting frustrated when it isn't perfect. If you wanted to do something just to make it a bit more polished, though, you could make your best estimation about where you want your trackpoint, and then run some traces to vias so that you could keep the wiring you have to do very short and clean, maybe even to the point where you could just use headers on the module.

    One final note is that a Pico's headers are just widely spaced enough that you can place them between three linearly spaced keys (e.g. your middle three). It makes running the traces a bit of an ass-ache, and you need to make sure you assemble things in the right order (solder headers, solder switches, then solder MCU) but it can be done. More sophisticated designs do away with a dev board altogether and integrate the MCU chip itself and the other necessary components onto the keyboard's PCB, but I'm not at the point where I feel comfortable trying that yet.

  • source
  • hideshow 1 child comment
  • [–] [S] 2 points 1 year ago

    I have a good idea of where the trackpoint should go and i put a hole in the PCB for the stem to go through, but that's the only change i've made for it.

    Sure enough, i could just fit the Pico on the middle pad if i move some diodes. I still think putting it under the PCB and hand wiring it will be neater and make the trackpoint easier to wire, but thanks for pointing out that possibility.

  • source
  • parent