added up to 2018 posts

This commit is contained in:
Matthew Tran 2023-07-09 16:35:04 -07:00
parent 1a6bff0820
commit 543ee5f992
75 changed files with 613 additions and 0 deletions

View File

@ -0,0 +1,48 @@
---
title: Cardboard Chair
date: 2018-04-20
categories: school
excerpt: Ergonomic, economical, and manufacturable - these were the design goals of the cardboard chair for our final project in IB Design Tech.
header:
teaser: /assets/img/2018/cardboardchair-5.jpg
gallery:
- image_path: /assets/img/2018/cardboardchair-mini-iso.jpg
- image_path: /assets/img/2018/cardboardchair-mini-bot.jpg
- image_path: /assets/img/2018/cardboardchair-mini-stand.jpg
gallery2:
- image_path: /assets/img/2018/cardboardchair-3.jpg
- image_path: /assets/img/2018/cardboardchair-4.jpg
- image_path: /assets/img/2018/cardboardchair-5.jpg
- image_path: /assets/img/2018/cardboardchair-6.jpg
- image_path: /assets/img/2018/cardboardchair-7.jpg
- image_path: /assets/img/2018/cardboardchair-8.jpg
- image_path: /assets/img/2018/cardboardchair-9.jpg
- image_path: /assets/img/2018/cardboardchair-1.jpg
- image_path: /assets/img/2018/cardboardchair-2.jpg
---
<sub>Written 8-29-19</sub>
As the culmination of everything we learned during the school year, our final project for IB Design Tech was to build a cardboard chair. The design process was very similar to the [salad tongs](https://matthewtran.dev/2017/11/salad-tongs/), so I wont go over it in too much detail. We took multiple measurements of every student in class to determine the 95th and 5th percentile bounds to create specifications for our chair. Using these measurements, we determined height and depth requirements to ensure our chair would have good ergonomics across most users.
## CAD
After going through the design process to get design specifications, we started modeling our chairs. Although using SolidWorks wouldve been just as easy, I ended up using Fusion 360. My main focus was ergonomics, so I used a spline curve to design the seat area in an attempt to better fit the curves of the human body. This did make it harder to manufacture because I had to approximate the curve instead of plotting straight lines, but it worked out in the end.
{% include figure image_path="/assets/img/2018/cardboardchair-cad.jpg" %}
## Mini Prototype
Before making a full size model, we had to make a 1:3 scale version. Like with the salad tongs, we had to thoroughly test the prototype to ensure it fulfilled all specifications. This included standing on it. Heres some pics:
{% include gallery %}
## Final Product
After our prototype was finished and most specifications met, we built the final, full-scale chair. The build process was pretty much the same as the scale model, but bigger.
{% include gallery id="gallery2" %}
Like with the salad tongs, we also had to do a bunch of testing to make sure our chair met all specifications. Today, the chair has been recycled because I tossed it after intentionally breaking it with multiple jumps onto the seat.

View File

@ -0,0 +1,75 @@
---
title: Hovercraft 2018
date: 2018-05-19
categories: projects school scioly
excerpt: For the SciOly 2018 season, the numerous rule changes for the Hovercraft event proved a fun and respectable challenge.
header:
teaser: /assets/img/2018/hovercraft2018-assembled.jpg
gallery:
- image_path: /assets/img/2018/hovercraft2018-comp-3.jpg
- image_path: /assets/img/2018/hovercraft2018-comp-1.jpg
- image_path: /assets/img/2018/hovercraft2018-comp-2.jpg
---
<sub>Written 8-31-19</sub>
Reading the rules for Hovercraft for the 2018 SciOly season, I immediately noticed a couple of changes I had to keep in mind. First and foremost, transistors were disallowed, probably because of my clever design from last year. Next, the hovercraft now had to carry about 2kg in penny rolls instead of being 2kg itself. Last, while the maximum dimensions for the hovercraft were larger, the track width was also much larger. Another change was that lithium batteries were now disallowed.
Like last year, the main task for the hovercraft was to travel a certain distance in a certain amount of time, without stopping for more than 3 seconds at a time. Since a hovercraft has a pretty small amount of friction, its hard to adjust the thruster to account for the range of times and distances needed.
## Astable Multivibrator using Relays
My idea from last year was to use an astable multivibrator using transistors (no integrated circuits allowed) and it worked absolutely perfectly. Pulsing the thruster every 3 seconds (2.5 to be safe) makes the hovercraft inch forward. A little before the target time passes, another timer triggers, putting the thruster at full speed, bringing the hovercraft to the finish line.
Although transistors were disallowed this year, relays were still allowed. This was perfect since I could use a relay to provide the same functionality as a transistor. The gist of an astable multivibrator is that there are two switches that each turn each other off. Capacitors and resistors slow down this oscillation to achieve the desired frequency and duty cycle.
At first I tested a delayed trigger on a relay using a capacitor and that worked. One thing to note is that since a relay has a coil that constantly draws a decent amount of current, there is a maximum resistor value. Then I moved onto the astable multivibrator part. I tried using just one relay first because I reasoned that the tiny pulse as a relay turned itself on then immediately off would be enough.
The pulse ended up being too small, so I ended up designing a dual relay astable multivibrator to be able to control all aspects of the frequency and duty cycle. Heres a video when I finally made a design that worked.
{% include video id="uVko5xeZZw0" provider="youtube" %}
With the circuit designed, I proceeded to design the final circuit and build it. Theres two parts, the astable multivibrator and the delayed trigger relay. Although I did use 4 relays, Im pretty sure I couldve reduced it to 3.
{% include figure image_path="/assets/img/2018/hovercraft2018-circuit.jpg" %}
I kept most of the capacitors and resistors separate and easily replaceable so that I could determine what capacitance I needed. The capacitor for the delayed trigger relay ended being about 70mF which meant a pretty big capacitor bank.
## Lifting All the Pennies
The next step was to lift 16 rolls of pennies (~2kg). I started by trying my design from last year. It did hold everything but was relatively unstable. In order to increase maximum weight held and stability, I designed an all-new hovercraft that was shorter and was as big as I could realistically work with to maximize area.
{% include figure image_path="/assets/img/2018/hovercraft2018-cad.jpg" %}
Since the hovercraft was now bigger than the area of my 3D printer, I cut the base plate out of acrylic on my CNC router. I printed the side walls and used super glue to attach them to the acrylic. Doing some basic tests with the same impeller from last year, there was a significant increase in lift. I tried changing the size of the impeller, but it didnt make much difference, likely because I didnt change the intake hole size.
{% include figure image_path="/assets/img/2018/hovercraft2018-both.jpg" %}
Next up was making the skirt because that was now a requirement. I initially used some leftover Mylar, but switched to the same Tyvek material from last year due to durability issues. I friction welded a couple of 3D printed parts together to hold the skirt in shape. The skirt increased carrying capacity and stability by a good bit.
## Putting It All Together
With the electronics done and a hovercraft that could lift all the pennies, it was time to put it all together and complete the project.
{% include figure image_path="/assets/img/2018/hovercraft2018-assembled.jpg" %}
Once the parts were together, it was time to do the fine adjustment to ensure my hovercraft was accurate at every distance and time target as well as being consistent across multiple different surfaces.
### Gathering Data
In order to achieve accurate times I had to gather a bunch of data points because solving equations like last year probably wouldnt be very accurate due to the relay coil. The astable multivibrator portion was basically set once and forgotten because I only needed a 2.5 second pause between thrusts. The length of thrusts was also just set once because it just needed to be long enough to move the hovercraft a little bit.
The part that needed adjustment was the one that controlled the delayed relay. Since this relay controlled when the hovercraft would go full speed ahead, it was important to be able to accurately control it. The circuit proved very consistent and predictable. I ended up just gathering a bunch of data points and interpolating instead of trying to do curve fitting.
### Solving the Wider Track Width Issue
A big issue I ran into was getting the hovercraft to hug one wall along its entire path. Because of the lack of friction and rotational inertia, if a hovercraft didnt press against one wall it would spin in the middle of the track and maybe even go backward. I changed the thruster direction and adjusted the balance of the pennies to bias the hovercraft toward one wall.
However, the issue that still remained was that different surfaces had different leveling. If I chose to say only hug the right wall, some surfaces were actually tilted to the left, so my method of a slight rightward thrust wouldnt work. For this reason, I had to practice adjusting the hovercraft on the fly based on the levelness of the competitions surfaces. A perfectly flat surface or ^-shaped one was optimal. I didnt encounter any U-shaped ones, but that wouldve been harder to account for.
## Conclusion
At the end of the day, I made a solid hovercraft reliable, precise, and easy to use. Heres some pics of me at Nationals in Colorado. It performed absolutely perfectly. The proctors even recognized me from last year because of my design!
{% include gallery %}

View File

@ -0,0 +1,227 @@
---
title: Mission Possible 2018
date: 2018-05-20
categories: projects school scioly
excerpt: For the SciOly 2018 season, I tackled the numerous challenges involved in making a device for the Mission Possible event and placed 2nd at Nationals.
header:
teaser: /assets/img/2018/mission-v2-comp-4.jpg
gallery:
- image_path: /assets/img/2018/mission-v1-cad-front.jpg
- image_path: /assets/img/2018/mission-v1-cad-back.jpg
gallery2:
- image_path: /assets/img/2018/mission-v1-eda-big.jpg
- image_path: /assets/img/2018/mission-v1-eda-mini.jpg
gallery3:
- image_path: /assets/img/2018/mission-v1-front.jpg
- image_path: /assets/img/2018/mission-v1-back.jpg
gallery4:
- image_path: /assets/img/2018/mission-v2-cad-front.jpg
- image_path: /assets/img/2018/mission-v2-cad-back.jpg
gallery5:
- image_path: /assets/img/2018/mission-v2-pcb-plated.jpg
- image_path: /assets/img/2018/mission-v2-pcb-test.jpg
- image_path: /assets/img/2018/mission-v2-allpcb.jpg
- image_path: /assets/img/2018/mission-v2-reflowed.jpg
- image_path: /assets/img/2018/mission-v2-soldered.jpg
gallery6:
- image_path: /assets/img/2018/mission-v2-comp-1.jpg
- image_path: /assets/img/2018/mission-v2-comp-3.jpg
- image_path: /assets/img/2018/mission-v2-comp-4.jpg
- image_path: /assets/img/2018/mission-v2-comp-2.jpg
---
<sub>Written 9-1-19</sub>
Coming in to senior year, one of the events that I was excited to have come in from rotation was Mission Possible. The gist of the event is to build a Rube Goldberg machine that comprises of various defined tasks. What I especially liked about this years rules was that microcontrollers were allowed. After getting the rules, I immediately got to brainstorming the most efficient and compact way to do every task and maximize points. I also noted the vagueness of various different rules that would prove a huge pain later in the year when clarifications would come out that changed the standard interpretation.
Heres a brief summary of the tasks that we had to do. Some of them actually changed after some clarifications and rule changes.
- Remove magnet to start
- Chemical reaction inflates balloon 20cm
- Endothermic action
- Exothermic action
- Add pure water to closed container to complete circuit
- IR emitter transmitter and receiver 20cm apart
- Light initiates chemical reaction
- Pulley of IMA >7 to lift >0.5kg object 10cm
- Pulley of IMA 0.5 to lift >0.5kg object 10cm
- Use all 3 classes of levers
- Flip a quarter airborne so it goes from heads to tails
- Thermal action expands gas
- Activate homemade electromagnet
- Play recording of phrase “The End” to signal end
- Chemical timer
## v1
I started v1 right when the rules came out in September. Since I never built a Mission Possible device before, I didnt focus too much on making it small. I just needed a platform to experiment with the various ideas I came up with. Also, the complexity of the event meant that pretty much no one would show up to tryouts except me. Still, I put off college apps to put together a device that would be able to perform admirably even at Nationals.
### CAD
Easily the most revolutionary thing I taught myself the past summer was building assemblies in Fusion 360 or at least designing multiple parts that fit together in one file. Yes, I did learn this a little late because I didnt have a teacher for CAD up until senior year. Well, after a huge brainstorming session, I got to designing v1.
{% include gallery %}
I could go off about how I designed each task, but considering how long that would take because of the numerous tasks, Ill just elaborate in the v2 section.
After printing out the parts and using my CNC router to make the backboard and base, I moved onto the electronics.
### Electronics
Based off of the initial release of the rules, I used one microcontroller (Teensy 3.6) to control everything. To comply with the rules, in the code I made sure each task clearly triggered the next one if successful. I spent a good 3 hours soldering together what I called the motherboard.
{% include figure image_path="/assets/img/2018/mission-v1-motherboard.jpg" %}
During tryouts, one of my coaches Mr. Kim noted that using one microcontroller was pushing the wording of the rules a bit. He was right because later on there was a clarification that said microcontrollers could only be used for one task each. Thankfully I made the switch before then so it didnt catch me off guard.
Using EasyEDA, I designed a general purpose Arduino based board for use in v1. This was also my opportunity to dive deep into using SMD components because I needed these boards to be small. I also made a mini ATtiny10 board for the simpler tasks and to start learning how to use Atmel Studio 7.
{% include gallery id="gallery2" %}
Initially for cost and time reasons I wanted to mill the boards at home. After finding out about [ALLPCB](https://www.allpcb.com), I settled for trying to make the boards at home while waiting for the ones from ALLPCB to come in. It was then that I realized that milling boards at home is only viable for a prototype or one-off, but definitely not when you need a bunch.
{% include figure image_path="/assets/img/2018/mission-v1-boards.jpg" %}
Rewiring the entire v1 for use with individual boards was a bit of a pain but I was successful.
### Performance
v1 performed all of its tasks perfectly. In terms of points achievable that didnt involve size, it got pretty much all of them. However, after multiple rule changes and clarifications that meant going back to the drawing board on some tasks and also wanting to make it smaller for easier transport, I did feel the need to build another one.
{% include gallery id="gallery3" %}
## v2
Partially because of senioritis but mostly because of cost, I initially didnt want to build v2. Troy SciOly engineering events are pretty much student-funded since the school only pays for our travel expenses. We do have a workshop, but it isnt particularly well stocked. Since he wanted us to perform better at Nationals, our head coach Mr. Wahl offered to sponsor my building of v2 using the funds we did have. Since I knew we didnt have too much funding, I only asked to be reimbursed for any new parts Id buy and would donate v2 to Troy at the end of the school year.
Over the course of our week-long spring break right before the State competition (SoCal), I completed v2. The main focus was to make it as small as possible while also accomplishing every task and following the various rule changes and clarifications that came out. Making it reliable and easy to use was a given. Also, it had to be pink.
### Designing Each Task
Planning out each task so that they triggered each other in the most efficient way was easily one of the biggest challenges with this project. Here Ill describe how I did each task in the order I did them in.
#### Start Removing a Magnet
The start task was to remove a magnet, which would release something and trigger the next action. This ones pretty trivial.
#### Chemical Reaction Inflating Balloon
Getting this task to be short was an interesting challenge. I didnt have the tools to build a custom airtight container, so I used an off the shelf mason jar. Instead of attaching the balloon to the top of it, which would be too tall, I used a silicone tube to redirect the air to the balloon on the other side.
For ease of acquiring materials, I used vinegar and baking soda. Pulling the magnet would let a cup of vinegar fall onto the baking soda, producing gas. To determine cup size, I did a rough calculation of how much vinegar was needed to make enough gas to fill the balloon. Designing the cup to always fall over took a bit of trial and error because the baking soda molds to the bottom of the container.
Getting a small balloon to hit an object 20cm away was also a challenge. I ended up making my own long balloon using a Nike shopping bag and a clothing iron. Inspired by party blowers, I rolled the balloon up and used guide rails to get the balloon to hit a flap 20cm away.
#### IR Transmitter and Receiver
This one is pretty trivial. The flap closed a switch which turned on the IR transmitter.
#### Endothermic Action
Since it didnt have to be a chemical reaction, I used a Peltier coupled with a thermistor.
#### Exothermic Action
For some reason, an LED counts as completing this task, so I used an LED and LDR (light dependent resistor).
#### Light Activates Photocell
For some stupid reason, the task that involved using light to trigger a chemical reaction was changed to light activating a photocell. In v1, I used UV color change filament coupled with a color sensor to do this task. I even printed out a page from ACS that stated the UV color change was a chemical reaction.
After the rule change, this task became trivial. See Exothermic Action above. I literally put these tasks next to each other to make a point.
#### Electromagnet
This ones pretty simple. I wrapped magnet wire around a steel rod to make an electromagnet. Of course, I didnt forget the flyback diode. I placed a Hall effect sensor next to the magnet, keeping in mind polarity.
#### 7 IMA Pulley
Unlike v1, I used a servo motor instead of a stepper for better torque, speed, ease of control, and size. I liked how I designed my own linear rails for this part.
Getting a small 0.5kg weight was definitely the trickiest part. I used copper plated BBs in v1 but because of spherical packing this wasnt optimal size wise. I needed to maximize density. Of course, this meant buying tungsten. Sadly, buying tungsten weights was ridiculously expensive for my budget. After spending two weeks talking to sellers on Alibaba trying to get a good deal I gave up.
Thats when I realized I had a relatively dense (still less than half of tungsten) material right at home. My invitational medals! They were the perfect size to build weights with. After some measurements, I determined I needed 19 medals to get ~0.54kg. Good thing I had 49 1st place invitational medals from my 6 years in SciOly.
{% include figure image_path="/assets/img/2018/mission-v2-medals.jpg" %}
#### 0.5 IMA Pulley
See 7 IMA Pulley above. Its similar.
#### Flipping a Quarter From Heads To Tails
Getting this one to be compact was quite the challenge. I had to do a complete redesign because a stepper motor would be too large. Other teams just dropped the coin from a certain height, which from my testing was perfectly reliable. However, this was disallowed at our State competition. I think it was allowed at Nationals but no one answered my question so I stayed safe and used the method below.
After some thinking, I came up with using a coil to launch a steel rod up, smacking a platform containing the quarter. The quarter was offset, so it would both fly up into the air as well as rotate 180°. After a bunch of tweaking, I was able to get >90% reliability. It was close to 100% if I used a charged battery and put the quarter in the right place each time.
To detect the quarter being flipped, I built a coil to use as an inductive sensor. Combining it with an LC oscillator circuit, I pretty much made a metal detector. The microcontroller would detect frequency changes to see when the coin left and fell back down. One thing to keep in mind was that turning on the coil that launched the steel rod caused a much larger frequency change so I had to be careful avoid false triggers.
#### Adding Water to Closed Container
The wording for this one was quite weird, but the good thing is there was a clarification. To be completely safe, I had a servo open the top of a closed container and another one would squeeze a dropper containing pure water. Then the container would seal back up.
The rules stated that we had to use pure water for this task. One interesting thing is that even distilled water is slightly conductive. Using a sufficiently high pull-up resistor, I was able to detect the presence of distilled water at some contacts at the bottom of the container.
#### Thermal Action Expands Gas
This one was pretty interesting to implement. After some trial and error, I came up with the idea of wrapping nichrome around a glass tube to heat up the gas inside. A bit of blue colored salt water would be placed in the top of the tube. When the gas expands, the water is pushed out, shorting two contacts, triggering the next action.
#### Using All Classes of Levers
This one was pretty trivial. My design goes from 1st > 2nd > 3rd class.
#### Chemical Timer
This was the most interesting task to implement. For v1, I came up with the perfect idea of using a candle wick. Sadly, the people over at CalTech saw this kind of design as unsafe and banned it for the State competition. With a week left to competition, I rushed to come up with a new design.
Eventually I came up with the idea of using an Alka-Seltzer tablet with a hole drilled in it to pass a string through. Once the Alka-Seltzer tablet dissolved, the string would release, dropping a weight on the other side. This idea was definitely not very reliable, but it did work.
After the State competition, I submitted multiple questions about using a flame timer, but for some reason no one answered them. This tends to happen with my questions.
#### “The End”
This one was pretty trivial. I did however have to modify some libraries to get it working with the Atmega328PB I used as a microcontroller. Of course, I used a recording of Emperor Palpatine saying “The End.”
### CAD
Just like v1, I designed all the parts in one file in order to make sure everything fit together and didnt interfere.
{% include gallery id="gallery4" %}
Like v1, the backboard and base were CNC milled out of some nice plywood I got from Home Depot. All the parts were printed in Inland Pink PLA.
### Electronics
Like with v1, I designed the board in EasyEDA, but I was able to make it much smaller this time because I didnt need to make room for a stepper driver. I used a QFN package for the microcontroller because I built a reflow oven earlier in the year. It was also an excellent opportunity to learn about the new Atmega328PB which had a few advantages over the older Atmega328P. I also used a TPN2R304PL MOSFET after finding out about Toshibas excellent line of MOSFETs while taking apart an ESC.
{% include figure image_path="/assets/img/2018/mission-v2-eda.jpg" %}
Before I sent my board to ALLPCB, I made one at home using my hybrid etch and mill method.
{% include gallery id="gallery5" %}
One issue I had with the boards was they werent very noise resistant despite the capacitor. So when using it with a noisy digital servo, the microcontroller randomly resets. I added a capacitor to the servo and that fixed things.
### Code
Having recently just learned about #ifdef and #define, I used them as the basis of the structure of my code. I wanted my code to be very modular so that if a task broke in transport, I could very easily modify the code and the wiring to skip that task. I didnt really know how to factor code in Arduino yet (theres a button I didnt notice until recently) so the file ended up being pretty long.
[Here](https://gist.github.com/dragonlock2/7dd62d69641f00a851e4926cf972311f) it is.
### Conclusion
At the end of the day, I had an excellent Mission Possible device. It satisfied basically every one of my requirements. It was compact, reliable, modular, easy to use, maximized points, and most of all it was pink. I didnt get any close up pics of it before I donated it, but heres some pics of me at Nationals.
{% include gallery id="gallery6" %}
I ended up getting 2nd at Nationals, which I thought was pretty dang good. After all, my device did only cost about $300 and I had very little help in designing and building it.
After competition, I found out that the banning of my flame timer was pretty much exclusive to SoCal. Our head coach Mr. Wahl and my parents got kind of mad about that since we were never notified that flame timers were ok at nationals. Oh well.
At the end of the day, what really mattered was the fun and learning that we all got doing SciOly. For that I am thankful.

View File

@ -0,0 +1,105 @@
---
title: STM32 Gaming Keypad
date: 2018-07-17
categories: projects
excerpt: A fun little keypad mostly used to make sure I don't break my keyboard with how much gaming I do.
header:
teaser: /assets/img/2018/stm32keypad-top.jpg
gallery:
- image_path: /assets/img/2018/stm32keypad-top.jpg
- image_path: /assets/img/2018/stm32keypad-back.jpg
---
<sub>Written 8-28-19</sub>
Since I recently found out about the STM32 Blue Pill board, I saw it as the perfect opportunity to dive right into learning ARM. The STM32 Blue Pill board costs only about $2 on eBay and boasts a number of advantages over standard Arduino boards. The one thing I was always interested in was building a gaming keypad. Of course, I couldve just used an Arduino Leonardo or a Teensy, but then I wouldnt really be learning anything and itd cost more.
After doing some research, I came across this [website](https://notes.iopush.net/stm32-custom-usb-hid-step-by-step-2/) which was invaluable in getting started with using the STM32 as a HID device. The gist is you send reports that contain your input data in the format specified by your device descriptor. With the basics down, I got to designing the keypad.
## Hardware
During the school year, I found out that Arrow was selling Cherry MX switches for $0.22 each. I immediately snatched up 25 Cherry MX Greens for myself. Unfortunately, theyve since gone way up in price, at least for small quantities.
First, I used EasyEDA to design a board that could hold all the switches. Since I just needed a plate to add rigidity and hold switches in place, I didnt add any traces.
{% include figure image_path="/assets/img/2018/stm32keypad-pcb.jpg" %}
Then I launched Fusion 360 and modeled a case for the board.
{% include figure image_path="/assets/img/2018/stm32keypad-cad.jpg" %}
Next I looked into making keycaps. Due to the tight spacing I used to fit 24 switches onto the limited size of my FR4, it wasnt compatible with standard keycaps. Trying some caps on Thingiverse, I found one that had a good fit and was relatively easy to bring into Fusion 360 and modify.
{% include figure image_path="/assets/img/2018/stm32keypad-cap.jpg" %}
After making the PCB using my hybrid mill etch method and printing out the parts, I got to assembly. It was a bit hard cramming all the wires in, but I eventually did it and hot glued everything down.
{% include gallery %}
## Software
After finishing the hardware, I got onto writing the code. I started by making a device descriptor that could send two different reports, one for mouse commands and one for keyboard commands. The computer distinguishes these two reports using a report id. I used this [tool](https://www.usb.org/document-library/hid-descriptor-tool) to help out.
{% highlight C %}
0x05, 0x01, // Usage Page (Generic Desktop Ctrls)
0x09, 0x06, // Usage (Keyboard)
0xA1, 0x01, // Collection (Application)
0x85, 0x02, // Report ID (2)
0x05, 0x07, // Usage Page (Kbrd/Keypad)
0x75, 0x01, // Report Size (1)
0x95, 0x08, // Report Count (8)
0x19, 0xE0, // Usage Minimum (0xE0)
0x29, 0xE7, // Usage Maximum (0xE7)
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
0x95, 0x06, // Report Count (6)
0x75, 0x08, // Report Size (8)
0x15, 0x00, // Logical Minimum (0)
0x25, 0x65, // Logical Maximum (101)
0x05, 0x07, // Usage Page (Kbrd/Keypad)
0x19, 0x00, // Usage Minimum (0x00)
0x29, 0x65, // Usage Maximum (0x65)
0x81, 0x00, // Input (Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position)
0xC0, // End Collection
0x05, 0x01, // Usage Page (Generic Desktop Ctrls)
0x09, 0x02, // Usage (Mouse)
0xA1, 0x01, // Collection (Application)
0x85, 0x01, // Report ID(1)
0x09, 0x01, // Usage (Pointer)
0xA1, 0x00, // Collection (Physical)
0x05, 0x09, // Usage Page (Button)
0x19, 0x01, // Usage Minimum (0x01)
0x29, 0x03, // Usage Maximum (0x03)
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x95, 0x03, // Report Count (3)
0x75, 0x01, // Report Size (1)
0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
0x95, 0x01, // Report Count (1)
0x75, 0x05, // Report Size (5)
0x81, 0x01, // Input (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position)
0x05, 0x01, // Usage Page (Generic Desktop Ctrls)
0x09, 0x30, // Usage (X)
0x09, 0x31, // Usage (Y)
0x09, 0x38, // Usage (Wheel)
0x15, 0x81, // Logical Minimum (-127)
0x25, 0x7F, // Logical Maximum (127)
0x75, 0x08, // Report Size (8)
0x95, 0x03, // Report Count (3)
0x81, 0x06, // Input (Data,Var,Rel,No Wrap,Linear,Preferred State,No Null Position)
0xC0, // End Collection
0xC0, // End Collection */
// 95 bytes
{% endhighlight %}
After that I wrote the structs for the reports and the code to handle each switchs keypress. Heres my [code](https://gist.github.com/dragonlock2/ae8e986bfac5201c19ba32f75179c6cb). I dont like the large, repetitive switch case statement, but its what I came up with at the time and is pretty user friendly. Its currently setup to play Destiny 2.
#### Sources: (Check these out!)
- <https://notes.iopush.net/stm32-custom-usb-hid-step-by-step-2/>
- <https://eleccelerator.com/tutorial-about-usb-hid-report-descriptors/>
- <https://www.usb.org/document-library/hid-descriptor-tool>
- <http://eleccelerator.com/usbdescreqparser/>

View File

@ -0,0 +1,30 @@
---
title: Pi Zero Gameboy
date: 2018-07-23
categories: projects
excerpt: A functional and fun Pi Zero powered Gameboy to relive some nostalgic memories.
header:
teaser: /assets/img/2018/pi0gameboy-4.jpg
gallery:
- image_path: /assets/img/2018/pi0gameboy-2.jpg
- image_path: /assets/img/2018/pi0gameboy-3.jpg
- image_path: /assets/img/2018/pi0gameboy-4.jpg
- image_path: /assets/img/2018/pi0gameboy-1.jpg
---
<sub>Written 8-27-19</sub>
Among the many projects for the Pi Zero is a handheld retro gaming console. It was the perfect opportunity to use up the Pi Zero v1.2 (one without the camera connector) that I had in my parts bin. I also had a backup LCD for cars that from my testing was pretty much only useful as a game console display and not any kind of text. With some parts in mind to determine the form factor, I got to designing in Fusion 360.
{% include figure image_path="/assets/img/2018/pi0gameboy-cad.jpg" %}
After printing the parts out, I got to the electronics. I started with soldering the buttons onto some perfboard and drilling the right holes to fit into my design. Then I built a little low battery circuit which if I remember correctly used a couple of transistors. After that I glued the speaker in place along with the Pi Zero, LCD, and battery. Then I soldered wires from each button to the Pi, following the wiring diagram of the PiGRRL Zero.
One issue I ran into was the fact that I didnt have a 5v boost circuit to power the Pi off a Li-ion. Since I didnt really have time to wait for the part to come in, I decided to try powering the Pis 5v line directly off the Li-ion. To my surprise, it actually worked perfectly. The USB flash drive, keyboard, mouse, and LCD all worked just fine. While my method is usable, I would definitely just buy a boost circuit in the future to be sure of the long term reliability.
Finally, I installed the software which was a really straightforward process. I just followed the instructions on [Adafruits PiGRRL Zero](https://learn.adafruit.com/pigrrl-zero/overview). Audio isnt enabled by default, so I followed [Adafruits Pi Zero PWM Audio](https://learn.adafruit.com/adding-basic-audio-ouput-to-raspberry-pi-zero/pi-zero-pwm-audio) instructions.
{% include gallery %}
At the end of the day, I had a functional and fun Pi Zero Gameboy. The Gameboy was the oldest console I ever had, so I get the most nostalgia playing games from that era.

View File

@ -0,0 +1,57 @@
---
title: STM32 Xbox Controller
date: 2018-07-31
categories: projects
excerpt: A cute little STM32 based Xbox controller. Perfect for on the go gaming.
header:
teaser: /assets/img/2018/stm32xbox-assembled.jpg
gallery:
- image_path: /assets/img/2018/stm32xbox-gs4-front.jpg
- image_path: /assets/img/2018/stm32xbox-gs4-back.jpg
- image_path: /assets/img/2018/stm32xbox-gs4-held.jpg
---
<sub>Written 8-27-19</sub>
Continuing my exploration of USB HID, I decided to try my hand at making a controller. I started with implementing a game pads HID descriptor and then firing up joy.cpl to test everything. To my delight, the two joysticks and 16 buttons all showed up. With the coding portion looking promising, I proceeded to make the actual controller.
## Assembly
First, I needed to make a CAD model of the remote. As with any mini project, I wanted to use only parts I already had on hand. The joysticks would be these tiny PSP replacement parts that I got about 8 years ago and would finally find a use for. The buttons would be leftover tactile switches from Mission Possible. Both the STM32 Blue Pill board and the joysticks served as the main restrictions determining the form factor and size of the controller. To determine the size of the D-pad and ABXY button spacing, I took measurements off of my DSi.
{% include figure image_path="/assets/img/2018/stm32xbox-cad.jpg" %}
Funnily enough, I didnt take any pictures of me assembling the electronics. The gist of the wiring that went into the controller was gluing the buttons down and soldering wires to every button. After that I sealed everything up with a couple of screws.
{% include figure image_path="/assets/img/2018/stm32xbox-assembled.jpg" %}
## Code
With the hardware done, it was time to finalize the software. I just took my test code from before and remapped all the GPIO that I used. Using joy.cpl, I made sure all the buttons and joysticks were working properly.
Trying to play Rainbow Six Siege with my new controller, I ran into my first problem. The game would not pick up my controller. I tried Battlefield 4 and had the same issue. Googling it, I found out that the problem was the fact that my controller communicated with the DirectInput API instead of XInput. It turns out that these games I was trying to play didnt support DirectInput.
Doing research on implementing an XInput controller on STM32, I stumbled across nesveras STM32-X360-xinput [repository](https://github.com/nesvera/STM32-X360-xinput). His code did literally everything I needed my controller to do and implemented XInput perfectly, so I decided to use it. I did have to download Keil uVision to open the project, but after changing all the GPIO mappings to match my controller, I was set.
Using [Game Controller Tester](https://www.microsoft.com/en-us/p/game-controller-tester/9nblggh4pnc7), I was delighted to see that everything was finally working. I could finally play R6S and BF4 using a controller. Since Im a PC gamer, I immediately switched back to my trusty mouse and keyboard.
## Android Gamepad
Inspired by all the Android gamepad controllers out there, I decided to make my own. I have a Galaxy S4, so I started with making a custom USB OTG cable to connect the microUSB from the GS4 to the microUSB of my controller. After making sure the controller was recognized on the GS4, I proceeded to design a mount.
{% include figure image_path="/assets/img/2018/stm32xbox-gs4-cad.jpg" %}
If I remember correctly, Retroarch has native support for the Xbox 360 controller, but games like Modern Combat 5 dont so I used Tincore Keymapper to help with that.
{% include gallery %}
All in all, this was a really fun and cute little project. Im not much of a console player, so Ive pretty much used this controller exclusively for retro gaming.
#### Sources
- <https://notes.iopush.net/stm32-custom-usb-hid-step-by-step-2/>
- <https://eleccelerator.com/tutorial-about-usb-hid-report-descriptors/>
- <https://www.usb.org/document-library/hid-descriptor-tool>
- <http://eleccelerator.com/usbdescreqparser/>
- <https://github.com/nesvera/STM32-X360-xinput>

View File

@ -0,0 +1,41 @@
---
title: Pi Zero W USB Dongle
date: 2018-08-10
categories: projects
excerpt: All the power, convenience, and GPIO of a Raspberry Pi in the compact form factor of a USB stick.
header:
teaser: /assets/img/2018/pi0w-dongle-capped.jpg
gallery:
- image_path: /assets/img/2018/pi0w-dongle-capped.jpg
- image_path: /assets/img/2018/pi0w-dongle-uncapped.jpg
---
<sub>Written 8-27-19</sub>
Among all the really cool things that a Pi Zero W can do is turning into a USB dongle. Power is provided over USB and the Pi shares your computers internet connection. All the power, convenience, and GPIO of a Raspberry Pi in a little USB stick.
The software setup of enabling USB dongle mode on a Pi is pretty trivial, but Ill give all the steps I took to get the Pi up and running.
- Install the latest version of Raspbian (I use Etcher)
- Enable SSH (`touch ssh` in the boot directory)
- Enable USB mode
- Open config.txt and add `dtoverlay=dwc2` to the very bottom
- Open cmdline.txt and add `modules-load=dwc2,g_ether` after `rootwait`
- Plug the Pi into your computer (you can actually just connect a microUSB cable from the USB port on the Pi for testing purposes)
- SSH into it at raspberrypi.local and change the hostname in raspi-config to whatever you like
- Expand the file system in raspi-config
- Install Vim
- `sudo apt update && sudo apt upgrade`
In order to do that last command youll need to share your internet connection with the Pi. I recommend checking out this [site](http://www.circuitbasics.com/raspberry-pi-zero-ethernet-gadget/) for more info. If youre on Windows and internet sharing isnt working, bridging the ethernet connections is inconvenient but usable. MacOS is much simpler, just enable one setting.
With the software set up, I proceeded to work on a case. Firing up Fusion 360, I got to modeling.
{% include figure image_path="/assets/img/2018/pi0w-dongle-cad.jpg" %}
After printing it and lots of sanding to get every edge smooth, I had this.
{% include gallery %}
One thing I really liked about my 3D print is the fit of the cap. Inspired by the feel of a Patriot USB flash drive I had laying around, I eyeballed a couple of bumps on the cap. To my surprise, in one try I ended up with a cap that has a very satisfying slide and tactile click.

View File

@ -0,0 +1,30 @@
---
title: HOPE PCB Decal
date: 2018-12-05
categories: school
excerpt: An excellent crash course on the circuit board design process. It's also the perfect intro to my favorite EDA software KiCad.
header:
teaser: /assets/img/2018/pcbdecal-top.jpg
gallery:
- image_path: /assets/img/2018/pcbdecal-pcb-top.jpg
- image_path: /assets/img/2018/pcbdecal-pcb-bot.jpg
- image_path: /assets/img/2018/pcbdecal-render-top.jpg
- image_path: /assets/img/2018/pcbdecal-render-bot.jpg
- image_path: /assets/img/2018/pcbdecal-top.jpg
- image_path: /assets/img/2018/pcbdecal-bot.jpg
---
<sub>Written 8-23-19</sub>
I absolutely loved this class because it introduced me to an excellent piece of PCB design software: KiCad. I used EAGLE in the past, but found that the learning curve was steep and finding footprints and schematic symbols was a pain. Well that was like 4 years ago so things have definitely improved since then. Then I tried EasyEDA. Since I was still basically a beginner, it proved the perfect learning ground to teach me the ins and outs of PCB design. Eventually though, I wanted something more.
After a slight learning curve, I was enamored with KiCad. It took the best parts from EasyEDA and EAGLE. Its also open source. Honestly, I shouldve started learning KiCad instead of EAGLE all those years ago. Its no wonder that KiCad is the software of choice for CalSol. Eventually though, I will probably need to use other EDA software for the features they may provide, but as a general purpose software, Im sticking with KiCad.
During the class, we learned all about making a PCB from scratch. Covering topics from schematic design to BOMs to routing traces, it was a very well taught class. Funnily enough, I actually used my Macbooks trackpad to do most of my design work even if mice are supposedly better. Nowadays I do switch between both.
For our final project, we were given the flexibility of designing our own project. Still wanting to make another lightsaber, I decided to design a board for just that. It was also the perfect opportunity to dive a little deeper into ARM, so I picked out the cheapest STM32 chip I could find that had every feature I needed and continued from there.
{% include figure image_path="/assets/img/2018/pcbdecal-schematic.jpg" %}
{% include gallery layout="half" %}

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB