Go Down

Topic: 8x16 Segment display driver with limited input (Read 744 times) previous topic - next topic

JordanSmith

Apr 19, 2019, 09:16 am Last Edit: Apr 20, 2019, 04:46 am by JordanSmith Reason: Whoopsidasies just ignore me pls
Hey guys,

First post here so I don't really know what I'm doing. Sorry, this will be really dumb but I really hope you can help!

So I pulled apart an old alarm clock. I pulled out the 7 segment display and I have been trying to figure out how to use it with an Arduino. Bottom line, I can't figure it out. The controller is TM1629A, the closest English data sheet I found is here. I also translated the actual Chinese one to English, so if you can be bothered that's here.

This is my sketch:
Code: [Select]
int clk = 8;
int data = 7;
int count = 0;
int temp = 0;
int raw[8] = {1,0,1,0,1,0,1,0};

void setup() {
  pinMode(clk, OUTPUT);
  pinMode(data, OUTPUT);
  pinMode(6, OUTPUT);
  digitalWrite(6, HIGH);
  Serial.begin(9600);
  //convert();
  //execute();
  Serial.println(raw[0]);
}

void loop() {
  handleSerial();
  delay(100);
  /*for(int i = 0; i < 8; i++)
  {
    Serial.println(raw[i]);
  }*/
  execute();
  delay(1000);
}

void handleSerial() {
  int check = 0;
  int incomingCharacter;
  for (int i=0; i< 8; i++) {
    while (check < 8) {
      incomingCharacter = Serial.read();
      if (incomingCharacter != -1) {
      //Serial.println(incomingCharacter);
      }
      if (incomingCharacter == 49) {
        raw[i] = 1;
        check++;
        break;
      }
      else if (incomingCharacter == 48) {
        raw[i] = 0;
        check++;
        break;
      }
      else if (incomingCharacter == 114) {
        check = 0;
        i = 0;
        Serial.println("Resetting... Done.");
      }
      delay(5);
    }
  }
}

void execute() {
  Serial.print("Sending: ");
  for (int i = 0; i < 8; i++) {
    //Serial.print(dat[i]);
    if (raw[i] == 0){
      digitalWrite(clk, LOW);
      delay(1);
      digitalWrite(data, LOW);
      digitalWrite(clk, HIGH);
      Serial.print("0");
    }
    else if (raw[i] == 1) {
      digitalWrite(clk, LOW);
      delay(1);
      digitalWrite(data, HIGH);
      digitalWrite(clk, HIGH);
      Serial.print("1");
    }
    else if (raw[i] != 1 && raw[i] != 0){
      Serial.println(raw[i] + " is an invalid character in string. Terminating...");
      break;
    }
    delay(50);
    digitalWrite(data, LOW);
    delay(50);  
  }
  Serial.println();
  Serial.println("Success");
  Serial.println();
}

Essentially, using the serial moniter you can provide as many bytes as you like to send to the data pin of the controller. I've just been trying to send commands listed in the data sheet but it doesn't seem to do anything. I don't know if I have hooked something up wrong or is there a better way I could approach this?

Here are a couple of images of the display and board: https://imgur.com/a/mcf0LD7.

In the second photo, the connections are labeled (not in picture) from left to right (top to bottom), VCC, GND, CLK, DAt, 3.3, CS, IR.
Out of these, I don't understand what the 3.3 (I guessed it just wanted a 3.3V input but idk) and CS pins are for.




I would like to learn how to turn on and off each segment.
If anyone could help me out at all, I'd be indebted to you. Thank you in advance! :D

PaulRB

Please attach images to your post. We don't want to visit image sites full of adverts and possibly viruses.

Thanks for using code tags, but your thread title gives away that you did not read the forum guide, so please do that.

JordanSmith

#2
Apr 19, 2019, 12:19 pm Last Edit: Apr 20, 2019, 04:46 am by JordanSmith
Please attach images to your post. We don't want to visit image sites full of adverts and possibly viruses.

