38 Atmel Automotive Compilation, Vol. 6 Standard Products Networking LIN Switch Matrix Module Design Using LIN SiPs ATA6612/13 Markus Schmid Introduction ing years can be explained by the out so that the customers can use continued requirement for comfort the well-established AVR tools. It The LIN bus is well established functions in next-generation auto- also provides the same flexibility for in automotives where it is used for motives. As almost all comfort func- the applications as when using the low-cost and low-speed applica- tions can be controlled by the pas- discrete parts. tions as an alternative to the CAN sengers via keypads, it is expected bus. The implementation of the LIN that the amount of the keypads will bus is still increasing: in 2011 there also increase. This article covers are approximately 600 million LIN efficient keypad evaluation using a transceivers expected in all cars switch matrix module. The popularity of LIN devices can The easiest way to evaluate a push button is to connect it directly to an worldwide, and in 2014 this number is set to increase to 900 million. Handling Keypads LIN SiPs ATA6612 and ATA66613 I/O pin of a microcontroller. This is the preferred solution, when only a couple of push buttons need to be evaluated by a single microcon- in part be attributed to their flexibility: they can be used in many The ATA6612/13 consists of two troller. But with an increasing num- different Typical chips in a single package; the first ber of switches, the number of I/O LIN applications either evaluate one is the LIN system basis chip pins increases accordingly. In many the data of sensors or switches (LIN SBC) ATA6624, which has cases this leads to a need for larger or drive actuators like motors or a an integrated LIN transceiver, a and heating system. However, those LIN 5V voltage regulator, and a win- microcontrollers. Using a switch applications must not have high- dow watchdog. The second chip matrix the number of I/O pins speed or even real-time require- is an AVR 8-bit RISC automo- required can be reduced. Using a ments. Therefore, LIN devices can tive microcontroller. The ATA6612 3 x 2 matrix up to six push but- be found in window lifts, mirrors, or consists of the LIN SBC ATA6624 tons can be monitored using only keypads in car doors. They are also and the ATmega88 with 8-kBytes five I/O pins. With the conventional used in seat heating or adjustment, flash, while the ATA6613 includes solution where a single push but- in climate control, in the dashboard the ATA6624 and the ATmega168 ton is connected to one I/O pin, or for wiper control, where LIN is with 16-kBytes flash. The only dif- only five push buttons can be currently the unchallenged stan- ference between the two micro- evaluated. With more push but- dard. controllers is the size of the Flash tons, a switch matrix will lead to applications. ® therefore more expensive memory. All pins of the LIN System even greater savings in the number the Basis Chip as well as all pins of the of I/O pins required. For example, amount of LIN devices in the com- AVR microcontroller are bonded a 3 x 3 matrix can handle up to nine The expected increase in www.atmel.com PD7 VCC VS VCC S1 S2 S3 S4 S5 S6 100 nF S21 S16 S22 S17 S23 S18 S24 PB6 VDD2 PB7 PD5 PD6 PB0 P7D PB1 PB2 PD3 GND4 LIN ADC7 GND ATA6612/13 PC0 NTRIG PC2 EN PC3 VS PC4 VCC PC5 PC6 S26 S27 S28 S29 100 nF 36 1 kΩ 220 pF S30 LIN WAKE 33 kΩ 10 kΩ VS PVCC KL_15 24 S25 LIN Master pull-up WAKE PC1 MODE S20 S15 PD4 AREF TM S19 S14 ADC6 WD_OSC S13 GND1 NRES 100 nF GND2 VDD1 AVDD TXD S12 INH S11 RXD S10 PD2 S9 PB4 PB5 PD1 S8 1 PD0 S7 100 nF PB3 48 + + 100 nF 10 µF S31 S32 S33 S34 S35 S36 51 kΩ 10 kΩ GND 100 nF 22 µF 10 kΩ PD7 VBAT 100 nF 47 kΩ KL15 Figure 1. Switch Matrix Application push buttons with six I/O pins lead- umns or rows. In general, pressing tially, reading the column result for ing to a saving of three I/O pins a key connects the key’s row and each row, thus getting all pressed compared to the single push button column lines. When pressing the keys. per I/O pin solution. top left key, the left-most column Switch Matrix Using LIN SiPs ATA6612/13 line is connected to the top-most The illustrated pull-up resistors in row line. The microcontroller can the light blue area are very impor- detect this connection by scan- tant for the scan algorithm to moni- ning the columns and rows. When tor the push buttons. These do only single keys are pressed, a not necessarily have to be external Figure 1 illustrates an application quick method is to first select resistors; however, as internal resis- that can be commonly seen in cli- (drive low) all row lines and read tors are very high ohmic and many mate control panels. It shows a the column result. Then all column applications need to have a higher switch matrix serving some addi- lines are selected, and the row current through a closed push tional requirements. result is read. Returned column button; it is common to add more and row values are combined into low-ohmic, external resistors allow- The keyboard matrix is orga- a unique scan code for the specific ing a higher current to flow. Using nized in 6 x 6 push buttons (light key pressed. When the detection only the internal pull-up resistors green area), which enables the of simultaneous key presses is of the AVR will lead to a current of ATA6612/13 to handle up to 36 required, this method has to be approximately 160 µA through the push buttons. That is a very large slightly changed. The rows must pressed keys. number of push buttons, but it can be scanned separately. The row be easily reduced by removing col- lines must be driven low sequen- www.atmel.com 39 Atmel Automotive Compilation, Vol. 6 Almost all keypads in a contempo- of the keypads themselves. Shown the current consumption does not rary car have the ability to switch on in figure 1 as two variable resis- increase since the INH pin will be a backlight in order to illuminate the tors in the gray area, which can be switched off in this mode. push buttons. This enables the pas- evaluated using two of the available sengers to find the desired key even eight ADC channels. As the resis- The other external circuitry in the in a dark environment. The back- tors are connected to the supply dark green box in the schematic are light illumination consists of several voltage in this example, it is best to blocking capacitors for the micro- LEDs, whose brightness can be also use the supply voltage as ref- controller or, as the INH pin, relevant varied when they are controlled by erence voltage for the conversion. for the features of the LIN part. The a PWM pin of the microcontroller. It is also possible to choose a fixed resistor connected to the WD_OSC In the schematic, the four LEDs in internal 1.1V or an external refer- pin, for example, is important as it the yellow area are connected to ence voltage between 1.0V and the adjusts the watchdog frequency of the PWM pins PB1, PB2, PD5 and voltage connected to the AVCC pin the internal window watchdog. The PD6. In general, the ATA6612/13 of the microcontroller. In addition, circuitry connected to the WAKE, has up to six PWM pins. pin PD7 serves as an input for an KL_15, and the LIN pin is optional analog-to digital conversion. It is and can be adjusted to the needs In addition to the backlight illumina- connected via a voltage divider to of the application. tion in an automotive keypad, there the INH pin. Therefore, the module’s are very often rotary encoders to battery voltage in standard opera- be evaluated by the microcontroller tion mode can be monitored very which also controls the evaluation efficiently. In current save mode S5 S6 S4 S5 S6 48 S10 S11 S12 100 nF 1 PB4 PB5 48 AVDD S10 S11 S12 100 nF GND4 PB4 PB5 AVDD AREF 100 nF 1 AREF 100 nF GND4 PC0 PC0 PC1 PC1 PC2 PC2 Figure 2. Current Flow During Simultaneous Key Presses PB3 S4 PB3 40 www.atmel.com Detection of Simultaneous Key Presses Current Consumption ing mode. The ATmega88/168 offers five different current saving modes Current consumption is, as in all with different active components electronic modules in cars, a key and wake-up sources. To continue Some additional hardware precau- parameter for the switch matrix. to scan the keys, the user should tions must be taken when detec- A current consumption limit of choose a power-saving mode with tion of simultaneous key presses is 100 µA in silent mode is the most a cyclic wake-up. After recognizing required. The schematic as shown common requirement, which is met a pressed key, the microcontroller in figure 1 may lead to erroneous by the ATA6612/13. The ATA6624 can then wake-up the ATA6624 as results, which is explained in the has two different current saving well as the complete LIN network, following. modes. The first is the sleep mode, and start the transmission of this which shuts down the watchdog, the event via the LIN bus after a master If the keys S5, S11 and S12 are LIN transceiver as well as the voltage request. With this set-up, no event pressed at the same time, the regulator. Thus, the microcontroller will be missed even in power-saving microcontroller will determine that remains currentless in sleep mode mode. key S6 is also pressed, although and it is not possible to continue to this is not the case. The current, scan the keys. The ATA6612/13’s which flows when the three keys typical current consumption in sleep S5, S11 and S12 are pressed, mode is 10 µA. The second current The ATA6612/13 is a perfect choice is shown in figure 2 in red. The saving mode is the silent mode. In for applications where many keys microcontroller can not distinguish this mode the watchdog and the have to be monitored and the key whether the three pins are pressed LIN transceiver are switched off, press events have to be transmit- or if the key S6 is pressed. In order but the internal voltage regulator ted via the LIN bus. Figure 1 illus- to avoid this behavior an additional remains active, thus allowing the trates how such a module can be diode has to be included at every microcontroller to continue to scan built. However, in many cases it is key which stops the undesired cur- the keys. The ATA6624’s typical necessary to adapt to the special rent flow and enables to achieve the current consumption in this mode is needs of a particular matrix. The correct result. Using these diodes 57 µA. The ATA6624 can wake-up ATmega88/168 included in the prevents undesired result. Shottky via a message on the LIN bus or ATA6612/13 is a standard micro- diodes are preferable as they have via an event at the pins WAKE or controller, therefore, the extensive a lower forward voltage compared KL_15. In order to achieve the application notes related to the to normal diodes. 100 µA limit, the microcontroller ATmega88/168 can also be used for must switch itself into a current sav- the ATA6612/13. Conclusion Application notes Atmega88/168 see http://www.atmel.com/dyn/products/product_card.asp?family_id=607&family_name=AVR%26reg%3B+8%2DBit+RISC+&part_ id=3757 and http://www.atmel.com/dyn/products/product_card.asp?family_id=607&family_name=AVR%26reg%3B+8%2DBit+RISC+&part_ id=3758 www.atmel.com 41