teaching machines

CS 352 Lecture 6 – Transistors and Diagrams

September 19, 2016 by . Filed under cs352, fall 2016, lectures.

Dear students,

Today we close out our discussion of the low-level electronic circuitry and begin our ascent to higher levels of abstraction. We start by replacing relays with transistors. The problem with relays is that they tend to be slower to activate, harder to miniaturize, and have a shorter life span than other electronic switching technologies. They are electromechanical—their moving parts were fundamentally slow and prone to wear and failure.

At the time of the transistor’s invention, vacuum tubes were the popular switching technology. They were faster than relays, but they generated a lot of heat and also failed frequently. The ENIAC could not be powered down, because powering it back on blew out many of the tubes. Some folks at Bell Labs were looking for something better, and they came up with the transistor. This technology behaves like a relay, but the only moving parts are the electrons.

My Snap Circuits set has two transistors in it, both bipolar junction transistors. One is NPN, which is a sandwich of two materials with extra electrons (N) surrounding a material with missing electrons (P). It has three leads called the base, emitter, and collector. The base leads into P, the collector carries electrons out from one N, and the emitter carries electrons into the other N. Normally no electrons flow through the switch, but when positive voltage is applied to the base, electrons will flow from the emitter to the collector.

Let’s use that NPN transistor to create a not gate and see how it compares to the relay approach.

How exactly do transistors work? Well, they are made of silicon. Silicon is pretty easy to find; it is the dominant element in Earth’s crust. It’s also a group IV element, meaning that it has four electrons in its valence shell. It would really like to bond with other atoms to reach the magic 8. If it bonds with other silicon, we’ve got a crystalline insulator.

However, if you sprinkle some arsenic in the crystal structure, what happens? Arsenic is a group V element, so four of its outermost electrons bond and the fifth is a relatively free agent, happy to circulate through a circuit. A structure like this, with extra electrons, serves as the N material of a transistor.

If you sprinkle boron in instead, boron’s outer three electrons don’t quite reach the magic 8 from its four silicon neighbors. A structure like this, missing some electrons, serves as the P material of a transistor.

Normally electrons won’t flow from P to N. But they will if you apply voltage to the base.

The big takeaway of all this transistor talk is that we are allowing circuits to be electrically switched. Imagine if you were a train conductor and you needed to switch tracks. You’d have to stop the train, disembark, go pull a lever, and then get the train going again. That’s a slow and clumsy process. Imagine instead that the switch could be activated in other ways, like from your cell phone. That’d save you a lot of time. This is what transistors do for us.

Our Snap Circuits examples used human-activated switches. For authenticity’s sake, let’s create a circuit with an Arduino that uses electricity to activate the switch. Let’s send an SOS signal.

After soaking up all these low-level ideas, it’s time to rise above to a higher level of abstraction. Instead of thinking about how electricity flows through a transistor, we will combine them up into AND, OR, and NOT gates, which we abstract away with cute little diagrams. We will do a few diagramming problems together:

Diagram This #0
You will get that job if your grades are decent or you know somebody, but not if you spell terribly.
Diagram This #1
You will go to that thing if friend A goes, but not if B goes too.
Diagram This #2
You will marry a person who is tall, dark, and handsome. Failing that, you will marry a person who is rich.
Diagram This #3
You wear long pants if its neither hot nor summer.
Diagram This #4
You will house sit for a friend, provided the friend has a cat—but no dog—or the friend has a dog—but no cat.
Diagram This #5
You will eat a cheap pizza if it has pepperoni without olives, or if it has olives with neither sausage nor peppers. However, if you paid a lot of money for it, you will eat it no matter what.

Here’s your TODO list:

See you next class!

Sincerely,

P.S. Here’s the code we wrote together in class…

sos.ino

void setup() {
  pinMode(13, OUTPUT);
  delay(10000);
}

void dot() {
  digitalWrite(13, HIGH);
  delay(250);
  digitalWrite(13, LOW);
  delay(100);
}

void dash() {
  digitalWrite(13, HIGH);
  delay(250 * 3);
  digitalWrite(13, LOW);
  delay(100);
}

void s() {
  dot();
  dot();
  dot();
  delay(1000);
}

void o() {
  dash();
  dash();
  dash();
  delay(1000);
}

void loop() {
  s();
  o();
  s();
  delay(10000);
}