Author Topic: How do I decide what components to use on a custom PCB?  (Read 1555 times)

0 Members and 1 Guest are viewing this topic.

Offline LOTA

  • Thread Starter
  • Posts: 7
How do I decide what components to use on a custom PCB?
« on: Fri, 23 August 2024, 09:20:11 »
I am working on designing a full-size keyboard with the same layout as a Cherry G80-3000 (104 keys, 3 status LEDs, 1.00u and 0.50u spacing between key groups), full n-key rollover over both USB and wireless connectivity, RGB underglow and per-key RGB LEDs, hot-swappable Cherry MX switches (plus support for as many other switch-types as is practical, but MX is my priority), and whatever onboard hardware is necessary to make it plug-and-play with any computer after the initial setup.

I haven't been able to find an existing PCB that fits all my requirements, so I've been looking into designing a custom PCB. I've found several guides on how to do so, but while they say what categories of components are necessary (microcontroller, diodes, resistors, et cetera), they don't say how to decide what specific types to use, instead including lines like "I'm using X but you can use whatever is best suited to your design" (except for a general consensus to use 1N4148 diodes).

How do I decide what types of microcontroller and other components to use?

Offline TomahawkLabs

  • Posts: 136
Re: How do I decide what components to use on a custom PCB?
« Reply #1 on: Fri, 23 August 2024, 11:31:46 »
As someone who is also trying to teach themselves hardware design with no background in electronics, engineering, or coding, good luck. In regards to diodes, you are looking to confirm that the diodes can handle the Amps of the circuit. USB (for our context) has 5v @ .500A (500 mV). Any diode you can find are going to work, I have used 1N4148 with no issues.

I think the best solution for your design would be take as many variables out that you can. First one would be the actual MCU hardware design. Don't reinvent the wheel when it comes to microcontrollers (MCU). Find a MCU that has the amount of GPIO you need and design a PCB for the MCU to mount to. RaspberryPi Stamps are probably the best bet for available GPIO. Small, should fit in a bare area near the LEDs or near the arrow cluster.

At this point you are left with designing a PCB to fit the stamp (which takes all the voltage regulation, crystal oscillation, etc out of the equation). Now you're left with:
1. Lock Indicator LEDs (x3) - Power + capacitor + resistor will get this working.
2. Per key LEDs (x104) - What kind of LEDs do you plan on using. They will likely be SMD so unless you have familiarity with soldering SMD or have a reflow oven, this will be very hard to do by hand.
3. Switches (x104) - Easy to find and are cheap
4. Diodes (x104) - Easy to find and are cheap
5. USB ports/Breakouts - Adafruit sells these in a variety of styles/shapes that could work.
6. Wireless capabilities - You would have to find out the specific circuitry design to implement this.
7. Hot swap capabilities (x104) - Not hard since you can buy hot swap sockets that solder to pads on the underside of the PCB.
8. RGB underglow LEDS (x??). These are also going to be SMD most likely, see above.
9. Cherry MX support + others - Don't even worry about that now. Alps SKCM/SKCL or cloness are the only other real switchtype to consider.

If you were to ask me I would pare down your wants to make the most complete, but simple board. All of the wants above need to be coded to actually work. It's not like a premade PCB that the firmware is already written for you need to flash. You would be needing to do a lot of, if not all of the coding by hand as it will be unique in which pins associate with what, etc.

I would scrap the per key LEDs and I would scrap the underglow LED. You just dropped x120+ parts (all surface mount) and remove hundreds of wire traces. Unless you have a real affinity for using Alps switches and plan to use it, ditch the multi switch or layout approach. It's complexity that would be nice, but will likely never be used. Alps keyboards never followed a standard layout. You would need to find a suitable host with all the keycaps, in a profile you like, and fits the curves of the board. I would also skip wireless as well. Unless you have the knowledge to create the circuit and understand the firmware to implement that hardware, you will have some struggles getting it to work properly.

Good luck with your adventures. I personally am trying to learn hardware design in relation to the ATMEGA32A. Through Hole components and a well documented history of use cases to gain inspiration.
Always looking for Alps SKCM/SKCL switches. Feel free to DM.
AMD 5600x | RTX3080 | 2x 1TB NVME + 4x 4TB HDD | B550M Pro-P | 32GB RAM | RM850x | Node 804 | Schiit Modius/Magnius + Audeze LCD-2 | 2x Dell S3422DWG
GMMK 1 Full Size Barebones | Zealio 67g ; Apple M3501 handwired | Alps SKCM Damped Cream
SA: Camping

Offline zegonix

  • Posts: 26
Re: How do I decide what components to use on a custom PCB?
« Reply #2 on: Mon, 26 August 2024, 02:52:51 »
have you decided on how to make the firmware? if you want to use tmk, qmk, zmk, kmk,.. be sure to check their compatible microcontrollers. another thing to look at, are the features the chip provides (U(S)ART interfaces, ADCs, DACs, etc.)

Offline TomahawkLabs

  • Posts: 136
