Car Door Keypad Using LIN
Car door keypads have traditionally comprised of micro-switches that directly carry the motor currents used to operate windows and mirrors. In the case of electrically operated folding mirrors, a single multiple contact switch unit controls six motors in both directions. This complexity combined with the high currents resultes in a heavy, expensive, and difficult to install wiring harness, especially in the driver’s door. The amount of copper at the hinge where the harness interfaces with the main body wiring can also pose a difficult design compromise between durability and ease of use.
Mirror keys
A car door differs from a calculator or a phone in that it makes sense to press more than one key at a time. This renders the traditional approach to keypad design, an X-Y matrix, of limited use in automotive applications. Without additional components, a matrix has only a limited capability to decode multiple key presses. If two keys are pressed on the same row or the same column, two lines are shorted together and the determination of the unique identity of a third pressed key lessens. The recognition of only one up, down, left, and right allows an acceptable employment of a matrix of mirror keys. The design presented here uses this arrangement for the eight mirror functions required by two mirrors. The folding key adds a ninth (ten if a separate un-fold key were required) and the resultant matrix becomes 5x2.

Simple Mirror Key Implementation
Window keys
The keypad requirements for window control are different from those of the mirror in that the driver door may have keys for all four windows, and it is possible, and not unreasonable, to expect two or more to operate simultaneously. For this reason, although there is a possible requirement of eight or even six keys, a conventional key matrix is not necessary. Even though up and down for four windows requires eight keys, further travel on a key causes an “express” movement of the window whereby it travels fully up (or down) even with the key’s release. The simplest way to implement this is to have 16 switches. As a 4x4 matrix is not appropriate without many additional components this would use 16 I/O lines from the controlling MCU. This number may require a more expensive device due to its availability or forcing the use of a higher pin-count.

Possible Window Key Arrangements
Hardware
The target MCU for the keypad module is the MC68HC908EY16. As this MCU is not available at the time of writing this application note it currently uses an MC68HC908AZ60A. Implementation on an MC68HC908EY16 or EY8 would significantly reduce the cost. Not only is the MC68HC908EY16 a lower pin-count lower cost device, but it will include an on-chip ICG (internal clock generator) module obviating the need for a crystal or ceramic resonator.

Keypad Module Circuit Diagram
The keypad module uses the Freescale/Metrowerks LIN driver software so the I/O activity is handled without the application code which simply uses a “LIN_PutMsg()” call to update the buffer used by the drivers. Similarly, a “LIN_GetMsg()” is used for receiving data. The main purpose of the keypad module is to supply data for the window and mirror modules and the only feature of the module controlled by “LIN_GetMsg()” is the keypad illumination. The use of the LIN drivers leaves the programmer free to think about the application without having to worry about the communications protocol.
Source Code
This is just a part of the Source Code. Please, contact us for the entire code.
/******************************************************************************
* Function: LIN_Command
*
* Description: User call-back.
* Called by the driver after successful transmission or receiving
* of the Master Request Command Frame (ID Field value '0x3C').
*
* Returns: never returns
*
******************************************************************************/
void LIN_Command()
{
while(1)
{
}
}
/******************************************************************************
*
* Function name: Main
* Originator: P. Topping
* Date: 5th June 2001
*
******************************************************************************/
void main (void)
{
unsigned char count = 0;
unsigned char window_last;
unsigned char mirror_last;
CONFIG1 = 0x71;
CONFIG2 = 0x19;
DDRA = 0xF0;
DDRB = 0xFF;
DDRC = 0x34;
DDRD = 0x00;
DDRE = 0xDD;
DDRF = 0x7F;
DDRG = 0x00;
DDRH = 0x00;
PTA = 0x00;
PTB = 0x00;
PTC = 0x00;
PTE = 0x04; /* MC33399 enable high */
PTF = 0x00;
Kpm_data[0] = 0;
Kpm_data[1] = 0;
Kpm_data[2] = 0;
Kpm_data[3] = 0;
asm CLI;
LIN_Init();
LIN_PutMsg (0x20, Kpm_data);
PITSC = 0x10; /* start PIT at /1 */
PMODH = 0x27; /* /10000 for a repetition */
PMODL = 0x10; /* rate of 200Hz @ 8MHz. */
while (1)
{
if (PITSC & 0x80) /* is PIT overflow set? */
{
PITSC &= ~(0x80); /* yes, clear it */
window = ~PTD; /* read window port */
PTB = 0x04; /* mirror, column 1 */
mirror = ((~PTH & 0x03) | (0x04*(~PTG & 0x07))); /* read rows */
if (mirror == 0) /* key pressed? */
{
PTB = 0x08; /* no, try column 2 */
mirror = ((~PTH & 0x03) | (0x04*(~PTG & 0x07))); /* read rows */
if (mirror) /* key pressed? */
{
mirror = mirror |= 0x20; /* yes, set 2nd column bit */
}
}
if ((0x04 & PTA) == 0x04) /* child lock active? */
{
mirror = mirror |= 0x80; /* yes, add MSbit */
}
if ((mirror == mirror_last) && (window == window_last)) /* same ? */
{
if (count == 1) /* yes, third time ? */
{
Save_history(); /* yes, save prev. window */
mirror_cur = mirror; /* set-up and xfer new */
window_cur = window /* status into current */;
Prepare_new_data (); /* xfer data to LIN buffer */
count ++; /* count=2 stops re-entry */
}
else if (count < 1) /* count=2 stops increment */
{
count ++;
}
}
else
{
count = 0; /* no, different, so reset */
mirror_last = mirror; /* count and save current */
window_last = window; /* status as last status */
}
LIN_GetMsg (0x21, Master_data);
if ((Master_data[2] & 0x40) == 0x40)
{
PTF |= 0x01; /* lights on */
}
else
{
PTF &= ~(0x01); /* lights off */
}
}
}
}
Read the Italian version: Usare LIN come Pulsantiera Per Porte Auto
CONTACT REQUEST
If you want to know more about this Freescale product, please submit your request to Arrow Italy using this form.
NOTE: this form is valid ONLY for Companies or Customers based in Italy and working in the Italian area.
- Ionela's blog
- 2337 reads





Hi In your netstation,the
Hi
In your netstation,the article of 'Car Door Keypad Using LIN 'interest me.
Now we are developing a new product,in which need some technology of LIN bus.
I think that before using LIN bus need read more code about LIN bus.
please support me the entire code.
thanks your supports
Post new comment