pd-rpi

Installing the latest PureData on a Raspberry Pi

After a fair bit of deliberation I was able to install Pure Data 0.49 on the Pi running Raspbian Stretch. I’ll walk through this step by step in case you’re not familiar with command line in Linux.

The default way to install PureData (Pd) is:

sudo apt-get install puredata

The only problem with this method of installing Pd is that you’ll get 0.47.

STEP1. Open Terminal

STEP2. Creating folder to organize compilation (optional):

mkdir src

STEP3. Enter in src folder / install dependencies / download pd source code / unpack downloaded file:

cd src
sudo apt install build-essential autoconf automake libtool gettext git libasound2-dev libjack-jackd2-dev libfftw3-3 libfftw3-dev tcl tk
wget http://msp.ucsd.edu/Software/pd-0.49-0.src.tar.gz
tar -xzf pd-0.49-0.src.tar.gz

STEP4. Compiling Pd:

cd pd-0.49-0
./autogen.sh
./configure --enable-jack --enable-fftw
make

STEP5. Confirming if compilation are ok:

cd bin
./pd

STEP6. If it run, you can install Pd in your raspbian:

cd ..
sudo make install

sensors

Sensors into OSC with Python

How do we move from analogue to digital? There seems to be quite a number of ways including 2D & 3D scanning, photography, and sensors. For the purposes of intentionally limiting our options we’re going to create a physical interface with potentiometers and buttons. We’ll be using the LOP board with a Raspberry Pi.

Once we’ve soldered the potentiometers and header on the LOP board we have to install a few things and enable some of the system level software on the RPi.

Starting with enabling SPI

  1. Run sudo raspi-config .
  2. Use the down arrow to select 9 Advanced Options.
  3. Arrow down to A6 SPI .
  4. Select yes when it asks you to enable SPI,
  5. Also select yes when it asks about automatically loading the kernel module.
  6. Use the right arrow to select the <Finish> button.

Installing the Python Tools:

sudo apt-get update
sudo apt-get install python-setuptools
sudo apt-get install python-pip python-dev

Now we're ready to run the code, wait! we need to 

#!/usr/bin/python

import spidev
import time
import os
import OSC
import RPi.GPIO as GPIO

# Open SPI bus
spi = spidev.SpiDev()
spi.open(0,0)

# Open osc

send_address = "127.0.0.1" , 9000
c = OSC.OSCClient()
c.connect(send_address)

# Function to read SPI data from MCP3008 chip
# Channel must be an integer 0-7
def ReadChannel(channel):
 adc = spi.xfer2([1,(8+channel)<<4,0])
 data = ((adc[1]&3) << 8) + adc[2]
 return data

# Define sensor channels
l0 = 0
l1 = 1
l2 = 2
l3 = 3
l4 = 4
l5 = 5
l6 = 6
l7 = 7

# Define delay between readings
delay = 0.1

while True:
 # Read the light sensor data
 ll0 = ReadChannel(l0)
 ll1 = ReadChannel(l1)
 ll2 = ReadChannel(l2)
 ll3 = ReadChannel(l3)
 ll4 = ReadChannel(l4)
 ll5 = ReadChannel(l5)
 ll6 = ReadChannel(l6)
 ll7 = ReadChannel(l7)
 print("channel 1: ",ll0)

# send off the OSC message with sensor values

msg = OSC.OSCMessage()
 msg.setAddress("print")
 msg.append(ll0)
 msg.append(ll1)
 msg.append(ll2)
 msg.append(ll3)
 msg.append(ll4)
 msg.append(ll5)
 msg.append(ll6)
 msg.append(ll7)
RaspberryPiSDCard

Creating RaspberryPi Disk Images

UPDATE: I’m using Etcher now. It’s an incredibly easy way to format disks and works cross-platform.

Etcher’s 3 step process. simple.

This is the first of a series of articles about RaspberryPi, I’ll start with a few introductory tutorials to get you up and running.

The first thing you’ll want to do once you have a Raspberry Pi is set it up with an operating system. If you’re wondering about the best place to buy a Raspberry Pi, I’ve been happy ordering from Newark Canada. Unlike an Arduino that runs only the small program that you upload into it, RPi boots up with a full operating system (typically some type of Linux distribution) that’s on its SD card. There are several variations of the RPi OS that can be found there at eLinux.org’s distribution list.

For now let’s start by installing the general purpose operating system Raspbian – a version of Debian Linux specifically configured to run on the Raspberry Pi and is recommended by the Raspberry Pi Foundation as the operating system to install.

Downloading Raspbian

You’ll be able to download Raspbian for free from the Raspberry Pi website. Look for Raspbian with the subtitle ‘Debian Wheezy’, download either the torrent or direct download.

Once you have the ZIP file downloaded to your computer, unarchive it. Sometimes double-clicking on the Zip file doesn’t expand the archive and you end up with a archive of a Zip file. If that’s the case you’ll need to open the Terminal and type in:

unzip 2014-01-07-wheezy-debian.zip

The result will be the disk image (.img file) that you will flash to the Raspberry Pi’s SD card. You will need an SD card with at least 4GB capactity. I suggest you look at the list of SD cards that are compatible with Raspberry Pi. I’ve been using 16GB SanDisk Extreme Class 10 disks, they work well.

Erase then Unmount the SD Card

Macs come with an app in /Utilities called Disk Utility, select the SD Card item in the list on the left. Click the “Erase” tab that appeared on the right hand pane. You’ll see a “Format” option and a “Name” field. Choose “MS-DOS (FAT)” as the format and enter a name. For the FAT-32 format, the name must be uppercase, I suggest something like “RASPBIAN.”

disk-utility
Then select the name of the SD card in the left column again and click “Unmount.” It’s important that the disk be unmounted.

Flash the Disk Image

Go back to the Terminal and type the following command, ensuring you replace the “[FILESYSTEM]” value with the one you noted earlier and the “[DISK IMAGE NAME]” with the proper file name obtained above.


sudo dd bs=1m if=[DISK IMAGE NAME] of=[FILESYSTEM]

For me, the command would look something like this:

sudo dd bs=1m if=2012-12-16-wheezy-raspbian.img of=/dev/rdisk4

Hit enter, and wait until the command to complete. This takes a while and unfortunately it the dd command doesn’t give us any signs of progress. You can hit the CMD T keys to get a bit of data about how much it has copied. Depending on the SD card’s speed this process can take up to 10 minutes. Once dd flashes the disk image, you can remove it from your Mac and plug it into your Raspberry Pi.

If you’d like to do this on something other than a Mac have a look at these comprehensive instructions.