Wednesday, February 16, 2022

Widget Wednesday: Breadboard Basics

As much as I lost my heart to -- and built my first Arduino project on -- Adafruit's Trinket, the game-changer (for me) was stumbling across the chip-on-board form-factor.  That form-factor is not unique to the Arduino universe, where it's sometimes called "Boarduino."  We'll get to that in a later post.  For now, however, I want to focus on the mechanics of the breadboard itself.  Because [extremely schmoozy voice] that's where the magic happens [/extremely schmoozy voice]

First things first:  What is it good for?  "Prototyping" is the obvious answer.  But, chez fivechimera, there's also a long -- and sometimes even honourable -- history of prototypes being "good enough" for literal years of full-time use. Until they're not and the parts go back into their Cabela's tackle-boxes for next time.

This is not a novel concept: "Breadboarding" gets its name from the days of yore -- by which I mean literally a hundred years ago -- when you wired up your project by literally pounding nails into a breadboard (or any wide slab of wood), and winding copper wire around them to create a circuit.  Homebrew ("cat's whisker") radios were a Very Big Deal.  (See also: https://www.mikeselectronicparts.com/wp-content/uploads/building-a-crystal-radio.pdf)  

But, doubtless, one big selling point in those pre-Radio Shack days, was that once that project's usefulness ended, one could always pry loose the widgets, un-string the wire for later use (copper is expensive, y'all!), and pull the nails from the breadboard to restore it to its blank-canvas state.

And so reusability is the main reason I prefer the Boarduino form-factor.  Assuming that you're working w/in certain constraints, reducing project footprint is the second-best reason.  Assuming, of course, that the project can live inside certain limitations:

  1. Current limitations:  Each small hole (a.k.a. "tie point," a.k.a. "pin") on a solderless breadboard should never carry more than 500mA, or 1/2 of an Amp. of current through it.  Theoretically, they can take up to one Amp.  Just don't.  Most especially projects that will be up and running for awhile.  It's not worth the risk.
  2. Voltage limitations:  Stick to 5 volts DC.  Again, you want to stay well within the safety zone.  
  3. Pin spacing:  If the widgets you're planning to plug into your breadboard don't have pins 2.5mm (or 0.1 inch) apart, you're going to need to make other wiring arrangements.  We'll get to those options in a subsequent post.
  4. "Stupid-proofing":  Nothing in a breadboard's construction limits current polarity.  By which I mean, if you mix up positive and ground, the breadboard will not step in to save you.  At best, your project just won't work.  A short can melt the breadboard plastic.  (Ask me how I know.)  You also risk frying any widget connected to the faulty wiring -- up to and including the microcontroller.
  5. Layout limitations:  Do you have enough room on the breadboard for the microcontroller chip (a.k.a. MCU) and all your widgets?  If not, how are you going to work around that when your project is up and running in the real world?

Which brings me to breadboard sizes and their features (or lack thereof).  There might be a few exotic outliers, but here's the range I've stumbled over through the last few years:


I would say that they come in all shapes and sizes, except that the shape is limited to rectangular.

Half-size (top left):  In my experience, this is usually the optimal size for a Boarduino projects. The holes ("pins") come in two flavours.  



  • The two rows that run (horizontally) along the long edges of each side are often referred to as "power rails."  Traditionally, red is connected to the positive end of the power source and runs, uninterrupted from one end to the other.  Ground is wired into blue.  By default, the power rails on each side are independent of each other.
  •  If we consider the power rails to be "rows," then the other flavour of pins can be considered "columns."  These run perpendicular to the rails.  The five pins of each column -- highlighted in neon green -- are connected to each other.  They are not, however, connected to the column on the other side of the trench that runs between them.  

Full size (right):  Similar to the half-size with more "tie points" and often more flexibility.  Depending on the manufacturer, you might need to bridge the two halves of the power-rails.  Or not, depending on your project layout.

