<topbar style="display:none;"> <item><a href="../index.html">Home</a></item> <item><a href="../about_me/about_me.html">About</a></item> </topbar> <!-- This is a comment, it is ignored by the compiler/interpreter --> <style> h0 { font-family:; font-size: 30px; color: #414040; margin-top: 50px; margin-bottom: 6px; word-spacing: 5px; } </style> ##week7: embedded programmning <br> ####Objective <br> Then, read the data sheet for your microcontroller and program your board to do something. I was previously struggling to have my chip read for bootloading. As a result, I decided to redo the PCB design (twice) and ended up with testing the LED-Button functions on SAMD11C. ####Metrics <br> **A. Designing part** <br> * Base design: USB-D11C-serial using ATSAMD11C14 <br><img src="./samd11c_datasheet.png" alt="laser_module" width="800"/><br> * Software: Eagle in Fusion 360 (electronics design) **B. Milling part** <br> * Milling machine: Roland MonoFab SRM-20 * Endmills: 1/64 endmill for cutting the copper, 1/32 endmill for cutting out the PCB * Material: Single-sided copper board * Software: mod **C. Coding part** <br> * Software: Arduino IDE (embedded programming) ####Protocols and results <br> **A. Design part** <br> 1. Pick up a basic design, onto which I put an LED and a button. I chose "hello.D11C.serial.5V.1.1" from [here](http://academy.cba.mit.edu/classes/embedded_programming/D11C/hello.D11C.serial.5V.1.1 "test"). <br> <br><img src="./hello.D11C.serial.5V.1.1.png" alt="laser_module" width="200"/><br> The one I did two week ago did not work, so I had to redo the schematic design. 2. Draw a skematic design on Eagle. This time, I made the board as simple as possible; for example, I did not make the wider copper layer for heat decipation or use the 5V-3V regulator with two extra capacitors, or use pullup resistor. I basically followed the simplest path i.e. putting LED and resistor in between one pin of D11C and GND, and a button in between another pin of D11C and GND. <br><img src="./final_schematic.png" alt="laser_module" width="800"/><br> 3. Complete the routing on PCB, using zero-ohm bridges where necessary. <br><img src="./final_pcb_des.png" alt="laser_module" width="800"/><br> 4. Export the trace design and the outer design. I did not know there was a critical mistake at this point... **B. Milling part** <br> 1. Use the above-mentioned sketches. 2. Pick up a copper board. 3. Put the copper board onto the milling machine. Now that I am becoming used to this process, I decided to use a smaller copper board to minimize waste. 4. Mill the copper layer of the circuit (trace with 1/64 endmill and line with 1/32 endmill). 7. Cut out the PCB. <br> **C. Stuffing part** <br> 1. After milling, first cut the unneccesary copper foils with knife. 2. solder the components one by one. **D. Bootloading part aka where I struggled the most** <br> 1. I used the bootloader for D11C, but the PC never seemed to be reading my chip. There were two mistakes: * I was initially using a wrong regulator with wrong direction; after several failed attempts to bootload this chip, I realized the component was wrong (thanks Nathan for figuring it out). I changed it to the right 3.3V regulator (1mA one). * I thought it should work after putting a smaller one. Instead, it melted with smoke! I could not figure out at this point, but when I finally gave up and decided to make a new board design and mill it, I realized that there was small area where the 1/64 endmill could not cut, therefore shortcutting the circuit. I cut this part apart by knife and voila, it worked. <br><img src="./comparison.JPG" alt="laser_module" width="800"/><br> <br><img src="./too_close.JPG" alt="laser_module" width="800"/><br> **E. Coding part** <br> 1. I used Arduino. Initially I could not install the board definition with the link `https://raw.githubusercontent.com/qbolsee/ArduinoCore-fab-sam/master/json/package_Fab_SAM_index.json`, but after several more attempts on Tuesday, it worked. (Thanks for the fix!) 2. There were a few more errors (port was not read, or it took forever to update the chip, etc.). Rob suggested that I uninstall and reinstall the IDE. After going over the same procedure written on MTM, it finally worked! 3. For the programming part, I made use of the basic design from "File" command of the IDE. I checked the mapping of the pins, and accordingly chose the port on IDE using `const int` rather than hard-code the port number every time. <br><img src="./samd11c_image_pin_map.png" alt="laser_module" width="800"/><br> <br><iframe width="560" height="315" src="https://www.youtube.com/embed/qmrBv4LuDsw" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe><br> [original files](https://hu-my.sharepoint.com/:f:/g/personal/ttokunari_mde_harvard_edu/Eo_MW5iJhp1GvL7Oqn-jOrYB6G4nvFlrPQ0QWN5hT0okVg?e=J0TZIo "original files") <br>