Sunday, December 15, 2013

Contact mic

So a friend suggested that I should build a contact mic out of a pizeo disc speaker. So, built me one of these pre-amp circuits last Thursday:

Shown here is an earlier version, I later added a longer, thinner wire between the disc and the preamp, so the disc could be silly puttied to something without the amp getting in the way. Works really well! My prior experience with analogue semiconductor use had left me expecting a tempermental, finicky result, but it turned out ok! It's really great for picking up the shuffling noises of lentils tumbling in Tupperware.

Thursday, December 12, 2013

Hardware mostly completed!

How was i going to access the raspberry pi once i closed the case up and tightened all the screws? I had to add a power socket and a ethernet jack. The ethernet jack I desoldered from an old ethernet card i had in a box of junk, and cut a section of ethernet cable, and the mini USB jack i got off a pair of silent disco headphones i found on the street once. For structural integrity i surface soldered the jack onto a piece of perfboard and wedged it between structural components of the case. The power leads were soldered according to the following schematic:, with this as an example: (except i soldered ground to the 0 ohm resistor R51 instead of diode D17.

This is the final product. Everything was glue-gunned into place. The RasPi is screwed into the bottom half of a RasPi case which i glue-gunned to the spell and math case. Hopefully there isn't too much EM interference from the ethernet cable and the I2C interface onto the audio jacks, but we'll have to see.

Running the demo python program for the LCD. I am controlling everything via ethernet cable!
Regret: I took off the original red sticker where the red button is (and in the process destroyed it). Should've kept it. Maybe i'll make my own custom sticker to put there.

1) make the usb sound card work!
2)Program a python script to set up the membrane keyboard!
3) Consider putting more buttons in that white space or maybe a sticker!
4) Program the PureData looper patch!

Sunday, December 8, 2013

Setting up software, I2C, Python

Setting up the software, I2C, Python

I had to completely re-image my RasPi because i messed up a config file. So, might as well document the installation process!

1) Installed Raspbian. Configured it to boot to command line, with minimal memory to graphics.
2) Installed TightVNC. Instructions from This setup is so that the RasPi has internet access, and I can access it from my laptop. For a setup where i connect directly to the RasPi with an ethernet cable but without internet access, the following instructions can be used:
3) Install PureData.
4) Install Python to interface with GPIO and I2C interfaces:
Python is the officially supported language and offers pretty good speed on the GPIO, according to the benchmarks at Maybe once i figure out what i'm doing i'll switch to wiringPi, but for now Python is a nice language to use with lots of sample code.

