Day 26: Raspberry Pi3 in the house (and seriously, Superman?)

Definitely the coolest scene in the movie for me.

Comic Con happened recently and a series of superhero movie trailers (on Youtube) later, I found myself itching to watch Batman Vs Superman (2016). I stayed up to 2am to finish watching, and I only have this to say about it: cool graphics and scores, but terrible plot. He could have flung the spear!

Finished Ruby on Codecademy

After about a week of 2–3 hours each day, I’ve finally finished the Ruby introductory course on Codecademy.

Ruby is the first ‘new’ programming language I have learned since JavaScript, which I dabbled in extensively for two months before the start of this 30-day writing commitment. Learning it was easier because of my recently acquired dexterity in reading lines of code (as opposed to English sentences). A lot of the concepts in Ruby also appear in the web programming language JavaScript, and that definitely helped in making Ruby more palatable and easy to digest.

From what I’ve read and heard, Ruby is mainly used in writing back-end scripts that handle databases and queries to them, but I don’t recall Codecademy once mentioning this. They should if it is true. That would really help frame the utility of learning Ruby for learners.

New arrival! A full fledged computer shipped in a box smaller than a smartphone case… wow.

Pi 3 just in

In other news, the Raspberry Pi 3 single-board computer I ordered just came in the mail today. Just two days after placing an online order on element14 (formerly Farnell) — nice. The SBC came in a sleek box that looks premeditated, as though the Raspberry Pi Foundation folks made it emphasise how far computing has come.

A silly thing cropped up as soon as I started fiddling with the RP3 though (as usual). I have never used the GPIO pins on an RP before and hadn’t realised that you need either female-male jumper wires or a proper add-no ‘cobbler’, as Adafruit calls it, to map the pins out onto a breadboard for easy interfacing. Nope, I have neither, and have to look for them tomorrow. (I suppose I could use crocodile clips, but that runs the risk of short-circuiting the nearby pins, and I would like to not set that kind of personal record so soon.)

hello_teapot sample programme in Raspbian OS.

So I did the next best thing to get a feel for the Pi: run all the the example programmes that ship with the Raspbian OS! Even though I previously owned a Raspberry Pi B+ (now used as the basis for my home surveillance camera), I never went through these exercises. Half a year ago when I first got it I was full of trepidation and didn’t dare tinker with it. Now things are slightly better and my anxiety about tinkering is somewhat subdued through incremental learning.

The Raspbian OS comes with programmes that showcase the Pi’s computing power, from playing HD video to rendering 3D objects. It was interesting while it lasted.

The voltage and current mystery

At this point I realised something that I now know that I previously had not: voltage and current.

For almost every person aspiring to make electronic projects, voltage and current will appear mysterious and difficult to grasp. The only thing I knew about them are the formula that my Physics teacher taught me: Power = Voltage x Current (P = IR) and Voltage = Current x Resistance (V = IR). These say nothing about what they measure.

Here’s what I know about voltage and current at this point. It’s important to know how they affect the overall operation of the circuit:

  • Voltage (measured in volts): Important to not exceed the safe range. Most single-board computers and microcontrollers used by hobbyists and pros alike operate at 5 to 9V.
  • Current (measured in amperes, or amps): Important to provide excess capacity in case there are power hungry peripherals attached to the computer. That said, there’s a critical caveat: if a peripheral draws more current than the computer (or other controlling board) it is attached is rated for, don’t power them from the same power source. Instead, power the high-amps peripheral with an external power source, with a transistor connection to the computer/controlling board. This is the way to achieve the functionality of turning on/off a power-hungry DC motor, for example, without running too much current through the Raspberry Pi and killing it while at it.
  • As an example, the Raspberry Pi 3’s recommended ratings are 5V and 2A. Using a power adapter with 5.2V and 5A is reasonable. If you use 7V and 2A, it may be fried. Doubt anyone likes a fried Pi.

I find that these details can be forgotten if they’re not frequently put to use. The only solution I know is to do as many projects as possible until a threshold is crossed, when things start to become second nature.

Raspberry Pi 3 in my hand. There are so many things you can do with this!

Network effect of expertise

I stopped to think about the approach I’ve decided to take to learn electrical engineering today because I wanted to know if what I’m doing is working and effective. Snipping and distilling everything I jotted down, this is the process that I use to learn electronics at the moment:

New component/board → fiddle physically and make observations → hook up with power and test with help of tutorials → use in a bigger project → internalise what works, what doesn’t, and why.

An example:

New Raspberry Pi 3 arrived → felt the weight in my hand, observed what chips are on board, noticed peripherals are literally skirting around the edges → tried hooking up to LED for testing with Python script, but realised lack of female to male jumper wires … to be continued.

By the end of the process I would have accumulated a small repository of what-works and what-does-not-works. That is my working knowledge base.

Often, I’ve realised, having an entry in that knowledge base means being 80 percent proficient in using that component. The things-to-know in the remaining 20 percent are harder to learn but also much less often needed.

For example, an LED only works when used in the correct direction because it’s a diode, and diodes are uni-directional components that only allow current to flow in one direction and not the other. An LED is also rated for maximum volts allowable before it goes kaboom, which means an appropriately rated resistor should usually accompany its use. That’s the 80 percent. Why an LED might flicker during operation, how much or little current it draws and how that changes with its temperature and other things like that belong in the 20 percent.

The cool thing about learning electronics this way (by no means ‘my’ way in terms of originality) is the network effect of expertise at play. When you know how to work an LED and a photoresistor, you are now suddenly capable of combining the two together to create an emergency LED-lit walkway like those found on airplanes. Add knowledge of another component and another 10 projects come within your reach. It’s an exponential network effect! I suspect even rocket scientists at NASA started like this.

Part of my 30-day commitment to write about my journey learning technical stuff. All posts can be found at Getting Technical.