Intro to Controllers

Our haunt is mostly operated via manual remote control. We really get a kick out of pressing the right button at the right time, and having the right prop spring to life and scare the trick-or-treaters.

At the same time, we appreciate the virtues of automation via intelligent controllers.

skip list of on-page links

Applications

An intelligent controller is a solution in search of a problem. Just about anything on the planet could benefit from having a little embedded intelligence. In many cases, tiny controlling computers are already being embedded in such mundane gadgets as sewing machines, toasters, washing machines, and other everyday items.

Since these pages are nominally intended to foster extreme Halloween decorating, we consider the possible uses of intelligent controllers in a haunt.

Types of Controllers

In the early days of computers, Grace Hopper fell in love with her first computer, the Mark I. In later years, Admiral Hopper remembered it fondly: "It was 51 feet long, eight feet high, eight feet deep. And it had 72 words of storage and could perform three additions a second." In 1949 Popular Mechanics forecast the relentless march of science, saying, "Computers in the future may weigh no more than 1.5 tons."

Computers have gotten somewhat smaller since then.

Practical choices for haunt automation are:

These themes have combinations, variations, and crossovers.

Bare CPU

The heart of any computer is the Central Processing Unit (CPU). The CPU:

In the early days of small computers, the CPUs were difficult to work with. Some required strange voltages or funky multiphase clocks. Some CPUs were partitioned into multiple chips.

Some early CPUs that were easy to hook up and get working were the 6502 and Z-80.

But a CPU by itself is not enough. You need to add components to make it a functioning computer. It has to have memory to contain the program, memory to store data, and input/output peripherals.

You could put together a nice little controller with a Z-80, EPROM, SRAM chip, and some jellybean logic chips for I/O.

Bare MCU

