Application Notes for LCD 36x24 Smart Switch/Display 7850 East Gelding Drive • Scottsdale, AZ 85260-3420 Application Notes for LCD 36x24 SmartSwitch/Display Revision B NKK Switches 7850 E. Gelding Drive Scottsdale, AZ 85260 480- 991-0942 FAX (480) 998-1435 e-mail <[email protected]> All Rights Reserved Worldwide NKK Switches makes no warranty for the use of these products and assumes no responsibility for any errors, which may appear in this document, nor does it make a commitment to update the information contained herein. SmartSwitch is trademark of NKK Switches. Application Notes for LCD 36x24 SmartSwitch B.doc Toll Free 1.877.2BUYNKK (877.228.9655) • Phone 480.991.0942 • Fax 480.998.1435 www.nkksmartswitch.com • Email [email protected] Page 1 of 13 1209 Application Notes for LCD 36x24 Smart Switch/Display 7850 East Gelding Drive • Scottsdale, AZ 85260-3420 TABLE OF CONTENTS Table of Contents ..........................................................................................................2 1. General Information .................................................................................................3 2. Part Numbers.............................................................................................................3 3. Pin-outs.......................................................................................................................3 4. Pin Descriptions and Functions ..............................................................................4 5. Controlling the SmartSwitch LED backlighting...................................................5 6. Controlling Multiple Modules ................................................................................6 7. Picture Bit Map for one Switch ...............................................................................7 8. Refresh and Timing ..................................................................................................8 9. Timer Interrupt..........................................................................................................8 10. Sample Schematics..................................................................................................9 11. Frequently Asked Questions .................................................................................12 Application Notes for LCD 36x24 SmartSwitch B.doc Toll Free 1.877.2BUYNKK (877.228.9655) • Phone 480.991.0942 • Fax 480.998.1435 www.nkksmartswitch.com • Email [email protected] Page 2 of 13 1209 Application Notes for LCD 36x24 Smart Switch/Display 7850 East Gelding Drive • Scottsdale, AZ 85260-3420 1. General Information The application notes should be used in conjunction with the LCD 36x24 data sheet which has the LED, LCD, and other specifications as well as the timing diagram for the communication. 2. Part Numbers The LCD 36x24 SmartSwitch is currently available as 36x24 standard pushbuttons, 36x24 compact pushbuttons and 36x24 displays. The pushbuttons and displays have a variety of options for backlighting. For the purpose of the application notes these are referred to as Modules. For prototyping it is recommended to use the relevant SmartSwitch socket accessory. Evaluation controllers and demonstration kits are also available. 3. Pin-outs The single and bicolor standard size pushbuttons all share the same pin-out. The LCD 36x24 RGB pushbuttons has a different pin-out. All the compact size pushbuttons have the same pin-out. All the displays have the same pin-out. All the functions are the same regardless of the pin-outs so for the purpose of the application notes the RGB SmartSwitch will be used as the example. The following are the pin-outs for the RGB SmartSwitch. Pins Symbol Pin Name 1 SW Switch Terminal 2 SW Switch Terminal 3 BL-LED(-) LED Backlight Terminal 4 BL-LED(-) LED Backlight Terminal 5 Dout Data Output 6 FLM First Line Marker 7 LP Latch Pulse 8 SCP Serial Clock Pulse 9 Din Data Input 10 GND Ground 11 VDD Power 12 VLC LCD Power 13 BL-LED(+) LED Backlight Terminal 14 BL-LED(-) LED Backlight Terminal NKK’s LCD 36x24 RGB SmartSwitch Pinout Function Normally open switch Normally open switch Cathode for Red Cathode for Blue To daisy chain, connect to Din of next switch. Control line for LCD display Control line for LCD display Clock for shifting data of LCD display Data input for LCD display +5 V power source for logic circuit Power source for LCD drive Common Anode for LEDs Cathode for Green Application Notes for LCD 36x24 SmartSwitch B.doc Toll Free 1.877.2BUYNKK (877.228.9655) • Phone 480.991.0942 • Fax 480.998.1435 www.nkksmartswitch.com • Email [email protected] Page 3 of 13 1209 Application Notes for LCD 36x24 Smart Switch/Display 7850 East Gelding Drive • Scottsdale, AZ 85260-3420 4. Pin Descriptions and Functions Switch terminals (SW, SW): The switch is normally open. The switch can be scanned by connecting one pin to Ground and the other pin to a micro-controller. For a matrix of switches many different methods can be used for scanning. Ground: The Ground for logic and OLED. VDD: Power source for logic (5V and 1mA). VLC: Supply voltage for LCD (7.3V to 7.5V and less than 1mA) The required voltage value depends on the refresh rate of the LCD display, the temperature, and the desired viewing angle. It is recommended that this voltage be adjustable. This can be achieved by using a potentiometer between higher voltage such as 9V or 12V and Ground or by the use of an OpAmp. BL-LED(+), BL-LED(-),BL-LED(-),BL-LED(-): LED backlighting as shown in diagram below. RED PIN13 GREEN BLUE PIN3 PIN14 PIN4 The LED forward voltages for the LCD 36x24 RGB SmartSwitch are as follow: LED (red) = 2.1V LED (green) = 3.3V LED (blue) = 3.3V The absolute maximum current rating is 20mA. A current limiting resistor should be used. The brightness of the backlighting is determined by the current value. Other colors are achieved by different combinations of red, green, and blue. Note: Please refer to the data sheets for the specific switch of interest as the LED specifications will be different than the LCD 36x24 RGB SmartSwitch. SCP and Din: Clock and Data communication. These are connected to data in and clock of an internal 40-bit shift register of the SmartSwitch. The clock pin and the data pin can be connected to pins of a micro-controller. Clock line should be normally high. First the data bit is set on the data line and then the clock is toggled. Application Notes for LCD 36x24 SmartSwitch B.doc Toll Free 1.877.2BUYNKK (877.228.9655) • Phone 480.991.0942 • Fax 480.998.1435 www.nkksmartswitch.com • Email [email protected] Page 4 of 13 1209 Application Notes for LCD 36x24 Smart Switch/Display 7850 East Gelding Drive • Scottsdale, AZ 85260-3420 The LCD display has 36 pixels in each row. Positions 37th, 38th, 39th and 40th of the internal shift register are not used. The maximum clock frequency is rated for 6.0 MHz. FLM and LP: Control lines for internal LCD driver. These lines are connected to micro-controller pins. They are normally low. LP is toggled after the data shifted to the right position in the internal shift register of SmartSwitches. FLM is set to high before shifting the data for the first line of the display and cleared after the data shifted and LP is toggled for the first line. Dout: Data out. This pin is the output of the 40th position of internal shift register. It is used to daisy chain the SmartSwitches. It connects to data in (pin 8) of the next switch. 5. Controlling the SmartSwitch LED backlighting Backlighting can be controlled using current limiting resistors and driver IC with latch as shown below. R1 249 Ohm RED VLED 5V GREEN R2 86 Ohm BLUE R3 86 OHM Rcntr Gcntr Bcntr The circuit below results in consistent brightness between single LED ON and multi LED’s ON. RED VLED 5V R4 25.5 Ohm R1 220 Ohm GREEN R2 60.4 Ohm BLUE R3 60.4 OHM Rcntr Gcntr Bcntr Application Notes for LCD 36x24 SmartSwitch B.doc Toll Free 1.877.2BUYNKK (877.228.9655) • Phone 480.991.0942 • Fax 480.998.1435 www.nkksmartswitch.com • Email [email protected] Page 5 of 13 1209 Application Notes for LCD 36x24 Smart Switch/Display 7850 East Gelding Drive • Scottsdale, AZ 85260-3420 Note: It is recommended is to use a LED driver such as the MAX6957 for controlling the backlighting. This eliminates the need for resistors and driver IC with latch. It allows for achieving any color as well as color matching via software control. 6. Controlling Multiple Modules a. b. c. d. All the SCP pins are connected to the same source All the LP pins are connected to the same source All the FLM pins are connected to the same source Din of the first switch is connected to the source. Dout of the first switch is connected to Din of second switch etc… Note: A buffer IC should be used for SCP, LP and FLM if the fan-out of the source is not sufficient. As the number of switches increases, directly controlling the clock and data by the micro-controller becomes inefficient. A different method should be used to shift the data faster. Some possible options are using a serial port in 8-bit mode or using three shift registers. Three parallel-in serial-out shift registers can be used to accomplish this task as shown in Figure 1. This circuit converts the parallel byte to serial. Figure 1, Multiple Modules Controlling Example Using Three Shift Registers FIG. 1 Clock in Q7N Q7 DS PL CE CP U1 D7 D6 D5 D4 D3 D2 D1 D0 U2 74HC165 Q7N Q7 DS PL CE CP D BUS D7 D6 D5 D4 D3 D2 D1 D0 74HC165 WR signa +V 5V U3 74HC165 D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0 DS PL CE CP Q7N Q7 Application Notes for LCD 36x24 SmartSwitch B.doc Toll Free 1.877.2BUYNKK (877.228.9655) • Phone 480.991.0942 • Fax 480.998.1435 www.nkksmartswitch.com • Email [email protected] SCP Din Page 6 of 13 1209 Application Notes for LCD 36x24 Smart Switch/Display 7850 East Gelding Drive • Scottsdale, AZ 85260-3420 7. Bit Map Picture Format for One Module The display on the SmartSwitch is a graphic LCD with a matrix of 36 columns by 24 rows. The SmartSwitch has an internal 40-bit shift register. The first 36 bits of the shift register correspond to the 36 columns of the display and the last 4 bits of the shift register are not used. See Figure 2. The internal shift register shifts left to right so the 40th bit is shifted first and the first bit is shifted last. The first four bits of data shifted in are not used. The fifth bit corresponds to the right most pixel of the row and the 40th bit of data shifted in corresponds to the left most pixel of the row. A high bit causes the corresponding pixel to be on and a low bit causes the corresponding pixel to be off. When the switches are daisy-chained the first forty bits of data shifted in correspond to the last switch and the last forty bits of data shifted in correspond to the first switch. LP and FLM are normally low. FLM must be set high before shifting the data for the first row and cleared after the data shifted and the LP is toggled. For the rows 2 to 24 after the data are shifted for each row LP must be toggled. Figure 2, bit map on 40-bit shift register 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 4 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 The memory data specified by grey are not used. Application Notes for LCD 36x24 SmartSwitch B.doc Toll Free 1.877.2BUYNKK (877.228.9655) • Phone 480.991.0942 • Fax 480.998.1435 www.nkksmartswitch.com • Email [email protected] Page 7 of 13 1209 Application Notes for LCD 36x24 Smart Switch/Display 7850 East Gelding Drive • Scottsdale, AZ 85260-3420 8. Refresh and LP Timing The display must be refreshed continuously. The LP to LP timing has to be consistent. LP causes the internal LCD driver to use the data from the internal 40-bit shift register to energize the pixels of the corresponding row. If the LP to LP timing is not consistent the pixel rows that are energized for a longer time will be darker. If a row gets charged for too long it could damage the display. When the LP to LP timing exceeds 1.2ms a flicker will be noticed on the displays. Lower LP to LP timing up to 0.7ms causes better contrast. However, LP to LP timing of below 0.7ms does not cause significant contrast improvement. 9. Timer Interrupt A timer interrupt should be used for refreshing the display, backlighting, and switch scan. The timer interrupt interval should be equal to desired LP to LP timing. The timer interrupt should be set to low priority. The following SmartSwitch related functions could be performed by timer interrupt routines: a. Start of interrupt routine. b. If it is the first line of the display set the FLM to high. c. Shift the data for the corresponding row of the displays. d. Toggle the LP. e. Set the FLM to low. f. Put LED data to effect. g. Increment line number of the display. If equal to 25 set it to 1. h. If the line number for the display is equal to 1 then scan the switches. This compensates for switch bouncing. i. End of interrupt routine. Manipulation of data and any other tasks can be done by the main program. Application Notes for LCD 36x24 SmartSwitch B.doc Toll Free 1.877.2BUYNKK (877.228.9655) • Phone 480.991.0942 • Fax 480.998.1435 www.nkksmartswitch.com • Email [email protected] Page 8 of 13 1209 Application Notes for LCD 36x24 Smart Switch/Display 7850 East Gelding Drive • Scottsdale, AZ 85260-3420 10. Sample Schematics Figure 3, Sample schematic for controlling 2 RGB SmartSwitches. Application Notes for LCD 36x24 SmartSwitch B.doc Toll Free 1.877.2BUYNKK (877.228.9655) • Phone 480.991.0942 • Fax 480.998.1435 www.nkksmartswitch.com • Email [email protected] Page 9 of 13 1209 Application Notes for LCD 36x24 Smart Switch/Display 7850 East Gelding Drive • Scottsdale, AZ 85260-3420 Figure 3, Sample schematic for controlling 3 RGB SmartSwitches. Continued on next page. Application Notes for LCD 36x24 SmartSwitch B.doc Toll Free 1.877.2BUYNKK (877.228.9655) • Phone 480.991.0942 • Fax 480.998.1435 www.nkksmartswitch.com • Email [email protected] Page 10 of 13 1209 Application Notes for LCD 36x24 Smart Switch/Display 7850 East Gelding Drive • Scottsdale, AZ 85260-3420 Figure 3, Sample schematic for controlling 3 RGB SmartSwitches (continued). Please note the microcontroller is capable of driving up to 48 SmartSwitches. Application Notes for LCD 36x24 SmartSwitch B.doc Toll Free 1.877.2BUYNKK (877.228.9655) • Phone 480.991.0942 • Fax 480.998.1435 www.nkksmartswitch.com • Email [email protected] Page 11 of 13 1209 Application Notes for LCD 36x24 Smart Switch/Display 7850 East Gelding Drive • Scottsdale, AZ 85260-3420 11. Frequently Asked Questions Does the display have to be refreshed? Yes. The displays have to be refreshed. The drawback for the switches that have a refreshing circuit in the switch cap is that the controller can not detect when the refreshing circuit freezes due to an ESD charge. Why is one of the display rows darker than the rest? The timing between the latch pulse of that row and the next row is longer than the timing between the rest of latch pulses. What happens if the display is not refreshed? If the VLC is present, one row of display gets charged for a long time, which can damage the display. If the micro-controller has to go to sleep mode, it must disable the VLC. Does the micro-controller have to have external memory? For a large number of switches the memory is needed to keep the pictures. For a small number of switches the pictures can be made on the fly using ASCII code and look up table without using external memory. Is the display visible without the backlighting? Yes. The LCD in the switch is transflective so it can be seen with sufficient ambient lighting. The negative LCD option requires backlighting. Is the display sun light readable? Since the LCD is transflective, it is sun light readable. However, the reflection from the lens may cause problem. How many switches can be driven by a micro-controller? The number of Modules that a Micro-controller can control depends on the instruction execution time, other tasks performed, hardware design, and software design. • Example Given: A micro-controller with an average instruction execution time of 1 MicroSecond and with 34% of the time performing other tasks. The LP to LP timing is 1 ms. Calculate: The number of Modules that can be controlled by the Micro-controller. Solution: Time to refresh one line = (1ms)* (.66) = .66 ms = 660 instructions The data has to be addressed, retrieved, and shifted. The time for each of these tasks depends on hardware and software design. The fastest addressing scheme is to have the Buffer of the picture data on the RAM as shown on Figure 2. This scheme has the higher byte of the DATA POINTER holding the Module line number and the lower byte of the DATA POINTER points to the last byte of the last Module (same number for all the lines). Once the DATA POINTER is loaded a byte of the data is retrieved and shifted, and the lower byte of the DATA POINTER decrements, a byte of the data is retrieved and shifted…and so forth until the lower byte of the DATA POINTER is equal zero. Application Notes for LCD 36x24 SmartSwitch B.doc Toll Free 1.877.2BUYNKK (877.228.9655) • Phone 480.991.0942 • Fax 480.998.1435 www.nkksmartswitch.com • Email [email protected] Page 12 of 13 1209 Application Notes for LCD 36x24 Smart Switch/Display 7850 East Gelding Drive • Scottsdale, AZ 85260-3420 Shifting the data with Micro-controller pins for many Modules is very time consuming. In this example we assume the data is written via the micro-controller parallel bus to a device such as the 3shift register method described above or via serial port (8-bit mode). The shift speed of data must be such that the Micro-controller does not wait to write the shift data. This method takes 3 Instruction per byte of data (Load the byte, Write the byte to the shift register and decrement the data pointer). If the Interrupt overhead takes 15 Instruction. This Micro-controller can control 43 Modules. (660 Instr./line – 15 Instr./overhead)/ ((5 byte/Module)*(3 Instr./byte)) = 43 Modules. However due to driver fan-out and noise the actual number should be less. WE have controlled 16 to 24 using 74HC4050 driver without any problem. Can the switches be controlled with the low voltage? The specification does not support it but we have tested the switches at 3.0V VDD and signals without any problem. I only need to display a small picture. Do I need to refresh the whole display? The FLM signal indicates the first line. If you do not need the display for all the 24 row of pixels, you can use FLM after as many lines as you need. If you need to center your display, you can toggle the LP to insert a line. Is it possible to have an image with shades of gray? Yes, it is possible. Multiple pictures must be refreshed consecutively. The pixels that are ON for all the pictures will be the darkest, the pixels that are OFF for only one picture will be the second darkest and so on. The number of shade of gray depends on how fast the controller can refresh the LCD. How many backlight colors can be achieved? Infinite. It depends on how many levels of control are present for each discrete color. For example with a RGB SmartSwitch and 16 levels of control for each color the total number of colors is 16x16x16 = 4096 different color. Application Notes for LCD 36x24 SmartSwitch B.doc Toll Free 1.877.2BUYNKK (877.228.9655) • Phone 480.991.0942 • Fax 480.998.1435 www.nkksmartswitch.com • Email [email protected] Page 13 of 13 1209