Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Big Font generation on 16X2 LCD

Status
Not open for further replies.

Mithun_K_Das

Advanced Member level 3
Joined
Apr 24, 2010
Messages
899
Helped
24
Reputation
48
Reaction score
26
Trophy points
1,318
Location
Dhaka, Bangladesh, Bangladesh
Activity points
8,254
I found some works, they are doing Big Fonts in just a 16X2 LCD. Like this photo:
big_char.jpg

Can any one tell me how can I do something like this in MicorC? As far I know its all about programming skill. I hope I can do the rest if you can give me clues.

Thanks in advance.
 

In mikroC it is very easy. Use Custom character tool to create custom Characters. In your image '1' is displayed using row1 col1 col2, row2 col1 col2 col3. So you need to make 6 custom charcater array for '1'. Then you just use CustomChar() function to print those 5 custom characters and you will get '1' on the display.

Actually you need only 3 custom characters for '1'.
 

Here is the error: big font error.png
and the code:
Code:
// LCD module connections
sbit LCD_RS at RC0_bit;
sbit LCD_EN at RC1_bit;
sbit LCD_D4 at RC4_bit;
sbit LCD_D5 at RC5_bit;
sbit LCD_D6 at RC6_bit;
sbit LCD_D7 at RC7_bit;
sbit LCD_RS_Direction at TRISC1_bit;
sbit LCD_EN_Direction at TRISC0_bit;
sbit LCD_D4_Direction at TRISC4_bit;
sbit LCD_D5_Direction at TRISC5_bit;
sbit LCD_D6_Direction at TRISC6_bit;
sbit LCD_D7_Direction at TRISC7_bit;
// End LCD module connections
 char stringOutput[5];
   short i=0;
const char segments[8][8]=
{
  {3,3,3,3,3,3,3,3},      // segmento 0
  {3,3,3,3,3,3,31,31},  // segmento 1
  {31,31,3,3,3,3,3,3},  // segmento 2
  {31,31,3,3,3,3,31,31},// segmento 3
  {31,31,24,24,24,24,31,31},// segmento 4
  {27,27,27,27,27,27,31,31},// segmento 5
  {31,31,27,27,27,27,27,27},// segmento 6
  {31,31,27,27,27,27,31,31} // segmento 7

};