Thanks for using code tags, but your thread title gives away that you did not read the forum guide, so please do that.
My apologies, there were so many pinned threads I just skipped all of them. I was having issues with this sites image hosts, both uploading and viewing. It seems to be okay now.

PaulRB

#3
Apr 19, 2019, 03:14 pm Last Edit: Apr 19, 2019, 03:34 pm by PaulRB
there were so many pinned threads I just skipped all of them
I'm quite sure you are clever enough to work out which one I meant from the titles of those threads.





CS will be "Chip Select". Although the data sheet just calls the interface "serial", I suspect it is SPI compatible. Maybe they didn't want to say that to avoid having to pay money to anyone. SPI is a bus system that can connect the Arduino (the master) to several devices at once (slaves) using the same data and clock lines. Each slave will have a CS pin which the master will change to LOW when it wants to talk to that particular slave. So assuming you don't need to connect any other SPI slaves, you can connect that CS pin to ground.

As for the 3.3V pin, it could be an input or an output, it's not clear. There could be a 3.3V regulator on the board somewhere we can't see. Suggest you connect it to ground with 10K to begin with, connect Vcc & GND to 5V & 0V and measure the signal on the 3.3 pin. If it measures 3.3V, then perhaps there is a regulator on board. If it measures 0V, maybe you should connect it to 3.3V, but I don't know what for. The data sheet for the chip says it needs 5V. Maybe the IR receiver needs 3.3V.

JordanSmith

#4
Apr 19, 2019, 04:01 pm Last Edit: Apr 20, 2019, 04:40 am by JordanSmith
CS will be "Chip Select". Although the data sheet just calls the interface "serial", I suspect it is SPI compatible. Maybe they didn't want to say that to avoid having to pay money to anyone. SPI is a bus system that can connect the Arduino (the master) to several devices at once (slaves) using the same data and clock lines. Each slave will have a CS pin which the master will change to LOW when it wants to talk to that particular slave. So assuming you don't need to connect any other SPI slaves, you can connect that CS pin to ground.

As for the 3.3V pin, it could be an input or an output, it's not clear. There could be a 3.3V regulator on the board somewhere we can't see. Suggest you connect it to ground with 10K to begin with, connect Vcc & GND to 5V & 0V and measure the signal on the 3.3 pin. If it measures 3.3V, then perhaps there is a regulator on board. If it measures 0V, maybe you should connect it to 3.3V, but I don't know what for. The data sheet for the chip says it needs 5V. Maybe the IR receiver needs 3.3V.
I really appreciate your response. I have done what you suggested. For some reason I though CS had to be high but I believe you are right. I regret to say that I don't have an ammeter, so I cannot clarify the connection of the 3.3 pin, I'm hoping it is irrelevant, I had it plugged into 3.3V for a while and nothing changed. I'm not really interested in the IR. I assume it doesn't need to be connected to operate the display.  There are no extra components on the board other than pictured.

I am thinking that my code might not be sending the data correctly? What I understand is if I send '01001100 11000000 10001000' (writing data test mode fixed address to display register, 00H address, display is on) a segment should turn on but nothing shows. Is there an issue with my clock timing?

Just, if you want it for more information, there is an image of the main board. The connection working with is in the bottom left corner.

Edit: I did as you said but used an individual LED in series. On 3.3V no connection lit up but with 5V on the 3.3 pin every connection lit up the bulb. I don't know what to make of that.

Update: found this which works (soz for the link u can use a search engine to find if you like just search 'TM1628 Arduino library' first link) https://github.com/BlockThor/TM1628. This is the most progress I've had being able to turn some segments on and off. However, I don't have precise control over which because my display isn't the same size as what the library was written for? any help here?


PaulRB

#5
Apr 19, 2019, 06:45 pm Last Edit: Apr 19, 2019, 06:47 pm by PaulRB
I have a few requests in return for any help I can give.

