Help for Arduino code for 80*16 dot-matrix display

Go To Last Post
16 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi All,

I am new to programming with limited background of programming. 

I have a 80*16 dot-matrix display controlled by shift registers for columns and 74138 (3 to 8 line Demux) for rows. I wanted to operate it with Arduino Uno and searched for code to use it and found a code here.

But the issue this code is for 64*16 DMD and mine is 80*16 (asper the shift registers count and first 8 bits of first shift register are not used so by Pixel count is 72*16 _Required code is for 80*16).

there were some other differences between the code required and found code but they are sorted out. now my main issue is to use this code as for 80*16.

I m providing the code and schematics of the display (Note, Schematics are not complete but is OK to understand the sequence of DMD).

For now I just need to know which part of the code is used to select the width of DMD and how to change it to work with 80*16 DMD.

I can not upload an .ino file as forum rules so I changed the code to .txt format.

Thanks in advance for HELP.

Attachment(s): 

Last Edited: Sun. May 9, 2021 - 12:15 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

SHAHG9948 wrote:
I have a 80*16 dot-matrix display controlled by shift register

But I count a 72x16 dot-matrix display on the schematic.

 

If the schematic doesn't match your actual display you don't stand much of a chance at getting it working. (other than by trial & error)

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

N.Winterbottom wrote:
But I count a 72x16

wasn't that covered in:

SHAHG9948 wrote:
first 8 bits of first shift register are not used so by Pixel count is 72*16

 

SHAHG9948 wrote:
my main issue is to use this code as for 80*16

Can't you just use it as-is, ensuring that you only use the 72x16 part?

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

N.Winterbottom wrote:
schematic

First of all, thanks for your support.
Yes I already mentioned this in my post. The existing code is for 64*16 DMD and working with this DMD but it start showing characters from column number 56and scrolling upto columnn number 1 and again showing text on column number 72 to 57 plus column number 56 to 1 i.e. two parts.
And it is due to configuration off 64 bit as the present Code sending LATCH signal after 64 bits of serial data while I need to send the LATCH signal after 80 bits of serial data. if this was changed to 80 bits of serial data,it will work perfectly on my DMD. As I already mentioned in my post.
As the function of shift registers they receives serial data and put it in a series for columns like now code sending 64 bits of serial data and the shift register put this 64 bits in corresponding columns and then when it receives LATCH signal it shows the data on the columns I need the code send 80 bits of serial data and after that send LATCH Signal then the DMD will put this serial data signals for 80 columns and then after the receiving LATCH Signal it will show that data on 80 columns out of 80, 8 will not showing as these are not connected and 72 will show on DMD.
I hope I explained well so it will be very easy to modify the code for 80*16 DMD.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Go on.   You just shift the required number of columns before you set the latch signal.

 

The multiplex is the same regardless of the number of columns.    i.e. it is dependent on the row count.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It's usual to classify a display by what is actually visible (or on the glass) versus what the control electronics can support. That confused me.

 

I imagine you write a display frame by clocking a single bit through those shift registers whilst changing the row drivers to suit the bit pattern required in each column of LEDs.

 

I'm also a bit confused by the shift register wiring, perhaps tracking of the outputs has determined their order; but it seems the column selected would jump about rather than progress step-by-step from left to right.

 

