<< Older Posts
Team Blog

Real-time audio processing is an example of an application where Maple really shines in comparison to Arduino. Maple has 12-bit ADCs with sample rates up to 1MSPS and PWM fast enough to clear ~11.8 bits of resolution (log2(72MHz/20kHz)=11.8) at a frequency twice the Nyquist frequency of the upper end of the bandwidth of the human ear (20kHz). And there’s a lot of clock cycles to do all kinds of really awesome stuff to the signal (e.g. echo, distortion, octave, harmony, equalization, flange, phaser, fuzz, ring modulation, and complete new imagined effects)! I drew up a schematic and layout in EAGLE and etched a PCB with two 1/8″ audio jacks, an adjustable preamp, input and output filters, and some potentiometers. Here’s a photo of the assembled shield and the schematic:

Note: The potentiometer knobs aren’t on the schematic; I hand wired them afterwards.

Here are the EAGLE schematic and board layout files for this board: audioshieldproto-r2-v1.sch audioshieldproto-r2-v1.brd

This can also be breadboarded with some increase in noise, but it’s not that bad for guitar. I made a similar board awhile ago that had no input filter, and it was a lot of fun, but I wanted to lower the noise floor of the system, which ends up sounding like a hiss in the background. To do this, I needed an input filter. Why? What happens is that the signal going into the ADC pin contains component frequencies above half the sampling rate of the ADC that get aliased back into the audible range. So any noise (environmental, digital transition, etc.) that contains frequencies above half the sample rate that’s around make the output noisier. The purpose of the analog input filter is to filter them out before they are digitized. This is what what the input filter looks like:

The filter is an active filter of the Sallen-Key topology. I used AD8452 op-amps that I got from Digi-Key, which is one of the few op-amps suitable for 3.3V single supply operation. Another good op-amp for this, which I’ll probably go with on the next version of this board, is the LM324, which is a quad op-amp (four in a package). This will make it easier and cheaper to build a higher order input filter. I modeled the filter I built on this board with LTSpice and this is what the frequency response looks like:

Here’s a link to the LTSpice schematic for the filter: sallen-keyinputlowpassfilter.asc

So what does it sound like? I’m obsessed with audio effects, but I don’t play guitar. I tried to play guitar for these recordings. Here’s a photo of the setup:

To record the effect, I simply connected the output to my computer instead of headphones or a guitar amplifier.

Here’s an mp3 of the guitar just being passed through with no effect:

audioshieldproto-passcleanguitar.mp3

This is where the knob that varies the mix between clean and the effect is turned about half-way up:

audioshieldproto-halfeffectguitar.mp3

Here’s full effect:

audioshieldproto-fulleffectguitar.mp3

These are with a sine and triangle wave input instead of a guitar and I turned the knob up and then down:

audioshieldproto-sinewave-turningknob.mp3

audioshieldproto-trianglewave-turningknob.mp3

I generated the sine and triangle waves with a signal generator app I downloaded onto an iPod Touch:


Notice the noise on all of these recordings. There are four main sources of this, which will be eliminated with more work. As mentioned, a higher input filter will rid of some noise. The code for the effect causes low amplitude signals are mapped to high amplitudes, which is another source of noise. This can be remedied by using a slightly different transfer function for the effect. A third source is from sampling an unbuffered 10k potentiometer. High-speed measurements made with the ADC require lower input impedances to achieve low noise. The reading of the potentiometer is being coupled to the input signal in the sketch for this effect by multiplying the reading by the input to derive the output. Most “control parameters” should probably be measured at a lower sample rate, and simply varying the mix of effect vs. no-effect is so common that it may should be a function that’s done completely in analog.

The final source of noise is really more of a systematic distortion. You might notice the non-gaussian sounding clicks/pops/ticks etc. This is likely due to timing irregularities in the sketch’s execution. While Maple is running the sketch, it gets interrupted a lot. For example, regular systick interrupts trigger the system timer to increment when using millis(), regular USB interrupts provide the SerialUSB functionality. An improved version of an audio application might remedy this by using DMA and timer features of the stm32. On the sampling side, this might include configuring the ADC’s to run in DMA mode, where they record samples into a buffer for you automatically without requiring any attention from the processor. You can then read from that buffer safe in the knowledge that the samples were captured at highly regular intervals (plus you save on processor time). On the output side, ideally we should be adjusting the PWM value at consistent intervals as well. To do this, we could configure a timer interrupt at high priority to guarantee an output event at fixed intervals such as 1/44000 of a second. These more advanced features are partially supported by the library in 0.0.6, and documentation is on the way. Check out the app notes from ST for more information on stuff that can be done to get the most out of the ADC systems onboard the stm32.

Here’s the sketch for the effect:

// Octave-ish/Harmonizer-ish Audio/Guitar Effect
// for handmade prototype audio effects Maple shield
// by okie and the leaf blowers

#define AIN 18
#define AOUT 6
#define POT 16

int knob = 0;
int signalin = 0;
int signalout = 0;

