Wednesday, March 2, 2022

Widget Wednesday: Wiring

 First things first:  What is it good for?  Actually, two things:

  1. Connecting widgets to the tie-points (i.e. holes, a.k.a. "pins") on a breadboard
  2. Connecting the breadboard tie-points to each other to make complete circuits

 For "Boarduino" purposes, there are two (realistic) options:

  • Flexible jumper-wire
  • Solid-core AWG wire

Let's break down the differences, which are almost-but-not-quite diametrically opposed.

  • Flexible wire is ideal for prototyping.
  • Flexible wire is also fine when you have to connect a breadboard-hostile widget to your project.
  • Solid-core AWG wire is what you use to connect breadboard pins for a project in full-time, real-world use.

In case it isn't obvious right now, you're going to want a mix of both kinds in your kit.

Flexible jumper-wire:  This is made for prototyping and not real-life.  Mostly.  The exception is when the widget doesn't actually plug into the breadboard.  That situation might or might not come with additional issues.  We'll get to those in a bit.

This kind of jumper-wire, under the coloured plastic coating, is actually a bunch of very fine copper wires.  Which is is less likely to break.  But, in my experience, it does like to degrade.  

"War-story":  I was experimenting with something called a Serial-to-Parallel chip to try and control 8-16 LEDs with an Arduino by way of three wires.  Problem was that one of the wires was going wonkier by the minute.  Well, no.  Problem was that I'm a programmer by trade.  So if anything goes wrong, my first instinct is to blame my code.  (Second instinct is to blame file/folder/network permissions, but that doesn't apply here.)

Ultimately, I had the great, good luxury of having an extra breadboard and enough extra widgets to duplicate my setup.  The second version worked flawlessly.  So I methodically replaced each wire in the original breadboarding project and realised that I had a bad one.  The wires weren't even that old, but it's not like they come with an UL rating, either.  So lesson learned.  (End of "war-story.")

Back to those "additional issues."  Off the top of my head, I can think of two widgets that I can only describe as "breadboard-hostile."  One is a common version of the passive infrared (PIR) sensor.  There are two of them below, so that you can see the underside and top-side of the unit.  The top-side (right side) is the lens that acts sort of like an eyeball; the brains -- including the header-pins that connect the sensor to the rest of your project are on the bottom of the board (left side).

