Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 95 - Toucpad robotics C11
P. 95

    Bitwise Operations: Directly manipulating individual bits within registers to control hardware features (e.g., turning
                     u
                        a specific pin on/off).
                        Pointers: Directly accessing memory locations, a powerful but advanced feature.
                     u
                     Example (Basic Embedded C for a LED)

                     This simple code would make a Light Emitting Diode connected to Port 1 of a microcontroller blink on and off repeatedly.

                     Interrupts: Responding to Events Immediately

                     Description

                     An interrupt is a signal that temporarily stops the Central Processing Unit’s current main program execution to handle a
                     higher-priority event. Once the event is handled (by an Interrupt Service Routine), the Central Processing Unit returns to
                     the point where it left off in the main program.

                     Purpose
                     This is crucial for real-time systems like robots, where immediate responses to external events (like a sensor detecting
                     an obstacle or a button being pressed) are necessary, without having to constantly check for them in the main program
                     (which is inefficient).

                     How it Works
                        An external event (e.g., a signal from a touch sensor, a timer reaching a specific count) triggers an interrupt.
                     u
                        The Central Processing Unit immediately suspends its current task.
                     u
                        It jumps to  a special  function  called the  Interrupt  Service Routine, which contains  the code  to  handle that
                     u
                        specific event.
                        After the Interrupt Service Routine finishes, the Central Processing Unit returns to execute the instruction it was on
                     u
                        before the interrupt occurred.
                     Application in Robotics

                        Emergency Stop: If an emergency stop button is pressed, an interrupt can immediately halt all robot movement,
                     u
                        regardless of what the main program was doing.
                        Sensor Event Handling: When a proximity sensor detects an object, an interrupt can trigger immediate obstacle
                     u
                        avoidance routines.
                        Motor Control: For precise motor control, encoders often generate interrupts for every small rotation, allowing the
                     u
                        microcontroller to accurately track the motor’s position and speed in real-time.
                        Communication: Receiving data through Universal Asynchronous Receiver-Transmitter or Inter-Integrated Circuit
                     u
                        can often trigger interrupts when new data arrives, so the microcontroller doesn’t have to constantly check for it.

                                                                                                                           93
                                                                                                              Computing System

| 90 91 92 93 94 95 96 97 98 99 100 |