int iomap[] = {256, 259, 262, 265, 268, 271, 274, 277, 281, 284, 287, 290, 293,
296, 299, 302, 305, 309, 312, 315, 318, 321, 324, 327, 330, 333, 336, 339, 342,
345, 348, 351, 353, 356, 359, 362, 365, 368, 371, 373, 376, 379, 382, 384, 387,
390, 392, 395, 398, 400, 403, 405, 408, 411, 413, 415, 418, 420, 423, 425, 427,
430, 432, 434, 437, 439, 441, 443, 445, 447, 449, 451, 453, 455, 457, 459, 461,
463, 465, 467, 468, 470, 472, 473, 475, 477, 478, 480, 481, 483, 484, 486, 487,
488, 490, 491, 492, 493, 494, 495, 497, 498, 499, 500, 500, 501, 502, 503, 504,
505, 505, 506, 507, 507, 508, 508, 509, 509, 510, 510, 510, 511, 511, 511, 511,
511, 511, 511, 512, 511, 511, 511, 511, 511, 511, 511, 510, 510, 510, 509, 509,
508, 508, 507, 507, 506, 505, 505, 504, 503, 502, 501, 500, 500, 499, 498, 497,
495, 494, 493, 492, 491, 490, 488, 487, 486, 484, 483, 481, 480, 478, 477, 475,
473, 472, 470, 468, 467, 465, 463, 461, 459, 457, 455, 453, 451, 449, 447, 445,
443, 441, 439, 437, 434, 432, 430, 427, 425, 423, 420, 418, 415, 413, 411, 408,
405, 403, 400, 398, 395, 392, 390, 387, 384, 382, 379, 376, 373, 371, 368, 365,
362, 359, 356, 353, 351, 348, 345, 342, 339, 336, 333, 330, 327, 324, 321, 318,
315, 312, 309, 305, 302, 299, 296, 293, 290, 287, 284, 281, 277, 274, 271, 268,
265, 262, 259, 256, 252, 249, 246, 243, 240, 237, 234, 230, 227, 224, 221, 218,
215, 212, 209, 206, 202, 199, 196, 193, 190, 187, 184, 181, 178, 175, 172, 169,
166, 163, 160, 158, 155, 152, 149, 146, 143, 140, 138, 135, 132, 129, 127, 124,
121, 119, 116, 113, 111, 108, 106, 103, 100, 98, 96, 93, 91, 88, 86, 84, 81,
79, 77, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 43, 41,
39, 38, 36, 34, 33, 31, 30, 28, 27, 25, 24, 23, 21, 20, 19, 18, 17, 16, 14, 13,
12, 11, 11, 10, 9, 8, 7, 6, 6, 5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 6, 7, 8, 9, 10, 11,
11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 23, 24, 25, 27, 28, 30, 31, 33, 34, 36,
38, 39, 41, 43, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74,
77, 79, 81, 84, 86, 88, 91, 93, 96, 98, 100, 103, 106, 108, 111, 113, 116, 119,
121, 124, 127, 129, 132, 135, 138, 140, 143, 146, 149, 152, 155, 158, 160, 163,
166, 169, 172, 175, 178, 181, 184, 187, 190, 193, 196, 199, 202, 206, 209, 212,
215, 218, 221, 224, 227, 230, 234, 237, 240, 243, 246, 249, 252, 255, 259, 262,
265, 268, 271, 274, 277, 281, 284, 287, 290, 293, 296, 299, 302, 305, 309, 312,
315, 318, 321, 324, 327, 330, 333, 336, 339, 342, 345, 348, 351, 353, 356, 359,
362, 365, 368, 371, 373, 376, 379, 382, 384, 387, 390, 392, 395, 398, 400, 403,
405, 408, 411, 413, 415, 418, 420, 423, 425, 427, 430, 432, 434, 437, 439, 441,
443, 445, 447, 449, 451, 453, 455, 457, 459, 461, 463, 465, 467, 468, 470, 472,
473, 475, 477, 478, 480, 481, 483, 484, 486, 487, 488, 490, 491, 492, 493, 494,
495, 497, 498, 499, 500, 500, 501, 502, 503, 504, 505, 505, 506, 507, 507, 508,
508, 509, 509, 510, 510, 510, 511, 511, 511, 511, 511, 511, 511, 512, 511, 511,
511, 511, 511, 511, 511, 510, 510, 510, 509, 509, 508, 508, 507, 507, 506, 505,
505, 504, 503, 502, 501, 500, 500, 499, 498, 497, 495, 494, 493, 492, 491, 490,
488, 487, 486, 484, 483, 481, 480, 478, 477, 475, 473, 472, 470, 468, 467, 465,
463, 461, 459, 457, 455, 453, 451, 449, 447, 445, 443, 441, 439, 437, 434, 432,
430, 427, 425, 423, 420, 418, 415, 413, 411, 408, 405, 403, 400, 398, 395, 392,
390, 387, 384, 382, 379, 376, 373, 371, 368, 365, 362, 359, 356, 353, 351, 348,
345, 342, 339, 336, 333, 330, 327, 324, 321, 318, 315, 312, 309, 305, 302, 299,
296, 293, 290, 287, 284, 281, 277, 274, 271, 268, 265, 262, 259, 256, 252, 249,
246, 243, 240, 237, 234, 230, 227, 224, 221, 218, 215, 212, 209, 206, 202, 199,
196, 193, 190, 187, 184, 181, 178, 175, 172, 169, 166, 163, 160, 158, 155, 152,
149, 146, 143, 140, 138, 135, 132, 129, 127, 124, 121, 119, 116, 113, 111, 108,
106, 103, 100, 98, 96, 93, 91, 88, 86, 84, 81, 79, 77, 74, 72, 70, 68, 66, 64,
62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 43, 41, 39, 38, 36, 34, 33, 31, 30, 28,
27, 25, 24, 23, 21, 20, 19, 18, 17, 16, 14, 13, 12, 11, 11, 10, 9, 8, 7, 6, 6,
5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 16, 17, 18,
19, 20, 21, 23, 24, 25, 27, 28, 30, 31, 33, 34, 36, 38, 39, 41, 43, 44, 46, 48,
50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 77, 79, 81, 84, 86, 88, 91,
93, 96, 98, 100, 103, 106, 108, 111, 113, 116, 119, 121, 124, 127, 129, 132,
135, 138, 140, 143, 146, 149, 152, 155, 158, 160, 163, 166, 169, 172, 175, 178,
181, 184, 187, 190, 193, 196, 199, 202, 206, 209, 212, 215, 218, 221, 224, 227,
230, 234, 237, 240, 243, 246, 249, 252, 255, 259, 262, 265, 268, 271, 274, 277,
281, 284, 287, 290, 293, 296, 299, 302, 305, 309, 312, 315, 318, 321, 324, 327,
330, 333, 336, 339, 342, 345, 348, 351, 353, 356, 359, 362, 365, 368, 371, 373,
376, 379, 382, 384, 387, 390, 392, 395, 398, 400, 403, 405, 408, 411, 413, 415,
418, 420, 423, 425, 427, 430, 432, 434, 437, 439, 441, 443, 445, 447, 449, 451,
453, 455, 457, 459, 461, 463, 465, 467, 468, 470, 472, 473, 475, 477, 478, 480,
481, 483, 484, 486, 487, 488, 490, 491, 492, 493, 494, 495, 497, 498, 499, 500,
500, 501, 502, 503, 504, 505, 505, 506, 507, 507, 508, 508, 509, 509, 510, 510,
510, 511, 511, 511, 511, 511, 511, 511, 512, 511, 511, 511, 511, 511, 511, 511,
510, 510, 510, 509, 509, 508, 508, 507, 507, 506, 505, 505, 504, 503, 502, 501,
500, 500, 499, 498, 497, 495, 494, 493, 492, 491, 490, 488, 487, 486, 484, 483,
481, 480, 478, 477, 475, 473, 472, 470, 468, 467, 465, 463, 461, 459, 457, 455,
453, 451, 449, 447, 445, 443, 441, 439, 437, 434, 432, 430, 427, 425, 423, 420,
418, 415, 413, 411, 408, 405, 403, 400, 398, 395, 392, 390, 387, 384, 382, 379,
376, 373, 371, 368, 365, 362, 359, 356, 353, 351, 348, 345, 342, 339, 336, 333,
330, 327, 324, 321, 318, 315, 312, 309, 305, 302, 299, 296, 293, 290, 287, 284,
281, 277, 274, 271, 268, 265, 262, 259, 256, 252, 249, 246, 243, 240, 237, 234,
230, 227, 224, 221, 218, 215, 212, 209, 206, 202, 199, 196, 193, 190, 187, 184,
181, 178, 175, 172, 169, 166, 163, 160, 158, 155, 152, 149, 146, 143, 140, 138,
135, 132, 129, 127, 124, 121, 119, 116, 113, 111, 108, 106, 103, 100, 98, 96,
93, 91, 88, 86, 84, 81, 79, 77, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52,
50, 48, 46, 44, 43, 41, 39, 38, 36, 34, 33, 31, 30, 28, 27, 25, 24, 23, 21, 20,
19, 18, 17, 16, 14, 13, 12, 11, 11, 10, 9, 8, 7, 6, 6, 5, 4, 4, 3, 3, 2, 2, 1,
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 4, 4,
5, 6, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 23, 24, 25,
27, 28, 30, 31, 33, 34, 36, 38, 39, 41, 43, 44, 46, 48, 50, 52, 54, 56, 58, 60,
62, 64, 66, 68, 70, 72, 74, 77, 79, 81, 84, 86, 88, 91, 93, 96, 98, 100, 103,
106, 108, 111, 113, 116, 119, 121, 124, 127, 129, 132, 135, 138, 140, 143, 146,
149, 152, 155, 158, 160, 163, 166, 169, 172, 175, 178, 181, 184, 187, 190, 193,
196, 199, 202, 206, 209, 212, 215, 218, 221, 224, 227, 230, 234, 237, 240, 243,
246, 249, 252, 255, 259, 262, 265, 268, 271, 274, 277, 281, 284, 287, 290, 293,
296, 299, 302, 305, 309, 312, 315, 318, 321, 324, 327, 330, 333, 336, 339, 342,
345, 348, 351, 353, 356, 359, 362, 365, 368, 371, 373, 376, 379, 382, 384, 387,
390, 392, 395, 398, 400, 403, 405, 408, 411, 413, 415, 418, 420, 423, 425, 427,
430, 432, 434, 437, 439, 441, 443, 445, 447, 449, 451, 453, 455, 457, 459, 461,
463, 465, 467, 468, 470, 472, 473, 475, 477, 478, 480, 481, 483, 484, 486, 487,
488, 490, 491, 492, 493, 494, 495, 497, 498, 499, 500, 500, 501, 502, 503, 504,
505, 505, 506, 507, 507, 508, 508, 509, 509, 510, 510, 510, 511, 511, 511, 511,
511, 511, 511, 512, 511, 511, 511, 511, 511, 511, 511, 510, 510, 510, 509, 509,
508, 508, 507, 507, 506, 505, 505, 504, 503, 502, 501, 500, 500, 499, 498, 497,
495, 494, 493, 492, 491, 490, 488, 487, 486, 484, 483, 481, 480, 478, 477, 475,
473, 472, 470, 468, 467, 465, 463, 461, 459, 457, 455, 453, 451, 449, 447, 445,
443, 441, 439, 437, 434, 432, 430, 427, 425, 423, 420, 418, 415, 413, 411, 408,
405, 403, 400, 398, 395, 392, 390, 387, 384, 382, 379, 376, 373, 371, 368, 365,
362, 359, 356, 353, 351, 348, 345, 342, 339, 336, 333, 330, 327, 324, 321, 318,
315, 312, 309, 305, 302, 299, 296, 293, 290, 287, 284, 281, 277, 274, 271, 268,
265, 262, 259, 255, 252, 249, 246, 243, 240, 237, 234, 230, 227, 224, 221, 218,
215, 212, 209, 206, 202, 199, 196, 193, 190, 187, 184, 181, 178, 175, 172, 169,
166, 163, 160, 158, 155, 152, 149, 146, 143, 140, 138, 135, 132, 129, 127, 124,
121, 119, 116, 113, 111, 108, 106, 103, 100, 98, 96, 93, 91, 88, 86, 84, 81,
79, 77, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 43, 41,
39, 38, 36, 34, 33, 31, 30, 28, 27, 25, 24, 23, 21, 20, 19, 18, 17, 16, 14, 13,
12, 11, 11, 10, 9, 8, 7, 6, 6, 5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 6, 7, 8, 9, 10, 11,
11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 23, 24, 25, 27, 28, 30, 31, 33, 34, 36,
38, 39, 41, 43, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74,
77, 79, 81, 84, 86, 88, 91, 93, 96, 98, 100, 103, 106, 108, 111, 113, 116, 119,
121, 124, 127, 129, 132, 135, 138, 140, 143, 146, 149, 152, 155, 158, 160, 163,
166, 169, 172, 175, 178, 181, 184, 187, 190, 193, 196, 199, 202, 206, 209, 212,
215, 218, 221, 224, 227, 230, 234, 237, 240, 243, 246, 249, 252, 255, 259, 262,
265, 268, 271, 274, 277, 281, 284, 287, 290, 293, 296, 299, 302, 305, 309, 312,
315, 318, 321, 324, 327, 330, 333, 336, 339, 342, 345, 348, 351, 353, 356, 359,
362, 365, 368, 371, 373, 376, 379, 382, 384, 387, 390, 392, 395, 398, 400, 403,
405, 408, 411, 413, 415, 418, 420, 423, 425, 427, 430, 432, 434, 437, 439, 441,
443, 445, 447, 449, 451, 453, 455, 457, 459, 461, 463, 465, 467, 468, 470, 472,
473, 475, 477, 478, 480, 481, 483, 484, 486, 487, 488, 490, 491, 492, 493, 494,
495, 497, 498, 499, 500, 500, 501, 502, 503, 504, 505, 505, 506, 507, 507, 508,
508, 509, 509, 510, 510, 510, 511, 511, 511, 511, 511, 511, 511, 512, 511, 511,
511, 511, 511, 511, 511, 510, 510, 510, 509, 509, 508, 508, 507, 507, 506, 505,
505, 504, 503, 502, 501, 500, 500, 499, 498, 497, 495, 494, 493, 492, 491, 490,
488, 487, 486, 484, 483, 481, 480, 478, 477, 475, 473, 472, 470, 468, 467, 465,
463, 461, 459, 457, 455, 453, 451, 449, 447, 445, 443, 441, 439, 437, 434, 432,
430, 427, 425, 423, 420, 418, 415, 413, 411, 408, 405, 403, 400, 398, 395, 392,
390, 387, 384, 382, 379, 376, 373, 371, 368, 365, 362, 359, 356, 353, 351, 348,
345, 342, 339, 336, 333, 330, 327, 324, 321, 318, 315, 312, 309, 305, 302, 299,
296, 293, 290, 287, 284, 281, 277, 274, 271, 268, 265, 262, 259, 255, 252, 249,
246, 243, 240, 237, 234, 230, 227, 224, 221, 218, 215, 212, 209, 206, 202, 199,
196, 193, 190, 187, 184, 181, 178, 175, 172, 169, 166, 163, 160, 158, 155, 152,
149, 146, 143, 140, 138, 135, 132, 129, 127, 124, 121, 119, 116, 113, 111, 108,
106, 103, 100, 98, 96, 93, 91, 88, 86, 84, 81, 79, 77, 74, 72, 70, 68, 66, 64,
62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 43, 41, 39, 38, 36, 34, 33, 31, 30, 28,
27, 25, 24, 23, 21, 20, 19, 18, 17, 16, 14, 13, 12, 11, 11, 10, 9, 8, 7, 6, 6,
5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 16, 17, 18,
19, 20, 21, 23, 24, 25, 27, 28, 30, 31, 33, 34, 36, 38, 39, 41, 43, 44, 46, 48,
50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 77, 79, 81, 84, 86, 88, 91,
93, 96, 98, 100, 103, 106, 108, 111, 113, 116, 119, 121, 124, 127, 129, 132,
135, 138, 140, 143, 146, 149, 152, 155, 158, 160, 163, 166, 169, 172, 175, 178,
181, 184, 187, 190, 193, 196, 199, 202, 206, 209, 212, 215, 218, 221, 224, 227,
230, 234, 237, 240, 243, 246, 249, 252, 255, 259, 262, 265, 268, 271, 274, 277,
281, 284, 287, 290, 293, 296, 299, 302, 305, 309, 312, 315, 318, 321, 324, 327,
330, 333, 336, 339, 342, 345, 348, 351, 353, 356, 359, 362, 365, 368, 371, 373,
376, 379, 382, 384, 387, 390, 392, 395, 398, 400, 403, 405, 408, 411, 413, 415,
418, 420, 423, 425, 427, 430, 432, 434, 437, 439, 441, 443, 445, 447, 449, 451,
453, 455, 457, 459, 461, 463, 465, 467, 468, 470, 472, 473, 475, 477, 478, 480,
481, 483, 484, 486, 487, 488, 490, 491, 492, 493, 494, 495, 497, 498, 499, 500,
500, 501, 502, 503, 504, 505, 505, 506, 507, 507, 508, 508, 509, 509, 510, 510,
510, 511, 511, 511, 511, 511, 511, 511, 512, 511, 511, 511, 511, 511, 511, 511,
510, 510, 510, 509, 509, 508, 508, 507, 507, 506, 505, 505, 504, 503, 502, 501,
500, 500, 499, 498, 497, 495, 494, 493, 492, 491, 490, 488, 487, 486, 484, 483,
481, 480, 478, 477, 475, 473, 472, 470, 468, 467, 465, 463, 461, 459, 457, 455,
453, 451, 449, 447, 445, 443, 441, 439, 437, 434, 432, 430, 427, 425, 423, 420,
418, 415, 413, 411, 408, 405, 403, 400, 398, 395, 392, 390, 387, 384, 382, 379,
376, 373, 371, 368, 365, 362, 359, 356, 353, 351, 348, 345, 342, 339, 336, 333,
330, 327, 324, 321, 318, 315, 312, 309, 305, 302, 299, 296, 293, 290, 287, 284,
281, 277, 274, 271, 268, 265, 262, 259, 256, 252, 249, 246, 243, 240, 237, 234,
230, 227, 224, 221, 218, 215, 212, 209, 206, 202, 199, 196, 193, 190, 187, 184,
181, 178, 175, 172, 169, 166, 163, 160, 158, 155, 152, 149, 146, 143, 140, 138,
135, 132, 129, 127, 124, 121, 119, 116, 113, 111, 108, 106, 103, 100, 98, 96,
93, 91, 88, 86, 84, 81, 79, 77, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52,
50, 48, 46, 44, 43, 41, 39, 38, 36, 34, 33, 31, 30, 28, 27, 25, 24, 23, 21, 20,
19, 18, 17, 16, 14, 13, 12, 11, 11, 10, 9, 8, 7, 6, 6, 5, 4, 4, 3, 3, 2, 2, 1,
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 4, 4,
5, 6, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 23, 24, 25,
27, 28, 30, 31, 33, 34, 36, 38, 39, 41, 43, 44, 46, 48, 50, 52, 54, 56, 58, 60,
62, 64, 66, 68, 70, 72, 74, 77, 79, 81, 84, 86, 88, 91, 93, 96, 98, 100, 103,
106, 108, 111, 113, 116, 119, 121, 124, 127, 129, 132, 135, 138, 140, 143, 146,
149, 152, 155, 158, 160, 163, 166, 169, 172, 175, 178, 181, 184, 187, 190, 193,
196, 199, 202, 206, 209, 212, 215, 218, 221, 224, 227, 230, 234, 237, 240, 243,
246, 249, 252, 255, 259, 262, 265, 268, 271, 274, 277, 281, 284, 287, 290, 293,
296, 299, 302, 305, 309, 312, 315, 318, 321, 324, 327, 330, 333, 336, 339, 342,
345, 348, 351, 353, 356, 359, 362, 365, 368, 371, 373, 376, 379, 382, 384, 387,
390, 392, 395, 398, 400, 403, 405, 408, 411, 413, 415, 418, 420, 423, 425, 427,
430, 432, 434, 437, 439, 441, 443, 445, 447, 449, 451, 453, 455, 457, 459, 461,
463, 465, 467, 468, 470, 472, 473, 475, 477, 478, 480, 481, 483, 484, 486, 487,
488, 490, 491, 492, 493, 494, 495, 497, 498, 499, 500, 500, 501, 502, 503, 504,
505, 505, 506, 507, 507, 508, 508, 509, 509, 510, 510, 510, 511, 511, 511, 511,
511, 511, 511, 512, 511, 511, 511, 511, 511, 511, 511, 510, 510, 510, 509, 509,
508, 508, 507, 507, 506, 505, 505, 504, 503, 502, 501, 500, 500, 499, 498, 497,
495, 494, 493, 492, 491, 490, 488, 487, 486, 484, 483, 481, 480, 478, 477, 475,
473, 472, 470, 468, 467, 465, 463, 461, 459, 457, 455, 453, 451, 449, 447, 445,
443, 441, 439, 437, 434, 432, 430, 427, 425, 423, 420, 418, 415, 413, 411, 408,
405, 403, 400, 398, 395, 392, 390, 387, 384, 382, 379, 376, 373, 371, 368, 365,
362, 359, 356, 353, 351, 348, 345, 342, 339, 336, 333, 330, 327, 324, 321, 318,
315, 312, 309, 305, 302, 299, 296, 293, 290, 287, 284, 281, 277, 274, 271, 268,
265, 262, 259, 255, 252, 249, 246, 243, 240, 237, 234, 230, 227, 224, 221, 218,
215, 212, 209, 206, 202, 199, 196, 193, 190, 187, 184, 181, 178, 175, 172, 169,
166, 163, 160, 158, 155, 152, 149, 146, 143, 140, 138, 135, 132, 129, 127, 124,
121, 119, 116, 113, 111, 108, 106, 103, 100, 98, 96, 93, 91, 88, 86, 84, 81,
79, 77, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 43, 41,
39, 38, 36, 34, 33, 31, 30, 28, 27, 25, 24, 23, 21, 20, 19, 18, 17, 16, 14, 13,
12, 11, 11, 10, 9, 8, 7, 6, 6, 5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 6, 7, 8, 9, 10, 11,
11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 23, 24, 25, 27, 28, 30, 31, 33, 34, 36,
38, 39, 41, 43, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74,
77, 79, 81, 84, 86, 88, 91, 93, 96, 98, 100, 103, 106, 108, 111, 113, 116, 119,
121, 124, 127, 129, 132, 135, 138, 140, 143, 146, 149, 152, 155, 158, 160, 163,
166, 169, 172, 175, 178, 181, 184, 187, 190, 193, 196, 199, 202, 206, 209, 212,
215, 218, 221, 224, 227, 230, 234, 237, 240, 243, 246, 249, 252, 255, 259, 262,
265, 268, 271, 274, 277, 281, 284, 287, 290, 293, 296, 299, 302, 305, 309, 312,
315, 318, 321, 324, 327, 330, 333, 336, 339, 342, 345, 348, 351, 353, 356, 359,
362, 365, 368, 371, 373, 376, 379, 382, 384, 387, 390, 392, 395, 398, 400, 403,
405, 408, 411, 413, 415, 418, 420, 423, 425, 427, 430, 432, 434, 437, 439, 441,
443, 445, 447, 449, 451, 453, 455, 457, 459, 461, 463, 465, 467, 468, 470, 472,
473, 475, 477, 478, 480, 481, 483, 484, 486, 487, 488, 490, 491, 492, 493, 494,
495, 497, 498, 499, 500, 500, 501, 502, 503, 504, 505, 505, 506, 507, 507, 508,
508, 509, 509, 510, 510, 510, 511, 511, 511, 511, 511, 511, 511, 512, 511, 511,
511, 511, 511, 511, 511, 510, 510, 510, 509, 509, 508, 508, 507, 507, 506, 505,
505, 504, 503, 502, 501, 500, 500, 499, 498, 497, 495, 494, 493, 492, 491, 490,
488, 487, 486, 484, 483, 481, 480, 478, 477, 475, 473, 472, 470, 468, 467, 465,
463, 461, 459, 457, 455, 453, 451, 449, 447, 445, 443, 441, 439, 437, 434, 432,
430, 427, 425, 423, 420, 418, 415, 413, 411, 408, 405, 403, 400, 398, 395, 392,
390, 387, 384, 382, 379, 376, 373, 371, 368, 365, 362, 359, 356, 353, 351, 348,
345, 342, 339, 336, 333, 330, 327, 324, 321, 318, 315, 312, 309, 305, 302, 299,
296, 293, 290, 287, 284, 281, 277, 274, 271, 268, 265, 262, 259, 256, 252, 249,
246, 243, 240, 237, 234, 230, 227, 224, 221, 218, 215, 212, 209, 206, 202, 199,
196, 193, 190, 187, 184, 181, 178, 175, 172, 169, 166, 163, 160, 158, 155, 152,
149, 146, 143, 140, 138, 135, 132, 129, 127, 124, 121, 119, 116, 113, 111, 108,
106, 103, 100, 98, 96, 93, 91, 88, 86, 84, 81, 79, 77, 74, 72, 70, 68, 66, 64,
62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 43, 41, 39, 38, 36, 34, 33, 31, 30, 28,
27, 25, 24, 23, 21, 20, 19, 18, 17, 16, 14, 13, 12, 11, 11, 10, 9, 8, 7, 6, 6,
5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 16, 17, 18,
19, 20, 21, 23, 24, 25, 27, 28, 30, 31, 33, 34, 36, 38, 39, 41, 43, 44, 46, 48,
50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 77, 79, 81, 84, 86, 88, 91,
93, 96, 98, 100, 103, 106, 108, 111, 113, 116, 119, 121, 124, 127, 129, 132,
135, 138, 140, 143, 146, 149, 152, 155, 158, 160, 163, 166, 169, 172, 175, 178,
181, 184, 187, 190, 193, 196, 199, 202, 206, 209, 212, 215, 218, 221, 224, 227,
230, 234, 237, 240, 243, 246, 249, 252};

