Weekending 12022012

This week in Barcelona started with the pleasure of having Quadrigram making the cut of the finalist of the Strata 2012 Startup Showcase. The tool is a couple of weeks away from seeing the light and the teaser video is now online. At Strata, I will present the tool with my friends at Bestiario right after my session on Sketching with Data.

On the invitation of Claro Partners to present the lab, I took the opportunity to present my experience working with network data, particularly focusing on the methods we employ to help innovate in the domain of ‘big’ data. Have a look at the slide deck: it starts with a reference to Napoléon Bonaparte ‘Un bon croquis vaut mieux qu’un long discours’, goes through the uses of sketches as part of any creative work exemplified by Le Corbusier, and concludes with Picasso and the art of sketching.

Okay. What else? In Los Angeles, we used a solder paste stencil for the first time. Impressed. Good stuff. Definitely worth $25-$50. You can tell in this video I haven’t used solder paste in awhile..I forgot to put the proper hot, hot air on so I’m basically just blowing balmy air on the board. More practice, again. I have to say, the stencil is definitely a time saver. Although, I’m still going to get a big-ass pick ‘n place machine cause that’d make it even faster to get boards done. ((That’s EarFreshener up in that video, by the way.))


Nicolas came to town on Saturday and Sunday we went to the crazy flea market at the Pasadena Coliseum, home of the Rose Bowl. We found weird things and Nicolas found a fantastic mint-condition Polaroid in its crushed red velvet case. Lucky old salt. Prior to that, his week was focused on both phone call with Lift12 speakers and the final presentation for the head-mounted display project, which went fairly well. Results from this field study are kind of secrets so far but there will eventually be a publication about that.

Sound Should Just Come Out Of It

I think going forward I should do a better job of talking around what we’re working on from a technical point of view, until such time as it’s okay to talk about what we’re doing from a principles, rituals and practices point of view. And, also — sometimes in the thick of a design-making-schematic-and-hot-air-baking fire-fight, I do something that I”ll likely have to do again, but without a good, thorough practice of writing things down to remember I, like..forget.

Here’s the thing. I’m making a little tiny audio device. It’s tiny and meant to be simple to use. Like Russell taught me — the thing about audio? You should be able to just turn it on and sound comes out.

I like that rule. That’s what radios used to do before all the knobs, settings, configuration preferences, long vertical scrollable lists and Internet connections fucked things up. You turn the little serrated rotary dial and *click* — radio sound. At worse? Static. But sound started. No swipes. No multi-finger gestures. No tyranny of the 10,000 hours of music & sound in the palm of your hand..and no idea what you want to hear.

There’s something lovely about that that is just pragmatic from an IxD and UX design point of view. I’m not being nostalgic.

So — translating this principle and making it active and not just a sweet, essentialist sounding statement into the guts of the things we’re making, I spent most of yesterday pondering how to make Ear Freshener exhibit and embody and be an exemplar of this design rule. Even to the point of saying, okay..no on-off switch.

Huh?

Yeah, well — the Ear Freshener has the advantage of being a plug-y thing. No speaker. It’s an intimate audio headphone thing. You’d only expect sound out of it when you plug in your headphones. Otherwise — it’s just a little thing that’s quite opaque. There’s only the tell-tale 3.5mm hole that indicates — audio/sound/plug-in-y-ness.

So — simple enough. I decided that plugging-in should equal sound-coming-out. That means that the plug action should turn the actual electronics on. In the world of audio connectors, CUI, Inc. is the go-to operation — along with what I’m sure is a thriving, teeming “ecosystem” of knock-off competitors who may even produce a superior product. They make all sorts of audio connectors for the world of audio devices. There’s a collection of them that have more than the three connectors that are necessary for a Tip Ring Sleeve style stereo audio signal, including the SJ-43614 which is a 3.5mm plug with four signals. The extra one switches from floating (not connected to anything) to ground (or the “sleeve” of the connector, which is normally connected to ground) when you plug a plug into it.

Brilliant. Something changes when you plug the plug into the SJ-43614. One of those signals on that connector gets shorted to the GND rail of the circuit.

Now..what to do with that state change in order to turn the whole circuit on and make sound come out of it with no fuss, no muss.

I pondered and scritched and screwed my face and looked for the answer somewhere on the ceiling over there. I thought of lots of overly-complicated things (as it turns out..in hindsight..) like using a low-power comparator to activate the chip-enable pin of the little 200mA step-up switching regulator I’m using so I can run the circuit off a single 1.5V battery cell.

In that over-designed scenario the NCP1402 step-up regulator is effectively the power supply for the circuit, which wants at least 3.0 volts to operate properly (and draws about 40mA). I can get an NCP1402 hard-wired to output 3.3v, although I may get the 5v version to have a bit more headroom with volume. In any case, this chip is fab cause you can take a little 1.5v cell and it’ll tune up the voltage. Of course, it’s not 100% efficient. Nominally, it’s about 80-ish% efficient at 40mA. So..you lose a little, but you can’t get something (5v) for nothing (1.5v) without giving up something in the trade.

