Custom Keyboard From Scratch Part 2

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome back to the custom keyboard from scratch series last time we created our layout defined our switch Matrix selected our microcontroller and picked our optional features if you haven't done some of these that's okay but you will have to do them eventually for the demo board I'm creating I'm using a standard 60% layout the at Mega 32 u4 and will include pins for an OLED display in this video we'll create the schematic and PCB which starts with key CAD kycad is free and open source software for designing printed circuit boards and schematics install the newest version of kycad then create a new project you'll be greeted by two files a schematic and a PCB open up the schematic let's first introduce the most useful hotkeys a allows you to add General components such as resistors diodes switches and microcontrollers M allows you to move a symbol R allows you to rotate that symbol and P allows you to place power symbols such as voltage rails and ground now that you know how to place components go ahead and place your microcontroller for me that's the at Mega 32 u4 I typically start with the microcontroller as it's the heart of the project that said you're free to work in whatever order you'd like I should let you know that passives are defined by their characteristic letter so a resistor is simply r a capacitor c a diode D and an inductor L more complex packages such as microcontrollers typically go by their full names as you place components you should prefer to their data sheets to view typical implementation diagrams and schematics some are better than others but they're all jam-packed with useful information one thing of note is that websites occasionally link to cover sheets or series breakdowns in place of data sheets these are typically much smaller than the actual data sheet and contain very little information the proper data sheet for the 32 u4 is 438 pages long I'll now follow the data sheet to add the required components to boot this microcontroller for with the 32 u4 that includes placing a 100 nanofarad capacitor at each Power Pin placing a 1 microfarad capacitor on ukap and adding a 10K pullup resistor and pull down button to the reset pin this is how we'll flash this board I'll add 22 ohm series resistors to each USB data line and finally I'll add the crystal the crystal requires a capacitor at each side values for these are typically around 10 picofarad but can be calculated from the Crystal's data sheet the 32 u4 requires a 16 MHz Crystal but this will vary for different microcontrollers with that supporting infrastructure complete it's time to add USB type c cuz I'm no fool I'd recommend the USB 2.0 receptacle for type- c as it has all the necessary pins for C Toc support and reversibility you can leave the shield and sbu disconnected pressing Q at top of pin will place an X at top it indicating that it's not connected you should also add two 5.1 kohm pull down resistors on the CC lines if you forget to include these your board will only work with USB a to c cables and not C to C cables finally I'll connect USB ground to ground and vbus to plus 5 volts I typically fail to include one but you may wish to include a USB protection IC it's basically a few xener diodes which dumps voltage spikes on the USB data lines to ground this is what I have but yours will likely differ let's now move on to the switch Matrix the other most important part this will be large so I'll create a new sheet with the S key name it switch Matrix and double click it to enter the new sheet I'll start by placing a single push switch and a diode then extend the leads to create a cell I'll copy the entire thing referencing the drawing we made in part one I'll paste connecting them until I have the appropriate number of columns then you can copy the entire thing again and paste in the rows remove any extra cells from The Matrix again following your drawing as a reference this is what I get for the demo board I now need to label and annotate The Matrix I'll use Global labels placed with contrl shift L to give each row and column a label so it can be accessed from the main sheet now annotate the sheet by clicking the annotate button in the ribbon selecting sort symbols by y position and clicking annotate this completes the work for the Matrix you can return back to the main sheet by pressing alt backspace you can now add any optional features such as LEDs encoders or displays for LEDs I might make a second sheet formatted something like this for encoders and displays I just throw them in the main sheet when working with the SSD 1306 I place a generic four pin connector and match the pins to my module almost done if you're using an STM 32 or similar you'll need to add a voltage regulator to get the 5 volts from USB down to 3.3 Volts for Simplicity I'd recommend the AMS 1117 ldo which should fit just fine here you'll also want some additional filter capacitors to go with it throw a 10 microfarad at the input and output and you should be set don't forget to use power symbols to Mark each voltage as a final consideration You may wish to include an ISP header so that you have a second way to flash your microcontroller if something goes horribly wrong this would be the S swd header for stm32 users at this point you should have a mostly complete schematic you're free to copy the labels from your switch Matrix and assign those to pins on the microcontroller but I found that easier to do once I was happy with the switch and microcontroller placements on my PCB this brings us to footprint assignment and component selection let's start easy with the key switches if you're going fully custom you probably already know which switches you intend to use if not you may wish to order a switch tester to find your favorites I like Cherry switches and think hot swap is king so I'm going to assign cherry hot swap sockets for my switches to do this we first need a library of components luckily one's available through the key CAD content manager navigate to the main key CAD window then click plugin and content manager tab over to libraries and install the key switch Library apply changes and close you'll then need to include those libraries navigate to preferences manage footprint libraries and add these paths hit okay then return to your schematic to assign the newly added Footprints run the footprint assignment tool from the top ribbon automatically annotate the remainder of your schematic if necessary then select all your key switches and assign the appropriate footprint for the switches or hot swap sockets you intend to use I start by assigning everything a oneu footprint then manually update the switches that need different sizes to manually update you can rightclick a switch and select edit footprint or press F You may wish to refer to the original Json that you exported from your keymap in part one the easiest package to assign a footprint to is the microcontroller the data sheet should list the packages or the supplier you intend to order from should list the package associated with the component you're about to order in many cases kycad even has preassigned packages for microcontrollers for USBC I like the hro 31 M12 connector as it's done everything I needed to do and has proven easy enough to solder the remainder should be capacitors resistors dodes and a crystal this will fall to you to pick components that match the correct value and are a suitable package I basically exclusively use smt surface mount packages at this point and have sample books in 0402 0402 components are like grains of sand however so you may wish to look into the 126 smt package or through hole packages such as d207 if you intend to hand soer through hole will present some challenges here as the switches need to rest flush against the PCB and your keyboard will likely be tight on space one last thing of note is that you don't have to assign every footprint now you can jump into the PCB design now then go back as needed and use the current design to help choose a package that fits into the available space so let's do just that I'll skip assigning my passes of footprint for now and jump into the PCB we do need one last thing from our schematic though a net list kycad Works in Nets a net is basically a common point or circuit node each pin gets assigned a net such as plus 5 volts ground or one of your labels that pin then needs to connect to all the other pins also assigned to that net to get the net list go file export net list save it to a common area then open the PCB and go file import net list load and test then update your PCB you should now see a pile of keys and a few other components I like to place these outside the sheet to start switching it up this time I'll start with the switch Matrix or layout as it makes the most sense here but first we need to change the grid settings select grid edit user grid then set the user defined grid to 19.05 by 19.05 mm this is as far as I know the standard spacing you're free to set this to whatever you'd like but I found this to be correct you may wish to divide the X portion of this grid by some nice power of two such as 2 4 8 or 16 but I'll leave this this is a whole one unit for now hit okay then select the user Grid it's now time to place Keys you can move items with the m key as before but I prefer a more direct approach in key CAD press t on your keyboard this box calls the reference designator of a component to your cursor as long as your Matrix schematic looks similar to mine you can type in s sw1 and the first switch in The Matrix should be brought to your cursor this should be Escape grave or whatever the top left key is place it somewhere near the top of the page then repeat it to call in switch two 3 and so on until you hit the end of the row you can then call in the next key and start the next row repeat this until your Matrix is complete and you can finally divide the grid if you haven't already to finish the arrangement I've ended up with this I'll now jump down to the standard 0.254 mm grid and move my microcontroller around to see where it best fits I'll also flip it to put it on the same side of the PCB as my hot swap sockets you'll definitely need to keep track of orientation here by default red is the front copper and blue is the back copper make sure you don't accidentally mirror your board you can press alt three to view a 3D render of the board finally if your switch Matrix hangs off the sheet you can go file page setup and change the size of the page to better fit before you go much further you should take note of Trace directions since traces can't intersect you need to cross above or below as such I'd recommend using one side of your board for horizontal traces and using the opposite side for vertical traces you can use Vias to switch layers this way you don't lock yourself into a corner requiring you redo large sections of the trace layout I guess I finally have to talk about component selection this one's hard for me I don't know what to tell you other than to pick components that match your specs and that you can solder finding components can be hard though so where to look I like LCS c as the prices are low and the shipping times are slower Mouser or Digi key work too but expect to pay 10 times more for the passives larger stuff like microcontrollers are generally priced about the same use as many filters as possible to find what you need I like to filter by value then by package then by Price may as well tack on an inst stock as well to hide the out of stock and discontinued stuff value is easy it's in the schematic but what about package that's a personal thing it takes takes time and experience to know what packages you like to work with I like the microscopic 0402 package as it saves a lot of space especially around microcontrollers I'd advise a beginner to stay well clear of them though I think this project has space for 1206 so that'll be my blanket recommendation if you're entirely unsure shrink that down as you see fit one recommendation for beginners who haven't searched for components before is to start with the resistors and capacitors search for and filter the resistors and capacitors then add those to your cart first this gives you some practice with the filters and hopefully prepares you to order your microcontroller and any other components you may need given the choice between general purpose diodes and shocky diodes you should pick shocky for your Matrix as they're slightly quicker to react but are worse at blocking current I'll use the sod 323 package in this board and I'll pick a reasonable enough but mostly random diode from my component supplier I'll add in these diodes then draw my rows and columns that leaves me with a structure like this now is probably not a bad time to route vbus from the USB input make sure each VCC pin receives power and that you're not blocking yourself in this can be tricky so don't be afraid to take multiple attempts while we're routing from the USB let's also talk about the USB data lines USB can tolerate some abuse but you should learn to impede and smash these traces USB has a characteristic impedance of 90 ohms to give our traces that Chara characteristic impedance we must calculate their width open up the calculator tools in the trans line tab I typically use c-plane or wave guide with ground plane it works but isn't ideal coupled micro strip line would be the correct option but it doesn't seem to function at the time of writing basically you can leave the defaults aside from height which you should set to the thickness between your trace and ground poure this is probably 1.6 mm then set Z knot to 90 ohms set the clearance of your ground por as s and click synthesize this is how thick your USB data lines should be if it's really thin make sure it's wide enough that your Boardhouse can fabit you can find that info on the board House's capabilities page you can round it up or down just try to keep it roughly around that size I'll use 0.15 mm as I know jlc's minimum width is 0.127 MM for two layer boards you should also route the data traces as differential pairs this can be done by clicking and holding on the trace button then dragging over to the differential pairs button make sure the data plus and data minus Nets have a plus and minus at the end which signifies a diff pair to key CAD then just draw the traces across the board taking care to avoid getting too close to any other traces the last two things I need to talk about are Edge cuts and grounding on the edge. cuts layer draw the outline for your PCB I went about 2 mm away from the edge of the switches then placed my Edge dot Cuts I also rounded the corners once you have your Edge dot Cuts in place you should select the Zone fill tool select all of your copper layers and fill using ground set it up with your clearances and hit okay box the entire board complete the rectangle and double click the zone you should now have a big colored Zone which represents ground make sure it connects to every component that needs ground and check for any gaps you want to use Vias to Stitch the top and bottom of this pore together use Vias to bring the ground pore into any large areas where it may only be on the top or bottom with that I'll leave you to Route the rest of your board and to place your components in a manner that appears easy to assemble take care to review your board a few times and make sure that everything is truly connected The Rat's Nest should show you but it can be easy to miss definitely run DRC which will inform you of any issues with your board some can be safely ignored and others will be critical you should also spend some time cleaning up your silk layers too arrange any reference designators you plan to Silk on and add any Easter eggs you want on the final board you may also wish to add a version number somewhere so you know what Hardware revision you're on for a really clean look consider removing the reference designators and adding a jlc jlc jlc under the microcontroller on the silk layer if you're using jlcpcb this hides the order number once the board's fully assembled once you've given it a fin final review and are happy it's time to export Gerbers go to file plot and create a Gerbers folder then click plot you'll also want to create drill files in the same location I use the defaults for all of these without issue you can use the Gerber viewer and import the Gerbers to see what the Boardhouse is going to get make sure it all looks right once you're completely happy navigate to where you saved those files and zip them up then drag and drop it to your Boardhouse configure the board's proper properties and order it while you've got your card out don't forget to order your components too this concludes part two hopefully it was helpful as before leave some comments below letting me know what I missed and what I should do in the future
Info
Channel: Casual Coders
Views: 38,463
Rating: undefined out of 5
Keywords: Science, Technology, Projects
Id: fYNxG8RwpaE
Channel Id: undefined
Length: 17min 12sec (1032 seconds)
Published: Fri Jun 14 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.