Decoding TM1628 LED Driver 3-line Serial Data

I'm using a Mega 2650 to drive a digital pot which in turn drives an external PWM. The PWM is used to drive a high current DC electric motor. The external PWM uses a three digit LED display to indicate drive percentage 0-100. This LED display is controlled by a TM1628 with a 3-line serial interface which I assume is an SPI interface.

The Problem:
The Mega 2650 has no idea what the PWM drive % is at any point in time. As such, the Mega 2650 is blindly commanding the external PWM.

What I would like to do:
Rather than having the external PWM drive the LED display, I would like to decode the serial data going from the PWM to the LED display and instead send said data to the Mega 2650, removing the display all together. This will allow the Mega 2650 to know based on the serial feedback where the drive % is prior to command.

What I have tried:

byte data1;
int datapin = 15;
int clockpin = 41;
int latchpin = 40;

void setup() {
pinMode(datapin, INPUT);
pinMode(clockpin, INPUT);
pinMode(latchpin, INPUT);

void loop () {
if (digitalRead(latchpin) == HIGH) {
data1 = shiftIn(datapin, clockpin, MSBFIRST);
if (data1 != 255) {

Where I'm lost:
Pretty much the whole thing. Should I be able to read the data coming from the PWM without having to respond? Or, do I need to use the SPI interface on the board to properly talk to PWM?

Any help would be greatly appreciated. Here is a link to the LED driver chip.



I am extremely sorry for answering late. My experience with TM1628 is that it works fairly well with SPI within the frequency range set in the datasheets. Its very simple to read through SPI.
Just make the arduino a slave make all as inputs, namely MOSI, MISO (dont connect anything), CLK, SS.
Just read commands that the drive is throwing at the display(TM1628).

See the attachment.
See the commands, datas and refer to the datasheet of TM1628.
For Display the main command is 0xC0 followed by 14 bytes of data (incase of incrementing the addresses), otherwise it would be command 3.

Let me know, if it works out.

SPI_Slave_arduinoRead.ino (607 Bytes)

I want help in similar case of decoding though I am using machine that detects the counterfeit money(currency) and display the value in 3-line segment display the value is paper note value for i.e $2 $3 the machine uses the same ic tm1628 I want to get the data that is displaying in seven segment display in my computer or serial monitor through arduino I uses the given code by MR:"Pbala " but it results in randomly generated hex value with great variation TIA.

@talhashan have you got any solution regarding TM1628 decoding, if yes i need your help

:confused: :confused: