LED dedicated drive control circuit TM1638 1. An overview TM1638 is an LED Controller driven on a 1/16 to 14/16 duty factor. 10 segment output lines, 8 grid output lines, 8 segment/key scan output lines, one display memory, control circuit, key scan circuit are all incorporated into a single chip to build a highly reliable peripheral device for a single chip microcomputer. Serial data is fed to TM1638 via a three-line serial interface. Housed in a SOP28 package, TM1638 pin assignments and application circuit are optimized for easy PCB Layout and cost saving advantages. 2. FEATURES • • • • • • • • CMOS Technology Display Mode 10 segments × 8-bit Key Scanning (8 × 3bit) 8-Step Dimming Circuitry Serial interface (CLK, STB, DIO) Oscillatory Manners: RC Oscillation(450KHz±5%) Built-in power-on reset circuit Available in SOP28 package 3. The pin definitions: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 K1 K2 K3 VDD SEG1/KS1 SEG2/KS2 SEG3/KS3 SEG4/KS4 SEG5/KS5 SEG6/KS6 SEG7/KS7 SEG8/KS8 SEG9 SEG10 STB CLK DIO GND GRID1 GRID2 GRID3 GRID4 GRID5 GRID6 GND GRID7 GRID8 VDD 28 27 26 25 24 23 22 21 20 19 18 17 16 15 www.titanmec.com -1- LED dedicated drive control circuit TM1638 4. The pin function: Symbol DIO Description PIN Name Data I/O This pin outputs serial data at the falling edge of the shift clock. This pin inputs serial data at the rising edge of the shift clock (starting from the lower bit) (N-Channel, open-drain) Serial Interface Strobe Pin The data input after the STB has fallen is processed as a command. When t his pin is "HIGH", CLK is ignored. STB Chip Select CLK Clock input K1 ~ K3 Key scan data input SEG1/KS1 ~ SEG8/KS8 Output (above) Segment output (also used as key source) (P-Channel, open drain) SEG9 ~ SEG10 Output (above) Segment output (P-Channel, open drain) GRID1 ~ GRID8 Output (above) Grid Output Pins (N-Channel, open drain) VDD Power Supply 5V ± 10% GND Ground Pin This pin reads serial data at the rising edge and outputs data at the falling edge. The data sent to these pins are latched at the end of the display cycle Note: DIO port is N-channel open drain output. When read data with MCU it require an external 1K-10K pull-up resistor (10K is recomended). Chip circuit 10K DIO CT GND Figure (1) www.titanmec.com -2- LED dedicated drive control circuit TM1638 5. Display memory address: Data transmitted from an external device to TM1628 via the serial interface are stored in the Display RAM and are assigned addresses from 00H-0FH. The RAM addresses of TM1638 are given below in 16 bits unit. LED display data write time, in accordance with the address from the show from low to high, the data byte from low to high operation. S EG 1 0 S E G9 S E G8 S E G7 S E G6 S E G5 S E G4 S E G3 S E G2 S E G1 xxHL (low nibble) X X xxHL (low nibble) xxHU (high nibble) B0 B 1 B 2 B 3 B 4 B5 B6 B7 B0 0 0H L 00 H U 0 2H L 02 H U 0 4H L 04 H U 0 6H L 06 H U 0 8H L 08 H U 0 AH L 0A H U 0 CH L 0C H U 0 EH L 0E H U B1 B2 01 H L 03 H L 05 H L 07 H L 09 H L 0B H L 0D H L 0F H L B 3 X X X X xxHU (high nibble) B 4 B5 B6 B 7 01 H U 03 H U 05 H U 07 H U 09 H U 0B H U 0D H U 0F H U G RI D1 G RI D2 G RI D3 G RI D4 G RI D5 G RI D6 G RI D7 G RI D8 Figure (2) LED display when writing data follow from low address to high address, from low to high byte operation, In the use of no use to the SEG output BIT in the corresponding address bit write 0 6. Key scan and key scan data register: Key scan matrix of 8 × 3bit, as shown in Figure (3) as follows: K3 K2 K1 KS1 KS2 KS3 KS4 KS5 KS6 KS7 KS8 Figure (3) Key scan data storage address is as follows, starting reading key command to start reading the key data BYTE1-BYTE4 bytes, reading it started from the low output; chip pins K and KS corresponding button is pressed, the corresponding BIT bit is 1 within the byte. www.titanmec.com -3- LED dedicated drive control circuit B 0 K 3 B 1 B 2 K 2 K 1 KS 1 KS 3 KS 5 KS 7 B 3 X B 4 K 3 B 5 B6 K 2 K1 K S2 K S4 K S6 K S8 TM1638 B 7 X BY T E1 BY T E2 BY T E3 BY T E4 Figure (4) ▲Note: 1.TM1638 can read up to 4 bytes, more is not allowed to read. 2.The data byte can only be read sequentially from BYTE1-BYTE4. For example: hardware KS8 and K2 corresponding button is pressed, then you want to read this key data, you must need to read the first 4 bytes of the first 5BIT bit, can read data; When K1 and KS8, K2 and KS8, K3 and KS8 three keys pressed simultaneously, the read data at this time BYTE4 B4, B5, B6 bits are 1 7. Instruction: Command to set the display mode and the LED status of the drive. In the DIO input after the STB falling edge of the rst byte as a command. After decoding, to take up B7, B6 two bits to Distinguish between dierent instructions. Instruction B7 B6 0 1 1 0 Data Command set Display control Command set 1 1 Address Command set If the instructions or data transmission STB is set high, the serial communication is initialized, and the instruction or data being transmitted invalid (instruction or data prior to transmission remain valid). 7.1 Data Command Set The command to set the data write and read, B1 and B0 bits are not allowed to set 01 or 11 M S B LS B B 7 B6 B5 B4 0 0 0 0 0 0 1 1 Unrelated 1 items, 1 fill in 0 1 1 B 3 B 2 0 1 0 1 B 1 B0 0 1 0 Set up Data read Write data to the display register 0 and write mode Read the key scan data Set up Address Automatic address increased increasing mode Fixed address Normal mode Test mode (Internal use) Test mode Function Explain www.titanmec.com -4- LED dedicated drive control circuit TM1638 7.2 Address Command Set MS B L S B B7 B6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 B 5 B 4 Unrelated items, fill in 0 B 3 B 2 B1 B0 Show Address 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 00 H 01 H 02 H 03 H 04 H 05 H 06 H 07 H 08 H 09 H 0A H 0B H 0C H 0D H 0E H 0F H Address Setting Commands are used to set the address of the display memory. The address is considered valid if it has a value of 00H to 0FH. If the address is set to 10H or higher, the data is ignored until a valid address is set. When power is turned ON, the address is set at 00H. Please refer to the diagram above. 7.3 Display Control Command Set M S B B 7 1 1 1 1 1 1 1 1 1 1 LS B B6 B5 B4 0 0 0 0 Unrelated 0 items, 0 fill in 0 0 0 0 0 B 3 0 1 B 2 B 1 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 B0 Function Explain Set the pulse width to 1/16 0 Set the pulse width to 2/16 1 Set the pulse width to 4/16 0 1 Set the number Set the pulse width to 10/16 0 of extinction Set the pulse width to 11/16 Set the pulse width to 12/16 1 Set the pulse width to 13/16 0 Set the pulse width to 14/16 1 Display off Display switch Display on www.titanmec.com -5- LED dedicated drive control circuit TM1638 8. Serial data transfer formats: Read and receive a BIT at the rising edge of the clock operation. 8.1 Reception (Data / Command Write) CLK 1 2 3 4 5 6 7 8 DIO B0 B1 B2 B3 B4 B5 B6 B7 STB Figure (5) 8.2 Transmission (Data / Read) CLK 1 2 `````` 8 DIO B0 B1 `````` B7 B0 B1 B2 B3 STB Data Read Command is Set Data Reading starts Twait Figure (6) Note: It must be noted that when the data is read, the waiting time(t ) wait between the rising of the eighth clock that has set the command and the falling of the first clock that has read the data is greater or equal to 1µ s. 9. Display and Buttons: (1) Display: 1. Common cathode LED: SEG1 SEG2 SEG3 SEG4 SEG5 SEG6 SEG7 1 1 1 1 GRID1 1 1 1 SEG1 SEG2 SEG3 SEG4 SEG5 SEG6 SEG7 A DPY a B C f g b D c Ee d F [LEDgn] G GRID1 Figure (7) Figure 7 shows the common cathode LED connection diagram, if the digital display to "0", Then you need to GRID1 low when so SEG1, SEG2, SEG3, SEG4, SEG5, SEG6 is high, SEG7 low, See Figure (2) shows the address table, just inside the 00H address unit write data 3FH You can make digital tube displays "0." www.titanmec.com -6- LED dedicated drive control circuit S EG 8 0 B 7 SE G 7 0 B6 S E G6 1 B 5 S EG 5 1 B 4 SE G 4 1 B3 S E G3 1 B 2 S EG 2 1 B 1 SE G 1 1 B0 TM1638 0 0 H 2. Common anode LED: GRID1 GRID2 GRID3 GRID4 GRID5 GRID6 GRID7 1 GRID1 GRID2 GRID3 GRID4 GRID5 GRID6 GRID7 1 1 1 SEG1 1 1 A DPY a B f b C g D c Ee d F [LEDgn] G SEG1 1 Figure (8) Figure 8 shows the LED common anode connection diagram, if the digital display to "0", then you need to GRID1, GRID2, GRID3, GRID4, GRID5, GRID6 time to SEG1 low to high, low, when in GRID7 so SEG1 low. To address unit 00H, 02H, 04H, 06H, 08H, 0AH which were written data 01H, all the rest of the address unit write data 00H. S EG 8 0 0 0 0 0 0 0 B 7 SE G 7 0 0 0 0 0 0 0 B6 S E G6 0 0 0 0 0 0 0 B 5 S EG 5 0 0 0 0 0 0 0 B 4 SE G 4 0 0 0 0 0 0 0 B3 S E G3 0 0 0 0 0 0 0 B 2 S EG 2 0 0 0 0 0 0 0 B 1 SE G 1 1 1 1 1 1 1 0 B0 0 0 H 0 2 H 0 4 H 0 6 H 0 8 H 0 A H 0 C H Note:SEG1-10 are P-Channel open drain output, GRID1-8 are N-Channel open drain output, SEG1-10 can only access the LED anode , GRID can only access the LED cathode, can not reverse. (2) Keyboard scan: You can follow the Figure (9) observed with an oscilloscope and SEG2/KS2 SEG1/KS1 the output waveform, SEGN / KSN is shown in Figure (10). www.titanmec.com -7- LED dedicated drive control circuit K1 K2 K3 VDD SEG1/KS1 SEG2/KS2 SEG3/KS3 SEG4/KS4 SEG5/KS5 SEG6/KS6 SEG7/KS7 SEG8/KS8 SEG9 SEG10 vcc Connected Oscilloscope probe 1 Connected Oscilloscope probe 2 R1 1k R2 1k TM1638 STB CLK DIO GND GRID1 GRID2 GRID3 GRID4 GRID5 GRID6 GND GRID7 GRID8 VDD Waveform when IC scans the keyboard SEGN / KSN : SEG1/KS1 SEG2/KS2 SEG3/KS3 SEGN/KSN Tdisp=500us Figure (10) Tsp and the oscillation frequency of the IC work, improve our TM1638 after several oscillation frequency is not exactly the same. 500uS only a reference to the actual measurement shall prevail. . General use diagram (11), to meet key design requirements. K1 S1 S3 K2 S2 S4 K3 S6 S5 SGE1/KS1 SGE1/KS2 SGE1/KS3 Figure (11) When S1 is pressed, the first byte B0 read "1." If multiple keys are pressed, it will read more than one "1", When the S2, S3 is pressed, the first byte in the B1, B3 read "1." Note: The use of composite key considerations: SEG1/KS1-SEG10/KS10 display and key scanning is re-used. In Figure (12) as an example, display the desired light D1, D2 off,need to SEG1 to "1", SEG2 "0" state, if S1, S2 are pressed simultaneously, the equivalent of SEG1, SEG2 is short, then D1, D2 are illuminated. www.titanmec.com -8- LED dedicated drive control circuit SGE1/KS1 TM1638 S1 SGE2/KS2 1 D1 1 S2 D2 K1 GRID1 Figure (12) Solution: 1. the hardware, you can press the keys will need to set the K-line in a different figure above (13), the SGE1/KS1 1 1 S1 D1 D2 S2 GRID1 GRID2 K1 K2 Figure (13) 2. in SEG1-SEG N series resistance shown in the above (14), the resistance of 510 ohms resistance should be chosen, resulting in too large Key failure, is too small to show interference may not solve the problem. SGE1/KS1 510 S1 510 S2 D1 D2 1 1 SGE2/KS2 K1 GRID1 Figure (14) 3. or series diode as shown in Figure (15) below. SGE1/KS1 S1 SGE2/KS2 D1 1 1 S2 D2 K1 GRID1 Figure (15) www.titanmec.com -9- LED dedicated drive control circuit :transmission: 10. Application of the serial data TM1638 10.1 Address increasing mode Use address auto-increment mode, set the address is actually transmitted data stream to set the starting address stored. Start address command word has been sent, "STB" do not set high data transmission followed up 16BYTE, data transfer is completed before the "STB" is set high. CLK DIO Command1 Command2 Command3 Data1 Data2 ``````` Data n Command4 STB Command1: Display Mode Setting command Command2: Data Setting Command Command3: Set the display address Data1 ~ n: Transfer Display Data (up to 16 bytes) Command4: Display Control Command 10.2 Fixed Address Mode Use a fixed address mode, set the address is actually a set of its need to send the address of 1BYTE data storage. Address to send completed, "STB" do not set high, followed by transfer 1BYTE data, data transfer is completed before the "STB" is set high. And then re-set the first two address data needs to be stored up to 16BYTE data transfer is completed, "STB" is set high. CLK DIO Command1 Command2 Command3 Data1 Command4 Data2 ``````` Command5 STB Command1: Display Mode Setting command Command2: Data Setting Command Command3: Set the display address 1 Data1: display data transmitted within 1 to Command3 address Command4: Set the display address 2 Data2: display data transmitted within 2 to Command4 address Command5: Display Control Commands 10.3 Read Timing button CLK DIO Command1 Data1 Data2 Data3 Data4 STB Command1: Set the display mode Data1 ~ 4: read the key data www.titanmec.com - 10 - LED dedicated drive control circuit TM1638 10.4 Programming Flow Chart The use of automatic address programming flow chart 1: Start Set the read key data Command (42H) Initialization No Read 1BTYE in Allow Set command to write data memory, The use of automatic address 1 (40H) Set from the beginning to Address (0C0H) The key value stored on the Register in the MCU No Transmission of data Read 4BYTE It? Yes 16BYTE data Send finished? A button is pressed Next? No Yes Yes Mass display control command set Maximum brightness (8FH) Button handler Order End www.titanmec.com - 11 - LED dedicated drive control circuit TM1638 Fixed address programming flow chart: Start Send command for Disp max.brightness (8FH) Initialization Read Key data Command (42H) Write memory command to the dataFixed address (44H) No Read 1BTYE in Allow Set Address to (0C0H) Key will be stored in Register in the MCU Send 1BYTE Data Read 4BYTE It? Yes Re-set Address to(0C1H) A button is pressed Next? Button handler Order No After the pass ... ... Some of the data Yes Send 1BYTE Data End www.titanmec.com - 12 - LED dedicated drive control circuit TM1638 11. Application circuit: 11.1 TM1638 with common anode LED displays, as shown in Figure (16): KS1 S1 KS2 S2 GR1 GR2 GR3 GR4 GR5 GR6 GR7 GR8 LED1 DPY a a b c f b g d e e c d f dp g dp GR1 GR2 GR3 GR4 GR5 GR6 GR7 GR8 LED2 DPY a a b c f b g d e e c d f dp g dp GR1 GR2 GR3 GR4 GR5 GR6 GR7 GR8 LED3 DPY a a b c f b g d e e c d f dp g dp KS3 S3 SG1 SG2 SG3 KS4 S4 GR1 GR2 GR3 GR4 GR5 GR6 GR7 GR8 LED6 DPY a a b c f b g d e e c d f dp g dp GR1 GR2 GR3 GR4 GR5 GR6 GR7 GR8 LED5 DPY a a b c f b g d e e c d f dp g dp GR1 GR2 GR3 GR4 GR5 GR6 GR7 GR8 LED4 DPY a a b c f b g d e e c d f dp g dp KS5 SG6 SG5 SG4 KS6 S5 GR1 GR2 GR3 GR4 GR5 GR6 GR7 GR8 LED7 DPY a a b c f b g d e e c d f dp g dp GR1 GR2 GR3 GR4 GR5 GR6 GR7 GR8 LED8 DPY a a b c f b g d e e c d f dp g dp GR1 GR2 GR3 GR4 GR5 GR6 GR7 GR8 LED9 DPY a a b c f b g d e e c d f dp g dp S6 SG7 GR1 GR2 GR3 GR4 GR5 GR6 GR7 GR8 LED10 DPY a a b c f b g d e e c d f dp g dp SG10 SG8 SG9 KS7 S7 KS8 S8 K1 S9 S10 S11 S12 S13 S14 S15 S16 S17 S18 S19 S20 S21 S22 S23 S24 K2 VCC K3 10K R1 10K R2 VCC VCC C5 100μF C4 104 Note: The capacitors conected betwen GND and VDD pins must be located as close as possible to the TM1638 chip. K1 K2 K3 VDD SEG1 SEG1/KS1 SEG2 SEG2/KS2 SEG3 SEG3/KS3 SEG4 SEG4/KS4 SEG5 SEG5/KS5 SEG6 SEG6/KS6 SEG7 SEG7/KS7 SEG8 SEG8/KS8 SEG9 SEG9 SEG10 SEG10 STB CLK DIO GND GRID1 GRID2 GRID3 GRID4 GRID5 GRID6 GND GRID7 GRID8 VDD R3 10K C3 GR1 GR2 GR3 GR4 GR5 GR6 104 C2 C1 104 GR7 GR8 TM1638 Figure (16) www.titanmec.com - 13 - 104 STB CLK DIO LED dedicated drive control circuit TM1638 11.2 TM1638 with common cathode LED display, as shown in Figure (17): DVD GR1 GR2 GR3 GR4 GR5 GR6 GR7 GR8 SG1 SG2 SG3 SG4 SG5 SG6 SG7 SG8 1 2 3 4 5 6 7 8 dts DDD a b c d e f g h VCD MP3 PBC VCC R3 VCC 10K R2 10K C1 100uF C2 104 K1 K2 K3 VDD SG1 SEG1/KS1 SG2 SEG2/KS2 SG3 SEG3/KS3 SG4 SEG4/KS4 SG5 SEG5/KS5 SG6 SEG6/KS6 SG7 SEG7/KS7 SG8 SEG8/KS8 SG9 SEG9 SG10 SEG10 VCC Note: The capacitors conected betwen GND and VDD pins must be located as close as possible to the TM1638 chip. R1 10K K1 K2 K3 STB CLK DIO GND GRID1 GRID2 GRID3 GRID4 GRID5 GRID6 GND GRID7 GRID8 VDD C3 C4 C5 GR1 GR2 GR3 GR4 GR5 GR6 101 101 101 GR7 GR8 TM1638 SG8 SG7 SG6 SG5 SG4 SG3 SG2 SG1 S2 S5 S8 S11 S14 S17 S20 S23 S3 S6 S9 S12 S15 S18 S21 S24 S25 S26 S27 S28 S29 S30 S31 S32 K1 K2 K3 Figure (17) Note: 1. VDD, GND filter capacitor between the PCB board layout should be placed as close to the TM1638 chip, enhanced filtering effect. 2. The three 100pF capacitors connected to the DIO, CLK, STB communication port can reduce the interference of the communication port. 3. Due to Blu-ray turn-on voltage of digital blood pressure is about 3V, so TM1638 power supply should be used in 5V. www.titanmec.com - 14 - STB CLK DIO LED dedicated drive control circuit TM1638 12. Electrical characteristics: Absolute maximum ratings (Ta=25C, Vss=0V) Symbol Parameter Ratings Unit V Logic supply voltage Vdd Logic input voltage VI1 LED Seg drive output current IO1 -50 mA LED Grid drive output current IO2 +200 mA Power dissipation PD 400 -0.5 ~ +7.0 -0.5 ~ VDD + 0.5 V mW Operating temperature Topt -40 ~ +80 C Storage temperature Tstg -65 ~ +150 C Recommended operating range (Ta = -20 ~ +70 C, Vss = 0 V) Parameter Symbol Typ Min Max Vdd High level input voltage ViH 0.7 Vdd - Low level input voltage ViL 0 - Test Conditions V 5 Power supply voltage Unit Vdd 0.3 Vdd V V Electrical Characteristics (Ta = -20 ~ +70 C, VDD = 4.5 ~ 5.5 V, Vss = 0 V Parameter Min Typ Max I oh 1 -2 0 25 -4 0 mA Se g 1~ Se g1 1 , V o=v dd -2 V I oh 2 -2 0 30 -5 0 mA Se g 1~ Se g1 1 , V o=v dd -3 V IOL1 80 Unit High-Level Output Current Low-Level Output Current Test Conditions Symbol 140 - mA G ri d1 ~ Gr id 6 V o= 0 .3 V www.titanmec.com - 15 - LED dedicated drive control circuit Low-level output current Segment High-Level Output Current Tolerance Idout 4 - - I t ol sg - - 5 Output pull-down resistor - - High-Level Input Voltage VIH 0. 7 VD D - Low-Level Input Voltage VIL - - VH - 0.35 Dynamic current consumption µA ±1 - - IDDdyn Vo=0.4V, dout VO=VD D– 3V , S eg 1~Se g1 1 kΩ Ii Hysteresis voltage % 10 RL Input Current mA TM1638 K1 ~ K3 VI = VDD / VSS V C L K,D I N,S TB 0. 3 VD D V C L K,D I N,S TB - V CLK, DIN, STB mA 5 no load, display off Switching Characteristics (Ta = -20 ~ +70 C, VDD = 4.5 ~ 5.5 V) Parameter Symbol Oscillation frequency Fosc Transmission Delay Time Min Typ Max Unit Test Conditions - 500 - KHz R = 16.5 K t P LZ - - 30 0 n s C LK→ D OU T t P ZL - - 10 0 n s CL=15 pF ,R L=1 0KΩ TT ZH1 - - 2 μs S eg 1 ~Se g 11 CL= 3 00 pF Rise Time G ri d1 ~G ri d 4 Se g1 2 /G ri d 7 ~ S eg 1 4/ Gr i d5 T T ZH 2 - - 0. 5 μs Fall Time TTHZ - - 120 µs CL = 300pF, Segn, Gridn Maximum clock frequency Fmax 1 - - MHz 50% duty cycle Input capacitance CI - - 15 pF www.titanmec.com - 16 - LED dedicated drive control circuit TM1638 Timing Characteristics (Ta = -20 ~ +70 C, VDD = 4.5 ~ 5.5 V) Typ Symbol Min Clock pulse width PWCLK 400 ns Strobe pulse width PWSTB 1 µs Data setup time tSETUP 100 ns Data hold time tHOLD 100 ns tCLK-STB 1 µs CLK↑→STB↑ tWAIT 1 µs CLK↑→CLK↓ Parameter CLK -> STB time Waiting time Max Unit Test Conditions Timing Waveform: www.titanmec.com - 17 - LED dedicated drive control circuit TM1638 13. Package size l A l ls p ec san dap p l ic a t io n ss h o wna bo v es u b je c tt och a n g ew i t ho u tp r i orn ot i c e. This application document was last updated :2011 -4-9 www.titanmec.com - 18 -