Week3: Embedded Programming
Soldering, Programming, and debugging

Introduction

This assignment is targeted at building a simple embedding system with input (touch bottom) and output (screen). We are going to learn both hardware, about how to solder the electronic board, and software, about how to program it and upload it.

AI Statement

I generated and debugged the code using ChatGPT 5. The troubleshooting of coding and questions of the underlying principle are also answered by ChatGPT. I originally used the Chinese prompt, but after I understood it, I manually wrote this documentation in English to help me test my knowledge.

ChatGPT conversation link, originally Chinese prompt

The soldering

1. The bare copper board practice

Because of the limited number of PCBs and the delayed shipment of new boards, I can only get the bare copper board as practice in the beginning. It’s QPAD-XIAO designed by Quentin Bolsee, and the design can be found here: Quentin Bolsee / qpad-xiao · GitLab, which is easy to solder because there is only one XIAO-RP2040 board, two 10k resistors, and one OLED screen (0.96inch, 128*64 pixel) on that. All pins are big enough for manual soldering, and I learned how to remove excess tin, how to use flux during the lab. The product directly passed the code test from TA: w3-1

2. The PCB versions QPAD-XIAO and QPAD21, based on ATSAMD21E18

The second week, in fact, it’s Tuesday because of the damn shipment delay, I finally get the PCB boards with an insulating layer covered, which is more durable than a bare copper board. There’s also the ATSAMD21E18 version, whose design can be found here: Quentin Bolsee / qpad21 · GitLab. But it’s much more challenging to solder because the pins on ATSAMD21E18 core are super small and close. I added tins first to all pins on the board, and then used the hot air gun to solder the core. It looks good in the beginning, but then I found cold solder joints under the microscope. So it took me more time to fix that.

w3-3

I also soldered a programmer with XIAO as the core (pub / programmers / swd+uart adapter - xiao rp2040 · GitLab), but I encountered the LED diode direction confusion, which was fixed later because I found the small green arrow on another side of the diode and another PCB version of the programmer with a label of direction on that:

w3-4

I finally got all three new boards, which are nice.

3. The embedding system programming

I didn’t get time for the office hour, so I explored all the software with the assistance of ChatGPT. It’s extremely hard to debug but finally I get something:

1) Example code test

I got some codes from the original design, including display test, serial test, and touch test. ( code/Arduino · main · Quentin Bolsee / qpad-xiao · GitLab) They all worked normally on my bare copper board while uploading from the TA’s computer. However, when I get the environment on my computer, something can’t work normally: The display test can work first, and the serial test can work too, so I asked ChatGPT to combine these two tests to display the words I sent from serials: w3-5

However, when it came to the Touch test(Original Code), a bug happened: I used the same test code from the designer, but every time I tried to compile and upload it, the serial port would go missing after uploading. The upload is shown as successful, but the OLED will not refresh from former test and computer can't get connected to the board anymore. w3-8

To fix it, I need to press BOOT button on the XIAO and then plug the USB-C cable, then upload a standard blink UF2 compiled file to it to replace the old program with a bug, which is instructed here: Reset the firmware on Nano RP2040 Connect – Arduino Help Center.

Then I tried to run the same code on the bare copper board, which has been proven to work normally from TA's computer, since I don’t know whether the problem comes from the soldering of the new board, but the same bug happened. As a result, I conclude that the problem comes from software but not hardware.

2) Revised display+touch test

I guess there are some deeper problems happening with the serial port, refreshing logic, the display initialization, etc. I struggle back and forth with ChatGPT and finally get a stable new code, added some protection logic, and it can finally work. (The revised code for the touch test)

I want it to go further more, so with the help of ChatGPT, I generated another version, which can also display the status on its screen, but not just send it back to my computer: (The code for this displayable touch test) w3-6

3)Tiny dino/alien game

Then I want to replicate the classic Tiny Dino game from Chrome. I asked ChatGPT to do that, but it can’t generate a good dinosaur figure: it’s a slime in the beginning!

Some text also overlapped in the V1, so I struggled with ChatGPT to develop V2, which is a dinosaur this time but very fat, which jumped not high enough, which increased the difficulty.

Then I generated V3, but I don’t know why the new dinosaur figure became a weird two-foot creature…I found it funny, so changed the name of the game from Tiny Dino to Tiny Alien. It works pretty well now!

w3-7

(The V1 code for Tiny Alien Game)

(The V2 code for Tiny Alien Game)

(The V3 code for Tiny Alien Game)