Digital Circuits
Microcontroller Principles
20 questions By Tony R. Kuphaldt
-
Question 1 of 20
Read the following quotation, and then research the term microcontroller to see what relevance it has to the quote:
- I went to my first computer conference at the New York Hilton about 20 years ago. When somebody there predicted the market for microprocessors would eventually be in the millions, someone else said, “Where are they all going to go? It’s not like you need a computer in every doorknob!” Years later, I went back to the same hotel. I noticed the room keys had been replaced by electronic cards you slide into slots in the doors. There was a computer in every doorknob. - Danny Hillis
Reveal answerI’ll let you do your homework on this question!
Notes:Not only is the quotation funny, but it is startling as well, especially to those of us who were born without any computers in our homes at all, much less multiple personal computers.
A point I wish to make in having students research the term “microcontroller” is to see that most of the computers in existence are not of the variety one ordinarily thinks of by the label “computer.” Those doorknob computers - as well as engine control computers in automobiles, kitchen appliances, cellular telephones, biomedical implants, talking birthday cards, and other small devices - are much smaller and much more specialized than the “general purpose” computers people use at their desks to write documents or surf the internet. They are the silent, unseen side of the modern “computer revolution,” and in many ways are more appropriate for beginning students of digital electronics to explore than their larger, general-purpose counterparts.
-
Question 2 of 20
A microcontroller unit, or MCU, is a specialized type of digital computer used to provide automatic sequencing or control of a system. Microcontrollers differ from ordinary digital computers in being very small (typically a single integrated circuit chip), with several dedicated pins for input and/or output of digital signals, and limited memory. Instructions programmed into the microcontroller’s memory tell it how to react to input conditions, and what types of signals to send to the outputs.
The simplest type of signal “understood” by a microcontroller is a discrete voltage level: either “high” (approximately V) or “low” (approximately ground potential) measured at a specified pin on the chip. Transistors internal to the microcontroller produce these “high” and “low” signals at the output pins, their actions being modeled by SPDT switches for simplicity’s sake:

Microcontrollers may be programmed to emulate the functions of digital logic gates (AND, OR, NAND, NOR, etc.) in addition to a wide variety of combinational and multivibrator functions. The only real limits to what a microcontroller can do are memory (how large of a program may be stored) and input/output pins on the MCU chip.
However, microcontrollers are themselves made up of many thousands (or millions!) of logic gate circuits. Why would it make sense to use a microcontroller to perform a logic function that a small fraction of its constituent gates could accomplish directly? In other words, why would anyone bother to program a microcontroller to perform a digital function when they could build the logic network they needed out of fewer gate circuits?
Reveal answerEase of configuration and flexibility!
Notes:Note that I did not bother to explain my extremely terse answer. This is a subject I desire students to think long and hard about, for the real answer(s) to this question are the reasons driving all development of programmable digital devices.
-
Question 3 of 20
A student decides to build a light-flasher circuit using a microcontroller instead of a 555 timer or some other hard-wired astable circuit. Unfortunately, there is a problem somewhere. When first powered up, the LED lights on for 1 second, then turns off and never turns back on. The only way the LED ever comes back on is if the MCU is reset or its power is cycled off and on:

Pseudocode listing Declare Pin0 as an output
BEGIN
Set Pin0 HIGH
Pause for 1 second
Set Pin0 LOW
END
A fellow student, when asked for help, modifies the program listing and re-sends it from the personal computer where it is being edited to the microcontroller, through a programming cable. The program listing now reads as such:
Pseudocode listing Declare Pin0 as an output
LOOP
Set Pin0 HIGH
Pause for 1 second
Set Pin0 LOW
ENDLOOP
When the MCU is reset with the new program, the LED starts blinking on and off . . . sort of. The LED is “on” most of the time, but once every second it turns off and then immediately comes back on. In fact, the “off” period is so brief it is barely noticeable.
What the student wanted was a 50% duty cycle: “on” for 1 second, then “off” for 1 second, repeating that cycle indefinitely. First, explain the significance of the classmate’s program modification, and then modify the program listing again so that the LED does what the student wants it to.
Reveal answerA “loop” is necessary for the MCU to repeat the on/pause/off sequence. What is needed now is another time delay within the loop:
Pseudocode listing Declare Pin0 as an output
LOOP
Set Pin0 HIGH
Pause for 1 second
Set Pin0 LOW
Pause for 1 second (new line of code)
ENDLOOP
Notes:The purpose of this question is for students to realize that the microcontroller must be told to “loop” through the light blinking instructions. Really, this is just an illustration of loops in a practical context.
In case you’re wondering why I write in pseudocode, here are a few reasons:
- No prior experience with programming required to understand pseudocode
- It never goes out of style
- Hardware independent
- No syntax errors
If I had decided to showcase code that would actually run in a microcontroller, I would be dooming the question to obsolescence. This way, I can communicate the spirit of the program without being chained to an actual programming standard. The only drawback is that students will have to translate my pseudocode to real code that will actually run on their particular MCU hardware, but that is a problem guaranteed for some regardless of which real programming language I would choose.
Of course, I could have taken the Donald Knuth approach and invented my own (imaginary) hardware and instruction set . . .