Mini (middle left):  In this case, there are no power-rails "rows"; only "columns" of five interconnected pins.  You will have to use one column for a positive rail and one for the negative.  Which brings one big no-no:  Never, EVER wire positive and negative into the same column.  Even for the simplest project.

Micro (bottom left, shown top and bottom):  For grins, I'm throwing this one in.  And, no, I have no idea what's going on with those "Lego-bumps" on the underside except to guess that they allow the breadboard to be glued/screwed into place from the underside of some project???  Again, I have no idea.

Now.  All of the above assumes that you have some basic understanding of how circuits work.  If you're still new to the concepts and/or hesitant to play with live electricity, you can "practice" your wiring skills virtually. 

Most electronics prototyping/visualisation software is geared for PCBs -- printed circuit boards.  That's both an intermediate/advanced move as well as one more or less alien to this feature's "Boarduino" focus.  If you're serious about electronics design, you will need to learn how to "think" in PCB.  For now, don't worry about it.  In practice, that leaves two non-trivial options:

TinkerCad is "free" in the sense that you can give AutoDesk your email address -- be sure to use the "spam" one -- and play around in the "Electronics" section to see what I mean.  

  • Pros:  It's "free" in the sense that you're giving a large company your email address and the user interface is quite intuitive.  Also, it's online, so no PC-vs.-Mac-vs.-Linux issues to worry about
  • Cons:  AutoDesk offers shockingly small range of "widgets" to plug into the breadboard.   