Re: How do I decide what components to use on a custom PCB?
« Reply #3 on: Mon, 26 August 2024, 07:15:43 »
have you decided on how to make the firmware? if you want to use tmk, qmk, zmk, kmk,.. be sure to check their compatible microcontrollers. another thing to look at, are the features the chip provides (U(S)ART interfaces, ADCs, DACs, etc.)

My plan is honestly just learning Arduino studio and the translating that to C as best I can to write to an ATMEGA32A.
Always looking for Alps SKCM/SKCL switches. Feel free to DM.
AMD 5600x | RTX3080 | 2x 1TB NVME + 4x 4TB HDD | B550M Pro-P | 32GB RAM | RM850x | Node 804 | Schiit Modius/Magnius + Audeze LCD-2 | 2x Dell S3422DWG
GMMK 1 Full Size Barebones | Zealio 67g ; Apple M3501 handwired | Alps SKCM Damped Cream
SA: Camping

Offline Findecanor

  • Posts: 5048
  • Location: Koriko
Re: How do I decide what components to use on a custom PCB?
« Reply #4 on: Mon, 26 August 2024, 08:11:07 »
(Hmm.. I thought I had replied already... forum reset from backup or did I just not click Post?)

- Most people use the firmware QMK for custom mechanical keyboards. Even if your official firmware would not use it, I would still select an established microcontroller which is supported by QMK, so as to give builders a choice.
- Individual RGB LEDs will need one or more LED controllers. There is support for a few in QMK.
  A LED controller drives the LEDs in a matrix with PWM instead of varying voltage, and this method keeps the current draw within USB's 500 mA limits. It interfaces to the microcontroller over IēC or SPI.
The same for RGB side-glow.

I think supporting Cherry MX-compatible switches is enough. There is no room for two types of hot-swap sockets and LEDs (pick two out of three), and lower-profile switches are best in a lower-profile case altogether.

Both LED controllers, RGB LEDs and hotswap sockets are surface-mounted, but hotswap sockets are easier to solder by hand. I would have RGB LEDs only if I would have the PCBs manufactured complete with mounted components so that the buyer wouldn't have to solder anything.
« Last Edit: Mon, 26 August 2024, 08:14:53 by Findecanor »
🍉

Offline zegonix

  • Posts: 26
Re: How do I decide what components to use on a custom PCB?
« Reply #5 on: Wed, 28 August 2024, 03:02:38 »
well the current consumption is more or less the same, whether you control your leds via pwm or separate controller (preferably integrated in the led; e.g. 'neopixel'). the power need for creating light is still the same and depends mostly on the efficiency of your circuits..
regarding the firmware, i would advise to go with an existing framework like the mentioned tmk, qmk, zmk or kmk. tmk has been around the longest from what i understand. qmk was forked from tmk at some point (been a while though) and is the most widely spread i think. from what i heard, zmk is very energy efficient. kmk is mostly python if i remember correctly, to me that was a no no, so i didn't look into it any further. i currently use qmk, but will at some point get into zmk, as i have some quarrels with qmk, totally personal preference though, qmk works perfectly fine and the people on the discord are very helpful and patient.
regarding multi switch style support.. i would probably make separate pcbs per switch style, or go for a solder pcb.
i made two pcbs so far and i used the stm32f401rct. it is a bit overkill for a keyboard, but also convinient to work with. but as someone already mentioned, the easiest way is to use a small dev board like the rp pico or the blackpills.

@TomahawkLabs if you want to make your own firmware from scratch, keep in mind that you will need a usb stack. writing that yourself will take a lot, REALLY A LOT, of time and effort.

Offline TomahawkLabs

  • Posts: 136
Re: How do I decide what components to use on a custom PCB?
« Reply #6 on: Wed, 28 August 2024, 11:18:04 »

@TomahawkLabs if you want to make your own firmware from scratch, keep in mind that you will need a usb stack. writing that yourself will take a lot, REALLY A LOT, of time and effort.

I don't "want" to write the firmware from scratch. What I am currently researching is more of a baby step solution. From what I gather the 32U4 is more or less the same as a ATMEGA32A, but the 32u4 has built in USB support and the ATMEGA32 had additional GPIO, but lack integrated USB support, but that is resolved using V-USB, which shouldn't be too hard to implement. Some Zener Diodes, a few resistors, etc. My current plan of attack is to create a custom 32u4 board with a 3x3 switch matrix, 3 bare neopixel LEDS, a single LED for testing, a single switch wired to a specific GPIO for testing locking switches, and a reset/bootsel button. From there I should be able to use Arduino studio to make a quick and dirty macropad without any consideration for USB hardware/firmware. Once I get the firmware for the board to function (3 neopixels for the 3 status LEDs tied to caps, scroll, and num lock) to work as intended, I should be able to create another similar PCB but using the ATMEGA32A THT chip and the VUSB hardware to go into a prototype of what I want. If that works successfully, I can translate that to a full size PCB by expanding the matrix and import past versions of the firmware. Lots of work ahead, but then I can isolate certain variables to make it easier to add features.