NCP1402SN50T1 efficiency versus output current


So, I have a 1.5v battery of some sort which sits behind the NCP1402. The NCP1402 has an active high chip-enable (CE) pin that turns the chip on — effectively powering the rest of the Ear Freshener circuit. In my overly-complicated scenario, I figured I could use a comparator to sense when the 3.5mm plug had been plugged-into because that one switched pin would go from floating to ground. If I had a simple little 10k resistor between the positive 1.5v side of the battery, the comparator inputs could go on either side of that resistor, with the IN- of the comparator on the side of the resistor that would get shorted to ground when the plug is plugged in. And then the IN+ of the comparator would go on the side of the resistor that is connected directly to the positive side of the 1.5v battery. When the plug goes in, the IN- of the comparator goes to GND, the 10k resistor has a little, negligible-y minuscule current draw and the voltage difference between IN- and IN+ causes the output of the comparator to saturate to pretty close to IN+, or +1.5v. The NCP1402 chip enable would trigger (specs say anthing about 0.8v means “enable” and anything below 0.3v means “disable”) and the whole thing would turn on.

Click the image to expand it and make it easier to read. This is the lousy, over-designed circuit.


How convolutedly and moronically clever is that, especially when you stop to think (as I did, after proudly building the schematic) that you could just use that pin from the plug shorting to ground as a way to close the GND rail of the whole circuit. I mean..if you disconnect the NCP1402 from GND, it should turn off. Basically, it’d have no complete, closed, power supply circuit. It’s as if you pulled the battery out — or half of the battery out. Or ripped out the ground wire.

Anyway. It was clever to get all busy with a comparator and stuff. Simple’s better, though.

This is the simple, no-brainer one that eliminates the need for several additional components.


That’s it. I like the principle and I like even better the fact that I can translate a lovely little design principle into action — materialize it in a circuit that exhibits a fun little unassuming behavior. I can imagine this’d be a bit like wondering if the light stays on in the fridge after closing the door, you know?

So sound stops coming out, the circuit powers down and you no longer need an on-off switch. Stop listening? Turn off. So much nicer than long-press, id’nt it?

Why do I blog this? Cause I need to capture a bit more about the production of this little Ear Freshener-y gem.

Update


Here’s my update on the power circuit. I hope it works. I added two transistors in place of the comparator. The idea here is that the transistor on the right would switch the CE of the step-up switching regulator. When the base goes low — i.e. when the 3.5mm plug is plugged in — the switch opens and CE gets switched to roughly VBATT and enables the step-up regulator. For the transistor on the left, plugging in opens the transistor and VBATT gets connected to the step-up regulator and it, like..steps-up VBATT to VCC. When the plug gets pulled out and floats at VBATT, the two transistors saturate and are on. So on the right, CE is at Vce or effectively ground and shuts the step-up regulator off. The transistor on the left does similar and VBATT drops over R6 and VBATT_SWITCHED is at GND and there’s no longer any supply to step-up, even if the step-up regulator were enabled.

That’s the idea.

We’ll see. I haven’t computed the values for the discretes around the transistors as of yet.

Related — I’ve just sent off the PCB to get fabricated. It’ll be a 2-off prototype. I’m using AP Circuits for the first time because my usual go-to guys Gold Phoenix are off for the Chinese New Year and I need to get this done for some building & testing next week.


But I think I mucked up the CAM data files I sent them, which appear to be slightly different from Gold Phoenix. They want other stuff, like the NC Tool list which I’ve never sent to Gold Phoenix. I guess we’ll see what they say.
Continue reading Sound Should Just Come Out Of It

Varieties of Controls

Never would’ve thought how particular a fella could get about the action of audio controls. I’ve collected an assortment of potentiometers for the audio mixer project. From well-dampened to action that goes tick-tick-tick with detents. The red one in the foreground? That’s an optical encoder that continuously spins — no stops. It might be a bit of a control fetish, but the action of these things matters. Even in an era of touch, click and very screen-y interactions tactility and motion matter. Which raises a little concern — not doubt, just concern — about going hog-wild with gestures.

Why do I blog this? Things are moving forward with the audio mixer. Slower than expected; unexpected things in and around the studio plus upcoming travel preparations and a shift-in-time to make the U.S. Labor Day holiday happen for me this Friday. Downtime and uptime. Sending the PCB off any minute now..
Continue reading Varieties of Controls

LM358 Op-Amp Issues

Audio Mixer Schematic

Should be simple…here’s the test circuit. It’s derived from the multi-channel mixer below. I’m just testing the circuit. It should basically pass through the one input signal perhaps with some attenuation. Instead, it distorts it all to hell-and-gone. Any ideas?

So — back to hammering and less yammering. I’m trying to build a small, portable, DIY audio mixer. Thus far — I’ve found nothing off-the-shelf that meets my, you know..specifications. There are lots of inexpensive and rather expensive field mixers but those are honking things with gigantic XLR inputs for proper microphones. I want about two 1/8″ stereo inputs, and maybe two or three 1/8″ mono inputs. I want to mix a few things and I want the whole thing about the size of deck of cards or something small like that. The only thing I can think to do is to build it.