void setup() {
  pinMode(AIN, INPUT_ANALOG);
  pinMode(AOUT, PWM);
  pinMode(POT, INPUT_ANALOG);

  // make PWM frequency at least greater than two times the upper end of the
  // signal bandwidth (signal bandwidth: ~20-20000Hz)
  timers_set_reload(1, 0x0200);
}

void loop() {
  signalin = analogRead(AIN);
  knob = analogRead(POT);

  // output: mix raw input and the input mapped to a sine wave stored in iomap
  // where the mix is weighted by the knob 
  // also: 
  //   - scale raw input term by 8 to convert 12-bit ADC reading to 9-bit PWM
  //   - iomap already scales the signal by 8, but scale by 8 again because its
  //     shape is natually louder than raw signal 
  //   - scale both terms by the range of the knob reading, 4096 
  //   - divide by 2 because two full scale signals are summed

  signalout = (signalin*knob/8 + iomap[signalin]*(4096-knob)/4)/4096/2;
  pwmWrite(AOUT,signalout);
}

This sketch is just a quick, easy way to do what it does. Many optimizations can be made for memory, speed, and using timers to make readings and output to PWM would reduce distortion. The main function of this code is to map every possible input value to a different output, which is a really simple concept that can create a slew of neat effects, many which are very common. Here’s a neat webpage about it: http://web.inter.nl.net/hcc/davies/apmicro.html

