Sunday, January 31, 2010

Drawing an Arduino Circuit Diagram


I've had an Arduino Duemilanove now for a couple of weeks. If you're not familiar with the Arduino, it is "an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software". It has a small microcontroller, a USB port to connect to your computer for programming, a power socket for providing power when the USB cable isn't connected, and various digital and analog input and output pins, for connecting up to leds, switches and various sensors.

It's inexpensive, and there's an open source IDE for programming. Works great, but one issue that I quickly ran into was remembering my circuits. I'd make something up on a breadboard, write a program for it, and then tear it apart to build another circuit. When I wanted to go back to an earlier circuit, I had the program saved, but I couldn't always remember how I had wired up the circuit.

So I went looking for a program that would let me document my circuits, and I found Fritzing. It's very easy to use. You drag parts off a palette and connect them up with drag and drop. You can work on a breadboard view or a schematic view, and they are automatically kept in sync. You can easily put bends into wires to route them in more visually appealing ways.



Here's an example of a circuit using the Arduino Duemilanove and a 7 Segment Red LED 0.3" Digital Display (RadioShack 276-075).

Building this I was able to experiment with another feature of Fritzing, because the 7 Segment LED included in the core parts of the tool was a common anode numerical display. Although these pictures don't show anode/cathode on the pins, it is visible in the tool, and I wanted to get it right. So I edited the part, changed the pin wiring, and saved it as a new part. This was all very straightforward.

Then I decided I wanted to have the pins be labeled A, B, C so that it would show up in the schematic view. All the images are SVG, and I didn't have an SVG editor handy, so I used svg-edit, an online browser based editor. I copied the "7-segment display.svg", added the letters, saved it into a new svg file, and selected it within fritzing. I did need to close and reopen Fritzing for it to refresh the schematic which already had the old image on it, but I didn't need to remove and re-add.

I'm still experimenting with Fritzing, but for something that I've only been using for an hour or so I've found it remarkably full featured and easy to use. It would be nice if it had a "snap to grid" feature that would recognize when I'm trying to route my wires horizontally and vertically and fix things when I'm just a little off. But that's really just a nit - and maybe something it has and I just haven't found yet.

One more thing that Fritzing can do is create a PCB layout in various formats, that can be used to manufacture the circuit boards. For example, you can export as a Gerber file and use a printed circuit board fabrication service like BatchPCB.

Lastly, in case you were looking for how to count from 0 to 9 on the above circuit over and over again, here's the sketch


// Counting on a 7-Segment Red LED (common cathode) numerical display
// RadioShack 276-075 / Wiring
//
// arduino pin -> 7-segment LED pin -> anode
// 13 -> 14 -> A --A--
// 12 -> 13 -> B | |
// 11 -> 9 -> RHDP F B
// 10 -> 8 -> C | |
// 9 -> 7 -> D --G--
// 8 -> 6 -> E | |
// 7 -> 2 -> G E C
// 6 -> 1 -> F | |
// --D-- O

int ledPins[]={0xDD,0x50,0xCE,0xDA,0x53,0x9B,0x9F,0xD0,0xDF,0xD3};

void setup()
{
for (int i=6;i<14;i++) {
pinMode(i,OUTPUT);
}
}

void loop()
{
for (int i=0; i<10; i++) {
displayNumber(i);
delay(500);
}
}

void displayNumber(int num)
{
for (int i=0; i<8; i++) {
digitalWrite(i+6, bitRead(ledPins[num],i));
}
}

Tuesday, January 05, 2010

Jabra SP700 Bluetooth speakerphone


I have been looking for a way to listen to music and podcasts on my IPhone 3G while driving to/from work. My current solution of wearing a headset was less than satisfactory in convenience, comfort and safety. I have experimented with a cheap FM transmitter bought at Walgreens, which plugs into a car cigarette lighter for power, and has a 3.5mm jack to connect to the IPhone. But reception was unbearable, and it was inconvenient when a call came in.

My Mazda6 doesn't have an audio input jack, or a tape drive. So there was no convenient way to play the IPhone over the stereo. I did find a product called Auxmod that could be used to add an audio input jack. But at $60 it wasn't cheap. Plus it seemed that if the connected device was also powered from the car cigarette lighter, then some additional shielding was necessary to avoid interference, which cost more. And installing the device involves pulling apart the dash.

The other device I explored was the Parrot MK6000. This was where I learnt about bluetooth streaming or A2DP. This allows stereo music to be streamed from something like an IPhone to a bluetooth device like the MK6000. The neat thing about the Parrot MK6000 is you're not having to plug in the IPhone to it. You can be playing music or podcasts, and when a call comes in, it just breaks in. And the device can be wired into a car stereo. But it's the latter that gets complicated. The only way I could see to wire it was to buy and install the Auxmod, or to get a professional to do it. And the ones I spoke to were quoting prices in the $200 range for installation. With the Parrot MK6000 itself costing $110 this was an expensive approach.

So when I learnt about the Jabra SP700 with a built-in speaker, thus offering about the same capabilities as the Parrot MK6000 but without the wiring trouble, it seemed ideal. My concerns were

  1. would it pair well with the IPhone 3G (my new Garmin Nuvi 265WT consistently loses the pairing)

  2. would the speaker be loud and clear enough to hear over the noise of the car and traffic


The device is a sleek black rechargeable unit with a clip that mounts to your sun visor. It comes with a USB cable and a cigarette lighter adapter that the USB cable can optionally plug into. So you can charge from your computer or in your car. When the unit arrived I charged it up, and then tried to pair. Jabra offer a super "pairing simulator" site where you can select your specific device and phone, and it shows you step by step with screen shots how to pair. I followed the steps for the IPhone 3G, and it didn't work. On the Bluetooth settings screen it never found the Jabra SP700. I tried rebooting, doing a hard reset, powering on/off the Jabra. Nothing worked. After some searching it seemed others experienced this too. My number 1 concern realized - my IPhone 3G would not pair with the Jabra SP700. But I found an article that mentioned an undocumented feature on the Jabra SP700. If you hold down the answer/end button for 7 seconds then it goes into "continuous emitting mode". The blue bluetooth light on the SP700 starts blinking faster than in normal pairing mode. When I did this my IPhone immediately paired. Since then I've turned on/off both devices, taken them apart, brought them together, and so far (in my 24 hours of experience) they have always seamlessly paired without any intervention.

The volume on the device is great. I read some comments that it was too loud, but for me it is perfect. I can make it too quiet, and too loud, and anything in between. The quality obviously isn't hi-fidelity. It's a small 2"x3.5" device that's about half an inch thick after all. But it's quite acceptable for both podcasts and listening to music. And the phone quality is great too at both ends.

Lastly, it also has an FM transmitter built in. I'm not sure whether I'll use this much, because it's a little difficult in this area to find a gap in the FM dial. But I did actually find a gap this evening and it played out through the car speakers very well. I also took a call in that mode, and it was perfect.

All around I'm delighted with how my IPhone 3G works with the Jabra SP700. I like the form factor, the simple interface, and the sound quality. 5 out of 5.