Week 11

Networking and communications

Goal: design, build, and connect wired or wireless node(s) with network or bus addresses and a local interface. This week I will work with an SD card reader/writer because I ultimately want to include an SD card with audio files in my final project.
Software Tools: Autodesk Fusion 360 (aka Autodesk Eagle), Thonny, Universal Gcode Platform (Version 2.0.20) to send the gcode file to the milling machine, Quentin's online gerber to image tool, and Professor Neil's modsproject online tool to create a gcode file.
Hardware Tools: Genmitsu milling machine, SD card reader/writer (CONN MICRO SD CARD PUSH-PULL R/A), Raspberry Pi Pico W microcontroller
Previous experience: Board design and soldering experience from previous weeks

This week can be broken down into three phases:
  1. Designing a board with an SD card reader and writer
  2. Milling the board and soldering the components on
  3. Communicating between the SD card and the microcontroller
I was able to setup the board and install Neil's micropython code on the microcontroller to speak with the SD card


Video running micropython code on the microcontroller to write to and read from the SD card.


I was also able to play a custom audio file from the microcontroller's local 2MB flash memory


Video of plugging in the microcontroller and playing a custom audio file.



Designing the board

Similar to the last two weeks, I needed some help this week. I referenced Prof. Neil's board diagram for inspiration on connecting an SD card reader to a microcontroller.

I created a schematic and PCD in Autodesk Fusion of the new board with a micro SD card reader/writer. I used the CONN MICRO SD CARD PUSH-PULL R/A component from our inventory.

I followed the process I documented in Week 06 Electronics Production to create the necessary IMG files and gcode files from the gerber files that I exported from Autodesk Fusion 360.

Here are the files I created for easy reference:

  1. .f3z File of my board schematic and PCB in Autodesk Fusion 360
  2. Board traces image file
  3. Board outline image file
  4. Board traces gcode file (.nc)
  5. Board edge gcode file (.nc)

Pico
Screenshot from Raspberry Pi Pico W microcontroller datasheet

schematic
Screenshot of the board schematic

PCB
Screenshot of the PCB

Milling the board

I used the Genmitsu milling machine in E15-043 with the Universal Gcode Sender software on the adjacent desktop machine.

I followed the process I documented in Week 06 Electronics Production to mill the board. There were unique challenges with the milling machine this week, however. See the challenges section below for more details.

If needed, this website has a good guide on how to use the "UGS platform".

These are the steps I followed to run the milling machine:

  1. Click “Open” - select my gcode file (.nc)
  2. Check if the drill is the right one (1/64” for traces, 1/32” for edge cutting)
  3. Click “macro” -> “[1] Raise Z”
  4. Setup the grounding cables, and click “macro” -> “[2] Probe and zero Z”
  5. Position the drill to the right position and set X0 and Y0
  6. Press the play button that reads “send” and start milling
  7. Turn on the vacuum cleaner and wear ear mufflers or noise-cancelling headphones
  8. Repeat the steps above for the edge of the board


Video of the milling machine running


bad milling
Picure of the first milling challenge I had - the mill did not reach the correct depth. More on this below.

final board
Picure of the final board held to the E15-043 light.

Soldering components to the board

Soldering this week was difficult. I think the soldering iron tips in E15-043 are old, damaged, or worn out. I struggled for hours to solder all the components on the board, especially the SD card reader/writer which has tiny pins. After struggling in the CBA shop, I decided to visit the EDS lab where I discovered an incredible soldering setup! Using the equipment there was much easier. For example, the soldering iron has a precise narrow tip which I could use to carefully solder the tiny pins of the SD card reader.

I used the following components for my board:

  1. Raspberry Pi Pico W microncontroller
  2. LM4871M amplifierlink to DigiKey
  3. Three 1.0 uF capacitors
  4. Three 10k Ohm resistors
  5. Two 0 Ohm resistors
  6. One 2x2 header
  7. One simple 4 ohm, 3 watt speaker from Amazon
  8. One CONN MICRO SD CARD PUSH-PULL R/A

EDS lab
My new favorite room, the soldering stations at 38-051

solder
The components I used on the board

amplifier
Amplifer on the board

final
Final board

final
Final board with close up view of the SD card reader

Communicating between the microcontroller and SD card

First I setup Thonny with the Raspberry Pi Pico W microcontroller. Specifically, I did the following:

  1. Plug in Raspberry Pi Pico W to laptop via micro-USB-A cable while holding the "BOOTSEL" button
  2. No lights turned on
  3. Then the microcontroller appeared as an external drive with the name “RPI-RP2”
  4. I installed the .uf2 file on the microcontroller by clicking and dragging the file to the "RPI-RP2" drive
  5. In Thonny, I went to the Run menu to select the option "Configure interpreter..."
  6. I made sure that MicroPython (RP2040) was selected, and the right port was selected

Then I formatted the SD card in FAT format so I could read from and write to the SD card via the microcontroller.

  1. See the video on the right to observe the steps I took to format the SD card on my Mac using "Disk Utility"

Finally, I copied the micropython files from the MAS website and saved them on the microcontroller via Thonny so I could communicate with the SD card. See the files below, and the video on the right running the code.

  1. hello.uSD.RP2040.py
  2. sdcard.py
  3. main.py
  4. : this is the same file as last week. It plays the Mario theme song via the connected speaker when the microcontroller is plugged in.


Video of formatting the SD card to "FAT"



Video running micropython code on the microcontroller to write to and read from the SD card.


Playing sound files from the microcontroller flash memory and an SD card (attempt)

Ultimately, I want my final project to play different audio files saved on an SD card. First I set out to play .wav files that are saved to the local Pico microcontroller flash memory.
This work was done in parallel with Samantha Chan. I could not have done any of this without her help.

This work has already been done before. Many of the steps I followed came from this MicroPython for Kids website

These are the steps I followed to play an audio file from the microcontroller flash memory:

  1. I downloaded these micropython files from the website above and saved them on the microcontroller via Thonny
  2. I created this main.py file to run code that will play the audio file
  3. I made a voice recoding using Mac's voice memos, saved it as a .m4a file, and then converted that file to .wav at 8K Hz 16-bit by using wav converter website
  4. I saved the audio file in a "sounds" directory directly on the microcontroller via Thonny. See the video to the right.
  5. When the microcontroller is plugged in to a power source, the main.py file runs and plays the audio file that is defined in the code.


Video of plugging in the microcontroller and playing a custom audio file.



Video of using Thonny to save a .wav file from my computer to the microcontroller flash memory


Challenges this week

There were a few major challenges this week:

  1. The first soldering job I did on the SD card reader was poor. The connections weren't clean, and so I went back to remove the original solder and try again. In doing so, I tore off the copper surface. I tried to bridge the gap with a piece of wire. This was a wasted 30 minutes. See the picture to the right.
  2. The first time I milled the board, the end mill did not drill down to the correct depth. I think this was because I did not correctly zero the z-axis. I zeroed the z-axis at the bottom left corner of the copper board. It's possible that the bottom left of the board was slightly raised, which resulted in the end mill just barely milling the surface towards the middle of the board. See the image to the right.
  3. When I play .wav files from the microcontroller memory following the steps above, there is a horrible static sound over the speaker that I cannot seem to remove or avoid.

wire fix
First attempt at trying to "bridge" the missing copper surface with a piece of wire. This did not work.

bad milling
Picure of the first milling challenge I had - the mill did not reach the correct depth.