Page 233 - Mechatronics with Experiments
P. 233

MICROCONTROLLERS  219

                                               Microcontroller
                                Microprocessor      Memory             I/O peripherals
                                  Program counter       ROM               Digital I/O


                                 Instruction decoder
                                                       Flash RAM          ADC
                                     ALU
                                                       EPROM              DAC / PWM
                                  Accumulator A
                                                       EEPROM              Timers
                                  Accumulator B
                                                                         UART/USART


                                                           (a)

                                               Microcontroller



                                 Registers for inputs:  CPU             Registers for outputs:
                                                       Memory
                                    - Setup                                - Setup
                                    - Status/control    Clock              - Status/control
                                    - Read/write                           - Read/write










                                                           (b)
                             FIGURE 4.5: Microprocessor and microcontroller comparison: (a) microcontroller includes a
                             microprocessor and I/O peripherals on the same chip. (b) High level programming view of a
                             microcontroller.

                             of kilobytes, as opposed to the hundreds of megabytes of memory commonly available
                             in desktop applications. As a result, the cost of microcontrollers is less compared to
                             general purpose computers, which makes them good candidates for embedded controller
                             applications.
                                  From a high level programming point of view, that is using C language or a
                                      ®
                                               ®
                             MATLAB /Simulink type graphical development environment, programming an embed-
                             ded controller for a real-time control application is a matter of defining the logic between
                             inputs and outputs (Figure 4.5b).
                                  The logic is application dependent and is implemented through basic constructs of a
                             high level programming language such as if…,for… , while(...) , basic AND, OR type logic
                             operators as well as mathematical operators and functions (+, - , * , / , sin(..), cos(..) etc.),
                             data structures to manage the data, and a hierarchy of functions for modular programming.
   228   229   230   231   232   233   234   235   236   237   238