The header-pins are the yellow bits near the middle of the pair.  Solid, clearly-labeled header-pins...blocked by two capacitors.  (If you don't know what capacitors are, don't worry; we'll get to that, too.  Just not today.)  

Everyone associated with this board's design is a jerkface.  Not only can you not plug this widget into a breadboard, even a printed circuit-board would have to be designed around this layout-felony.  

It doesn't have to be this way.  The first PIR sensor I ever ordered certainly wasn't this way.  But some slovenly, bean-counting dweeb decided that their rat-race-to-the-bottom retailers could shave $0.00000000000001 off the cost of each unit by massively inconveniencing their customers.  A pox and a plague and a sock-eating dryer upon everyone responsible for this travesty.  (Did I mention that these people are jerkfaces?)

Anyhoo.  Sometimes this sort of stupidity can be turned into a virtue.  But in this case it was only because I had a variety of jumper-wires on-hand.

As some of my Gentle Readers know, my very first real-world Arduino project was designed to teach our omnivorous ElderCat to stay off the counters. 

And, while Mister Kitty is not exactly the sharpest tool in the shed, it only took it three rounds with this thing to convince him that his hoomins were onto him.  (After ten years of yelling and squirt-guns and locking him in the basement after hearing the tell-tale "thump" of his paws hitting the kitchen floor, you're darned tootin' I'm patting myself on the head for that breakthrough.)

The mechanics of this setup are pretty straightforward:

  • Top right is the Arduino-ish Adafruit "Trinket" that is the brains of the outfit.
  • The green board at the bottom-left is a passive infrared (PIR) sensor that detects deviations from the ambient temperature (i.e. a warm, moving body) w/in 3-4 meters
  • The black button is a piezzo buzzer -- a crude audio speaker.

When the PIR sensor detected a warm body in motion w/in the 3-4 meter range, the Trinket fired off a sequence of timed electrical pulses which made the piezzo buzzer play Looney Tunes Tweety-Bird's "I Taught I Taw A Puddy-Tat."  And -- dude! -- it was loud.  Which, of course, was the point.



 

But at the time, we hoomins weren't certain that it would be that easy to convince Mister Kitty that he was being watched.  Also, it didn't take much for either of us to trigger this thing.  And we probably levitated as much as Mister Kitty.  Clearly, we needed a bit more precision.  So I added something called an ultra-sonic range-finder, which acts somewhat like a bat's echo-location.  

In the Mark II version, the PIR sensor detected a warm body moving somewhere in that 3-4 meter range and only then did the Arduino trigger the range-finder to determine whether there was a solid body within a half meter or so away.  Only when those two conditions were met would the piezo element sing its loony-tune to tattle.  

Muuuuuch less levitation on the part of the hoomins.  And after a month or so, the Mark II followed its predecessor into honourable retirement.



Problem was, the 2nd PIR sensor I bought came with that obnoxious, breadboard-hostile layout.  Which is why, in this case, you see it attached to the rest of the project via an umbilical cord of jumper-wires.  But it turned out to be the proverbial blessing in disguise in that also gave us more flexibility in how we could orient the PIR sensor and the ultrasonic range-finder.  Otherwise, we'd be limited to 90-/180-/270-degree angles.  There might be folks in this world with such geometrically-pure lines of sight on their kitchen counters.  Those people are psychopaths who Doordash all three meals. ;~P

And, as much as an chick raised as an anglophone during the 1970s rolls her eyes at the notion of anything under the sun -- including electronics and language -- being gendered, flexible jumper-wires are labelled with three gender-pairings [thumbs nose].  

  • M/M wires have "male" (i.e. solid wire) headers on both ends.  Because they cover at least 90% of prototyping, you will likely get far, far more mileage out of these than the other two kinds.  Stock up accordingly, 
  • M/F wires are...hermaphroditic.  A solid wire on one end and a matching socket on the other. Again, sometimes you need to connect widgets off-board; these are your play.  Those both came into play with the examples above.  Again, stock up accordingly.
  • F/F have the socket on both ends.  Thus far, I can't recall needing any.  But I can recall being a few $CDN short of the threshold for "free" shipping, and so the small handful I have were basically "free." [shrugs]

Regardless of form-factor, jumper-wires (like the solid-core wires we'll be talking about shortly) come in a rainbow of colours.  In the language of electrical engineering, a few colours matter.  Like far too many other things, which country/region you live in determines the norm.  In this (Canadian) series, we're dealing exclusively with two colours/functions:

  • Red == Positive
  • Black == Ground (functionally equivalent to Negative for our DC purposes)

Norms (and consistency) matter -- particularly when you need someone else's help debugging a layout.  Beyond that, it's up to personal preference.  Shocking precisely no one, I have a couple of those:

  • The "warm" colours (orange, yellow, white) I use for "output."  In practice, that means things like lighting up an LED, buzzing a Piezo element, controlling some sort of motor, what-have-you.
  • The "cool" colours (blue, green, purple) I use for "input."  In practice, that means things like listening for the user to press a button, reading a sensor-value, what-have-you.

Again, that's personal preference.  But it's worked out pretty well so far.  Especially when one of my creations stops working and I haven't looked at it in awhile.  Like every person with a full-time job, debugging my personal projects is done in one-/two-/maybe-three-if-I'm-lucky-hour bursts.  Colour-coding in the here-and-now is a priceless gift from Present Me fiddling on a weekend to Future Me trying to get something up and running before bedtime on a weeknight.  'Nuff said.

Okay, assuming that you're done with prototyping and ready to put your invention into real-world use, AWG-based wiring, by laying flush with the breadboard, is far, far less likely than even a short jumper-wire to be accidentally pulled out where it could become a menace. 

Solid-core American Wire Gauge (AWG) wire:  Again, first things first.  AWG22 wire is your no-brainer breadboarding go-to.  In a pinch, you can probably get away with AWG20 (which, incidentally, is thicker than AWG22, not thinner).  There will be more wear & tear on your breadboard, but if that's all you can find down at the local hardware or auto parts store, it will get you through until you can order 22-gauge. 

Whatever else you do, give the pre-formed wire-kits a big ol' pass. #DoAsISayNotAsIDid  The reason being is that pre-formed wire is colour-coded by length, not function.  We'll deal with why that's a problem in just a bit.

Now.  The thing with AWG wire (of any gauge) right off the roll is that you will need an extra tool -- more likely two tools -- to work with it.  First and foremost is a wire-stripper to separate the insulating plastic from the conductive metal.   Any self-respecting wire-stripper will come with a variety of notches (corresponding to different gauges) plus a wire-cutter built in at the rear of its "jaw."

Because you're already expecting to work in AWG22, my strong recommendation is to permanently mark the 22 "notch."  Grab a tooth-pick and break out (or borrow) a bottle of nail-polish.  Bright red, hot pink, baby-blue, glitter-gold -- whatever will stand out against the dull black or maybe dull silver of the jaws.  Dunk ~1cm-worth of toothpick into the nail-polish and use it as a pen to draw a stripe parallel with the "22" groove on all four sides of the notch.  Then there should never be any ambiguity about which notch you're using to strip the wire.  Because when your wire-stripper includes finer gauges (e.g. AWG24, AWG26, etc.), "ambiguity" can mean that you cut your wire where you meant to strip it.  Ask me how I know.  :~/

When you're cutting wires for breadboarding, you will probably also want basic needle-nose pliers to bend the wire at right angles.  Yes, you might be able to skip the pliers and do this with your fingers.  Assuming that you're, um, blessed with something like the ten scrawny won't-last-a-day-after-The-Apocalypse twigs that my DNA gave me.  And even I prefer the precision of pliers  Pony up a few bucks at Home Hardware and call it a day, already.

Cutting wires for breadboarding has a learning-curve (albeit shallow).  But because I hate waste as much as I love you, I'll try to save everyone a few cm of wasted wire and go over my technique here in a "FWIW" spirit:

  1. With the wire-stripper, strip just under 1cm of coating from the free end of the wire.  My go-to technique is to grab onto the wire where I want to cut the plastic and twist the cutting edge of the notch around the wire core to ensure I cut through all the coating. 
  2. Insert the stripped ~1cm of wire into the "From" breadboard tie-point/pin.
  3. Bend the wire at a 90-degree to lie flush with the breadboard. 
  4. Stretch the wire to the "To" breadboard tie-point.
  5. Bend the wire at a 90-degree angle north of the breadboard -- i.e. the loose end of the wire should point up.
  6. Clip the free end of the wire ~1cm above the surface of the breadboard.
  7. Temporarily remove the "From" end of the wire from the breadboard to make the wire easier to finish off.
  8. Strip the coating off the "To" end of the wire from about half-way into the curve.
  9. Using your needle-nose pliers, bend the newly-stripped wire 180 degrees.
  10. Insert both ends of the wire into the breadboard tie-points.

(Bee-tee-dubs?  The same colour-coding principles as flexible wires apply.)

Once you have cut, stripped, and formed AWG jumper-wire, it tends to be less reusable than the flexible wires used for prototyping.  So until you develop an instinct for breadboard layout, you can save yourself a bunch of scrap by virtually breadboarding your project.  I talked about a couple of options (Tinkercad and Fritzing) toward the end of the "Breadboards" installment.  If you haven't checked them out yet, please do.

Next time, I want to talk about options for powering breadboarded projects.  Until then:  Tchein ton siault d'beluets!