Skip to content
Snippets Groups Projects
Commit 3be21c8f authored by Erik Strand's avatar Erik Strand
Browse files

Add networking page

parent ce5eaf77
No related branches found
No related tags found
No related merge requests found
+++
title = "Networking"
date = "2018-12-05"
menu = "main"
weight = 15
+++
Files: [audio_interface.sch](/designs/14_audio_interface.sch) [audio_interface.brd](/designs/14_audio_interface.brd)
This week we're making machines talk to each other. I've used I2C before, so want to venture into using USB to connect my own boards with computers.
## Board Design
For part of my final project I want to make my own USB audio recording device. So I'll try to develop all the necessary electronics this week. I have all the analog circuitry I need from [inputs week](../10_input_devices). But I don't have a board ready to go with a USB-capable microcontroller (bit-banging will not suffice, since I need the CPU to be available for audio processing). I've heard that [LUFA](http://www.fourwalledcubicle.com/LUFA.php) is much nicer than ATMEL's own USB [libraries](https://www.microchip.com/wwwAppNotes/AppNotes.aspx?appnote=en591207) so I'll try to use that. I'd like to use an XMEGA board, since they are fast, have a good amount of memory for audio applications, and I've used them [recently](../12_machine_week). LUFA's [XMEGA support](http://www.fourwalledcubicle.com/files/LUFA/Doc/120219/html/_page__x_m_e_g_a_support.html) is technically experimental, but people have been using it since [2013](https://www.avrfreaks.net/forum/lufa-xmega-hello-world). So I think it should be ok.
![](/img/14_schematic.png)
On the left I have my microcontroller. I'm using an external 16MHz crystal to give it an accurate clock signal. High speed USB 2.0 requires a 48Mhz clock, which I can get by multiplying the crystal's output by 3 using the XMEGA's phase locked loop (PLL). On top I have my power section, including a regulator to bump USB's 5V power down to 3.3V, some filtering capacitors, and a power indicator LED. The two circuit groups with op-amps together amplify and bias the audio input, as I learned in [inputs week](../10_input_devices). Finally I have some headers that provide convenient debugging access to certain signals, and a 0-ohm resistor I needed to connect all my ground signals.
![](/img/14_board.png)
Laying out the board took a long time, since this is the most complex circuit I've designed from scratch. I'm using thinner traces than before, so that they can reach all the XMEGA's pins without shorting and so that I can route multiple traces under a single 1206 component. I kept the USB signal traces as short as possible. One open question I have is what to do with the USB connector's shield. Plenty people have [asked](https://electronics.stackexchange.com/questions/4515/how-to-connect-usb-connector-shield) this [question](https://forum.allaboutcircuits.com/threads/usb-device-cable-shield-connection-grounding-it-or-not.58811/) online, but the answers are split between grounding it directly and connecting it to ground via a capacitor and a large (ex 1MΩ) resistor. I don't yet have the expertise to know which makes more sense in this situation. [This](https://www.ti.com/sc/docs/apps/msp/intrface/usb/emitest.pdf) document looks like it might help, but I haven't had time to read it all yet.
## Fabrication
I milled the board on a Roland SRM-20. For the most part the smaller traces worked fine. However the end of the power trace for the USB port did get pulled off. (The same is true for part of the 'S' in the text, but that won't require any jumper wires.)
![](/img/14_milled.jpg)
I soldered the XMEGA and the USB connector first, since I knew jumping the USB power wire and dealing with the tiny XMEGA traces would be the trickiest tasks. The XMEGA's leads are smaller than anything I'd soldered before, but it still went fine. Most of them I soldered individually, but in a few places I globed pins together and later removed the excess solder to unshort them. Generous amounts of flux were essential, since I used a very fine guage of solder that doesn't have a flux core. To connect the USB power, I took a small piece of wire and used it to jump directly from the USB conenctor pin to the trace. It was so short that it was almost impossible to solder one side without melting the other, but eventually I got it to stick in place with good quality joints on either side. (In the photo below it looks like it's shorted to the USB plug chassis, but this isn't the case.) After these I soldered on the minimal number of other components to get the power indicator LED working (ok, the crystal wasn't necessary but I had already taken it out).
![](/img/14_powered_on.jpg)
From here it was a routine soldering job.
![](/img/14_stuffed.jpg)
## Software
I started by flashing it with an empty hello world program, to verify that it could be programmed at all. Then I started writing the USB software. Unfortunately, disaster struck: I accidentally tore off the USB connector. I'm in the process of fixing this now.
![](/img/14_broken_connector.jpg)
This diff is collapsed.
This diff is collapsed.
static/img/14_board.png

99.4 KiB

static/img/14_broken_connector.jpg

109 KiB

static/img/14_milled.jpg

113 KiB

static/img/14_powered_on.jpg

114 KiB

static/img/14_schematic.png

156 KiB

static/img/14_stuffed.jpg

114 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment