Thursday, November 14, 2019

DIY Numpad

In the summer I replaced all the switches on my keyboard from Cherry Blues to Hako Royal Clears and wasn't sure what to do with the rest of the switches. Why not build a numpad!

I first began making a few drawings of what the numpad should look like. I wanted to have an encoder and the layout would be 4x5. The size would be dictated by the size of the largest PCB I could get manufactured for cheap (100mm x 100mm). This is perfect for a fully filled out 5x5 layout, but I wanted that encoder and an angle in the design.
Layout.
Render of the PCB from KiCAD.

With a general concept in mind, I went over to Fusion 360 to generate a CAD model. A few iterations later and relearning how to CAD in a not entirely garbage manner, I had a workable design. I still don't know what is the best way to create the sketches and dimensions in a way that is easy to adjust later, but I tried my best.
CAD Model of the case.
At the same time I began putting together a schematic and layout for the circuitry. The microcontroller of choice was the ATMega32u4, since it is the most popular microcontroller for the QMK firmware I plan to use. A few switches, diodes, and LEDs later, I had something ready for shipout:

With parts and boards on the way, I tested out making the case for the numpad (Oct 12). The cutting operation began with an adaptive clearing for the pocket in the middle:
Adaptive Clearing with 1/8" endmill.
Afterwards, the program cut out the inner lip for the plate, then the drills for the corner screws, and finally the contour operation for the outside:
Inner lip, drills, and outer contour operations all done with 1/8" endmill.
The finished cutout (the part was not removable since I tested it out in 3/4" MDF while the model is 1/2"): 
Test cutting of the case in MDF.


I laser cut out some stencils for solder paste and reflowing the parts (Oct 29):
Stencil laser cut in 0.003" Duralar.

Spreading the paste.
After reflow:
Didn't have the USB C connector at the time and had to hand solder that later.

For the plate, I wanted to use aluminum. I never cut aluminum before on my CNC but now was a great time to try (Nov 11).  The stock was 1.5mm thick 5052 aluminum, and I used a 1/8, 2 flute end mill and some Tap Magic. The feedrate was 20 IPM with 0.012" depth of cut per pass:
Test cutting out the holes of the switches.
Got a little too ambitious trying to see if it would fit in the bottom hole with 1/16" radius corners (datasheet max is 0.3mm).
Switch fits in the dogbone'd hole.
After that successful run, I went on to the whole plate. I slightly modified the dogbone geometry for the corners so they would be smaller. My first dogbones in the cutting test I manually put in, but there was a nice add-in for Fusion 360 that I used to add dogbones for the whole plate that can be found here.
1/8" 2 flute endmill for all operations.


After exporting the G-code and continuous application of Tap Magic for cooling, I got this:
Messy.
With some clean up:
Removed most of the burrs.
Switches all fit!
The plate dimensions in CAD were 108.00 mm by 104.43 mm. The actual cut out plate came out to 107.9 mm by 104.7 mm. Not bad.

Before soldering all the switches to the PCB I realized there was going to be a clearance issue with the USB C connector with some types of USB C cables that have a thicker housing:
Uh-oh. USB C connection collides with the plate.
Soldering the PCB to the bottom of the legs for the switches (instead of the PCB sitting flush with the the bottom of the switches) gives just enough room for most cables to fit. It also turns out the cables I bought were very low quality and in some ports the USB-A side is loose, which led to my numpad being intermittently connected. When I used a snug cable or a C to C cable the numpad works fine every time.
Plate and PCB all together.
Backside.
The basic QMK firmware was easy to get working, and I was able to get keypresses on the switches and volume control on the encoder with minutes. However, the RGB LED control turned out to be a large pain in the neck. The APA102 driver in the QMK firmware has never been used before by anyone else's design and it clearly shows. Right off the bat, the base file does not compile since there was an unmatched parenthesis. I'm going to need to put some time into fixing the code and hopefully can get some nice colors running.

Tuesday, August 27, 2019

CNC Upgrade??

One final upgrade to put this debacle of a machine into a usable form. I wanted to get rid of the main wood frame and since the gantry was now so heavy (and my fasteners for the 8020 not used effectively), I wanted to make that fixed. I could simply turn the y-axis rails inwards and have the bed move.

