LED tube display

I have an LED tube display that I am trying to display certain letters on. Some of the letters do not look like whats supposed to be the letter and I am trying to figure out how to fix that.

I used the letters that i saw in this example and it all worked pretty good except for the small 'n' letter, it actually looks like a mirrored reversed 'h'. Can someone verify what could be wrong with the 0xA9? Is there another value to display the 'n' properly.

LED_0F[18] = 0xF9; //I
LED_0F[19] = 0xF1; //J
LED_0F[20] = 0xC3; //L
LED_0F[21] = 0xA9; //n
LED_0F[22] = 0xC0; //O
LED_0F[23] = 0x8C; //P

Also, how can you go about in adding more characters to what you already have? Where is there a conversion that that will show the hex representation for other chars? I have looked online and the conversion tables i found surely didn't change an 0x8C into a 'P'.

Appreciate the help..

What code ?
What "LED tube display" ?
What circuit ?

UKHeliBob:
What code ?
What "LED tube display" ?
What circuit ?

The tube is a serial 595 driver

The circuit is just the tube connected to the Arduino uno, nothing else.

unsigned char LED_0F[] = 
{
 0xC0, // 0 display 0
 0xF9, // 1 display 1
 0xA4, // 2 display 2
 0xB0, // 3 display 3
 0x99, // 4 display 4
 0x92, // 5 display 5
 0x82, // 6 display 6
 0xF8, // 7 display 7
 0x80, // 8 display 8
 0x90, // 9 display 9
 0x88, // 10 display A
 0x83, // 11 display b
 0xC6, // 12 display C
 0xA1, // 13 display d
 0x86, // 14 display E
 0x8E, // 15 display F
 0xC2, // 16 display G
 0x89, // 17 display H
 0xF9, // 18 display I
 0xF1, // 19 display J
 0xC3, // 20 display L
 0xA9, // 21 display n
 0xC0, // 22 display O
 0x8C, // 23 display P
 0x98, // 24 display q
 0x92, // 25 display S
 0xC1, // 26 display U
 0x91, // 27 display Y
 0xFE, //28 display -
};
unsigned char LED[4]; // 4
int SCLK = 2;
int RCLK = 1;
int DIO = 0; 
void setup ()
{
  pinMode(SCLK,OUTPUT);
  pinMode(RCLK,OUTPUT);
  pinMode(DIO,OUTPUT);
}
void loop()
{
  LED[0]=28;
  LED[1]=13;
  LED[2]=21;
  LED[3]=14;

  while(1)
  {
    LED4_Display ();
  } 

}

void LED4_Display (void)
{
  unsigned char *led_table;
  unsigned char i;
  // 1
  led_table = LED_0F + LED[0];
  i = *led_table;
  LED_OUT(i); 
  LED_OUT(0x01); 
  digitalWrite(RCLK,LOW);
  digitalWrite(RCLK,HIGH);
  // 2
  led_table = LED_0F + LED[1];
  i = *led_table;
  LED_OUT(i); 
  LED_OUT(0x02); 
  digitalWrite(RCLK,LOW);
  digitalWrite(RCLK,HIGH);
  // 3
  led_table = LED_0F + LED[2];
  i = *led_table;
  LED_OUT(i); 
  LED_OUT(0x04); 
  digitalWrite(RCLK,LOW);
  digitalWrite(RCLK,HIGH);
  // 4
  led_table = LED_0F + LED[3];
  i = *led_table;
  LED_OUT(i); 
  LED_OUT(0x08); 
  digitalWrite(RCLK,LOW);
  digitalWrite(RCLK,HIGH);
}

void LED_OUT(unsigned char X)
{
  unsigned char i;
  for(i=8;i>=1;i--)
  {
    if (X&0x80) 
    {
      digitalWrite(DIO,HIGH);
    }  
    else 
    {
      digitalWrite(DIO,LOW);
    }
    X<<=1;
    digitalWrite(SCLK,LOW);
    digitalWrite(SCLK,HIGH);
  }
}