Don't quote entire posts when you respond, it just makes the whole thread longer but adds nothing. If you want to quote something specific, just quote that part. If not, use Reply instead of Quote.

Please learn to attach your own pictures to your posts. It's a little awkward. You have to attach them and post, as you have done, but then copy the address of the image, edit the post, hit the insert image icon and paste the address.

Quote
Edit: I did as you said but used an individual LED in series. On 3.3V no connection lit up but with 5V on the 3.3 pin every connection lit up the bulb. I don't know what to make of that.
I don't know what to make of that entire paragraph. I read it several times. Can you explain again using more precise terms, avoiding any possible ambiguous interpretations? Thanks.

JordanSmith

#6
Apr 20, 2019, 01:16 am Last Edit: Apr 20, 2019, 04:41 am by JordanSmith
My apologies, thanks for the advice. I have followed what you said.
I don't know what to make of that entire paragraph. I read it several times. Can you explain again using more precise terms, avoiding any possible ambiguous interpretations? Thanks.
I don't have an ammeter so I connected the 3.3 pin to 3.3V and used another wire connected to ground to test which pins were actually connected. As you said their would either be 0V or 3.3V so I don't need to know the exact voltage, but only if there is a voltage. Using the LED I can see when the circuit is closed or open. When supplied with 3.3V all connections cause the led to (VCC CLK DAt CS or IR) light up but very dimly, almost unnoticeably so I'd guess it would read 3.3V.


Using this sketch
Code: [Select]
#include <TM1628.h>
// define - data pin D9, clock pin D8 and strobe pin D7
// обьявление портов: DIO - порт D9, CLK - D8, STB - D7
TM1628 dvdLED(9, 8, 7);

void setup() {
  dvdLED.begin(ON, 2);
  dvdLED.print(8888);
}

void loop() {
    
}
/* sequence of LEDs:
   порядок светодиодов:
    LED_SE0 0x00
    LED_SE1 0x01
    LED_SE2 0x02
    LED_SE3 0x03
    LED_SE4 0x04
    LED_SE5 0x05
    LED_SE6 0x06
    LED_SE7 0x07
    LED_DVD 0x08
    LED_VCD 0x09
    LED_MP3 0x0A
    LED_PLY 0x0B
    LED_PAU 0x0C
    LED_PBC 0x0D
    LED_RET 0x0E
    LED_DTS 0x0F
    LED_DDD 0x10
    LED_CL1 0x11
    LED_CL2 0x12
*/

I get this output:


This display operates without the ground pin connected??? how?

PaulRB

The return current must be finding a way back to the Arduino through one of the other wires. This is not a good thing, damage could be happening. Always connect the ground wire. I would connect 5V to Vcc and if the display works without it, leave 3.3 pin unconnected.

PaulRB


JordanSmith

#9
Apr 20, 2019, 08:03 am Last Edit: Apr 20, 2019, 08:36 am by JordanSmith
Did you see this?
Yes, I did come across that article. I sent an email to Vasyl asking for help, awaiting a reply.

Using his library, I got the output in the image above. I realize I didn't explain it very well. I can't generate a readable display. It all seems random, I am yet to find a pattern but I believe the dimensions of my display are different from what the library was originally written for.

Any insight for this issue? I'm thinking I could I possibly rewrite the library for my borad but I am still trying to understand it, I am a newbie.

Edit: I orgininally had the TM1629 library from here: https://github.com/BlockThor/TM1628. The library attached to that article doesn't seem to do anything to my display. I don't know if I'm using it wrong though, I just copied the sketch straight into IDE, it didn't do anything.

Edit 2: I had the pins incorrectly defined. I got it to work but I have the same issue. This library is easer to understand for me but I don't know how to edit it so I can use it. This is the output of the sketch from the site you linked.

PaulRB