I bought more 8020 a few weeks ago and just this last weekend put all the upgrades in place:
New bottom frame (upside down).
Old base removed.
Gantry corrected to maintain flush faces and fixed in place.
Functional. The block for the y-axis nut will need some work.
Everything has much less flex now and the envelope of the machine has shrunken.

After updating my LinuxCNC from 2.5.4 to 2.7.14, I cut out some samples to make sure it was really working:
LinuxCNC splash g-code.

Fractal example in LinuxCNC.




I also tested out some isolation routing for PCBs to finally put to use the copper clad board I've had for several years now; it turned out much better than I expected, and the base is significantly flatter relative to the router bit right of the bat than before. I used FlatCAM to generate the g-code:
First attempt with multiple runs of the code.









Round 2: really even cutouts and I run a cutting pass.



I have some thinner bits and drills on the way to make complete PCBs (and even double sided).

Saturday, July 13, 2019

High Power LED Driver

I've been wanting to create a some drivers for high power, high CRI LEDs to use as lamps, and last month I designed and made a few that work fairly well. Made a few blunders and the original design had to undergo a few bodges but the base idea works.

I originally wanted to create a boost converter from scratch to drive the LEDs, as the LEDs require about 34V to run a full brightness. It would have been a good learning experience to setup basic control for the switching and the circuit topology isn't that complex. However, since I really wanted to use these day to day and the power being delivered was around 50W, I decided to just go ahead with a boost converter chip.

I considered a few: the AL3353 looked nearly perfect for the job, as it offered current sensing and was designed specifically for LED boost applications. However, the switching frequency was rather low and a large inductor would have been needed. I looked a few others, and eventually settled on the LM3478. This chip was designed to be a general purpose constant voltage boost converter. I wanted to modify the feedback path to be constant current: a small current sense resistor with a current sense amplifier to reach the high feedback reference voltage of 1.26V:

Seems like a good idea at the time. Schematic could also be better formatted.
The microcontroller would create an offset voltage that was added to the amplified current sense voltage so that the current could be regulated. I would quickly realize my implementation was flawed.

For the microcontroller (to control the brightness levels and regulate temperatures) I used the ATtiny1616. This was really nice to use as it was relatively cheap compared to older ATtinys, had a DAC (which I needed for the offset voltage), and had a one-wire programming/debug interface (woo!).
Programming with
ATtiny dev board
The LEDs I used were high CRI Cree LEDs: the CMA1825 series in 2700K and 5700K. I also ordered a few cheap 50W and 100W LEDs for testing.

Cheap LEDs
Cree LEDs
I did the board layout following the TI WebBench design, soldered up the boards, wrote a little code and voila:
Light!
I was a little surprised this worked this well. Almost immediately after sending out the board I was a little concerned the boost converter driver would not like the new feedback setup, especially at the high frequencies it was running at. I looked at the datasheet for the INA199 current sense amplifier I was using and uh-oh:
Not high enough.
Should have looked a little more closely before I chose this part. The LED did light up and I could control the brightness. But, there was some coil whine at low brightness, and at high brightness the switching MOSFET and inductor quickly became very hot. Over 80C hot. 

I had some time today to take out my feedback path and just setup a voltage divider from the output to the feedback pin as intended, and the whine disappeared and the temperatures didn't rise much over room temperature.
Potentiometer from output to feedback pin.
Light! Again!
Guess I'll have to setup a couple of potentiometers for dimming (the functionality of the board doesn't change, just the brightness can no longer be programmatically controlled) to prevent over and undervoltage for the LED.

I bought a new heatsink and lens combo and tested it with the cheaper LEDs:

The yellow edge on the beam is a little gross and may just not use the lens reflector combo and use a larger diffuser.

7.21.2019 Update:

I bought a bowl from IKEA to act as a reflector and got rid of the lens to get a wider beam that was more even:

For some reason the board I was using developed a short across the input power terminals but I can't find where it is for now. I tested the input capacitor and that was okay. Will have to investigate more later. For now I just swapped over to one of the spare boards I had put together and flashed over the firmware:

Works very well!
Let there be light!
Since I don't want to get a new board made, I'll probably find some sort of digital potentiometer to use for brightness control and hack it in for the feedback.