You have a 4-digit Seven Segment Display with a serial input.

In general, each bit of the byte will turn one of the seven segments on or off.

Look at the binary representation of the values to get an idea of which bit controls which segment:

 0x80, 10000000 // 8 display 8
 0xC0, 11000000  // 0 display 0

From these two we can see that 0 means ON and 1 means OFF, that the top bit is probably the decimal point, and that x1xxxxxx turns off the middle horizontal line, changing '8' to '0';

0xF9, 11111001  // 1 display 1
So the two vertical segments on the right are xxxxx00x

 0x86, 10000110 // 14 display E
 0x8E, 10001110 // 15 display F

So xxxx0xxx is the bottom horizontal line.

 0xA9, 10101001  // 21 display n

Well, you can tell SOMETHING is wrong because four bits are set to 0 and the 'n' only has 3 segments lit. If it's looking like a backwards 'h' then the top right vertical segment is lit when it should not be. That segment is the difference between a '6' and an '8'.

0x82, 10000010 // 6 display 6
 0x80, 10000000 // 8 display 8

So we know that the bit that is ON (0) that should be OFF (1) is xxxxxx1x. That would change the 'n' pattern from 10101001 to 10101011. Translate back to hexadecimal to get 0xAB. Change that line to this to get the 'n' to look right:

 0xAB, // 21 display n

John,

Thank you very much for explaining it like you did. I am trying to find a chart that shows these representations because some of them just doesn't add up. For example I am looking at the binary output for the number 9.

a


| |
f | | b
|g|
| |
e| | c
|___|
d

I think this is what its supposed to look like.

1110111 - turn on a, b, c, e, f, g

The numbers that I see on some charts are 1101111 (no wonder I am confused). Now if I draw that out it looks like a ????


| |
| |

_____

That doesn't look like a 9. I still have to find something to convert from the binary to hex, what I have seen out there returns different values from the code segment library so I am still looking.

The tube is a serial 595 driver

Sorry but from a technical point of view that photograph is just rubbish.
We need to know the circuit and the wiring.

Basically you have that conversion array wrong. You need to identify what bit correspond to what segment. When you have that you can define the correct array to use.

Grumpy_Mike:
Basically you have that conversion array wrong. You need to identify what bit correspond to what segment. When you have that you can define the correct array to use.

Can you show me how that is done?

Why not just write a code that sets one bit in the variable and see what segment it lights. Then modify the code to set the next bit, etc. It will only take you 7 compiles to see which bit is assigned to every segment.

Then, dump the code you have and start over. It's so ugly that it made my brain hurt.

gfvalvo:
Why not just write a code that sets one bit in the variable and see what segment it lights. Then modify the code to set the next bit, etc. It will only take you 7 compiles to see which bit is assigned to every segment.

Thats a great idea, I will have to do that.

Thank you..

royjames:
I am trying to find a chart that shows these representations because some of them just doesn't add up. For example I am looking at the binary output for the number 9.

 __a__

|     |
f |     | b
 |g|
 |     |
e |     | c
 |d|

First of all, it looks like the bit order your hardware is using is:

.gfedcba

In other words, the segments are labeled right to left.

Also, remember that your hardware is using 0 for ON and 1 for OFF.

To make a '9' you would turn on these segments:

   __a__
  |     |
f |     | b
  |__g__|
        |
        | c
   __d__|

That's a, b, c, d, f, and g with segment 'e' and the decimal point being turned off. Reverse the order and use 0 for ON and 1 for OFF to get 10010000. Groups the bits in sets of four and substitute the hexadecimal digits to get 0x90. Your table uses 0x90 so it makes perfect sense.

johnwasser:
That's a, b, c, d, f, and g with segment 'e' and the decimal point being turned off. Reverse the order and use 0 for ON and 1 for OFF to get 10010000. Groups the bits in sets of four and substitute the hexadecimal digits to get 0x90. Your table uses 0x90 so it makes perfect sense.

This right here made perfect sense, now I know how to calculate and get the hex representation.

Thank you very much.