| The Datasheet Archive - 100 Million Datasheets from 7500 Manufacturers. |
AN1775 Freescale Semiconductor, Inc. Expanding Digital Input
Top Searches for this datasheetOrder this document AN1775/D Rev. AN1775 Freescale Semiconductor, Inc. Expanding Digital Input with Converter Brad Bierschenk Motorola Applications Engineering Austin, Texas Introduction This application note documents method extending digital input using analog-to-digital converter (ADC) microcontroller unit (MCU). Many applications require digital input arbitration. example, determining which keypad pressed. This commonly done arranging switches matrix configuration, connecting series digital input pins, reading digital input data register determine which pressed. While this method easily implemented, does require MCU's parallel port pins. Some applications require available bidirectional input-only pins other purposes. such case, alternate method arbitrating keypresses desired. using connected resistor ladder, user input more efficiently processed. Motorola, Inc., 1998 AN1775 Rev. More Information This Product, www.freescale.com Freescale Semiconductor, Inc. Application Note Background Dedicated Input microcontroller typically receives user input through digital input pins. simplest implementation single switch directly connected digital input pin. This easy realize, most efficient resources, with dedicated input. port data represents state switch. Freescale Semiconductor, Inc. Matrix Input Another method uses keypad, common element embedded systems. These ordinarily arranged matrix, shown Figure this case, byte value entire port data register polled determine which pressed. This more efficient, keypad interface keys with eight input pins. Figure Resistor Matrix Keypad Using Parallel Port Pins AN1775 Rev. More Information This Product, www.freescale.com MOTOROLA Application Note Implementation Alternative many cases, input pins premium. can't always freely assign input pins function user input. more efficient microcontroller resources devised. common feature many Motorola MCUs analog-to-digital converter, ADC. Motorola usually features four eight channels analog input, which compared with reference voltage converted 8-bit digital value. When resistor ladder connected analog input through switches each segment, conversion result used arbitrate input. This allows many keys interfaced with input pin, with only little more software overhead. Figure shows such implementation. Freescale Semiconductor, Inc. INPUT Figure Resistor Ladder Keys Using Analog Input Implementation Operation typically 8-bit precision. This means there 256, distinguishable inputs, including analog inputs converted binary number, which represents magnitude input voltage relation reference voltage. AN1775 Rev. MOTOROLA More Information This Product, www.freescale.com Freescale Semiconductor, Inc. Application Note range difference between high reference voltages. This means analog input between VREFH VREFL will convert 8-bit number, with VREFL converting VREFH converting $FF. resolution, defined range divided precision, defines analog step that change least significant (LSB) represents. case 5-volt, 8-bit ADC, resolution 5/255 (volts), 19.6 This means that change data register reflects change about analog input. Freescale Semiconductor, Inc. Resistor Ladder Voltage Divider Consider resistor ladder connected input, shown Figure Because this arrangement voltage divider, each segment ladder alter voltage input when grounded. switches provided each segment, selectively ground that segment, altering composition divider, thus altering voltage presented pin. this way, software determine which switch ladder selected reading resulting data value. resistor acts pullup maintain analog input line while keys active. Thus, conversion value indicates that been pressed. INPUT Figure Digital Input Alternative AN1775 Rev. More Information This Product, www.freescale.com MOTOROLA Application Note Implementation Considerations Using this method, theoretically connect input switches pin. However, there many potential sources inaccuracies, which make impractical connect many inputs. should account some error padding. Resistor Precision Freescale Semiconductor, Inc. inaccuracy provided resistors themselves. Resistors categorized according their variance from labeled value. application should tolerant precision resistors being used (typically, percent percent). Also, calculated resistor value might commonly available value, user should plan range resistor values. Accuracy Typically, 8-bit accurate within least significant bits. This should accounted well. best allow these tolerances assign each switch range resulting data register values. analog input falls within particular range, determine that pressed. adjusting range results which represent given keypress, user change error margin application. ensure best accuracy, full range converter should used. cases where high reference variable, typically fixed operating voltage. spreadsheet good determine resistor values result ranges. example computing values Figure shown Table AN1775 Rev. MOTOROLA More Information This Product, www.freescale.com Freescale Semiconductor, Inc. Application Note Table Spreadsheet Calculations Keys Voltage Steps pressed 0.625 (VDD/# Keys) 1.25 3.75 3333 10000 30000 10000 1429 1904 2667 4000 6667 13333 40000 10000 (Pullup) (Hex) Vinmin 4.6875 0.3125 0.9375 1.5625 2.1875 2.8125 3.4375 4.0625 Vinmax 0.3125 0.9375 1.5625 2.1875 2.8125 3.4375 4.0625 4.6875 ADDRmin (Hex) ADDRmax Converter Resolution 0.01961 (Vdd/255) 0.625 1429 1.875 6000 3.125 16667 4.375 70000 Freescale Semiconductor, Inc. Some notes spreadsheet: determined decrementing high voltage reference voltage step each segment ladder. (See Figure resistor value current segment needed form desired equivalent resistance Req. represents equivalent resistance ladder, including current resistor (Rn) excluding pullup resistor (R0). Vinmin Vinmax minimum maximum voltages that arbitrated particular key. this case, +/-Vstep/2 used. ADDRmin ADDRmax data register value range used represent given keypress. This range narrowed widened affect precision. this case, ranges were maximized, conversion result undefined. This particular spreadsheet resistor precision, this could considered further error. AN1775 Rev. More Information This Product, www.freescale.com MOTOROLA Application Note Implementation REQ(N-1) Figure Voltage Divider Constants First, VREFH, high reference converter) number keys determined. converter resolution found dividing converter precision. number voltage steps needed divided number switches. should always operated full range. pullup resistor, typically, should chosen between limit current) limit time constant). Freescale Semiconductor, Inc. Variables Once these constant values decided, spreadsheet used determine resistor values needed each segment divider ladder, according desired input voltages. When using ADC, always entire range converter (VREFH VREFL). This reason determining voltage steps first (VDD n*step value) then calculating necessary resistor values achieve these voltages through divider. each segment ladder, segment's necessary resistor value needs calculated spreadsheet). When pressed, equivalent resistance included segment resistors forms voltage divider with pullup resistor. Given voltage desired input (VIn), user determine equivalent resistance needed achieve that voltage Req(n) (VIn*R0)/(VREFH VIn) resistor that will form needed equivalent resistance with other resistors ladder determined, Req(n) Req(n AN1775 Rev. MOTOROLA More Information This Product, www.freescale.com Freescale Semiconductor, Inc. Application Note only exception which connects input needs resistor. assigning range conversion values each key, user provide fair amount error padding. Considerations include resistor tolerance, accuracy, parasitic time constants. range conversion values particular keypress narrowed improve accuracy application. "quick dirty" arbitration, keep range wide possible. Freescale Semiconductor, Inc. Using Single Resistor Value method presented here used different resistor values produce equal voltage intervals. Another method would same resistance value segments divider. disadvantage using same resistor values that greatly diminishes effective range conversions. Also, resistances kept equal, voltage step between switches approaches resolution ADC. Therefore, error margin diminishes more keys added. Programming Considerations There several ways implement such application. thing choose whether poll when desired link keypress interrupt source. Some ADCs continuously convert once enabled, allowing value available every clock cycles. Others single conversion when register written don't another conversion until register written again. polling scheme periodic timing source signal poll. example, real-time interrupt (RTI) timer overflow (TOF) interrupt used scan input given rate. linking keypress interrupt source cause timing problems might miss keypress. Careful consideration should given timing voltage error requirements determine this method appropriate. AN1775 Rev. More Information This Product, www.freescale.com MOTOROLA Application Note Brief Example with MC68HC705P6A Brief Example with MC68HC705P6A small code segment example that follows illustrates software implementation this method keypress arbitration. example defined around spreadsheet analysis example shown Table MC68HC705P6A (P6A) features 4-channel, 8-bit converter. uses continuous conversion, making value available every internal clock cycles after being turned Freescale Semiconductor, Inc. software example assumes resistor ladder connected (A/D channel port software intended complete application. This software starts ADC, selects channel conversions, then polls data register determine pressed. software uses lookup table, with predefined maximum minimum values which represent specific segment divider being grounded. Once been arbitrated, variable InKey will tell application which switched most recently. AN1775 Rev. MOTOROLA More Information This Product, www.freescale.com Freescale Semiconductor, Inc. Application Note Code Listings -EXPANDIO.ASM Written MC68HC705P6A microcontroller code segment example illustrate converter input arbitration This simple example polls channel, compares conversion result lookup table, determines which keys were pressed. Freescale Semiconductor, Inc. Memory equates RAMSPACE ROMSPACE Registers ADSC ADSC Bits ADRC ADON $100 ;A/D Data register ;A/D Status control ;Conversion complete flag ;A/D oscillator enable ;A/D enable Variables -ORG RAMSPACE ;Start user InKey ;Identifies last pressed ADValue ;Stores last result -Program code Simply loops, polling converter channel determining which pressed -ORG ROMSPACE ;Start user Start: #$20 ;Turn A/D, select channel ADSC MainLoop: BRCLR CLRX CC,ADSC,* ADValue InKey ;Wait conversion complete ;Get result ;Record result ;Clear InKey variable ;Clear offset AN1775 Rev. More Information This Product, www.freescale.com MOTOROLA Application Note Code Listings Freescale Semiconductor, Inc. ;Check entries table, find value range ;that corresponds data register value. KeyLoop: KeyTable+1,X ;Check high range ADValue Match ;Within range KeyTable,X ;Check range ADVAlue Match ;Within range INCX ;Point next table record INCX ;Increment value, when match made, ;the variable will contain that pressed. InKey KeyLoop this point, InKey variable holds keypress information arbitrate press here. this simple example just repeat main loop Match: MainLoop lookup table. Holds minimum maximum values which identify particular resistor ladder -KeyTable: NoKey $EF,$FF pressed Key1 $00,$0F Key2 $0F,$2F Key3 $2F,$4F Key4 $4F,$6F Key5 $6F,$8F Key6 $8F,$AF Key7 $AF,$CF Key8 $CF,$EF Vector definitions -ORG $1FFE ;Reset vector Start AN1775 Rev. MOTOROLA More Information This Product, www.freescale.com Freescale Semiconductor, Inc. Application Note Freescale Semiconductor, Inc. Motorola reserves right make changes without further notice products herein. Motorola makes warranty, representation guarantee regarding suitability products particular purpose, does Motorola assume liability arising application product circuit, specifically disclaims liability, including without limitation consequential incidental damages. "Typical" parameters which provided Motorola data sheets and/or specifications vary different applications actual performance vary over time. operating parameters, including "Typicals" must validated each customer application customer's technical experts. Motorola does convey license under patent rights rights others. Motorola products designed, intended, authorized components systems intended surgical implant into body, other applications intended support sustain life, other application which failure Motorola product could create situation where personal injury death occur. Should Buyer purchase Motorola products such unintended unauthorized application, Buyer shall indemnify hold Motorola officers, employees, subsidiaries, affiliates, distributors harmless against claims, costs, damages, expenses, reasonable attorney fees arising directly indirectly, claim personal injury death associated with such unintended unauthorized use, even such claim alleges that Motorola negligent regarding design manufacture part. Motorola registered trademarks Motorola, Inc. Motorola, Inc. Equal Opportunity/Affirmative Action Employer. reach USA/EUROPE/Locations Listed: Motorola Literature Distribution, P.O. 5405, Denver, Colorado 80217, 1-800-441-2447 1-303-675-2140. Customer Focus Center, 1-800-521-6274 JAPAN: Nippon Motorola Ltd.: SPD, Strategic Planning Office, 141, 4-32-1 Nishi-Gotanda, Shinagawa-Ku, Tokyo, Japan. 03-5487-8488 ASIA/PACIFIC: Motorola Semiconductors H.K. Ltd., Ping Industrial Park, Ting Road, N.T., Hong Kong. 852-26629298 MfaxTM, Motorola Back System: RMFAX0@email.sps.mot.com; http://sps.motorola.com/mfax/; TOUCHTONE, 1-602-244-6609; Canada ONLY, 1-800-774-1848 HOME PAGE: http://motorola.com/sps/ Mfax trademark Motorola, Inc. Motorola, Inc., 1998 AN1775/D More Information This Product, www.freescale.com Other recent searchesSCD26918 - SCD26918 SCD26918 Datasheet MPSA06 - MPSA06 MPSA06 Datasheet MAX6814 - MAX6814 MAX6814 Datasheet ER2A - ER2A ER2A Datasheet ER2M - ER2M ER2M Datasheet DS1685 - DS1685 DS1685 Datasheet DS1687 - DS1687 DS1687 Datasheet DS1287 - DS1287 DS1287 Datasheet
Privacy Policy | Disclaimer |