Electronic Design

  
Reprints     Printer-Friendly    Email this Article    RSS        Font Size     What's This?


[Ideas For Design]
Compact Algorithm Filters 16 Digital I/O Signals In Emebbed Systems

Contributing Author  |   ED Online ID #4746  |   September 18, 2000


This idea presents a piece of firmware that has proven to be both compact and extremely useful in several field applications involving embedded controllers.

The concept originated when one of our embedded-system customers had problems in the field with a programmable indexer for a stepping motor. It turned out that an inverter mounted into the main electrical box was emitting significant electrical noise. This noise emission was so powerful that it would occasionally activate the digital input of our indexer.

What the customer requested was an increase in the time constant of the filter on the indexer board. Due to the physical dimensions of the required capacitor, however, this was impossible. Another option was to increase the software filtering. But while a large filter time constant was acceptable for this client’s application, it wasn’t suitable for all installations.

Writing a filter routine would be the ideal solution. It would have to be small, fast, and programmable for a range of values that customers could adapt to their applications. A small but quite powerful routine resulted.

Using a time constant ranging from 1 to 16 ms, the algorithm (implemented in assembly on an MC68332-based embedded system) filters 16 digital inputs. Listed below is the algorithm’s goal:

  • Set the n-th bit of exit_input_status if and only if all n bits of the filter_body elements are logic-one.
  • Reset the n-th bit of exit_input_status if and only if all the n bits of the filter_body elements are logic-zero.
  • In all other cases, the contents of exit_input_status are left unaltered.

Algorithm operations:

The algorithm defines a buffer of 16 unsigned 16-bit integers (UINT16) as a filter shift register, a 16-bit integer (UINT16) to store the previous filtered status of the input, and an unsigned 8-bit byte (UBYTE) to store the time constant of the filter as follows:

Ram definition:
UINT16 filter_body (16)
UINT16 previous_state
UBYTE filter_time_constant

Algorithm operations for a 16-ms time-constant:

  1. AND the entry_input_status and each of the filter_body elements
  2. OR the entry_input_status and each of the filter_body elements
  3. XOR the result of #1 and #2
  4. NOT the result of #3
  5. OR the result of #1 and #3
  6. AND the result of #2 and #4
  7. AND previous_state and result of #5
  8. OR the result of #7 and #6
  9. Save result of #8 into previous_state
  10. Shift all filter_body elements down by one position to push out the oldest input reading from the filter and insert the newest input reading.

To accomplish this functionality in my MC68332 embedded system, the routine shown in the listing is called every 1 ms.


Reprints   Printer-Friendly  Email this Article  RSS    Font Size   What's This?


  • Network-On-Chip Tools Arrive for The Masses
  • Tackling System Design Challenges Through Early Verification
  • ESL Tools Take Center Stage As Designers Move Up
  • Parasitic Extraction Tool Targets Next-Generation Custom ICs
  • Synopsys Jumps Into ESL-Synthesis Pool
  • Verify Control Systems Before Committing To Hardware
  • You're Using How Many FPGAs?
  • Tool Up For The FPGA Blitz
    1) Build A Smart Battery Charger Using A Single-Transistor Circuit
    (184 views today)
    2) Hot Hands For Some Cool Rock: Motion Sensing Meets Audio Engineering
    (172 views today)
    3) GPS-Derived Grandmaster Clock Delivers Ultra-Precise Time And Frequency Sync
    (91 views today)
    4) What's All This Transimpedance Amplifier Stuff, Anyhow? (Part 1)
    (79 views today)
    5) Downconverting Mixers Lower Power Consumption While Improving Performance
    (73 views today)
    ALL TOP 20



    POST YOUR COMMENTS HERE
    Name:

    Email:
    Your Comments:

    Enter the text from the image below


    Please refresh the page if you have trouble reading this text.

    Search Electronic Design
         
      
     
    Web Seminar
    Sponsored By:
    Title: Read Pacing: A Performance Enhancing Feature of PCI Express Gen 2 Switch Devices
    Speakers: 
    Date: 07/01/08
    Register: 

    Electronic Design Europe Electronic Design China EEPN Power Electronics Auto Electronics Microwaves & RF
    Mobile Dev & Design Schematics Find Power Products Military Electronics EE Events Related Resources