How to use an CT1642 or SM1642 Led Driver with Key Scan. (Arduino Project)

Discussion in 'General Electronics Chat' started by George -, Oct 28, 2015.

  1. George -

    Thread Starter New Member

    Oct 28, 2015
    Hello dear members,

    after some months of lurking in the forum I have decided to post my first question.

    Some background: I have recently "liberated" some Set Top Box front LED panels with buttons from Chinese manufactured STBs.
    I would like to use one in one of my projects but I am not able to find any information or an example on how I would be able to do so.
    Or more accurately, I cant really understand how to use it.
    A problem is that that datasheet is in Chinese and also I have little experience with shift registers and key scan chips and not so great experience in interfacing ICs overall.

    Hence my request for your help.

    [STB Front Panel]
    The STB Front panel looks like this:

    The IC is the CT1642:
    I forgot to indicate c4 in the above picture (it is the only non-referenced pin).

    [IC CT1642 PINOUT]

    [IC CT1642 Datasheet]
    This is the Datasheet I have found online:
    View attachment ct1642_data1.pdf
    and the google translation:
    View attachment ct1642_data1.pdf.Translate.txt

    [CT1642 Patent]
    and here is a relevant patent I have found also online:

    [Things I have tried so far]
    So far, I have tried to use I2C [arduino Wire library] since I thought that it was using this protocol and I had managed to get a response by turning on some LEDs on the 7seg displays the first time.
    Unfortunately I was not able to re-produce the result or have any control over the 7segs with any value I wrote to the slave. (Which I am not also sure if it has an address or not). I think that turning on the display was a lucky first strike.

    Then I have tried to use the bit shift method [Arduino ShiftOut] to write 18bits (i think this is so weird! why 18?) as per the datasheet:
    Code (Text):
    1. shiftOut(DATA_PIN, CLOCK_PIN, LSBFIRST, B11111111);
    2. shiftOut(DATA_PIN, CLOCK_PIN, LSBFIRST, B11111111);
    3. shiftOut(DATA_PIN, CLOCK_PIN, LSBFIRST, B11);
    But now the display won't even light up.

    So I am thinking that maybe it requires some initial condition to "prepare" the chip for writing to the bit registers or some masking on the actual value.
    Unfortunately I dont have an oscilloscope to pry on the STB boot sequence in order to identify the bits used.

    Has any of you dear sirs have any experience with this kind of led drivers/key scanners or any suggestion on what to try next?
    Your help is greatly appreciated.
  2. dl324

    Distinguished Member

    Mar 30, 2015
    Can you show the signals you're generating for DATA and CLK and describe the results?

    I have no experience with this part, but studying the timing diagram in the datasheet:
    • It appears that the first 4 clocks are used to select digit.
    • After clock 17, DATA is set LO in preparation of toggling to cause data to be displayed.
    • After the 18th clock pulse, CLK is held HI while DATA is toggled high then low to cause the data to be sent to the display.
    • CLK is forced LO before DATA returns HI and is held LO while data is displayed.
    Since there are 13 clocks where segment data could be transferred, you'll need to experiment to find out which correspond to segments a-f and decimal point.
  3. George -

    Thread Starter New Member

    Oct 28, 2015
    Thank you for this suggestion dl324. It put me on the right track for clocking in the data.

    The problem with these chinese chips is that they lack clarity on their datasheet [to put it mildly]. After too many tries and errors I have managed to send some data on the LCD Display with this chip.

    The actual steps for the CT1642 are the following:
    1. Clock in 4 bits to choose the digit. Clock needs to be rising edge. From LOW to HIGH.
      See below for address.
      Code (Text):
      1. X0:00 ->  0x7f, BIN-B01111111
      2. 0X:00 ->  0xbf, BIN-B10111111
      3. 00:X0 ->  0xdf, BIN-B11011111
      4. 00:0X ->  0xef, BIN-B11101111
    2. Clock in 6 High but unused bits.
      Code (Text):
      1. 0x3f, BIN-B111111
      As per the questionable Google translation:
    3. Clock in a full byte of the desired data
      Code (Text):
      1. 0xff, BIN-11111111
      In may case for the common cathode LED Display and chip connection the data is : ABCDEFG(dp)
    4. Output the data with the following:
      Code (Text):
      1. DATA_PIN -> LOW
      2. DATA_PIN -> HIGH
      3. CLOCK_PIN -> LOW
      4. DATA_PIN -> LOW
      5. DATA_PIN -> HIGH
    And voila you have all segments on!

    I am moving on to discover how the key scan works now. Once I am done I will probably create a small arduino library for this cheap chip [pun intended] and I will post it here in case someone else needs it.

    Again thank you dl324 for putting me on the right direction.
  4. George -

    Thread Starter New Member

    Oct 28, 2015
    I have now completed an Arduino Library for the CT1642 IC.

    With this Library one is able to write to the CT1642 Led Display Driver and Scan the keys attached to it.

    If anybody is interested in this see :