Wire-Scrounging Challenge

August 5th, 2008 by Keith Neufeld

I brought my “Arduino on the go” along to New Mexico, but discovered I’d installed a pushbutton on the breadboard in a spot that was already wired to ground, making the button always “pressed.” In order to move it, I needed more jumper wires; and due to a combination of hurry and hubris, I had brought none along.

I needed some 24- to 26-gauge solid wire, in a cabin, on a mountain (excavaaaaaating for a mine). The nearest Radio Shack was twenty miles and about forty minutes away, and I couldn’t think of any store in Angel Fire likely to have wire for me.

So, where would you scrounge up wire in an emergency? I’m actually interested in suggestions — add them to the comments if you can come up with something other than my ideas. I didn’t have anything along that I could take apart for wire, I didn’t have a soldering iron to tin stranded wire, and I wasn’t willing to damage anything in the cabin, the car, or the area.

Read the rest of this entry »

Arduino on the Go

July 31st, 2008 by Keith Neufeld

A week-long vacation without the Arduino? The horror . . . the horror . . .

Arduino, LCD, and breadboard on foam-core sheet

Arduino, LCD, and breadboard strapped down on foam-core sheet, for travel.

Refitting a Strain Relief

July 21st, 2008 by Keith Neufeld

My dad had a break in the power cord of his hair clipper, right next to the strain relief. That should be ironic, except I already know most strain reliefs are too stiff and just move the site of cable stress rather than relieve it. I guess that makes it ironic but expected.

At any rate, the strain relief was molded onto the cable, so the cord wouldn’t just slip out for repair; and the break was so close he didn’t know quite how to splice it back together; and he asked me to fix it for him.

Hair clipper strain relief with broken power cord

At first all I could think of was hideous things like replace the strain relief with a grommet and a huge wad of hot glue. But I let it sit for a day, and realized that the much easier solution would also be both cosmetically and functionally superior.

I cut off the power cord flush against the inner and outer ends of the strain relief, then drilled the power cord out of the center of the strain relief with progressively larger bits until the hole was large enough to push the cord through again. Super simple, and it leaves a very finished appearance — you can only tell it was repaired if you look closely.

It’s more obvious if you look inside, of course. The extra loop on the long wire really shouldn’t be there. I had both wires cut to the same length and spliced, and then the original short leg popped loose of the switch’s crimp connection and it seemed more practical to cut off the splice and fit the new end straight into the crimp. By then I didn’t feel like reopening and resoldering the long connection, so I just mushed it in and let it be.

Good enough.

Arduino MIDI Volume Pedal

July 12th, 2008 by Keith Neufeld

I’m playing keyboards this fall in another rock concert to benefit the high school robotics team, and for some of the tunes I need to be able to fade an organ in and out over a period of a measure or two. My keyboards are velocity-sensitive, so if you hit the keys harder they play louder (like a piano); and they have aftertouch, so if you press down extra-hard on the keys you can get special effects. But there’s no good way to change the volume of their organ sounds dynamically, and these synths don’t have inputs for volume pedals.

This is the MIDI volume pedal project I was starting to work on when I took apart a Baldwin organ swell pedal and decided to leave it intact based on what I found inside. I got another analog volume pedal from a pile of unknown origin at the school lab and finished the job.

Homebrew MIDI volume pedal using Arduino

Read the rest of this entry »

LED Calculator with Rotary Quadrature Encoder for Target System Voltage Selection

July 6th, 2008 by Keith Neufeld

LED calculator with rotary encoder for target supply voltage

I’m still working on the LED calculator (original idea and most recent work) — I’ve finally got ’round to adding a rotary encoder to set the target system voltage. Now you can turn the potentiometer to set the LED brightness, turn the rotary encoder to set what voltage will be used in the ultimate LED circuit, and read the LED voltage, current, and current-limiting resistor values off the screen.

I also found the Ω in my LCD’s character matrix, so I tidied up the display a little.

And most significantly, I wrote an Arduino library for reading (multiple) quadrature encoders. The simple approach of polling them inside loop() was causing me to lose a lot of steps from the encoders; and the code to read them using hardware external interrupts (lower on the same page) only works on digital pins 2 and 3, so only supports one encoder if both pins are wired to interrupts for the highest resolution, or two if interrupting on a single pin and polling the other.

My Quadrature library uses the TIMER2 overflow interrupt service routine to poll multiple encoders rapidly and track the results, supporting as many encoders as you have room for on the digital pins. It also encapsulates all the dirty work into the library code, so using it is as simple as