#10
Apr 20, 2019, 09:15 am Last Edit: Apr 20, 2019, 09:25 am by PaulRB
The problem here, as you figured out, is that both libraries you tried were designed for tms1629 used with a particular display, neither of which is like your display. Neither library is generic/flexible enough to drive an arbitrary display without needing to be altered. You have the added difficulty of not knowing the pinout of your display, or how it is wired to the chip. It's going to take some skill and determination to reverse engineer that and adapt the library. Oh, and a multimeter. Just a cheap £10 one will be good enough for 95%+ of projects.

JordanSmith

You have the added difficulty of not knowing the pinout of your display
Sorry, what do you mean by that?
What logical method would I need to take to solve this?

PaulRB

#12
Apr 20, 2019, 11:20 am Last Edit: Apr 20, 2019, 11:52 am by PaulRB
You have no data sheet for the display, which would tell you what pins are connected to which anodes & cathodes. You could unsolder it from the board and test it to work that out, but you would also need to know which pins on the tms chip they are connected to, so it's probably no easier than other methods.

Suggest you write a test sketch to light one segment of one digit at time and methodically work out how segments are wired to the chip. Which is where you started out, but that sketch was too simple, I guess.

I think those libraries have a buffer[] array and an update() method/function which could be used to light a single segment, so maybe try using those in a new test sketch.

JordanSmith

#13
Apr 20, 2019, 11:51 am Last Edit: Apr 20, 2019, 12:21 pm by JordanSmith
You have no data sheet for the display, which would tell you what pins are connected to which anodes & cathodes. You could unsolder it from the board and test it to work that out, but you would also need to know which pins on the tms chip they are connected to, so it's probably no easier than other methods.
OKay, I have been able to determine the GRID pins are all anodes and the SEG pins are all cathodes, I can light each segment up but touching 5V and GND to them in combinations.
At this point, the best solution I can see is wiring each GRID and SEG to an individual pin and just set them high and low, simply from a lack of a better option(obvs not gonna do this idek how I'd do the gnd pins).

I would like to be able to use the data pin I don't know what information to actually send to the chip to tell it what I want it to do.

JordanSmith

#14
Apr 21, 2019, 04:35 am Last Edit: Apr 21, 2019, 05:22 am by JordanSmith
This is what I am struggling to understand.

What is 00HL? I thought they were addresses but I can't write to them, or at least I don't know how to. How can there be a single one for four segments?

I don't know how it operates. I mean, I don't really know what the code does. I interpret it the best I can but I get confused because I don't have a lot of experience with microprocessors the code isn't commented. I came to this forum because you guys know what you're doing! I have been trying different things but I think I need to edit this from TM1628ts.h (https://github.com/onetransistor/arduino-libraries/tree/master/Display_Segment/TM1628ts)
If anyone could skim over that ^^ and give me any ideas I would be very grateful because I'm lost.
Code: [Select]
const unsigned char tm_digit[18] = {0x7e, 0x48, 0x73, 0x6b, 0x4d, // 0, 1, 2, 3, 4
                                    0x2f, 0x3f, 0x68, 0x7f, 0x6f, // 5, 6, 7, 8, 9
                                    0x7d, 0x1f, 0x36, 0x5b, 0x37, 0x35, // A, b, C, d, E, F
                                    0x01, // minus sign
                                    0x65 // degree sign
                                   };

 byte tm_buffer[14] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};


Update:

I have determined the anode connections include(segments from right to left of the display):
GRID1 - Second segment
GRID2 - First segment
GRID3 - third segment
GRID4 - fourth segment
GRID5 - Utility
GRID6,7,8 - N/C

and the cathode connections:

Seg 11    o---Seg10---o       Seg 9
             |                         |
             |                         |       Seg 8
             |                         |
Seg 2      o---Seg4---o       Seg 16
             |                         |
Seg 1    |                         |       Seg 15
             |                         |
Seg12     o---Seg3---o       Seg 14

The top left segment is connected to grid5. Sorry, just documenting this here for my own purposes.

Go Up