Fritzing is payware.  (Normally, I'm more than happy to trade money-for-value...until that money is processed by [spits] Paypal.)

  • Pros:  A much, much broader variety of widgets.  Some vendors (wisely) contribute to the Fritzing project; others don't.  But you can normally find something "close enough."
  • Cons:  A slightly steeper -- if unsurprising -- learning-curve because there are more features.  (Pro tip:  Save yourself a bunch of grief and learn how to "lock" main widgets like the breadboard in place.  Otherwise, it's far, far too reminiscent of the mayhem of resizing and image in Microsoft Word.)

Of the two, I personally prefer the features-vs.-complexity balance of Fritzing.  If you're not sure that you're going to stick with this hobby (or don't have access to a payment method that [spits] Paypal will accept), TinkerCad should be more than enough to get a feel for breadboard circuitry.

That' about all I have for this installment.  An excellent deep-dive into the construction of breadboards can be found here: https://protosupplies.com/guide-to-solderless-breadboards.

Next time, I'm planning on going through the often-overlooked mechanics of creating circuits, with, of course, a particular emphasis on breadboards.

Until then, Tchein ton siault d'beluets!

- - - - -

Credit where it's due:  Dennis Freeberg, for the square-on photo of the half-size breadboard.

Wednesday, February 9, 2022

Widget Wednesday: Multi-meters Matter!

First things first:  What is it good for?  The short answer is measuring voltage (for our immediate purposes, DC voltage) and resistance and, hopefully, amperage.  The longer answer is that, if you don't make your multi-meter part of your tinkering/debugging, you are (in the immortal phrasing of South Park) gonna have a bad time.

Regardless of what kinds of widgets you intend to tinker with, your first purchase should be a multi-meter.  I'm serious here.  Like, Global Thermonuclear Armageddon levels of serious.  When you're first tinkering, a multi-meter is mainly useful for checking voltage levels and verifying whether current is flowing where you intend it to flow...and in the direction you intend it to flow.  A short-circuit can be an, ahem!, highly unpleasant surprise -- even without damaged equipment/widgets.  A multi-meter will ultimately, easily pay for itself in visits that you don't receive from The Magic Smoke Fairy.  

In addition to its money-saving graces, a multi-meter will not only give you more time to "play," it will also make that time more enjoyable.  What do I mean by that?  Well, I'm a programmer by trade.  So my first instinct is to blame my own code when I connect all the wires and [sad trombone] the project doesn't work. I've wasted entire evenings on wonky jumper-wires.

But in this hobby, I'm usually working with inexpensive, no-name widgets -- the kind shipped by the cargo-container-load.  These are most certainly not UL-rated, much less ranked in Consumer Reports.  (This includes power supplies, which is a whole 'nuther subject for a whole 'nuther post.) 

Also, unlike programming for full-size computers, debugging options are pretty thin on the ground.  I'm not at a point where I can justify the cost of an oscilloscope.  Often, a voltage level (or lack thereof) is my only way of seeing what's going on inside the wires.  

I was naive when I bought my first multi-meter; I was casing out the "Electrical" aisle at the small Home Hardware franchise, saw this model, and thought, "Oh, hey!  I'm gonna want one of those!"  Turns out, it doesn't measure amperage.  That's mostly an inconvenience; rarely do I need anything besides DC voltage:   

  • "Is this supposedly-recharged battery ready for the 'special' recycling box?"
  • "Is this jumper-wire borked?"
  • "Did I screw up my voltage-divider math (again)?"

That being said...get yourself one that measures amperage alongside DC voltage, AC voltage, and resistance.

Also make sure that you have more than one way to attach the red and black tips of your multimeter to whatever it's measuring.  Like I said, I was pretty naive; my model only came with the probe-style leads.  For checking battery voltage, that'll do ya: 

 

One important note about the colour-coding here:  

  • Red == Positive voltage, noted by the "plus-sign" on your battery or DC power source.
  • Black == Ground voltage, noted as the "minus-sign" on your battery or DC power-source.  There's technically a difference between "negative" and "ground" voltage.  That's (once again) another topic for a later time.

 "What is it good for?" Verdict:  This battery is freshly charged.  (Note:  AA and AAA Alkaline batteries -- i.e. the throwaway non-rechargeable ones -- are expected to put out 1.5 volts in their prime.  Their rechargeable counterparts?  Only 1.2 volts.  And I will go to my heckin' grave wanting to wedgie every last corporate moron responsible for that travesty...)

 But for most other purposes, probe-type leads are useless.  Even if you had enough hands to hold the leads to the positive and negative wires in your project's circuitry, we all can understand what a spectacularly, gawdawfully BAD IDEA that would be.  Even with the relatively low voltages/currents of battery packs.

That's where "alligator cords" come in.  Checking the voltage of bunch of batteries in a pack looks like this: 


 

"What is it good for" Verdict?  We have three AA rechargeable batteries in series, with the expectation that they will add up to ~3.6V.  So, yeah, these are pretty freshly charged.  

My Gentle Reader will notice that, again, colour-coding comes into play.  When you buy a handful of alligator-cords, they are colour-coded.  Stick to the formula:  Red is for positive voltages; black is for ground/negative.  We'll talk about other colours at a later date.

But what if you're measuring voltage/current/resistance in-circuit?  For instance, how can we objectively know that the 3mm LED in this circuit is operating at something close to the optimal voltage:

Even accounting for the artificial lighting under which this photo was taken, that green LED looks a tad pale.  Going by experience, that is usually a symptom of low voltage.  But, checking the LED's datasheet, we know that the LED's operating-range voltage is 3.0V-3.6V -- a tad under the 3.72 voltage of the battery-pack.

Now, because the "Intro to Electronics" tutorials say that we're supposed to add a resistor to the LED's circuit to keep the voltage under the 3.06V maximum, and also the operating current under 20mA (a.k.a. 0.02 Amperes).  The kit came with 220-Ohm resistors for this kind of circuit, and I popped in one of those to make sure that the LED doesn't pop because -- dude! -- those things can be LOUD when they blow out.  Ask me how I know. :~/

So let's see what the multi-meter has to say about the voltage.  We do that by splicing the multi-meter into the circuit with the alligator cords and a couple extra jumper-wires (the latter of which we'll address in a future blog-post):

 

 

To splice the multi-meter into the circuit, notice how we add a red ("positive") jumper-wire ahead of the LED and a black ("ground") jumper-wire behind the LED.  And how we patch each jumper-wire into the appropriately-coloured multi-meter lead via jumper-wire.  We are essentially making the multi-meter the "middle-man" in the circuit to measure the total amount of voltage.  We could do the same for resistance.  Or -- with a more sophisticated multi-meter -- the amperage.  (But, with Ohm's Law, you only need two out of the three values to compute the other.)

"What is it good for?" Verdict:  Turns out that we were right about the voltage (and by the math of Ohm's Law, current):  That LED is, basically, running too cool.  (The upshot -- again, something that will be covered shortly -- is that we can afford to adjust the value of the resistor used in the circuit.  Downward, in fact.

That's a good place to start/end with multi-meters.  When "Widget Wednesday" covers trimpots and rheostats and the like, measuring resistance will come back into play.  But for now, the intent is to give My Gentle Reader enough tooling to figure out whether or not the magic electron-juice is flowing through a given set of wires...and whether it's too little or (worse!) too much for the widgets in its path.

Until next time, Tchein ton siault d'beluets! 

- - - - -

Credits where they're due:

  • Dennis, for taking the first photograph while my hands were busy keeping the battery from rolling away from the multi-meter's leads.
  • Nicole, for "rehoming" her electonics supplies and gear with me, including the alligator-cords.  One can never have too many alligator-cords. :~)
  • BJW Electronics, for soldering leads onto the wire of the battery-pack to make it breadboard-friendly.


Wednesday, February 2, 2022

Introducing "Widget Wednesday"

I'm kicking off a regular feature that digresses more than a little from the usual focus on programming as a vocation and a business.  

I've been faffing about with Arduino since January of 2015 and failing my way into micro-controller programming every since.  To date, I've done far more personal tinkering than professional work.  And while I've learned whole new skills throughout the last seven years, the lesson that hit hardest was how the overlap between folks who understand circuitry and folks who can write code for micro-controllers is surprisingly thin.  

That said, the RaspberryPi and, to a greater extent, Arduino (and the ecosystem it spawned) have been nothing short of game-changing.  Correspondingly, an abundance of inexpensive, usually breadboard-friendly electronics (what I'm going to call "widgets" from here on out) has mushroomed.  Which puts both those ecosystems into something of a virtuous cycle.

Mostly, I play for Team Arduino.  My use-case for the RaspberryPi has largely involve running tiny, specialised web servers inside a network.  In this context, I adore the Pi.  But for what's generally known as "physical computing"?  It's a sub-optimal form-factor.  Now, for all I know, this might have changed with later models.  But the earlier Pi iterations offered a laughably low amount of current to any 3rd party widgets connected to them.  I'm talking about hooking up three 3mm LEDs and powering them at ~80% capacity.  From a board that requests a 2-Amp power supply (enough to power 100 of these LEDs)?  Yeah, laughable.

Additionally, my experience with the Pi (thus far) is that it's Global Thermonuclear Armageddon(TM) levels of overkill when it comes to the computing power it takes to process these widgets' input and output.  Mainly because whatever's controlling the widget often only needs to know "Is it on or is it off right at this very microsecond/nanosecond?" Or, "Does this widget need to be on or off at this very nanosecond/millisecond?"  Or, if we start to get fancy, "Is it outputting a current somewhere between 0V and 5V right now?"  

For that purpose, the Arduino's 8-bit processor and trivial storage space are more than adequate.  Face it:  8-bit computing ran the original Space Shuttles.  And I'm more interested in the Space Shuttle, vs. the number-crunching IBM beasties that computed its trajectories/orbits Back In The Day(TM).

Now.  For a 21st-century web programmer who takes 64-bit processing with gigabytes of memory/storage for granted, there was for sure some Getting-Used-To(TM) involved.  But I was lucky enough to stumble into Programming School(TM) in the 1990s when C/C++ was still used to flush out the posers.  (Hello, bit-shifting and bit-masking!)  Then stuff like StackOverflow happened and embedded computing stopped being such a High Priesthood.

But as much as I manage to fumble and faff my way through circuit-diagrams, I will always, always see things through a coding lens.  Alas, that's not the best perspective from which to learn - much less presume to coach anyone else in learning -- this topic.  I personally know at least a half-dozen folks who have legit. forgotten more circuitry than I will ever know.  But they come to me for code.  And there lies the rub.

So on those occasions when I'm asked to teach Arduino, I am fully, cringingly, aware of the huge disservice I'm doing by skimming through the bare-bones concepts of, say, Ohm's law or how to calculate resistor values.  Or what to look for in a datasheet.  Yadayadayada.

Because the reality is that if you're already a programmer, learning the Arduino API is literally the least of your concerns.   That's even true when you get bored with the API and branch out into the pure C/C++ code beneath the surface...or (gasp!) the snippets of Assembly language that can be spliced in when performance matters.  No, it's the hardware (not to mention the electromagnetic branch of physics) that will hose you from Hell to breakfast and back again.  So you'd better get used to the idea before you get cocky.  There's coding for the hermetically-sealed walled garden of a web browser or smartphone.  And then there's the messy real world.  Where allllllllll sorts of things can go wrong.

The upshot is that, while I might have to screen-shot snippets of code from time to time, right now I really can't see needing anything like a Git repository.  Maybe for the datasheets?  I dunno -- I guess we're going to find out together.

Specifically, I will be focusing on electronics components that I have used -- or for which I have a designated project.  In reality, a lot of this will be an exercise in me thinking out loud, to some degree organising a meandering reference manual for my own sweet sake.  Documenting things, even things I already know, forces me to understand them at a deeper level.  Writing, even as a moderately fast typist, slows me down.  That's a good thing.  I have no option but to question how, exactly, I actually came to know what I think I know.  Sometimes that's a rude awakening.  But again, this is a good thing.  

Thus, this series/feature will start off pretty basic and hew fairly close to the proverbial metal:  Elemental generic components to start, progressing to inexpensive, breadboard-friendly "breakout boards."  Again, we can thank the Pi/Arduino ecosystems for the absolute embarrassment of riches we now enjoy here.  Limor Fried's Adafruit (and similar businesses like Sparkfun) has reaped the dividends of the education they've sown (in tandem with making these boards affordable enough to take a lot of the risk out of tinkering).  Explaining basic concepts like "What is a circuit?"  "How are Current, Resistance, and Voltage related?" in a way that doesn't make anyone feel condescended-to is an invaluable service to beginners who might not have access to formal education.  

Additionally, Adafruit and Sparkfun, like the Digikey-/Mouser-scale suppliers, are good about providing datasheets/specs.  (WIDGET SHOPPING COMMANDMENT #1:  Thou shalt not add a widget to thine cart without downloading its datasheet.)  Datasheets exist to splash some cold reality on the idea you had in this morning's shower.  E.g.: This widget won't (reliably) work if the ambient temperature is below the freezing point.  Or:  This widget operates at a different voltage than the microcontroller.

But, helpful as tutorials and datasheets both are -- and you always read them both, riiiiiiiiight??? -- someone stepping beyond the "Hello, World!" winky-blinky LED phase of embedded electronic development is left to fend for themselves on their first non-trivial project.  That can leave a newbie on the proverbial horns of a dilemma:

  • A widget's datasheet will tell you the min./max.voltages/currents/temperatures/etc. of where it will and won't work.  But it's hardly inspiring.  
  • A project found on the web may have a given widget in its parts-list but give no clue about what makes that particular widget a good fit for that particular project.  (So screw your project, amirite?)

"Widget Wednesday" aims to fill that gap.  So when a given widget is profiled, the first thing covered is "What is it good for?" Then we'll address things like constraints, limitations, tolerances, reliability, etc..  Like I said, I've been doing this for several years; I have a few war-stories to share.  Elsewhere, I've only been half-joking when I've said that the most toe-curling five words in the English Language are "Ask me how I know."  Stick with me, and you'll find out.

Until next time, Tchein ton siault d'beluets!