Mahesh Voleti
Mahesh Voleti

Reputation: 21

Decoding TM1628/SM1628/Ht1628 LED driver Chip serial data

hi i'm using arduino uno to drive an digtal pot which in turn drives external PWM to take controll of it over the internet using Esp8266. the PWM is used to drive my heater. my heater unit consists an LED display with TM1628 driver IC to indicate the current tempearture and controll temperature of heater.

this LED display consists 5 wire configuration, which i assumed is serial interface.

1. GND
2. VCC
3. Strobe
4. Data in/out
5. clock

rather than having external PWM control i would like to decode the serial data going to heater through LED driver and the data coming from the PWM to the LED display to make Arduino as a controller board to the circuit. This will allow the microcontroller to know based on the serial feedback where the drive % is prior to command.

But when i tried to read the datasheet i can't able to understand it clearly.

i have used this code to control the led chip:

int datapin = 8;

int clkpin = 9;

int stbpin = 11;


void setup() {

  Serial.begin(9600);

  pinMode(datapin, INPUT);

  pinMode(clkpin, INPUT);

  pinMode(stbpin, INPUT);

}

void loop () {
button = getKeyboard()
if (button != 0){

    for(int i=0;i<8;i++){

      if((button >> i) & 0x01) {

        serial.print("No");
        serial.print(i);
        serial.print('-');
        serial.print(button);
      }
}


void getKeyboard()
{

    byte keys = 0;

    digitalWrite(stbpin, LOW);
    tm_sendByte(0x42); // command 2
    for (int i = 0; i < 5; i++)
        keys |= tm_receiveByte() << i;
    digitalWrite(stbpin, HIGH);

    return keys;
 }


// *** Basic communication

void tm_sendByte(byte data)
{

    for (int i = 0; i < 8; i++)

        {

            digitalWrite(clkpin, LOW);
            digitalWrite(datapin, data & 1 ? HIGH : LOW);
            data >>= 1;
            digitalWrite(clkpin, HIGH);
        }
}

void tm_receiveByte()
{

    byte temp = 0;

    pinMode(datapin, INPUT);
    digitalWrite(datapin, HIGH);

    for (char i = 0; i < 8; i++)
        {
            temp >>= 1;
            digitalWrite(clkpin, LOW);
            if (digitalRead(datapin))
                temp |= 0x80;
            digitalWrite(clkpin, HIGH);
        }

    pinMode(datapin, OUTPUT);
    digitalWrite(datapin, LOW);

    return temp;
}

void tm_sendCommand(byte data)

{

    digitalWrite(stbpin, LOW);

    tm_sendByte(data);

    digitalWrite(stbpin, HIGH);
}

but when i tried to read the command it shows hex values and when i tried to send the same command to the heater it is not responding..

how can i decode the data from the led chip and the data coming to led chip..or how can i make a byte of data for key press since i'm not able to understand through Datasheet

Any help would be greatly appreciated. Here is a link to the LED driver chip. http://aitendo3.sakura.ne.jp/aitendo_data/product_img/ic/LED-driver/TM1628english.pdf

Upvotes: 2

Views: 4017

Answers (2)

Vinayak Jadhav
Vinayak Jadhav

Reputation: 1

in void tm_receiveByte()

for (char i = 0; i < 8; i++)

{

temp >>= 1; // Error

temp <<= 1; // use this

digitalWrite(clkpin, LOW);

if (digitalRead(datapin))

temp |= 0x80;

digitalWrite(clkpin, HIGH);

}

Upvotes: 0

Doug Fenster
Doug Fenster

Reputation: 1

Looks like you are setting and clearing your chip select in send byte. Then trying to read bytes from chip - during command 0x42

Upvotes: 0

Related Questions