Plus..we like to build things.

It should be simple but I’m about a decade out of analog electronics. I used to be able to debug op-amp circuits but not any more. And back when I could they didn’t have the internet the way they have now, so I’m sorta putting it out there with as much evidence of the problem as I can muster.

I built the circuit you see above using an LM358 op-amp. Seems like a reasonable go-to unit to build around and many op-amps, as I recall, are generic enough that I feel like it should work in this circuit. (But, I’m prepared to be wrong.)

The problem is that the signal gets super distorted right from the get go.

I’m using my MBP to generate a signal using Max/MSP. It’s just a 1kHz pure tone — a sine wave. The output comes out of the computer, right? Max/MSP generates the signal to go out on one channel and that’s what I feed into my circuit.

Basically — it gets distorted, even at the input. Check out the signal at pin 2 (the + on the left-most op-amp) — it’s what comes after a resistor and capacitor from the input signal. Why’s it so clipped even before it gets processed except for a couple of discrete components? I think that’s the heart of the issue cause the signal doesn’t even touch the op-amp?

So — obviously screen shots from my scope. The top cyan trace is the audio signal I injected into the circuit. It’s a 1kHz sine wave generated from Max/MSP and output over my MacBook’s audio output. It’s about 280mV P-P.

Pin 2 – Basically the input signal after a resistor and capacitor. It’s like..totally clipped there. Why it’s clipped between the raw signal and the input on pin 2 is baffling me. I’ve been so far from analog circuits for so long..I’m just not even sure why putting it on pin 2 alone clips it this way.

The output from the first Op-Amp in the mixer circuit..looks kinda hinky..worse than the input on pin 2.

Things only get worse from there. The output of the first op-amp looks like worse crap. This is basically the op-amp processing one signal and mucking it all up.

Now we’re at pin 6 which is the input to the second op-amp which comes after pin 6 with a 10k resistor in between.

Pin 7 is the final output. This should be a clean signal basically like the input for this test.

Final-final output after a couple of resistors and a capacitor. Distorted crap.

Why do I blog this? Well..I can’t figure out what might be wrong and because the circuit is so simple, I figure the problem is something as simple as the circuit. But, I may be a bit out of my depth and I’m baffled especially because the signal as measured at pin 2 — effectively the input — is distorted already.

Any ideas?

Continue reading LM358 Op-Amp Issues

DS1803 Digital Potentiometer

I’ve been fussing with this digital potentiometer, the DS1803 by Maxim. They’re “digital” because you can control the resistance over its range programmatically, by sending it commands over a 2-Wire (I2C/TWI) serial interface. So, that means that I can hook it up to some microcontroller, like the Arduino, and adjust the resistance in a little program. I chose this one in particular because it can operate at either 3V or 5V, which is convenient, and it comes in a few different models with various resistance ranges. I’m using the DS1803-010, which means it has a range of 0-10K Ohms.

I created a little PCB with two DS1803s on it. Each DS1803 has two potentiometers on it, so I’ve got four on this board. The code for controlling the DS1803 is pretty straightforward. Each one is addressable over the 2-Wire interface, but because we have two on the same interface, I had to configure one to listen to a slightly different address. The details are in the specification sheet, but basically you hardwire the three lines A0, A1, A2 (see the schematic above) to change the address. Effectively you can have up to 8 individually addressable DS1803s on one interface.

In the Arduino source code example below I am only talking with one DS1803 at address 0x28. (if I was talking to to the second one in the schematic, its address was 0x29.) Here I’ve hooked up a logic analyzer to the interface to just make sure we’re communicating. The code below simply adjusts the potentiometer incrementally upward.

[ad#ad-4]

//
// Control the DS1803 Digital Potentiometer

#include <Wire.h>

void setup()
{
  Wire.begin(); // join i2c bus (address optional for master)
}

byte val = 0;

void loop()
{
  Wire.beginTransmission(0x28); // transmit to device 0x28)
  Wire.send(0xAA);            // sends instruction byte,
                               // write to potentiometer-0
  Wire.send(val);             // sends potentiometer value byte
  Wire.endTransmission();     // stop transmitting

  val++;        // increment value
  if(val == 150) // if reached 64th position (max)
  {
    val = 0;    // start over from lowest value
  }
  delay(100);
}


Logicport Overview

So, just a brief overview here of the Logicport Logic Analyzer and it’s top-line features and set-up. When I set out to figure this thing out, I took a decent “known” set-up that was running a not terribly complicated, but still useful protocol — SPI. As it happens, the Playstation 2 communication between its controller is roughly the SPI protocol, so that’s as good a test as any, seeing as I had been doing some work with the PS2 anyway.

I wrote a bit about that set up already, so this is the part where I describe how I set the Logicport up. Here are links to two other posts related to the Logicport.

PS2 Logic Analysis
Logic Analyzer

There are three main features of the Logicport I’ll describe — Interpreter’s, Triggers and Measurements. (I’ll also briefly describe some of the basic set-up things that I learned.) Interpreters are like templates for specific protocols. The Logicport supports four protocols as these Interpreter “templates — I2C/TWI, SPI, RS232 and CAN 2.0A/2.0B. For the work done at the Near Future Laboratory, we’re basically covered with these.

Creating a new Interpreter from one of these templates is pretty easy. Just with the case of a SPI Interpreter, your job is to specify which of the Logicport’s channels is probing which of the standard SPI channels. In my setup, I configured two different Interpreters — one for the “master” side and one for the “slave” side. On the master side, the Interpreter probes for the MOSI (master-out, slave-in), SCK (serial clock) and SS (slave select — active low) channels. The “slave” side the Interpreter probes for the same stuff, except the data moves across the MISO (master-in, slave-out) channel.

The Interpreter configuration window also allows you to specify a whole bunch of other useful things. First off is the bit order. The PS2 SPI style protocol sends data least-significant bit first, which is okay, but opposite of the canonical SPI protocol. Fortunately, the Interpreter allows you to specify this. You can also tell it how many bits to interpret as data, and what format you want that data to be represented — Hex, Binary, Decimal, Signed or ASCII. So, that’s super useful.

In the lower image above (click it to enlarge it if you need), I’ve set up this additional slave Interpreter, called PSX-MISO-4, to take advantage of a few additional features of the Interpreter. What I wanted to do was isolate the 5th byte of slave data. So, the fifth chunk of information sent by the slave across the MISO channel. In the PS2-controller communication, this represents the right bank of buttons on the controller — triangle, square, circle, ex — as well as the front triggers — L1, L2, R1, R2. (Here’s more information about the frames of data and what they represent.) So, simply for convenience and to make things easy to interpret, I can specify that this particular Interpreter ignore the first 32 bits of data — four bytes — and just start interpreting and showing the data afterwards. Because I _really_ want to isolate this one byte alone, I also tell it to ignore basically everything else after it does the interpretation of the fifth byte — so I just say, ignore the next 800 bits.

[ad#ad-4]

And, you can see in that second image above, that that one byte is represented in binary, which is useful because each of those switches can be interpreted as a 1 (switch open) or a 0 (switch closed or pressed) without converting from decimal or hexadecimal. Here I’m holding down the triangle and ex buttons simultaneously, so bits one and three are 0.

You can also see that the SPI Interpreter allows you to specify the SPI “mode” — clock phase and clock polarity. This can be useful for trying to figure out how an unknown part is actually operating. In my experience, this can be one of the two or three serious “gotchas” when debugging SPI.

Triggers are probably the first thing you’ll set up, but I guess the second thing I’m describing, partially because I haven’t had any complicated triggering scenarios. In the case of the SPI protocol, you want to trigger when the SS line goes low, or active. This is basically saying that the master is beginning to communicate with the slave, which is usually where your interest starts. And this is what this particular Trigger configuration specifies — Trigger when Edge A occurs once. In the main Logicport window, I specify Edge A as a falling signal on the SS line. Easy-peasy. More complicated triggers could be specified, including the variations you can see greyed out in the configuration window. If you had lots of parallel data from a data bus or something you could specify a specific data value, for example. (One thing that would be nice would be to trigger on a specific SPI MOSI value or a specific I2C device address but for reasons I don’t entirely understand, it was explained to me that this is the equivalent of time travel or something. The work-around is to create a debug trigger on an unused signal from your device to indicate that the thing you want to start watching is now happening and use that signal to trigger the Logicport. Fair enough.)

Finally, Measurements. Another very useful and very configurable-y feature. Measurements use either a set of six movable “cursors”, the trigger point or a specific channel to make time-based measurements. You use this Measurement window to specify what you’d like to measure and what you will use to make that measurement. Here I’m using all of them. First, Measurement A is a frequency measurement, using the built-in Hardware Counter (nice..). With this kind of measurement, I have to specify the source, but not in the Measurement Setup window, strangely enough. In the top of the main window, I specify the Measurement A Source as channel D6, which is the blue/white wire from the Logicport. In this case I have clipped that wire to the clock out (CLKO, PB1) of the Atmega324 that’s sitting on my STK500 break-out board. This simply routes the clock signal that the Atmega324 is using to that specific pin. I’ve got a 16MHz crystal connected to the XTAL pins, and so I see a roughly 16,000,000 Hz frequency measurement for Measurement A, as shown in the bottom part of the main window.

Measurement B is a time interval between Cursor A and Cursor B. That’s basically the clock period of the SCK, the SPI clock, which comes out to be 2uS. Measurement C is the same thing, only the frequency of the SPI clock, or 500KHz. Finally Measurement D is the time between Cursor C and Cursor A, which is the time between SS going low and the first bit of MOSI data, 20.1uS. (I could have also specified “Trigger” instead of Cursor C, which might’ve been more accurate.)

These are the main Logicport features I’ve used to get a basic understanding of how it works. It’s pretty straightforward, particularly for simple set ups like this. The other configurations I’ve had to tweak in order to get good analysis has been the sample rate and the logic levels. I’ve had to vary the sample rate, especially when putting a microcontroller on here that’s faster than the sample rate. With the PS2 on its own, and if I’m not measuring signals from a faster microcontroller, I can slow the sample rate down to 1 or 5 MHz. (Not that it matters a whole lot, unless I want to acquire more total samples.) The logic level specifies what counts as logic high (1) and logic low (0) for the logic analyzer. If you specify it too high, your data will go away, or appear flakey, mostly because the logic analyzer is starting to interpret noise or other spurious signals. And, speaking of noise, the Logicport has four wires that are grey wires with black heat shrink. These are for grounding the device to other things, which is crucial to avoid noise. In the case of my setup, I have one grounding the PS2 and another grounding the STK500 breakout board. This creates a common ground across all three boxes and basically eliminates spurious data and other signaling weirdness.

Printed Circuit Board Fab Houses — A Few Reviews

So, I’m at the point with the Flavonoid project that I need to start getting printed circuit boards made. (The printed circuit board includes an accelerometer, a real-time clock, touch sensor, and a bit of EEPROM memory, if you want to know.) A fair bit of the break was spent schooling up on Eagle, doing layouts, making mistakes and that sort of thing. (It’s remarkably full-featured for a free product and, despite a few quirks, does what it says it will do. Plenty of activity in the forums and help is quick to come when I’ve gotten in trouble.)As I closed in on a design I thought was close enough to gold to send off, I started poking around various forums to find out what operation might be suitable for small (1-10 piece) runs.

It turns out that most of the places you’ll hear about won’t do fewer than 5 pieces, and they’ll charge you for it, too. By way of example, I considered trying Advanced Circuits as the Spark Fun FAQ suggests them if you’re in a pinch for time. It’d have to be more than a side-project financed with my own wallet to use them, but maybe they’re better for big projects. (I compare them to the other two board houses near the end of this post.)

The one great exception is Batch PCB, the operation started up by the Spark Fun guys. They’ll do single pieces for, like..$2.50 per square inch. In my limited experience, that’s a great deal. In exchange, you’ll have to wait a bit longer to get your boards back — I think they’ve worked something out with their guy in China so that the numbers work out to get that kind of pricing.

The two places I’m trying are Batch PCB and PCB Fab Express. I picked PCB Fab Express because they had something they refer to as a special for prototypes, but it’s still pretty expensive (but less expensive than other places that’ll turn something around in under a week). I’m doing this so I know what my options are in the future. I can imagine times when waiting a couple of weeks is fine, and other times when I’d like to have something in a few days.

Batch PCB

This is Spark Fun‘s boardhouse operation, which I’d generally just use without even thinking twice, and I have, basically. The one small thing that makes it not necessarily a slam-dunk is the turn-around, which will be at least 10 days. But, that’s probably just fine, except sometimes I feel anxious. But, you know — it’s not like I have customers waiting for product or anything..just me. So, that aside, the Spark Fun guys are friends of the cause and so I support them whenever possible. What you’ll get are 2-layer (seems like they’re doing up to 4 now) boards with pretty much everything. No need to count vias or stuff. Silkscreen on both sides. 8 mil wires and a recommended 10 mils spacing. You can order one board if you want, which is fantastic (as opposed to most other places that make you order 5 of something for which you need only one, or which isn’t 100% yet, so you may end up getting 5 drinks coasters for your $100.) You can put more than one design in your board and just score the two, which can save you some trouble. They have one thing that most places don’t even think to provide — a simple, short-and-sweet Eagle tutorial on preparing your Gerbers. They have a hopped-up forum, where answers to your questions come back pretty lickity-split. Their DRC bot sends you a decent design review summary within a few minutes of uploading your Gerber .zip file (I’m still waiting to get back the DRC from PCB Fab Express, which I sent in a couple of hours ago.)

Flavonoid PCBs from BatchPCB

Flavonoid PCB’s just arrived from BatchPCB.com

All-in-all, this is the place to go if you can wait a couple of weeks for your parts. The PCBs you see above were sent in on December 28, and arrived on January 18. Considering generally delays during the holidays, and that Boulder (where those guys are) got socked in by a nasty blizzard, I’d say that’s satisfactory. Total cost for four boards with express shipping was $49.92 Compare to $82.95 for PCB Fab Express, five boards, five days, super-saver shipping. If you’re in a rush or just hopped-up and heads-down in a project, I’d guess the extra $30 is nominal. Note that PCB Fab Express won’t silk screen the back of the board, but that’s not such a big deal in most situations, particularly for prototyping.

One thing I noticed about the boards is that they’re not all 100% the same footprint. By this I mean that the way they were cut out of the larger panel (with probably lots of other people’s boards on it) resulted in slightly different dimensions. I mean, slightly. If you put the boards together like a sticks of gum in a pack, you can tell that some are slightly larger/smaller along the various dimensions. One even seemed slightly curved. This could be an issue if the packaging in which these boards are placed has critical sizing issues. But, it’s ever so slight — nothing that a fine file couldn’t smooth out, if it even caused a problem. (I’m talking about something that’s noticeable if you eyeball it, and measuring, it seems to be about 1mm or less discrepency in size.)

Summary: BatchPCB.com, four boards, silk screen on both sides, 14 business days turn-around, with a blizzard interfering, $49.92 with shipping.

Note that BatchPCB turn-arounds get shorter the more work they do as a company. Presumably, they are able to fill panels sooner and ship whatever minimums they need to their guy in China. Now (January 19) they say they’ll panelize a board in four days, so the turn-around is likely closer to 10 days or thereabouts. That’s fantastic. I also found BatchPCB to be much more “user-friendly”, as is generally the way with the Spark Fun team. (Their tutorials are excellent, particularly the one on does and don’ts for prototyping, all based on real experiences. Don’t forget their surface mount technology tutorials, too, found here. I had two situations where I needed to cancel an order I had submitted. Fortunately, it hadn’t gone too far into the cycle and they could delete the order. Their DRC bot is also quick and provides some useful graphics to give you a sanity check about what precisely you’re submitting.

PCB Fab Express
Okay, this operation seemed a little weird from the get-go, mostly because I got a call about 20 minutes after I created an account. (That sort of bothers me.) But, I talked to the sales guy and was assured that when I submitted by Gerber zip file, I’d get a design review check done and an email back. I submitted my Gerber zip file and must’ve misread something somewhere because my order was put “in process.” The board, my fault completely, had a ground plane copper pour that seemed okay, but I noticed that there were these friggin’ vias going through it. It was just all messed up, but I fixed it in about 3 minutes. Unfortunately, if they even had a DRC, it didn’t catch this (not sure it would’ve, even though it basically meant that nets that shouldn’t connect were connected.)

I tried to cancel it (calls and emails) but probably between a mix of my not being as attentive to what I clicked on and the holidays, there was no way to get the order out. I think there’s a problem in the Gerber I sent them, and I’m a bit surprised I didn’t get a DRC email or anything, but..well..I guess chalk that up to experience. (Update — it seems fine after eyeballing the boards I got.) Their prices are a bit more reasonable than other operations for the turn-around — 5 boards, 5 days, $82.95 with tax and “super saver” shipping. They’ll do a finer line spacing than is typical (6 mils). The largest drill hole they’ll do is 246 mils plated, which is fine, only sometimes a mounting hole might be larger, possibly. They have some restrictions on the average number of holes per square inch, which could be annoying if there are lots of vias or whatever. Two-layers, but no silkscreen on the bottom, which one can typically live with for a prototype.The boards just came in, which is exciting. The problem I thought I was going to have didn’t appear for some reason. Unfortunately, I over-wrote the board file from Eagle and so I can’t double-check what I sent them. (I could look at the Gerber’s, though.)

I don’t have all the parts yet, but just a cursory look-see and I thought of a few notes to think about for any redesign.

Flavonoid PCB Prototype Recto

PCB Prototype Recto from PCB Fab Express Flavonoid PCB Prototype Recto

PCB Prototype Verso from PCB Fab Express. Notice there’s no silkscreen on the bottom.* First, some of the vias are unnervingly close to the pins of the DS1306. I’ll look for that in the future and put in a via keepout or something.

* Second, the crystal for the RTC I pulled from the crystal library. The pads for the package aren’t much bigger than a via, and there’s not much of a pad to speak of on the thru-hole. It might be just as well to find an SMT pad for it, or perhaps there’s a package in the crystal library for a surface-mount device.

* The mounting pin for the coin cell battery holder on the back is a bit close to the VBAT pad I put back there. I’m not sure if that mounting pin is connected to anything electrical in the coin cell holder, but I need to check just to be sure.

Summary: Quick turn-around. No hand-holding despite getting a sales call and promise of an email once I submitted. $82.59 with shipping for 5 boards, $16.52 per board, $6.19 per square inch. They took normal Gerber’s RS274X. I used the CAM processor user language program that Spark Fun provides for Eagle in their tutorial.

Advanced Circuits
Expensive and no real reasonable hobbyist pricing for a prototype option. This is probably “okay” for some situations, but certainly not for a hobbyist who’s just looking to get some boards done. No fault, no blame. Just thought I’d add it in since I went through the trouble of checking them out, but I won’t order from them.For comparision, I got a quote from Advanced Circuits for my test case — this Flavonoid PCB that you see above. For a “prototype” run, five boards in 3 days (the longest possible turn-around), it was $47 per board, or $235 without shipping. Their best value deal is 2 days, $57 per board. One day is $61 per board, and same day is $117 per board. Their production pricing — 50 units, say — is $5.86 per board in 2 weeks, or $7.57 a board in 3 days. So, roughly speaking, BatchPCB (described below) is priced in the same ballpark as Advanced Circuits’ production prices, even at single units. My BatchPCB boards came in 2 weeks and cost $7.50 a board ($2.50 per square inch, rounded up.)

Conclusion It’s hard for me to think why I would not use BatchPCB unless I really needed boards quicker than two weeks. If I need something in under a week, I’d go with PCB Fab Express. And, if I really am in some kind of project where I need dozens of printed circuit boards, I’d almost certainly go with BatchPCB — it’s just the best value.

If anyone has any suggestions of other board houses, please drop a line.


R0014191

Update! I’ve been using Gold Phoenix when I need more boards as soon as possible — under a week. I haven’t completely run the numbers, but it’s pretty clear that for more than 10 boards or so, they’re the place to go to. If I need just singles of boards and can wait, I’ll use BatchPCB. I have a review of Gold Phoenix here.
For $89 (special summer deal pricing) you can get 1000 sq centimeters of PCB. When I put six designs on this size, I got 10 of each back. That’s 60 total boards. I paid extra to have some special features like white soldermask and black silkscreen and a $30 tax for multiple designs. Still, it seems like a great deal. Turn-around was under about 12 days.

Arduino and the Two-Wire Interface (TWI/I2C) Including A Short Didactic Parenthetical On Making TWI Work On An Arduino Mini

I have been using the Arduino and Atmel microcontroller’s generally using the SPI (serial-peripheral interface), but decided to look at the two-wire (a.k.a. I2C) interface as well. I’m doing this partially because it would be good to know how it works, but also because it’s electrically more compact. It only uses two-wires, rather than the four required for SPI, so schematic designs and board layouts become a bit more manageable. The trade-off is a little bit more complicated protocols semantics, but nothing out of control. (I’m also looking at using a two-axis accelerometer that’s much less expensive than the three-axis one I’ve been using – $4 versus $15. For some experiments, two-axes may be perfectly fine, and I’m happy to save the $11.)

The first step was making sure the Arduino would handle the TWI – there’s pretty much no reason it shouldn’t, because the Atmega8 certainly handles it. So, the next step was finding out how best to handle TWI transactions.

To do this, I consulted the Atmega8 specification sheet, which has a pretty thorough explanation of the protocol and the implementation details on the Atmega8. (There are also a couple of useful application notes available here and here.) It’s so thorough that I had to print it out. I got a pretty good understanding of how it works but before I started coding, I noticed that there were some TWI libraries both in avrlibc and in the “Wire” library in Wiring.org happens to be packaged as a “sanctioned” external library for Arduino, so that was pretty much that.

Nicholas Zambetti, who wrote the Wire library, pretty much told me it should work with no problems, and he was pretty much right. No problems. His library abstracts the TWI innards really nicely, so I don’t have to muck with any Atmega registers or anything of that sort.

I hooked up my Arduino to a handy accelerometer for testing. (I’m still using the expensive LIS3LV02DQ.) Analog In 4 goes to SDA, and Analog In 5 goes to SCL. I have pull-up resistors on those lines, but Nicolas explains that his library enables the internal pull-ups on the Atmega, so I can probably pull those from my breadboard. Either way, it’s working just fine, even with the external pull-up resistors. (I’m using 4.7k resistors.)

Arduino Mini TWI (I2C)

(I also found in one weird situation that I had to explicitly clear the clock prescaler to get the UART functioning properly. This was while getting TWI working on an AT90USB1287 – TWI worked fine, but the UART was spitting out garbage. On chips where the clock prescaler can be set through the fuses, it’s important to verify that the prescaler isn’t hard wired to divide the clock. This’ll cause anything that is dependent on timing to potentially be off kilter. In my case, the UART was expecting an 8MHz clock to determine timing and baud rate, but the clock was being divided in hardware – not even in the firmware.)

Wire/TWI (I2C) on the Arduino Mini

Getting TWI working on the Arduino Mini (Although the Arduino and Arduino Mini share a name, they don’t share the same processor. The Arduino Mini uses an ATmega168, while the Arduino..normal.. uses an ATmega8. You’ll need to recompile/re-“verify” the Wire library files in order to get TWI to work on the ATmega168/Arduino Mini. There’s a thing or two you’ll have to do by hand to get this to work, and you’ll need to do it each time you move code that’s using the Wire library to a different processor. In other words, when you decide to port the code to the ATmega8, or you put an ATmega16 in your Arduino, or whatever — you’ll need to recompile these libraries. Here’s the drill:

Navigate in a file browser or command prompt to the root of your Arduino file hierarchy. Then go into:

lib/targets/libraries/Wire/
delete Wire.o

lib/targets/libraries/Wire/utility
delete twi.o

Once you’ve done this, make one modification to the header file twi.h in lib/targets/libraries/Wire/utility. Look around line 27 for a commented out line like this:

//#define ATMEGA8

Un-comment it (take out the “//” in the front.) This’ll ensure that the internal pull-up resistors on the ATmega8 are enabled when you’re developing for the normal Arduino. You’ll only need to make this change to twi.h once and for all. Future builds of Arduino should have this fixed.

For those who are curious — pull-up resistors are required on the TWI lines — SCL and SDA. You may use your own external pull-ups, but enabling the internal ones saves you the hassle. But, I don’t think you’ll do much harm if you have the internal one’s enabled and use external ones. But, generally you’ll want to avoid having both internal and external pull-ups.)

Anyway. These modifications described above should get TWI working on the Arduino Mini.)

Here’s the code I wrote and ran:

#include

// TWI (I2C) sketch to communicate with the LIS3LV02DQ accelerometer
// Using the Wire library (created by Nicholas Zambetti)
// http://wiring.org.co/reference/libraries/Wire/index.html
// On the Arduino board, Analog In 4 is SDA, Analog In 5 is SCL
// These correspond to pin 27 (PC4/ADC4/SDA) and pin 28 (PC5/ADC5/SCL) on the Atmega8
// The Wire class handles the TWI transactions, abstracting the nitty-gritty to make
// prototyping easy.

void setup()
{
  pinMode(9, OUTPUT);
  digitalWrite(9, HIGH);
  Serial.begin(9600);

  CLKPR = (1<<clkpce);
  CLKPR = 0;

  Wire.begin(); // join i2c bus (address optional for master)
  Wire.beginTransmission(0x1D);
  Wire.send(0x20); // CTRL_REG1 (20h)
  Wire.send(0x87); // Device on, 40hz, normal mode, all axis's enabled
  Wire.endTransmission();

}

void loop()
{

  byte z_val_l, z_val_h, x_val_l, x_val_h, y_val_l, y_val_h;
  int z_val, x_val, y_val;
  //Serial.println("hello?");
  //byte in_byte;
  // transmit to device with address 0x1D
  // according to the LIS3L* datasheet, the i2c address of is fixed
  // at the factory at 0011101b (0x1D)
  Wire.beginTransmission(0x1D);
  // send the sub address for the register we want to read
  // this is for the OUTZ_H register
  // n.b. supposedly masking the register address with 0x80,
  // you can do multiple reads, with the register address auto-incremented
  Wire.send(0x28);
  // stop transmitting
  Wire.endTransmission();
 // Now do a transfer reading one byte from the LIS3L*
 // This data will be the contents of register 0x28
 Wire.requestFrom(0x1D, 1);
  while(Wire.available())
 {
   x_val_l = Wire.receive();
 }
 Wire.beginTransmission(0x1D); Wire.send(0x29); Wire.endTransmission();
 Wire.requestFrom(0x1D, 1);
 while(Wire.available())
 {
    x_val_h = Wire.receive();
 }
 x_val = x_val_h;
 x_val <<= 8;
 x_val += x_val_l;

 // Y Axis
 Wire.beginTransmission(0x1D); Wire.send(0x2A); Wire.endTransmission();
 Wire.requestFrom(0x1D, 1);
 while(Wire.available())
 {
    y_val_l = Wire.receive();
 }
 Wire.beginTransmission(0x1D); Wire.send(0x2B); Wire.endTransmission();
 Wire.requestFrom(0x1D, 1);
 while(Wire.available())
 {
    y_val_h = Wire.receive();
 }

 y_val = y_val_h;
 y_val <<= 8;
 y_val += y_val_l;

// Z Axis
 Wire.beginTransmission(0x1D); Wire.send(0x2C); Wire.endTransmission();
 Wire.requestFrom(0x1D, 1);
 while(Wire.available())
 {
    z_val_l = Wire.receive();
 }
 Wire.beginTransmission(0x1D); Wire.send(0x2D); Wire.endTransmission();
 Wire.requestFrom(0x1D, 1);
 while(Wire.available())
 {
    z_val_h = Wire.receive();
 }

 z_val = z_val_h;
 z_val <<= 8;
 z_val += z_val_l;
  // Set up to read the next register
  // Supposedly, if you set the most significant bit of
  // the register address to 1, you can do a multiple read,
  // with the register address auto-incrementing. This way, you
  // don't have to do another write — specifying the next register —
  // before reading the next register value. This would be very good, but
  // with a cursory attempt, I have yet to make this work.
/*
    Wire.beginTransmission(0x1D); // transmit to device #4
  Wire.send(0x2C);        // read outx_h
  // stop transmitting
  Wire.endTransmission();
  Wire.requestFrom(0x1D, 1);
 while(Wire.available())
 {
   z_val_l = Wire.receive();
 }

 z_val = z_val_h;
 z_val <<= 8;
 z_val += z_val_l;

  // z axis acceleration, all set.
  // Perfectly still and with the z-axis parallel to the ground, it should be about 1024-ish
  // (I find in practice it is around 1019.)
  // When the z-axis is orthogonal to the ground, it should be zero.
  // 1024 is +1g acceleration, or normal gravity
  // 2048 is +2g
  // 0 is 0g
  Serial.println(z_val, DEC);
*/
Serial.print(x_val, HEX); Serial.print(" ");Serial.print(y_val, HEX); Serial.print(" "); Serial.println(z_val, HEX);
delay(100);
}

Technorati Tags: ,