For I2C: I'm using Adafruit's own python demo code.
The P5 header on the raspberry pi is not enabled by default, and needs to be configured before it can be used. Somebody posted a quick python program to do that configuration at
It also does not have a built in pull-up resistor on the two data pins, which are necessary for a I2C interface (see The I2C interface sends data by pulling the two pins low, and without the pull-up, the device is not even visible to the I2C driver (giving me a good ESD scare). Therefore I built my own pull-up resistors onto the external IC of the LCD shield. I used two 56K resistors soldered directly from the data lines to the 3.3V line.

For GPIO: I'm using the python rpi.gpio library. Here is my membrane keyboard / pushbutton interface. This is by far the most delicate thing I've tried to solder so far, and it's probably the most fragile part of the entire endeavor, so if this breaks, i'll etch my own PCB. I've decided not to use the keys on the I2C interface after all because the GPIO is much faster and supports interrupts so I don't have to poll them in a loop.
Also pictured: extension plugs with screw mounts for the USB dongle's 3.5mm jacks. That way, the attachment is more sturdy. The red pushbutton gives a nice tactile click and will be used to trigger record/stop.

Next steps: Configuring the USB audio to work, putting it all together structurally, and actually coding the damn thing! I'll be accessing the RasPi through TightVNC on my laptop from now on!

Saturday, December 7, 2013

The Raspberry Pi

An update on the Raspberry Pi Looper

This week in pictures:

Trimming the original LCD display frame so the Adafruit LCD unit can fit. The dremel at 35,000 RPM simply melts through the plastic with minimal dust, but the molten blobs of resolidified plastic have to be scraped off afterwards.

A piece of CD jewel case cover provides a perfect pane of protection against dust and fingerprints for the LCD.

All the components placed in their approximate final locations in the case. The board resting at a slant must be cut to make way for a structural support strut of the original case. Left: the PCB I will cut to allows interfacing with the membrane keyboard. Still deciding on the placement of buttons on the case though.

A "Leaning header of Pi5a" I soldered onto the Raspberry Pi board. This was originally an unpopulated header which can serve as a second I2C interface; you can see from the previous picture that the leaning header is not present in the original board. I chose to add this so it would not interfere with my use of the P1 GPIO pins. From 

The I2C interface complete! Originally the blue board and the LCD screen are supposed to be stacked, and the entire thing is supposed to be stacked on top of the Pi. But due to the constraints of the case, I had to separate them and connect them with the blue wires and create the P5 header. Lots of soldering involved. Pin out reference from

Coming soon: The GPIO membrane keyboard system.

Tuesday, December 3, 2013

New Blog, First Post!

A good friend of mine suggested i start writing about the stuff i make. So, here it is. A list of projects I currently have going on:

1) Casio SK1 circuit bend
I only very recently acquired this item at a thrift store, it wasn't working. The feature that immediately drew me to it was the fact that it could sample audio with its internal microphone and play it back at different pitches. It came non-functional. When batteries were inserted, the pilot LED lit up regardless of the on-switch being off, and none of the buttons did anything. Luckily, a service manual exists for it on the internet (multiple versions exist, i had to look around for a high res one). Using the service manual's circuit diagram and reference voltages, i determined that the VL1 line was too high. Upon grounding that line with an alligator clip, the SK1 started to produce sound, so I tracked down the problem to the NPN transistor T6, replaced it, and voila, SK1 working!
Casio SK1 service manual found at:
 A run-down of how the SK1 works:

With my now working SK1, I added the patch bay mod (e.g. a la The term "patch bay mod" refers to a class of mods whereby wires are connected from bend points on the PCB directly to an array of ports for plugs on the outside of the instrument. Normally, bends are identified on the PCB and connected directly to dedicated switches and knobs, but a patch bay allows on-the-fly reconfiguration of bends. With nothing in the patch bay, the instrument behaves as if it were unmodded. My patch bay is a female COM1 port, with each pin soldered to one pin on the RAM chip. The SK1 uses 3 memory chips (the three gray IC blocks in the picture) and multiplexes them with a chip select signal from the CPU. With the 25 pins on the COM1 port, 12 are from the address bus, 8 are from the data bus, one is the chip enable (CE), one is the output enable (OE), one is VCC (5V), and the metal of the port itself is Ground (0V). Shorting any pin to the metal casing (ground) activates the pin, while shorting pins to the VCC often glitches the entire SK1. The patch bay successfully produces a selection of very interesting sounds, and I have yet to explore all its possibilities. Looks neat too! The screw pins were put in for aesthetics. The hole in the plastic (and what thick, sturdy plastic it was) was made with an electric drill, but you may get better results with a dremel or a router.

 Next, I tried taking the SK1 to a jam session at my friend's place, and found it quite annoying that while sampling from a line in source, it was impossible to hear the line in signal to capture the correct portion of sound. At the same time, I read about the SK1 filter bypass mod ( I had a bunch of SPCO switches (single pole, centre off, refer to wikipedia:, so I thought, why not have one switch position setting as a filter bypass, one switch position as a line in pass-through, and the middle position as the original? That's what I did. For the line-in pass-through, I used the lower voltage side of R130 (refer to the service manual, this is just outside of the mic amp circuit but before the voltage step-up circuit for the analogue-digital converter) with a 1 uF capacitor (to block current flow) and a 112 Ohm resistor (to reduce the volume). Note that I use a lot of spare parts i de-solder from scrap electronics i have, so the numbers don't really matter. The signal is injected directly into the mixer circuit, same as the filter-bypass mod. I kept the filter intact, so my SK1 actually produces both the filtered signal as well as the unfiltered signal when i have the switch on filter-bypass mode. In retrospect, I shouldn't have bothered because the unfiltered signal sounds WAY nicer imo.
Future plans for the Casio SK1: 1) a 555-timer trigger for the memory auto-play button, with timing controlled by a potentiometer, to allow looping of patterns in the memory (super cool!!!). I've already made calculations for this circuit, will post details in a future post. 2) a bank of 5 switches (or audio jacks?) to control each of the SK1's voices before the mixer (seen at 3) a pitch mod to extend the frequency range of the SK1 by replacing the timing crystal with a 555-timer circuit. However my SK1 is already starting to show signs of structural fatigue from all the opening up and manipulating I've been doing to it, so I might just add just the looper trigger and call it a day.
 2) Raspberry Pi Looper / drum machine