The mapping being done by my sketch is stored in the array called “iomap”. I computed this array with a simple Python script. Here’s a graph of the map and the script:

Python script: iomapgenerator.py

The horizontal axis is input and the vertical axis is output. I think the behavior of this mapping is interesting. A very low amplitude sine wave is simply amplified but as the amplitude becomes larger, it gets transformed into sine waves with frequencies that are octaves above it.

We’re interested in your comments and ideas! And if you’re interested in continued development on a shield for this stuff, let us know.

Posted by okie on Saturday, July 24th, 2010 | 4 Comments »

It’s been a long week coming, but the latest/greatest version of the IDE has been released; get it now from the install page or the following direct links. If you’re upgrading, you can just back up your old IDE directory and extract the archive to the same place.

Most of the changes were in libmaple; the primary focus was on fixing SerialUSB issues (blocking and autoreset), squashing bugs, and adding interrupt support to the hardware timers.

Fixed SerialUSB.print() blocking issue

Usercode would frequently not run when disconnected from a serial port monitor; now it should at least run slowly. See USB docs for more details; in the long run we intend to add even more flexibility here.

Changed USB reset scheme

Hopefully fixes some issues with auto-reset on Windows XP.

init() called earlier (thanks xttocs!)

This should help porting some libraries.

New Makefile scheme for libmaple