byte buffer[256] = { // Display buffer (which is scanned by the interrupt timer) of 8x32 bytes
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  ...
  ...
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

Firstly there's no need to initialise with zeros like that - use memset instead.

Secondly I might re-arrange the display buffer as below to better match the scanning method.

uint16_t displaybuffer[72]; // Display buffer (Scanned by Timer ISR) of 72 LED columns, each 16 LEDs deep.

 

Last Edited: Sun. May 9, 2021 - 11:53 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The shift register wiring looks absolutely crazy to me.   Mind you,  it does not make much difference for a static display.   You just mangle the bits appropriately when writing to the SRAM display buffer.    The Multiplex will display whatever pixels are in the buffer.

 

However I would expect this sort of display to scroll text messages left and right.    In which case you would choose consistent msb-lsb mapping.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The shift register TB62726AFG is just that, kind of HC74 or HC595. Filled with 80 bits, and latch fired, it will display
first-come on the latest column. Only problem is to organize memory to store/fetch extra bits properly.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

Can't you just use it as-is, ensuring that you only use the 72x16 part?

 


Yes I am doing the same thing, and it has nothing bad effect on displaying scrolling characters only if I use it for static text/characters then the first one character (8columns) will not be showing.
that's why I requested that if someone can edit this code for 80*16 DMD.
If my first post was read properly then..........

Last Edited: Sun. May 9, 2021 - 02:03 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

grohote wrote:

The shift register TB62726AFG is just that, kind of HC74 or HC595. Filled with 80 bits, and latch fired, it will display
first-come on the latest column. Only problem is to organize memory to store/fetch extra bits properly.


Hats off, you got what I needed.
But I have no experience of programming that's why I requested people to modify the provided code to do what you say.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:

Go on.   You just shift the required number of columns before you set the latch signal.

 

The multiplex is the same regardless of the number of columns.    i.e. it is dependent on the row count.


Please read my post #4 to understand the effect of firing the LATCH.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can you please check the code I uploaded. This code is working on it but upto 64 columns (actually upto 56 columns, already explained in my older post #4).
I need to modify this code to work for 80 columns.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

I don't understand why you don't move the displays so that they are connected in a way that you could just send 72 bit data instead of 80 bit.

 

 

edit:

 

anyway, this seems to be part of the code that needs to change:

 

void shiftOut(byte row) { // fast routine to shove out 8 columns into two rows via board's shift registers
  for(byte column=8;column>0;column--) {
    byte _index = column + (row<<3);
    for(byte i=0;i<8;i++) {
      PORTB &=~(3<<(data_R1-8));                                 // data_R2 is LOW; data_R1 is LOW;
      PORTB &=~(1<<(clockPin-8));                                // digitalWrite(clockPin,LOW);
      PORTB |= !((buffer[_index]>>(7-i)) & 0x01) << (data_R1-8);  // top set of rows
      PORTB |= !((buffer[_index+128]>>(7-i)) & 0x01) << (data_R2-8); // bottom set of rows
      PORTB |= 1<<(clockPin-8);                                  // digitalWrite(clockPin,HIGH);
    };
  };
};

 

I guess it needs to be something like

 

void shiftOut(byte row) { // fast routine to shove out 8 columns into two rows via board's shift registers
  for(byte column=10;column>0;column--) {
    byte _index = column + (row<<3);
    for(byte i=0;i<8;i++) {
      PORTB &=~(1<<(data_R1-8));                                 // data_R2 is LOW; data_R1 is LOW;
      PORTB &=~(1<<(clockPin-8));                                // digitalWrite(clockPin,LOW);
      PORTB |= !((buffer[_index]>>(7-i)) & 0x01) << (data_R1-8);  // row
      PORTB |= 1<<(clockPin-8);                                  // digitalWrite(clockPin,HIGH);
    };
  };
};

Since now you have 10 logic columns, and they are shifted only one at a time.

 

Note: this hybrid Arduino/non Arduino code is terrible. This is because the digitalWrite() function is quite slow so the author did an ugly workaround. I think if you want to keep the Arduino "feel", it's better to use a library with a fast digitalWrite() replacement (there are several choices, including from forum members: https://www.avrfreaks.net/forum/arduinoshrink-library-v010-v070 ).

Last Edited: Sun. May 9, 2021 - 05:11 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

El Tangas wrote:

I don't understand why you don't move the displays so that they are connected in a way that you could just send 72 bit data instead of 80 bit.

I look at the schematic and think :  there is no way that I would unsolder all those chips.

 

However you can mangle things in software.   i.e. put your data into the weird lsb-msb, msb-lsb order for the multiplex.

 

But if you intend to make a pcb revision you would put all the columns in the same order.   Which would mean you could scroll the display buffer easily.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
I look at the schematic and think :  there is no way that I would unsolder all those chips.

 

Well, yes, I just assumed this was still in design stage. Should have read more carefully blush

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

El Tangas wrote:

 

I don't understand why you don't move the displays so that they are connected in a way that you could just send 72 bit data instead of 80 bit.

 

 

edit:

 

anyway, this seems to be part of the code that needs to change:

 

void shiftOut(byte row) { // fast routine to shove out 8 columns into two rows via board's shift registers
  for(byte column=8;column>0;column--) {
    byte _index = column + (row<<3);
    for(byte i=0;i<8;i++) {
      PORTB &=~(3<<(data_R1-8));                                 // data_R2 is LOW; data_R1 is LOW;
      PORTB &=~(1<<(clockPin-8));                                // digitalWrite(clockPin,LOW);
      PORTB |= !((buffer[_index]>>(7-i)) & 0x01) << (data_R1-8);  // top set of rows
      PORTB |= !((buffer[_index+128]>>(7-i)) & 0x01) << (data_R2-8); // bottom set of rows
      PORTB |= 1<<(clockPin-8);                                  // digitalWrite(clockPin,HIGH);
    };
  };
};

 

I guess it needs to be something like

 

void shiftOut(byte row) { // fast routine to shove out 8 columns into two rows via board's shift registers
  for(byte column=10;column>0;column--) {
    byte _index = column + (row<<3);
    for(byte i=0;i<8;i++) {
      PORTB &=~(1<<(data_R1-8));                                 // data_R2 is LOW; data_R1 is LOW;
      PORTB &=~(1<<(clockPin-8));                                // digitalWrite(clockPin,LOW);
      PORTB |= !((buffer[_index]>>(7-i)) & 0x01) << (data_R1-8);  // row
      PORTB |= 1<<(clockPin-8);                                  // digitalWrite(clockPin,HIGH);
    };
  };
};

Since now you have 10 logic columns, and they are shifted only one at a time.

 

Note: this hybrid Arduino/non Arduino code is terrible. This is because the digitalWrite() function is quite slow so the author did an ugly workaround. I think if you want to keep the Arduino "feel", it's better to use a library with a fast digitalWrite() replacement (there are several choices, including from forum members: https://www.avrfreaks.net/forum/arduinoshrink-library-v010-v070 ).


Mr. El Tangas, Thanks for giving your time I will try this modifications and let you know what happens.