Page 1 of 1

Use LoP-Parameters with PureData

Posted: Fri Sep 06, 2013 8:16 am
by RoyBear
Hi Guys & Gals,

I got me a Lots of Pots, soldered the Pins and Pots, strapped some other Buttons and Encoder and a Friend set me an Environment, i could work with.
He used Arch Linux, installed a GUI, phyton2 and PureData with all the stuff you need to work with (including ALSA and Jack).
Then he wrote down the Pyhton code and showed me how it works. Fine.

But thats all i know 'bout that stuff :(

could someone tell me how i could "tunnel" the Parameters of that codesample to PureData, so i could use them as classic midi-data?

i don't even know if this Forum is the right place, but i thought that it should be a good start :)


Re: Use LoP-Parameters with PureData

Posted: Sat Oct 05, 2013 12:13 pm
by paul

Shawn is working on an example and tutorial for a blog post. Coming up on the blog front page.

Re: Use LoP-Parameters with PureData

Posted: Wed Feb 07, 2018 2:09 pm
by haigarmen
Has anyone been able to get LoP working with Raspberry Pi 3 with Raspbian 9 (Stretch)? When I run the test script I don't get any errors but 0's for all the 8 potentiometer readings. Any help would be appreciated.

Re: Use LoP-Parameters with PureData

Posted: Fri Jan 17, 2020 11:37 pm
by JeffAvery
I was able to get the code working on more modern hardware with a bit of massaging :) also be sure to actually solder the pots in.

Code: Select all

import time
import spidev

spi_ch = 0

# Enable SPI
spi = spidev.SpiDev(0, spi_ch)
spi.max_speed_hz = 1200000

def read_adc(channel, vref = 3.3):

    if channel > 7 or channel < 0:
        return -1

    # spi.xfer2 sends three bytes and returns three bytes:
    # byte 1: the start bit (always 0x01)
    # byte 2: configure bits, see MCP3008 datasheet table 5-2
    # byte 3: don't care
    r = spi.xfer2([1, 8 + channel << 4, 0])

    # Three bytes are returned; the data (0-1023) is in the
    # lower 3 bits of byte 2, and byte 3 (datasheet figure 6-1)    
    v = ((r[1] & 3) << 8) + r[2]

    return v;

while True:
    for i in range(8):
        value = read_adc(i)
        print "%4d" % value,

Re: Use LoP-Parameters with PureData

Posted: Tue Jan 28, 2020 1:10 pm
by paul
Jeff Avery,

Thank you for your code snippet. I'm glad you got it working.

Paul Badger