void writeCGRAM() {
  char i,j=0;

  for (i=0; i<=7; i++) {
     LCD_Cmd(64+i*8); //write CGRAM address
     for (j = 0; j<=7; j++) {
        LCD_Chr_Cp(segments[i][j]);
     }
     LCD_Cmd(_LCD_RETURN_HOME);
  }
}
void writeBigChar(short column, char character) {
  switch(character){
    case 0: {
      LCD_Chr(1,column,6);
      LCD_Chr(2,column,5);
      break;
    }
    case 1: {
      LCD_Chr(1,column,0);
      LCD_Chr(2,column,0);
      break;
    }
    case 2: {
      LCD_Chr(1,column,2);
      LCD_Chr(2,column,4);
      break;
    }
    case 3: {
      LCD_Chr(1,column,3);
      LCD_Chr(2,column,1);
      break;
    }
    case 4: {
      LCD_Chr(1,column,5);
      LCD_Chr(2,column,0);
      break;
    }
    case 5: {
      LCD_Chr(1,column,4);
      LCD_Chr(2,column,1);
      break;
    }
    case 6: {
      LCD_Chr(1,column,4);
      LCD_Chr(2,column,5);
      break;
    }
    case 7: {
      LCD_Chr(1,column,2);
      LCD_Chr(2,column,0);
      break;
    }
    case 8: {
      LCD_Chr(1,column,7);
      LCD_Chr(2,column,5);
      break;
    }
    case 9: {
      LCD_Chr(1,column,7);
      LCD_Chr(2,column,1);
      break;
    }
    case 10:{
      LCD_Out(2,column,".");
    }
  }
}
void ASCIItoDec(char *string, short size) {
   short i=0;

   for(i=0; i<=size; i++) {
      if ( (string[i]==46 || (string[i]==0))) {  //dot character
         string[i]=10;
      }
      else if (string[i]!=32){
         string[i] = string[i]-48;
      }
   }
}
void writeBigFloat(short column, float floatNumber) 
{
   

   char size[] = sprintf(stringOutput,"%4.1f",floatNumber);//string generator

   ASCIItoDec(stringOutput,size)
{
   for (i=0; i<=size-1; i++) 
   {
     if(stringOutput[i]!=32) { //Display string generator
       writeBigChar(column,stringOutput[i]);
       if(stringOutput[i]==10) { // dot
       writeBigChar(column,10);
     }
   }
}




void main()
{
  TRISA  = 0xFF;
  Lcd_Init();
  Lcd_Cmd(_LCD_CLEAR);
  Lcd_Cmd(_LCD_CURSOR_OFF);
  writeCGRAM();

  do
  {
     writeBigChar(2,10);
  } while(1);
}
 

Read Help file. I guess sprintf() returns char or int type.

Try these


Code C - [expand]
1
2
3
char size = sprintf(...
 
int size = sprintf(...



If these doesn't work then define the variables as global and then use it like

Code C - [expand]
1
size = sprintf(...

 

Same error bro. Error.

- - - Updated - - -

Code:
// LCD module connections
sbit LCD_RS at RC0_bit;
sbit LCD_EN at RC1_bit;
sbit LCD_D4 at RC4_bit;
sbit LCD_D5 at RC5_bit;
sbit LCD_D6 at RC6_bit;
sbit LCD_D7 at RC7_bit;
sbit LCD_RS_Direction at TRISC1_bit;
sbit LCD_EN_Direction at TRISC0_bit;
sbit LCD_D4_Direction at TRISC4_bit;
sbit LCD_D5_Direction at TRISC5_bit;
sbit LCD_D6_Direction at TRISC6_bit;
sbit LCD_D7_Direction at TRISC7_bit;
// End LCD module connections
 char stringOutput[5];
   short i=0;
const char segments[8][8]=
{
  {3,3,3,3,3,3,3,3},      // segmento 0
  {3,3,3,3,3,3,31,31},  // segmento 1
  {31,31,3,3,3,3,3,3},  // segmento 2
  {31,31,3,3,3,3,31,31},// segmento 3
  {31,31,24,24,24,24,31,31},// segmento 4
  {27,27,27,27,27,27,31,31},// segmento 5
  {31,31,27,27,27,27,27,27},// segmento 6
  {31,31,27,27,27,27,31,31} // segmento 7

};

void writeCGRAM() {
  char i,j=0;

  for (i=0; i<=7; i++) {
     LCD_Cmd(64+i*8); //write CGRAM address
     for (j = 0; j<=7; j++) {
        LCD_Chr_Cp(segments[i][j]);
     }
     LCD_Cmd(_LCD_RETURN_HOME);
  }
}
void writeBigChar(short column, char character) {
  switch(character){
    case 0: {
      LCD_Chr(1,column,6);
      LCD_Chr(2,column,5);
      break;
    }
    case 1: {
      LCD_Chr(1,column,0);
      LCD_Chr(2,column,0);
      break;
    }
    case 2: {
      LCD_Chr(1,column,2);
      LCD_Chr(2,column,4);
      break;
    }
    case 3: {
      LCD_Chr(1,column,3);
      LCD_Chr(2,column,1);
      break;
    }
    case 4: {
      LCD_Chr(1,column,5);
      LCD_Chr(2,column,0);
      break;
    }
    case 5: {
      LCD_Chr(1,column,4);
      LCD_Chr(2,column,1);
      break;
    }
    case 6: {
      LCD_Chr(1,column,4);
      LCD_Chr(2,column,5);
      break;
    }
    case 7: {
      LCD_Chr(1,column,2);
      LCD_Chr(2,column,0);
      break;
    }
    case 8: {
      LCD_Chr(1,column,7);
      LCD_Chr(2,column,5);
      break;
    }
    case 9: {
      LCD_Chr(1,column,7);
      LCD_Chr(2,column,1);
      break;
    }
    case 10:{
      LCD_Out(2,column,".");
    }
  }
}
void ASCIItoDec(char *string, short size) {
   short i=0;

   for(i=0; i<=size; i++) {
      if ( (string[i]==46 || (string[i]==0))) {  //dot character
         string[i]=10;
      }
      else if (string[i]!=32){
         string[i] = string[i]-48;
      }
   }
}
void writeBigFloat(short column, float floatNumber)
{


    char size = sprintf(stringOutput,"%4.1f",floatNumber);//string generator

   ASCIItoDec(stringOutput,size)
{
   for (i=0; i<=size-1; i++)
   {
     if(stringOutput[i]!=32) { //Display string generator
       writeBigChar(column,stringOutput[i]);
       if(stringOutput[i]==10) { // dot
       writeBigChar(column,10);
     }
   }
}




void main()
{
  TRISA  = 0xFF;
  Lcd_Init();
  Lcd_Cmd(_LCD_CLEAR);
  Lcd_Cmd(_LCD_CURSOR_OFF);
  writeCGRAM();

  do
  {
     writeBigChar(2,10);
  } while(1);
}
 

Zip and post the complete mikroC Project files. I will try to compile.


Edit: I don't know whether your code works or not but here is the fixed code which compiles.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// LCD module connections
sbit LCD_RS at LATC0_bit;
sbit LCD_EN at LATC1_bit;
sbit LCD_D4 at LATC4_bit;
sbit LCD_D5 at LATC5_bit;
sbit LCD_D6 at LATC6_bit;
sbit LCD_D7 at LATC7_bit;
 
sbit LCD_RS_Direction at TRISC0_bit;
sbit LCD_EN_Direction at TRISC1_bit;
sbit LCD_D4_Direction at TRISC4_bit;
sbit LCD_D5_Direction at TRISC5_bit;
sbit LCD_D6_Direction at TRISC6_bit;
sbit LCD_D7_Direction at TRISC7_bit;
// End LCD module connections
 
char stringOutput[5];
short i = 0;
 
const char segments[8][8]=
{
  {3,3,3,3,3,3,3,3},      // segmento 0
  {3,3,3,3,3,3,31,31},  // segmento 1
  {31,31,3,3,3,3,3,3},  // segmento 2
  {31,31,3,3,3,3,31,31},// segmento 3
  {31,31,24,24,24,24,31,31},// segmento 4
  {27,27,27,27,27,27,31,31},// segmento 5
  {31,31,27,27,27,27,27,27},// segmento 6
  {31,31,27,27,27,27,31,31} // segmento 7
 
};
 
void writeCGRAM() {
  char i,j=0;
 
  for (i=0; i<=7; i++) {
     LCD_Cmd(64+i*8); //write CGRAM address
     for (j = 0; j<=7; j++) {
        LCD_Chr_Cp(segments[i][j]);
     }
     LCD_Cmd(_LCD_RETURN_HOME);
  }
}
void writeBigChar(short column, char character) {
  switch(character){
    case 0: {
      LCD_Chr(1,column,6);
      LCD_Chr(2,column,5);
      break;
    }
    case 1: {
      LCD_Chr(1,column,0);
      LCD_Chr(2,column,0);
      break;
    }
    case 2: {
      LCD_Chr(1,column,2);
      LCD_Chr(2,column,4);
      break;
    }
    case 3: {
      LCD_Chr(1,column,3);
      LCD_Chr(2,column,1);
      break;
    }
    case 4: {
      LCD_Chr(1,column,5);
      LCD_Chr(2,column,0);
      break;
    }
    case 5: {
      LCD_Chr(1,column,4);
      LCD_Chr(2,column,1);
      break;
    }
    case 6: {
      LCD_Chr(1,column,4);
      LCD_Chr(2,column,5);
      break;
    }
    case 7: {
      LCD_Chr(1,column,2);
      LCD_Chr(2,column,0);
      break;
    }
    case 8: {
      LCD_Chr(1,column,7);
      LCD_Chr(2,column,5);
      break;
    }
    case 9: {
      LCD_Chr(1,column,7);
      LCD_Chr(2,column,1);
      break;
    }
    case 10:{
      LCD_Out(2,column,".");
    }
  }
}
 
void ASCIItoDec(char *string, char size) {
   short i=0;
 
   for(i=0; i<=size; i++) {
      if ( (string[i]==46 || (string[i]==0))) {  //dot character
         string[i]=10;
      }
      else if (string[i]!=32){
         string[i] = string[i]-48;
      }
   }
}
 
void writeBigFloat(short column, float floatNumber)
{
   char size = sprintf(stringOutput, "%4.1f", floatNumber);//string generator
 
   ASCIItoDec(stringOutput, size);
 
   for (i=0; i<=size-1; i++)
   {
     if(stringOutput[i]!=32) { //Display string generator
       writeBigChar(column,stringOutput[i]);
       if(stringOutput[i]==10) { // dot
       writeBigChar(column,10);
       }
     }
   }
}
 
 
void main()
{
      TRISA = 0xFF;
      TRISC = 0x00;
      PORTC = 0x00;
 
      Lcd_Init();
      Lcd_Cmd(_LCD_CLEAR);
      Lcd_Cmd(_LCD_CURSOR_OFF);
 
      writeCGRAM();
 
      do{
         writeBigChar(2,10);
      } while(1);
}

 
Last edited:

I need more information. I want to know what characters you have created. Post the screen shot of each pattern that you have created. Without that I can't tell you why it is not working.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top