FLOPPY FRAME

I’m using a modified Moppy Sketch from SammyIAM. You can find the original Version at his Github source:  SammyAMI@Github

There are nine floppy drivers mounted on a wood plate. The floppys are controlled by a Teensy 2.0++. The Teensy runs as an USBMIDI device, which is connect over an USB connection to a Raspberry Pi. The Raspberry Pi runs a MIDI sequenzer Pure Data (PD-extended) patch and a webserver in headless mode. So you only have to turn on power, the Rapsberry Pi will boot and starts the PD patch and webserver. Open a webbrowser and type the ip adress and filename. A webpage will be shown with some control elements. With these control elements you can control (start,stop, BPM manipulation, select midifile etc.) the floppys.

Some photos of the build process. The Aim was, to build the “Floppy Frame” with parts I have owned and don’t have to buy.

Needed parts & tools:

  • Power Supply Unit
  • Floppy drivers
  • Teensy (2.0) ++
  • Raspberry Pi
  • SD Card
  • WIFI Dongle
  • Network Router
  • Wires
  • Fe(-male) headers
  • Wire cutter
  • Solder iron
  • Apache, PHP webserver
  • Arduino IDE + Teensyduino
  • PD-extended
  • Github files (midi_seq.pd, moppyhtml, js bin etc.)
  • Some time

Wiring Instructions to connect Floppys, Power Supply, Raspberry Pi and Teensy

MOPPY (Raspberry Pi & Teensy)

Be careful with the power supply unit. It delivers small voltages but the amperes can be huge and deadly! So always check, if your power supply is already turned off!

Some ATX power supply units needed to be modified, else they will not get powered on. Then you have to connect the green wire (Power On) with some of the black (GND) at the 24pin pinsocket. Check Wikipedia for more informations and the right Pins: Power supply unit

To get the floppy drives run, you need to make the floppy drive as slave. The odd numbered Pins are GND. So connect pin 12 to pin 13. You can use a jumper. Pin 18 is for direction and pin 20 is the step function. For more information about the floppy drive pinouts, visit this source: pinouts.ru

pin

Connect floppy pin 20 to Teensyduino Pin 2 and the floppy’s pin 18 to Teensyduino pin 3. The odd Teensyduino pin 3-33 are step control and the even pinnumbers 2-32 are used for direction. Check the Teensyduino source to get the right pinnumbers for your Teensy: pjrc.com

Teensy/MIDI Ch.

  • Pin 2/3 = MIDI Ch. 1
  • Pin 4/5 = MIDI Ch. 2
  • Pin 6/7 = MIDI Ch. 3
  • Pin 8/9 = MIDI Ch. 4
  • Pin 10/11 = MIDI Ch. 5
  • Pin 12/13 = MIDI Ch. 6
  • Pin 14/15 = MIDI Ch. 7
  • Pin 16/17 = MIDI Ch. 8
  • Pin 18/19 = MIDI Ch. 9
  • Pin 20/21 = MIDI Ch. 10
  • Pin 22/23 = MIDI Ch. 11
  • Pin 24/25 = MIDI Ch. 12
  • Pin 26/27 = MIDI Ch. 13
  • Pin 28/29 = MIDI Ch. 14
  • Pin 30/31 = MIDI Ch. 15
  • Pin 32/33 = MIDI Ch. 16

Connect the GND of the power supply unit with GND of your Teensy and the 5V from power supply unit to Teensys 5V pin. Everytime you turn the power of the power supply unit on, the teensy will be turned on, too. Do the same with Raspberry Pi’s 5V/GND GPIO pins.

Warning: The GPIOs are raw inputs! Be Careful with the power supply. If you have an old USB micro wire, cut this and solder the 5V and GND wire from the power supply to the red and black wires of the USB. The micro USB input has a fuse. So it’s much safer to power the Raspberry Pi by USB.

Setup Teensy for MOPPY

  • First Download and install the Arduino IDE and Teensyduino for your OS.
  • Visit my Github source and download the “moppy_usbmidi.ino
  • Connect the Teensy to your computer and open the “moppy_usbmidi.ino” with Arduino IDE.
  • At the Arduino IDE go to “Tools -> Boards” select your Teensy and set the “USB Type:” as MIDI.

Arduino IDE

  • Then upload the Sketch to your Teensy. At the uploadmode the Teensyloader should start automaticaly. If not, open it. In some cases you have to press the reset button at your Teensy.
  • Connect the floppy drivers as described above and the Teensy part is ready to go!

Instructions Raspberry Pi (if your Raspberry Pi is already setup, skip this section)

  • Download Raspbian (Wheezy) for Raspberry Pi and reformate your SD card. The Image and instructions, how to setup a Raspberry Pi with Raspbian, are at:  Raspbberypi.org
  • Now, you have two options to finish the setup. One method will be to connect a keyboard, mouse and screen to the Raspberry Pi. The other method is to connect the Raspberry Pi by LAN cable to a router and log in with ssh. For the ssh connection, just open a comandline tool and type: “ssh pi@127.0.01” (Replace the ip with the IP of your Raspberry Pi. The default Password for ssh login is: raspberry).
  • Finish the Raspberry Pi Setup. At “rpi-config” select “expand file system”, “enable ssh”.