Thursday, January 17, 2019

PortaLED Budget Edition

Using the spare time I had today I partially assembled a PortaLED PCB, as I had all the parts on hand. This time, I put in a one ohm resistor for the current sense resistor instead of 0.3 ohms to reduce the drive current to make the circuit work with the tiny inductor (which actually had a saturation current of 250mA, while my original design wanted to run at 630mA; I only noted the current rating of 1.9A). I didn't put in the microcontroller and tied the enable pin high. I also didn't put in the battery/USB switchover MOSFET/diode combination out of laziness. I just wanted to test to see if the circuit would work as a basic light and if there was really nothing too wrong about my design from before.

Mostly soldered board.

And it did work!
Assembled.
Stacked boards to form a case.
Plenty bright enough at this drive current. Charger works fine, just don't have it plugged in when on.
This one photo refused to be uploaded by Google Photos.
Not sure why I only get partially uploaded.

Saturday, January 12, 2019

Box

After nearly five years, I've finally gotten around to making a box for the electronics for my (crappy) CNC. I spent the last week on and off designing and building it.

I used Fusion 360 for the CAD and CAM, and relearned the limitations of my CNC's rigidity.

CAD model.
During milling it took me a little while to figure out why the end mill kept descending during the cutting process; the coupler for the z-axis was loose and causing retractions to not pull back fully. After tightening it was fine.

A second pass created deeper grooves due to the z-axis slowly falling.
A better look at the bad grooves.
You can also see where the end mill dragged through the piece between drills.
However, the biggest problem was the lack of rigidity. I think it is mostly from the wood plate and clamp for the router, but I know the entire machine is kinda shady. All the hexagons in the back plate were round and all the holes and slots for the connectors and walls were all undersized. I had to go back into the CAD and oversize all the slots, and just manually drilled out/filed the rest of the holes bigger.

All undersized. :(
Soldering outside in a light drizzle.
Connectors for the motors.
Finally used them after buying them five years ago.
Electronics mounted.
The lid was just the original piece of wood I had the electronics temporarily attached to before.

Box! Much neater now.
I may plan to put a fan on the top lid to help with ventilation if it actually becomes too warm.

Monday, August 20, 2018

CNC Upgrade?

I've been using my CNC on and off over the last couple of years, making parts for random projects but not really using its full potential. I recently had to make some plates for a keyboard a friend was making, and it had been nearly a year since I last used my CNC. It took a trial run to figure out the right feeds and speeds for my machine, but I was able to cut out some acrylic successfully for him.

However, during this quick run I saw the shortcomings of my CNC (and remembered how the last "upgrade" reduced my machine's rigidity) and decided to completely replace out the gantry. A significant amount of flex came from these unsupported x-axis pipes and I wanted them replaced with supported rails.

Added a steel bar so the bearing blocks don't roll independently.
After adding a temporary fix to the old gantry, it was time to start anew.

I bought some SBR20 rail, 8020 extrusion, and some screws that I didn't already have in my collection of random screws from overbuying for previous projects.
Parts arranged how they will go together.
In the span of a week after my summer internship ended, I steadily pieced everything together and got the gantry installed.

SBR20 rail installed into tapped holes.
Scrap piece of wood used as a mounting plate.
Nut mount for the plate.
Screw installed.
Old gantry.
New gantry.

Complete.
Spent some time figuring out how to use CAM in Fusion 360 and will likely be doing all my CAD/CAM all in Fusion now.
Test engrave of China. Seems to work fine.

Some things to fix:

The original bearing blocks for the y-axis rails have become loose (as expected with screws threaded into wood) and will need to be replaced with aluminum. The blocks also have some independent wiggle (issue that arose from the last upgrade) and I will likely need some more brackets to strengthen the gantry.

Now that the y-rails are further apart (due to my lack of planning; I really should have just used 1530 extrusion for the vertical beams too but no big deal), they extend over the edge of the wood sides and are currently only supported by a couple of bolts on the edge on top of far too thin aluminum angle (the only hardware I had on hand). This need to be beefed up and properly aligned to be square the the other axes. When installing the axes I only rolled the gantry back and forth hoping for the right alignment. The rails about 1/8" too far apart so the bottom extrusion of the gantry isn't flush.

Haha.