Smarter, less magical, rules based Makefile system.

Improved udev rule

Hopefully fixes some issues for Ubuntu 10.04 users.

SerialN.end() and SerialN.flush() methods

By popular request!

New Timer class for configuring interrupts with the hardware timers

Whole bunch of goodness! See the docs.

More

Many documentation updates, new highlighted keywords, and examples for Serial passthrough, the timers, SerialUSB, and crude VGA.

For a complete list of changes see these github changelogs for the IDE and libmaple.

Please post your successes, failures, comments, and condolances in this forum thread, and have a productive weekend!

Posted by bnewbold on Thursday, July 22nd, 2010 | No Comments »

While debugging our new SerialUSB implementation I needed to use the regular Serial2 interface to track down ASSERT failures, but couldn’t find a spare FTDI chip around the lab. I’ve got one of these super slick little ones in the mail, but in the meanwhile I wrote this sketch in about 2 seconds which turns a spare Maple into a Serial-USB passthrough:

void setup() {
  Serial2.begin(9600);
}

void loop() {
  if(SerialUSB.available()) {
    Serial2.write(SerialUSB.read());
  }
  if(Serial2.available()) {
    SerialUSB.write(Serial2.read());
  }
}

There are a million better ways to do this but I love how easy this was!

Posted by bnewbold on Sunday, July 18th, 2010 | No Comments »