#include "Quadrature.h"

Quadrature myencoder1(9, 10);  //  Connected to pins 9 and 10

loop() {
  x = myencoder1.position();
}

It still has some rough edges and it’s by no means perfect (more on that below), but it sure makes it easy to use rotary quadrature encoders. It’s available on a new Downloads page for anyone interested.

Read the rest of this entry »

Swell Pedal from Baldwin Model 5 Organ

July 3rd, 2008 by Keith Neufeld

July 7, 2008

Welcome, MAKE: Blog readers!

Whoever posted this to the MAKE: Blog jumped the gun a bit — I haven’t interfaced anything to a synthesizer yet. What I found in the Baldwin pedal isn’t suitable for interfacing and is (in my opinion) worthy of preservation, so this post is just a teardown of the Baldwin pedal showing the intriguing mechanism inside.

I have since gathered all the parts I’m going to use to build the MIDI volume/expression pedal and expect to do that within a few days; so if you’re interested, please check back!


I want to build a volume pedal for my synthesizer(s), and I figured it’d be easier to do if I started with . .  a volume pedal. So last night I went to storage and pulled the swell pedal out of Jacob’s most recently discarded electric organ, a Baldwin Model 5.

Baldwin Model 5 organ swell pedal, front view

It’s actually quite a bit higher off the floor and more steeply angled than would really suit me; but I had it on hand and figured I might as well start working with it. As it turns out, I’m not going to retrofit this, and I’ll show you why in a little bit.

Baldwin Model 5 organ swell pedal, mechanism

Rocking the pedal forward pushes the square lever away from the box, and rocking it back pushes the lever toward the box and presses a pin at the base of the lever into the box.

Baldwin Model 5 organ swell pedal, electronics enclosure

The lever and box assembly looks kind of like a giant microswitch. Or a bird with a long neck.

Baldwin Model 5 organ swell pedal, electronics mechanism

Here’s the part that makes me say, “Wow.” Apparently potentiometers hadn’t been invented yet (I think I’m joking), or weren’t available with a high enough power rating to use in this volume control circuit.

The volume pedal’s lever presses against a ladder of leaf switches (it’s hard to see, but all the contacts at the left end of the leaves are normally open, but only barely) wired to a resistor ladder. Pressing the pedal connects together increasing numbers of leaves and shorts across increasing numbers of resistors. Wow, wow, wow.

I just don’t feel right about dismantling this to stick in a potentiometer (nor are the mechanics of it really built to make that easy).

So now I’m looking for another swell pedal (with a pot) to repurpose, ideally a twin swell pedal like what’s on Jacob’s current organ. I don’t find much on eBay, and I’m not sure where else to look.

Free: Boxed Manuals → Cases for Prototyping On the Go?

June 25th, 2008 by Keith Neufeld

I’ve been saving these relics of the Information Age forever, initially because I had the computers to go with them, then out of nostalgia, then because I forgot I had them, and now because it seems like the boxes should be useful. But really, I’d just like them to go away.

Anybody want some three-ring binders with matching boxes, maybe to put an Arduino and breadboard in to take with you on vacation and play with circuits when you’re stuck in Saint-Tropez for a couple of weeks with nothing to do? The rings oughtta be good for holding baggies of parts, or something.

Seriously, if anyone wants any of these, they’re yours for the cost of shipping. The MS-DOS Operating System is missing one of the two volumes from the double-wide case; the Wordstar and Operating Instructions are intact in single-wides.

“Airduino” Scungy Anemometer Part 2: Digital Connections and Interrupts

June 8th, 2008 by Keith Neufeld

In part 1, I described making a propeller out of foil to measure the airflow of my air conditioning system, building an optointerruptor from an LED and a CdS photocell, and amplifying the signal to a usable level.

Next, I needed to feed the signal into a digital input on the Arduino. Old-school digital inputs don’t like having analog signals fed into them; but I knew from working with a PIC that some of the Arduino/ATmega pins would probably have Schmitt-trigger inputs, which have hysteresis.

A digital input with hysteresis turns on when the analog input becomes higher than an upper threshold but doesn’t turn off until the signal falls below a lower threshold. The effect is that an analog signal wandering back and forth around the midpoint doesn’t cause lots of twitching back and forth of the digital interpretation. Regular thermostats work this way — they turn on your AC when the temperature gets one-half to one degree above the thermostat set point, and turn off the AC when the temperature falls one-half to one degree below.

Schmitt-trigger on ATmega input