This all started when I was visiting some friends who played with a lot of guitars. Somebody showed me how a looper pedal worked, and I thought, Boom, this is it, this is what i need to go with my SK1!
A day later, I bought the following from the thrift store (not my picture):
Some of you in the know will recognize the item on the left as the famous Texas Instruments Speak&Spell. Now there's a classic piece of bendable equipment i'm not touching until I get way better at circuit bending. But the thing on the right? Turns out it's a cheap radio shack rip-off, and it wasn't even fun to play with. I ripped it apart immediately. Inside: a single PCB with some components and a CPU, a LCD screen, and a piezo disc speaker. I decided it was useful only for its case. Ripping the keyboard's surface sticker off made it look very cool:
I knew immediately that this thing was destined to be the body of my looper. But now i had to find some brains for it. What I wanted out of the looper: 1) good signal quality 2) long memory length 3) ability to save the loop and replay it 4) multiple layers of loop. 5) stand-alone operation, because I didn't want to carry a computer around with it. Two options were available for me in terms of an embedded system: an ardurino, or a Raspberry Pi. The ardurino, although cheap, runs too slowly (16MHz) and has too small of a memory (somewhere around 32kb without a custom ram chip) for this function. I wanted 44khz, 16 bit stereo! So it had to be the RasPi.
This project is still in progress. Here's what I've planned to go ahead with, and I have no idea how it will all turn out. 
I'm basing my RasPi looper on this one: PureData will be running on the raspberry pi, with a USB sound card (a Creative Sound Blaster Play!) as the ADC (analogue to digital converter) and DAC (digital to analogue converter), since the Pi has no ADC and its DAC is 11 bit.
I didn't want to put an ardurino in it (though i totally could). Instead, i bought this: It uses the I2C interface, leaving the rest of the GPIO port unused. I will use the GPIO port to poll the membrane keyboard. The membrane keyboard will control some drum effects and have a few buttons for pre-configured drum patterns, essentially, a drum machine. These features will be integrated into the looper as a seperate procedural data track (as opposed to line-in input for the looper, which will be stored as an audio data track). Not sure if this will interfere with the purely looper functions, but why not try it?
So far, I've managed to get the stock PI working (Raspbian, 16gb class 10 memory card) just by itself and installed PureData on it. This is the first time I've done anything in linux! I intend to run the RasPi looper headless, and where necessary, access its terminal via the ethernet jack. Running headless will reduce the latency and allow me to dedicate all the video memory to audio processing. Definitely won't be playing OpenArena on it, which is a pity.
I also need to mount the RasPi, and its LCD screen into the Spell&Math case, and hook up the GPIO pins to the membrane keyboard, as well as installing a bunch of buttons onto the front of the S&M case as controls. Currently cutting the plastic case with a newly purchased Dremel 100! Will post pics soon. I'll also have to program the PureData patch, of course!