We got a big new batch of Maple rev3 boards in a couple days ago… we got Nintendo style with this batch and have pushed the heck out of the buttons on every board we will ship to make sure they aren’t “sticky”; doves cried tears of sorrow when a few people got finiky boards in the last batch. We also built a head-crab style zombie Maple to test the connectivity of every single GPIO pin:

These boards are on sale in our shop and now also available through our first distributor RobotShop. Check out the awesome Maple graphic they made! If you’re a distributor who would like to stock Maple we’d love to talk to you, especially if you are overseas; hit up our contact form.

I finally wrote up a quickstart for programming the Maple from the Unix command line; this setup makes it easier to track the most recent changes to libmaple and even contribute patches. As a bonus I also got Code::Blocks working as an alternative to the Maple IDE:

We’ll leave you with this kick ass project video from Okie; what kinds of hackery have you been up to with your Maples?


Posted by bnewbold on Friday, June 18th, 2010 | No Comments »

New Maple IDE release today, direct links below!

This is notable as our first Mac OSX 10.6 release (finally!), and hopefully the last version before a stable and consitent 0.1.0 release. Other changes include getting rid of “HardwareUsb” (use the already-instantiated “SerialUSB” instead), a much more robust reset scheme (including a DFU search period that shoudl fix timing issues many people were having), and a “less blocking” Serial-over-USB implementation.

