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

Update inputs page

parent 05af1f99
No related branches found
No related tags found
No related merge requests found
...@@ -12,27 +12,20 @@ This week we're exploring input devices, so our microcontrollers can start sensi ...@@ -12,27 +12,20 @@ This week we're exploring input devices, so our microcontrollers can start sensi
### Design Considerations ### Design Considerations
For my final project I plan on winding my own pickups, but I'd like to start by interfacing with existing ones so I can be certain that they work. So my goal is to read the signal from the pickups on my bass guitar, a five string Musicman Stingray. For my final project I plan on winding my own pickups, but I'd like to start by interfacing with existing ones so I can be certain that they work. So my goal is to read the signal from the pickups on my bass guitar.
The pickups generate an analog electrical signal, so the most direct way to read their output is with the ADC found on pretty much any microcontroller. But there are a few complications. First, the raw signal from my bass is probably in the hundreds of millivolts range, but to get the most out of the ADC's bit depth I'd like its maximum peak-to-peak amplitude to span almost the full difference between VCC and GND. Second, the pickups produce a signal with no DC bias. The ADCs on many microcontrollers don't read negative voltages, so I may need to add a DC bias of 0.5 * VCC. Alternatively, I can find a microcontroller with an ADC that supports bipolar input (whether single-ended or differential). The pickups generate an analog electrical signal, so the most direct way to read their output is with the ADC found on pretty much any microcontroller. But there are a few complications. First, the raw signal from my bass is probably in the hundreds of millivolts range, but to get the most out of the ADC's bit depth I'd like its maximum peak-to-peak amplitude to span almost the full difference between VCC and GND. Second, the pickups produce a signal with no DC bias. The ADCs on many microcontrollers don't read negative voltages, so I may need to add a DC bias of 0.5 * VCC. Alternatively, I can find a microcontroller with an ADC that supports bipolar input (whether single-ended or differential).
### A note on processors
At this point I'm reasonably certain I will use an ATMEL SAMD51 microcontroller for my final project, but to get started with audio sampling I'm going to explore the functionality of the ATTINY44A. It's a lot easier to program, and should teach me some things that I might otherwise miss in the SAMD51's more complex datasheet.
For maximum resolution (10 bits), the ATTINY44A's ADC desires a clock input of 50kHz to 200kHz. A single conversion takes 13 ADC clock cycles, which means that the maximum sampling frequency is about 15kHz (section 16.5 of the datasheet). This is a bit slow for audio, but is sufficient for my current test purposes.
### Circuit Design ### Circuit Design
To gain experience with analog circuitry, I'm going to make an off-chip preamp stage that boosts the signal and provides a DC offset. Instead of adding a microcontroller to this board, I plan on connecting it to my existing board using an ISP header. This will save me some soldering, and will allow me to test the same preamp stage with different microcontrollers. To gain experience with analog circuitry, I'm going to make an off-chip preamp that boosts the signal and provides a DC offset. Instead of adding a microcontroller to this board, I plan on connecting it to my existing board using an ISP header. This will save me some soldering, and will allow me to test the same preamp stage with different microcontrollers.
I mostly followed Amanda's [Instructables article](https://www.instructables.com/id/Arduino-Audio-Input/), but added some modifications I found on [Electronics Stackexchange](https://electronics.stackexchange.com/questions/14404/dc-biasing-audio-signal). To amplify the signal, I use an op-amp in a non-inverting configuration, and to provide a DC offset I pass the amplified signal through a capacitor that's connected to a voltage divider circuit. I mostly followed Amanda's [Instructables article](https://www.instructables.com/id/Arduino-Audio-Input/), but added some modifications I found on [Electronics Stackexchange](https://electronics.stackexchange.com/questions/14404/dc-biasing-audio-signal). To amplify the signal, I use an op-amp in a non-inverting configuration, and to provide a DC offset I pass the amplified signal through a capacitor that's connected to a voltage divider circuit.
![](/img/10_schematic.png) ![](/img/10_schematic.png)
I think I found a pretty good layout for the board. By routing signals underneath capacitors and resistors, I can keep the traces pretty short. I did have to cheat a little with the design rules: mods is generally happier when the clearances are much larger than the diameter of the end mill, but using these rules globally would prevent me from routing under components. So I changed the design rules as I worked. I think I found a pretty good layout for the board. By routing signals underneath capacitors and resistors, I can keep the traces pretty short. As you can see I cheat a little with the design rules: mods is generally happier when the clearances are much larger than the diameter of the end mill, but using these rules globally would prevent me from routing under standard 1206 components (edit: not sure why I didn't use the 1206FAB variants here...). So I changed the design rules as I worked.
![](/img/10_board.png) ![](/img/10_board.png)
...@@ -54,7 +47,7 @@ Upon closer inspection, however, it's clear that my amplification isn't linear. ...@@ -54,7 +47,7 @@ Upon closer inspection, however, it's clear that my amplification isn't linear.
### Sampling ### Sampling
Finally I connected the output of my preamplifer to a spare input on my microcontroller board. Ignoring for the moment the strange preamp behavior, I connected the output of my preamplifer to a spare input on my microcontroller board.
![](/img/10_isp_reuse.jpg) ![](/img/10_isp_reuse.jpg)
...@@ -124,3 +117,21 @@ int main(void) { ...@@ -124,3 +117,21 @@ int main(void) {
This reads samples and spits them out over the serial connection. This reads samples and spits them out over the serial connection.
![](/img/10_oscillations.png) ![](/img/10_oscillations.png)
## Circuit Design Rev2
A friend pointed me to Mark Feldmeier's wonderful [op-amp guide](https://ocw.mit.edu/courses/media-arts-and-sciences/mas-836-sensor-technologies-for-interactive-environments-spring-2011/readings/MITMAS_836S11_read02_bias.pdf), which I relied on heavily for a total redesign of my preamp. It includes a number of improvements. First, my voltage divider gets a buffer (i.e. an op-amp wired so that its output is always the same voltage as its input). Once I'm processing audio from multiple strings at once, this will help prevent crosstalk via the bias voltage rail. I'm also biasing my signal before amplification, which means the bias voltage rail is only connected to the high-impedance op-amp inputs, and that the low-impedance op-amp output can be used directly.
![](/img/10_preamp_v2.jpg)
I also made a number of improvements for my instrumentation. I connected header pins not just to the output, but also to both sides of the guitar input and my bias voltage. This should help with debugging if there are still problems. I also soldered some jumper wires to proper audio jacks, so that I can plug my bass in without clips.
Picture here...
This board's output looks a lot better than the previous one's.
![](/img/10_better_amplification.png)
I decided to plug it into my audio interface so I could listen to the output directly. It [sounds](/audio/10_bass_test.mp3) just like the untreated output of my bass.
File added
static/img/10_better_amplification.png

63.3 KiB

static/img/10_preamp_v2.jpg

93.6 KiB

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