So imagine my delight to find that every ATmega8/168 input pin has Schmitt-triggering. Any pin would do! But I had two particular ones in mind . . .

External Interrupts

All I wanted the program to do was count how fast the propeller blade went by, activate a relay when it got above a higher speed, and deactivate the relay when it got below a lower speed (hysteresis again, at a different layer of the system). For a program that simple, I could write a loop to watch the input pin in software . . . but why, when the ATmega can do it in hardware?

Read the rest of this entry »

“Airduino” Scungy Anemometer Part 1: Detection and Amplification

June 8th, 2008 by Keith Neufeld

Necessity is said to be the mother of invention, and 90+°F daily temperatures with the air conditioner on the fritz made me feel pretty inventive.

Arduino anemometer, angled view

Our air conditioner was low on refrigerant and the blower fan motor may be running slower than spec and not moving enough air. Between the two problems, the expansion coil inside the furnace housing would ice up, over a few hours completely blocking the airflow and preventing any meaningful heat exchange. I’d then have to switch off cooling mode and run only the fan for a few hours to melt the ice.

On a weekend when I was home all day, I discovered that I could keep the house fairly cool by setting the blower fan to run all the time, manually monitoring the airflow out the vents, and cycling the AC off when airflow was restricted and back on when it opened up. Which sounded like a perfect job for a microcontroller.

Introducing the scungy anemometer, or Airduino v0.1, for short. Also introducing real-life code using the Arduino’s external interrupt pin(s).

Read the rest of this entry »

Arduino I2C Expansion I/O

May 26th, 2008 by Keith Neufeld

Arduino with I2C connection to TI PCA9535 and PCA9555 GPIO chips

Cort and I are good friends and both interested in electronics, but have had surprisingly little opportunity to work on electronics together. He’s an amateur radio operator and very much into RF design, and I’m more interested in physical computing.

So when he started describing his receiver voter project and suggesting that I might be able to help out on some of the digital interfacing, I jumped at the opportunity. A radio repeater receives transmissions at one frequency and rebroadcasts them at a nearby frequency, effectively boosting the signal (by repeating it) without increasing transmission power over the legal limit.

The voter picks the best signal from several different receivers (possibly several miles apart, linked back to the repeater base) and routes it to the repeater. And Cort’s voter will have lots of pushbuttons, LEDs, and digital controls — more than he could wire directly to the Arduino he’s planning to use to control it.

That’s where I come in. Cort is very interested in learning the Arduino, but he hasn’t done much with microcontrollers lately and is to some extent playing catch-up with a decade’s worth of advances in technology. So I’ll pitch in and give him some ideas and programming assistance on the digital I/O.

I2C I/O Expansion

I started by looking for digital I/O expansion chips, and I did not start by looking for I2C. I’ve never worked with I2C before and I thought I’d find something with SPI, but oh no, that was not to be the case. Nearly everything I could find — and everything I could find that was readily available and affordable — used I2C. This is actually a good thing — I2C uses only two interface pins to talk to up to 127 devices, and SPI needs two pins for the bus plus a separate chip select line for each device — but it wasn’t what I was hoping for when I started looking.

So I ordered some samples, warmed up by trying to interface to an I2C EEPROM I had lying around (with no luck whatsoever, although I now know several things I did wrong and will go back to it soon), built some breakout boards, and got I2C communications up and running on the Arduino this weekend.

And the number of mistakes I made along the way was staggering. Not just little misunderstandings, but mind-numbing stupid mistake after stupid mistake, things I’ve know better since I was six. With a weekend like this, it’s a wonder I haven’t run over myself with my own car somehow.

So do what I say, not what I did.

Arduino I2C

First off, I had to get the Arduino talking to I2C. There’s not much online about doing I2C on the Arduino, and the most useful for me was Julian Bleecker’s blog post prosaically entitled Arduino and the Two-Wire Interface (TWI/I2C) Including A Short Didactic Parenthetical On Making TWI Work On An Arduino Mini.

It turns out there’s a Wiring library called Wire (why not, oh, say, I2C???) that operates the ATmega’s hardware I2C port and which has been incorporated into the Arduino software since version 6, so everything I needed was right there; I just had to figure out how to hook it together.

Between the Wire documentation being sketchy and not explaining how each function corresponds to an I2C function, its code examples being outdated and occasionally incorrect, my lack of familiarity with I2C in general, my not yet having a working I2C circuit to reference, and of course my many, many mistakes, this made for a bit of a vexing experience.

Let’s do it.

Read the rest of this entry »