Note that for the first program upload with with this new release you may have to put your Maple in “perpetual bootloader mode” by holding the BUT button immediately after releasing the RESET button; you would only have to do this once. More details in the linked forum post linked at the bottom.

We tested on all the computers we had around the office but there are tons of details and incompatabilities out there, plese let us know in the forums if you have any problems! I’ll kick things off with some known issues in this thread.

Have a great weekend, and happy hacking!

Posted by bnewbold on Friday, June 11th, 2010 | 2 Comments »

So way back when, after we announced that Maple was moving to a four-layer design, several of you suggested that we give KiCad a try. KiCad is open source under GPL, and (unlike the free version of Eagle) plays nicely with four-layer designs, which are both, you know, pretty good things, so we decided to give it a whirl for the design of Maple Native[1].

Overall, it went pretty well – the software is reasonably intuitive and I didn’t encounter any huge blocking issues. The assorted “getting started” resources out there are pretty comprehensive. Obviously there are glitches and idiosyncrasies that take some getting used to. KiCad seems to have a large user community which was invaluable for dealing with problems beyond the level of the readily available documentation, but I found it to be pretty scattered which can make ferreting out solutions difficult.

One of my biggest annoyances was the way KiCad handles via connectivity to zones. If you’re trying to connect a trace to a power plane on another layer, you can’t simply place a via to the power plane. Before doing a zone fill on the power plane, you must go in and manually connect all the vias on the power plane layer to one another, and then to the zone fill, which essentially “covers” all the traces you just drew. It’s not a huge time sink, but I can’t think of any reason it’s a good idea to do it this way, and it took me a long time to figure out that yes, this is actually the way it’s supposed to work.

