Page 475 - Robot Builder's Bonanza
P. 475

444  UNDERSTANDING MICROCONTROLLERS


                   tions make efficient use of data space. As long as you follow good coding practice, you should
                   seldom run out of data storage space.

                   ERASING AND STARTING OVER
                   As noted, most microcontrollers are meant to be programmed over and over again. Each time
                   you download a program to it, the old one is erased, and the new one takes its place. The
                   most common program storage used in modern microcontroller is flash, the same as that used
                   in USB thumb drives, or the CompactFlash cards in a digital camera.
                   There is an exception to completely erasing the flash memory
                   each time you download a new program. Some micro-
           G       controllers are set up to allow a special “bootloader” area in
                   flash, which contains special setup code to make it easier to
                   reprogram the chip without having to pull it out of its circuit.


                     IN- FIELD PROGRAMMING (AND REPROGRAMMING)
                   A key benefit of microcontrollers with flash memory is that they can be programmed and
                   reprogrammed “in circuit”—that is, while the chip is still plugged into whatever circuit board
                   home it’s living in.
                     This has enormous potential for use in your programmable robot. With  in- field program-
                   ming there is no need to remove the microcontroller chip from its circuit in your robot to
                   reprogram it. Instead, you merely connect a cable from your PC and download the new pro-
                   gram. Of course, this requires that the microcontroller have an onboard connector so it can
                   be attached to your PC cable.

                     ONE- TIME PROGRAMMABLE

                   Less costly microcontrollers are made to be programmed only once, and are intended for
                   permanent installations. These  one- time programmable (OTP) microcontrollers are popular
                   in consumer goods and automotive applications.
                     For robotics applications, the OTP is useful for dedicated processes, such as controlling
                   servos or triggering and detecting a sonar ping from an ultrasonic distance measurement
                   system. You’ll find a number of the  ready- made hobby robotic solutions on the market today
                   that have, at their heart, an OTP microcontroller. The microcontroller takes the place of more
                   complex circuitry that uses individual integrated circuits.

                   Microcontroller Programmers


                   All microcontrollers need to be programmed. The complexity of the programming setup
                   depends on the architecture of the microcontroller. For example, the PICAXE and BASIC
                   Stamp controllers can be connected to a PC using a simple  cable— typically just a serial cable
                   that has the usual DB- 9 connector on one end (for connection to the PC) and header pins on
                   the other (for connection to the controller).
                       Chip- only microcontrollers without a  built- in language need a programmer, a physical
                   device that provides all the necessary power and signal connections to the chip. The program-









   35-chapter-35.indd   444                                                                     4/21/11   11:57 AM
   470   471   472   473   474   475   476   477   478   479   480