raspi expand filesystem

raspi enable ssh

  • If everything is setup, select “finish” and reboot the Raspberry Pi.
  • Next step is to setup up the wifi connection and set a static IP. Plugin your wifi dongle and type at the commandline tool:

$ sudo nano /etc/network/interfaces

  • Edit the “iface wlan0 inet dhcp” to “iface wlan0 inet static”, hit enter and add the IP Adress for your Raspberry Pi, the Netmask and the Gateway. Next lines add wifi ssid and the password of your wifi. If everything is done, just press “ctrl+x”, “yes” and hit enter. At the end it should look like this:

rapsi wifi static

  • To enable the wifi connection, reboot the Raspberry Pi or type the following code:

$ sudo /etc/init.d/networking restart

Install and setup webserver

  • First we need to update the apt-get source. So type:

$ sudo apt-get update
$ sudo apt-get upgrade

  • Now install the Apache and PHP webserver:

$ sudo apt-get install apache2 php5 libapache2-mod-php5

  • After everythin is installed, check if usermod and groupadd are created:

$ sudo groupadd www-data
$ sudo usermod -g www-data www-data

  • The webserver should be working. You can put your HTMLs etc. at “/var/www”

Install PD-extended.

The extended Version will be needed, because “midi_seq.pd” and the websocket will use the mrpeach library, which is included at PD-extended.

  • First edit the sources:

$ sudo nano /etc/apt/sources.list

  • Copy, paste following and then hit “ctrl+x”, yes & enter:

deb-src http://archive.raspbian.org/raspbian wheezy main contrib non-free rpi

  • Update the sources:

$ sudo apt-get update

  • Now get the latest PD-extended Version. For me, it was “pd-extended_0.43.4~extended1-1~raspbian_wheezy_armhf”. You can find the current version at: PureData.org
  • Download pd-extended:

$ wget http://sourceforge.net/projects/pure-data/files/pd-extended/0.43.4/pd-extended_0.43.4~extended1-1~raspbian_wheezy_armhf.deb

  • And decompress it:

$ sudo dpkg -i pd-extended_0.43.4~extended1-1~raspbian_wheezy_armhf.deb

  • Then install the missing files:

$ sudo apt-get install -f

  • And make it executable:

$ sudo chmod 4755 /usr/bin/pd-extended

  • PD-extended should be installed and ready to go.

Download and setup the Moppy files

  • First check, if github is already installed:

$ sudo apt-get install git-core

  • Then download the “MOPPY-modified” Source from Github:

$ git clone http://github.com/HerrPaule/MOPPY-modified.git

  • Go to the HTML files & move them to your “/var/www” folder:

$ cd /MOPPY-modified/raspberry_pi/
$ sudo mv html /var/www

  • If you want to run everything in headless mode, you have to create a script, which will be run on boot. So create a folder and make a executable script with the following codes:

$ cd
$ mkdir ./bin
$ cd /bin
$ sudo nano moppy_pd

  • paste the following things and hit “ctrl+x”, “yes” and enter:

# !/bin/bash
# This script will start Pd in nogui, noaudio and selected midioutport
# more commandlines for pd check:
# http://puredata.info/docs/faq/commandline
# mode and will open the patch
# named “midi_seq.pd”
# check your mididevice id and edit the number corresponding to your connected teensy
echo “Starting Pd…”
pd-extended -nogui -noaudio -midioutdev “1” /home/pi/MOPPY-modified/raspberry_pi/midi_seq.pd &

  • It should look like this:

raspi moppy_script

  • And make the script file executable:

$ sudo chmod 755 script_pd

  • The “&” at the end of the path in “moppy_pd” make Pure Data run in background, so you can type new commands.
  • Now, you can test, if everything is working right. Paste the following command. Pure Data will run in commandline mode and prints everything to it.

$ /home/pi/bin/moppy_pd

  • Now you can open a webbrowser, type the IP Adress of your Pi + /html/index.html and you can send messages to Pure Data. The received commands are printed to the commandline window. To exit Pure Data just type this:

$ sudo killall pd-extended

  • Now the script should be run on boot. To do this, we have to edit the “rc.local”

$ sudo nano /etc/rc.local

  • And paste the following at the end of the comments (#):

/home/pi/bin/moppy_pd

  • hit “ctrl+x”, “yes” and “enter”. It should look like this:

raspi rc_local

Now, you can reboot your Raspberry Pi. At the next boot, “moppy_seq.pd” will be run automatically. Open a webbrowser, type the Raspberry Pi IP + /html/index.html and have fun. The HTML file is in beta. There will be some changes in the future.