Page 147 - Embedded Microprocessor Systems Real World Design
P. 147

the normal running current. If the software simultaneously starts multiple motors,
                  the resulting current surge may disrupt the system electronics or even the proces-
                  sor itself. It  may  be  necessary for  the  software to  sequence motor  startup  and
                  braking to prevent  these problems. Software also may need  to filter sensors that
                  are  susceptible to radiated  interference.  In general, it is  better  to provide such
                  protection in hardware, but sometimes the nature of the sensor makes it impossi-
                  ble to filter the interference. This might happen if the sensor must sense very low-
                  level signals or has to sense over a long cable. In cases like these, the software may
                  need to perform some filtering.
                     Other similar cases include turning off PWM-controlled devices while making
                  sensitive ADC measurements. This includes motors, solenoids, heaters, and so on.
                  Even DC devices may need to be turned off. A typical example would be a heater
                  that draws enough current  to produce  a significant DC drop in  the wiring, and
                  where  the heater ground is shared with  a temperature  sensor such as a thermo-
                  couple or thermistor. In a case like this, it may be necessary to turn the heater off
                  so an accurate temperature reading can be made.

                  Interrupt Protection

                  Sometimes the software needs to protect itself against spurious interrupts. One real-
                  world case involves a motor with a reflective strip on the shaft (see Figure 4.3). The
                  strip is sensed with a reflective optical sensor to count and time motor revolutions.
                  In some cases, the motor would stop with the reflective strip right on the edge of
                  where the sensor could detect it. Vibration when the machine was running would
                  then cause the sensor output to switch at a high rate, flooding the processor with
                  interrupts. The problem was complicated by the fact that the resulting error code
                  indicated that the processor was running out of time to complete its tasks-which
                  it was, since it was spending enormous amounts of time in the interrupt routine.
                  A similar case can occur when an operator does not quite close a hood with a sensor
                  on it or if a sensor is not securely mounted, leaving it susceptible to vibration. Any


                                                  REFLECTIVE OPTICAL SENSOR
                                      O\Q





                                        MOTOR
                                             SHAFT
                                                     REFLECTIVE STRIP


                  Figure 4.3
                  Unstable Interrupts from an Optical Sensor.


                  128                                             Embedded Microp-ocessor Systems
   142   143   144   145   146   147   148   149   150   151   152