Hotkeys also gave me some grief. I’m running KiCad in an Ubuntu VM on a Mac (complete with silly little Mac chiclet keyboard and mouse) so a lot of the hotkeys didn’t work properly out of the box, and nobody seems to be able to get editing the hotkeys config file to work properly. Even lacking certain hotkeys routing was still reasonably painless, however, which is pretty impressive. The “hug traces” function is nice.

Setting drill sizes was also sort of obnoxious. There doesn’t appear to be a way to select a via and find out and/or edit what its drill size is. You can only choose to set it to default or alt, which means you can only have two possible drill sizes for vias, maybe…? And changing the default drill size seems to go back and change all the vias you’ve already placed, maybe…? To be honest by this point in the design process I had routing-brain a little too badly to figure out the software and ended up just editing the .drl file by hand which of course was a wee bit buggy. I’ll have to better figure out how KiCad handles drill sizes before we spin the next prototype, so if anyone has any tricks they want to share, please do.

So what about you guys? KiCad users, weigh in!

[1]: We’re getting a lot of inquiries about timeline for Maple Native, so I just want to reiterate: we’re chugging away as fast as we can, but we don’t feel comfortable committing to a release date just yet. We’ve got a prototype in our hot little hands, and right now we’re at the “basic functionality” stage of testing. One major item still on the to-do list is bringing up the FSMC bus for the memory chip, and then, you know, fixing the myriad problems with the board design that will undoubtedly come up during testing. Extrapolate from that as you will.

Posted by jessb on Thursday, June 10th, 2010 | 2 Comments »



Contact webmaster@leaflabs.com with website issues

Powered by WordPress, nginx, Linux, vim, and coffee.

This site intended to be valid HTML 4.01 Strict. Best viewed with any standards-compliant browser.

Copyright LeafLabs LLC, 2009-2010.
Unless otherwise noted all content on this website is released under the Creative Commons Attribution Licence 3.0

Hello Anonymous! Login?