The end goal is a full size PCB using VUSB and the ATMEGA32A for a complete THT project. USB data/power/ground pins vs a connector to use any style connectors. RGB LED status lights that are user changeable, and a locking capslock key. No underglow, no per key LEDs, no wireless, etc. Just a boring full size keyboard with THT parts and RGB LED (to assign color, not for effect) status lights. An ambitious project, but I have the time to learn.
Always looking for Alps SKCM/SKCL switches. Feel free to DM.
AMD 5600x | RTX3080 | 2x 1TB NVME + 4x 4TB HDD | B550M Pro-P | 32GB RAM | RM850x | Node 804 | Schiit Modius/Magnius + Audeze LCD-2 | 2x Dell S3422DWG
GMMK 1 Full Size Barebones | Zealio 67g ; Apple M3501 handwired | Alps SKCM Damped Cream
SA: Camping

Offline zegonix

  • Posts: 26
Re: How do I decide what components to use on a custom PCB?
« Reply #7 on: Fri, 30 August 2024, 02:17:46 »
well THT is quite the restriction in terms of microcontrollers.
i can come up with some reasons to go THT but i would like to hear yours.

Offline TomahawkLabs

  • Posts: 136
Re: How do I decide what components to use on a custom PCB?
« Reply #8 on: Fri, 30 August 2024, 10:35:09 »
well THT is quite the restriction in terms of microcontrollers.
i can come up with some reasons to go THT but i would like to hear yours.

It is very restrictive, but from my research the ATMEGA32A is the best choice for my project. It should be supported by QMK/TMK because it's the same family of microcontrollers as the 32u4 (once VUSB is configured). It comes in a DIP40 form factor which allows for more PINs than similar THT microcontrollers and is readily available. The justification for THT was user serviceability and accessibility. Anybody with a cheap soldering iron should be able to buy a bare (unpopulated) PCB and solder all the necessary components to the PCB without the need for reflowing or having the PCB manufacture pre-solder SMD components to complete the project. VUSB Solution B (Level Conversion on D+ and D-) is achievable with two 3.6v Zener diodes, and 3 resistors.

My personal goal is to make a THT drop in replacement PCB for the Apple M3501 (Apple AEK II) keyboard that I can wire to the original ADB connector cable, with a USB end. The experience would be a drop in solution to make AEK II keyboards USB compatible using the original case, connector, and cable. The only visual give away would be the RGB status LEDS (I like the idea of choosing a color other than green) and the fact the cable has a USB port on one end and a Apple ADB (which is really just a 5-pin Mini-DIN connector).

The ATMEGA32A has 32GPIO pins. I will need 1 for "Data In" on the first Bare LED Neopixel, 1 for the Caps Lock (I have never been able to get locking switches to work in a matrix), 6 for the rows, and 21 for the columns for 29 total. 3 extra for expansion/additional features. subtract the LEDs and you have enough for SPI displays, etc.

I want to remove as many barriers as possible to get people into making their own custom keyboards. I want to, ideally, have an open source hardware "platform" where people can take the schematic and make their own PCB to revive old keyboards with a modern PCB. I see a lot of users on this forum who want to make their own modern PCB or custom layout, but due to a lack of engineering experience are stuck dreaming. Having the hardware already resolved, a user would just need to use KiCad to make the puzzle fit without worry about part values, schematics, design, math, etc.

« Last Edit: Fri, 30 August 2024, 11:30:25 by TomahawkLabs »
Always looking for Alps SKCM/SKCL switches. Feel free to DM.
AMD 5600x | RTX3080 | 2x 1TB NVME + 4x 4TB HDD | B550M Pro-P | 32GB RAM | RM850x | Node 804 | Schiit Modius/Magnius + Audeze LCD-2 | 2x Dell S3422DWG
GMMK 1 Full Size Barebones | Zealio 67g ; Apple M3501 handwired | Alps SKCM Damped Cream
SA: Camping

Offline zegonix

  • Posts: 26
Re: How do I decide what components to use on a custom PCB?
« Reply #9 on: Sat, 07 September 2024, 18:50:17 »
fair enough. lqfp packages are also solderable by hand, but it is a bit harder to do and probably takes a few tries for people new to soldering.

Offline TomahawkLabs

  • Posts: 136
Re: How do I decide what components to use on a custom PCB?
« Reply #10 on: Sat, 07 September 2024, 20:36:58 »
My biggest concern was SMD capacitors and resistors. My hope was to give a universal schematic with THT parts. A gift to those who want to make a USB keyboard out of an old Alps board with a one off layout. Ordering 10 bare PCBs at 18” x 6” vs ordering a PCB that is populated and 18” x 6” is a big difference.

Always looking for Alps SKCM/SKCL switches. Feel free to DM.
AMD 5600x | RTX3080 | 2x 1TB NVME + 4x 4TB HDD | B550M Pro-P | 32GB RAM | RM850x | Node 804 | Schiit Modius/Magnius + Audeze LCD-2 | 2x Dell S3422DWG
GMMK 1 Full Size Barebones | Zealio 67g ; Apple M3501 handwired | Alps SKCM Damped Cream
SA: Camping