[Some people use the term "MCU" to mean "Mini CPU", to distinguish it from the "big iron" of mainframe computers. I don't mean that.]

I use "MCU" to mean "Micro Controller Unit". This is a single chip that contains most or all of the components necessary for a functioning computer, including:

A good MCU is ready to run limited applications by just adding a battery.

Some notable MCUs are:

Here is an assortment of MCUs from various generations.

Don't confuse power with size. The 68HC11 (left) is much more powerful than the 8748 (bottom).

Please note the word "family" in all cases. Most MCUs are available in a plethora of different variations, each appealing to different user requirements. If you don't need much I/O, you can get an MCU in an 8-pin DIP package. If you need more ports, essentially the same CPU is available in larger packages, and with other peripherals.

Here are a couple Atmel AVR chips. The processors ave virtually identical, but the larger chip allows more input/output options.

This is Marvin Green's original BotBoard. It runs a 68HC811E2 microcontroller in single chip mode.

The components on the board are the bare minimum in order to get the MCU to run.

Augmented MCU

This type of controller is a MCU with additional support chips and peripherals crammed on a small circuit board. There is a strong tendency to use a serial bus to reduce pins consumed in iterfacing to peripherals and EEPROM.

Since a lot of thought goes into the design of this hardware, they usually consider the software, too - and provide some sort of software operating environment.

The BASIC Stamp from Parallax launched this revolution, and there are plenty of others following it.

This is the OOPIC offering.

Note the little 8-pin sockets on the left. These accommodate serial peripherals like EEPROM.

Single-Board Computer

A single-board computer contains a CPU or MCU, with a generous quantity of memory and I/O peripherals. These systems have enough real estate to use byte-wide memory.

This is a SBC from New Micros. The CPU is a Motorola 68HC11, with a FORTH environment on-chip.

Note the large 28-pin sockets on the left. These accommodate byte-wide RAM and ROM.

Personal Computer

Personal computers are easy to find nowadays. Laptops, towers, mini-towers, and PCs with small form factors.

Since these are general-purpose computers, they can be programmed for whatever purpose is needful.

MORE SOON...

Levels of Programming Languages

"Programming" is simply the creation of a series of instructions that the computer is to follow, in order to perform some task. These instructions are prepared in a "programming language". There are many different programming languages, roughly divisible into levels:

  • Machine Language
  • Assembly Language
  • Compiled Languages
  • Interpreted Languages
  • Pseudo Machine Languages
  • Machine Language

    The microcontrollers actually execute a series of instructions in a numerical form, known as machine language. It might look like
    3A 10 51
    E6 DF
    32 38 00
    

    Assembly Language

    It gets to be a bit of a pain to remember all the numerical codes of machine language, so low-level programming is usually done in Assembly language. This lets you use key words instead of magic numbers for the instructions. It also does some of the computation and number base conversion for you. A sample might say
    ld a, (lstout)
    and NOT videna
    ld (conport),a
    
    It might not look like much, but it's much easier for the programmer.

    NOTE: There is usually a close correspondence between the assembly program, and the machine language it turns into. In this case:

    ld a, (lstout)  -> 3A 10 51
    and NOT videna  -> E6 DF
    ld (conport),a  -> 32 38 00
    

    Compiled Languages

    But most programming is actually done in a higher-level language (HLL). This allows the programmer to express more complex concepts, which are fed into a "compiler" program. The compiler automatically simplifies the higher-level language into Assembler, and then into machine code. In the above example, one might write:
    conport = lstout & ~videna
    
    We have lost the correspondence - one line of the higher-level language can explode into dozens or hundreds of machine instructions.

    The above is the procedure that you would follow when programming on a bare PIC or Atmel chip. You program in C or BASIC, and the compiler translates it into the machine code. The machine code is run directly by the microcontroller.

    Interpreted Languages

    COMING SOON.

    Pseudo Machine Languages

    Compiled languages run rapidly, but when their machine language form is in the computer it takes up a lot of space. Interpreted languages can do a lot for very little stored-program space, but they are slow.

    Pseudo machine languages tread a middle ground. The original program is written in a high-level language that the computer is unable to directly execute. The program is compiled into instructions for a machine that doesn't really exist - a pseudo machine. The pseudo machine (p-machine or virtual machine) is designed with powerful instructions that do a lot but take little space. Then the real computer runs an interpreter that executes the p-code.

    This approach first became popular with USCD Pascal. More recent implementations include: BASIC Stamp from Parallax, Java, and Microsoft's C# language for .NET.

    Following is a posting I made on the subject then one of the Halloween e-mail lists was discussing the trade-offs between compiled code and the p-code approach of the BASIC Stamp.

    The BASIC Stamp works differently. They have devised an intermediate computer language. Your program isn't translated into machine code, it is translated into a pseudo computer language, called p-code. The p-code is then downloaded into the Stamp (which contains a PIC), but the PIC can't run that, because it's not in the PIC's native language (machine code). Instead, the PIC runs a small program that reads in the p-code and follows the instructions that it gives. This program is called an interpreter.

    Think about building a house with two workers. One reads the blueprints. One does the work. [You told the architect what you wanted the house to look like (programming), and he drew the blueprints (compiled the instructions).] So when the house is under construction, the first guy looks at the first part of the blueprint and says "get an 8-foot 2x4". The second guy does that. The first guy looks at the next part of the blueprint and says, "put it over there".

    Since the guy doing the work is one step away from the blueprint, there is a delay in processing. That's why the Stamp (which contains a PIC) is slower that programming a bare PIC. The stamp isn't running your instructions. It is running an interpreter that runs your instructions.

    Please note that further combinations are possible. One might compile a HLL to p-code, and download that. But the target machine uses a just-in-time (JIT) compiler to generate machine code for execution.

    Some Specific Controllers

    The "BASIC Stamp", by Parallax, is an augmented MCU that runs pseudo machine language.

    Terminology

    Related Pages

    Skip this list.
    You may be interested in these related pages:
    privacy policy | write to us | tip us
    ©Copyright 2004-2006 by The Wolfstone Group. All rights reserved.
    You must read and abide by our terms of service.