Page 470 - Robot Builder's Bonanza
P. 470

ALL ABOUT MICROCONTROLLER CATEGORIES    439


                     Low- Level Programmable
                   The traditional way to program a microcontroller has been with assembly language, using
                   your PC as a host development system. Assembly language appears arcane to newcomers,
                   and for many it proves to be a stopping point in further study of microcontrollers. Making
                   matters more complex is that the assembly language for one brand of microcontroller is dif-
                   ferent from that for another.
                     Fortunately, most microcontrollers today can also be programmed with a more  user- friendly
                   language, such as BASIC, C, or Pascal. These languages are much more approachable, mak-
                   ing them easier to learn. You might already know a little (or a lot) about one or more of these
                   languages, in which case you’re well on the road to programming a microcontroller. Software
                   on your computer converts your program into  so- called machine code, which can be directly
                   read and used by the microcontroller (see Figure 35- 2).
                     An example of a microcontroller that is  low- level programmable is the Arduino, which
                   actually uses the Atmel AVR (a popular 8- bit MCU) as its processor. As you’ll read in Chap-
                   ter 37, “Using the Arduino,” this microcontroller is more than just a chip. It takes a holistic
                   (whole system) approach that’s become very popular among robot builders and electronics
                   experimenters.

                     Integrated- Language Programmable
                   In this type of microcontroller, the chip itself contains a kind of language interpreter. A pro-
                   gram on your computer, a compiler, converts your program into an intermediate language
                   that uses “tokens” to represent actions. The interpreter inside the microcontroller finishes the
                   job of translating the tokens to the  low- level code needed by the chip.
                     Examples of microcontrollers that use this approach include the BASIC Stamp and the
                   PICAXE. Both are based on 8- bit MCUs. These two controllers are further detailed in their
                   own chapters. See Chapter 38, “Using the PICAXE,” and Chapter 39, “Using the BASIC
                   Stamp.”

                   Choice of Programming Language
                   A  low- level programmable microcontroller is basically a blank canvas; it’s up to you what you
                   put in it and how you do it. With these controllers you have an option of choosing the lan-
                   guage you wish to use. These include:

                     BASIC: This language is popular with those just starting out in programming, as the lan-
                       guage is designed for  beginners— in fact, the B in BASIC stands for beginner. It’s also
                       a favorite among those already familiar with a BASIC language for the PC, such as
                       Visual Basic. BASIC is a more forgiving language than the others; for example, it’s not


                                        Conversion to
                                        machine code

                                             Download of
                                     Program  machine code        Figure 35- 2  Programming cycle
                                                                  of a microcontroller. Programs are
                                                                  developed on a PC, where they are
                                                                  compiled to a  machine- readable
                                                                  format, and then downloaded
                                                       Microcontroller  (usually via cable) to the
                                                                  microcontroller.









 35-chapter-35.indd   439                                                                   4/21/11   11:57 AM
   465   466   467   468   469   470   471   472   473   474   475