Skip to content
mxmxmx edited this page Mar 5, 2017 · 61 revisions

ADC (mcp3208) doing ok?

A. compile ADC external (or simply run install.sh):

  • the following steps assume that 1) pd is installed and 2) the SPI device enabled (see here):

  • compile / install the spi external: [terminal_tedium_adc]:

    • first, run gcc:
    gcc -std=c99 -O3 -Wall -c terminal_tedium_adc.c -o terminal_tedium_adc.o
    
    • then ld:
    ld --export-dynamic -shared -o terminal_tedium_adc.pd_linux terminal_tedium_adc.o  -lc -lm -lwiringPi
    
    • then move the external to wherever your externals folder resides, e.g.
    sudo mv terminal_tedium_adc.pd_linux /home/pi/pd-0.47-1/extra/
    

B. test ADC:

  • locate the test patch called adc_test.pd on your pi.

  • the gist of the patch simply looks somewhat like this:

  • besides open (and close), terminal_tedium_adc has two additional methods: smooth and deadband. you can use them to de-jitter the ADC values. more details here.

  • if you have the wm8731 version, you can leave things as they are; if using the pcm5102a version, we need to read 8 channels, not just 6; we tell the external by sending not just [open( but [open adc(. (ie disconnect the message on the left, and connect the one on the right instead)

  • now run the patch (modified, if need be): e.g. sudo pd -rt -nogui -noadc -verbose adc_test.pd

  • this should print something to your shell: e.g. adc:: 1725 1159 2332 591 31 1471 0 0, where the values map onto the panel pots (1st pot = 1st position, 2nd pot = 2nd position, etc).

  • turning the knobs, you should see values from 0-4095 coming in. outputs 6 and 7, when using the pcm5102a version, should be steady at around 2048. (those are the two CV inputs without manual offset.) patch a lfo or the like into the CV jacks, to check they behave ok, too.

  • the values you see should be steady, ie not flipping around a great deal. if not, check your soldering or whether you didn't forget to solder something (caps, jacks, pots?). ditto if you don't get meaningful results.

  • Note: there's also a set of corresponding dummy-externals for osx, ie to make development of patches easier. Also note the [metro] object -- it needs a bang to read the ADC (hence metro); the message [open( opens the device:


  • alternatively, get the ADC-to-FUDI 'converter' thingie here: adc2FUDI.c, and move it onto your rpi (scp or use wget). it doesn't matter where it goes, choose/make a folder you like. ('FUDI' is the serial protocol used by pd: http://en.wikipedia.org/wiki/FUDI).

  • cd into that folder and compile it: in the terminal, run
    gcc adc2FUDI.c -lwiringPi -std=c99 -Wall -O3 -o adc2FUDI

  • the next steps assume both your rpi and notebook/computer are on the same network (wifi) or connected with an ethernet cable: on your (proper) computer, open up puredata and create a simple [netreceive] patch like the one below (example is using port 54321). the 6 resp. 8 ADC channels are prefixed with # 0-5 resp. # 0-7 (that's what adc2FUDI.c is doing), so we tap them with [route 0 1 2 3 4 5] resp. [route 0 1 2 3 4 5 6 7]

  • now run the little program above. ie: on your rpi, in the respective directory, run sudo ./adc2FUDI [IP-address] 54321 8 &, where [IP-address] the IP-address of your notebook (most likely something like 192.168.0.xx), 54321 is the port (matching netreceive), and 8 a variable selecting the hardware version / number of ADC channels (6 = wm8731 vs 8 = pcm5102a). (if you have a monitor connected to your raspberry, you could do the same with: sudo ./adc2FUDI 127.0.0.1 54321 8 &. in this case, you'd have to run the pd patch on your rpi, obviously)

  • terminal tedium / the ADC should now transmit to your computer. turning the knobs, you should see values from 0-4095 coming in (mapping is: top/bottom from left to right == 1-2/3-4/5-6). outputs 6 and 7, when using the pcm5102a version, should be steady at around 2048. those are the two CV inputs without manual offset. patch a lfo or the like into the CV jacks, to check they behave ok, too.

  • the values you see should be steady, ie not flipping around a great deal. if not, check your soldering or whether you didn't forget to solder something (caps, jacks, pots?). ditto if you don't get meaningful results.

  • if turning the knobs fully CCW doesn't get you down to zero, that'll be due to variations in the resistors. if you're annoyed by this, you could change the line #define RESOLUTION 4095 in the C program (the - inverted - ADC reading is subtracted from it. make sure you take care of cases when the difference is < 0). generally speaking though, it doesn't matter much.

Clone this wiki locally