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.

[SOLVED] Progress Bar Display Problem on LCD , please help ??

Status
Not open for further replies.

xpress_embedo

Advanced Member level 4
Advanced Member level 4
Joined
Jul 5, 2011
Messages
1,154
Helped
161
Reputation
396
Reaction score
189
Trophy points
1,353
Location
India
embeddedlaboratory.blogspot.in
Activity points
10,591
I have to make a progress bar on my lcd (16x2), but having some problem

Previously i had made a progress bar based on 16 Values as on lcd we can display 16 characters easily, I had done this successfully
Have a look at this video
https://www.youtube.com/watch?v=5XYMfwnPXtQ

But now i have to create 32 steps on lcd, that's why i use one shaded box to display one value and other to display full.
By this i had created 32 steps on lcd.
But i am not able to display progress bar in negative direction pls help

here is my code

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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
// LCD module connections
sbit LCD_RS at RC0_bit;
sbit LCD_EN at RC1_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
 
sbit LCD_RS_Direction at TRISC0_bit;
sbit LCD_EN_Direction at TRISC1_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
 
unsigned char key;
unsigned char flag;
int counter = 0;
const char Less_Than[] = {1,3,7,15,15,7,3,1};
const char Greater_Than[] = {16,24,28,30,30,28,24,16};
const char Shaded_Block[] = {21,10,21,10,21,10,21,10};
 
void interrupt(void)
{
 if(INTCON.RBIE & INTCON.RBIF)
 {
  key = PORTB;
  key = key & 0xC0;
  if(key == 0x40)             //Down key is Pressed
  {
   if(counter > -16)
   {
    counter--;
   }
  }
  else if(key == 0x80)        //Up Key Pressed
  {
   if(counter < 16)
   {
    counter++;
   }
  }
  key = PORTB;
  key = key & 0xC0;
  while(key != 0xC0)
  {
   PORTB = 0xC0;
   key = PORTB;
   key = key & 0xC0;
  }
  flag = 1;
  INTCON.RBIF = 0;
 }
}
 
void Display_Value(int value)
{
 unsigned char ones,tens;
 if(value >= 0)
 {
  Lcd_Chr(1,14,'+');
 }
 else
 {
  value = value * (-1);
  Lcd_Chr(1,14,'-');
 }
 ones = value % 10;
 value = value / 10;
 tens = value % 10;
 ones = ones | 0x30;
 tens = tens | 0x30;
 Lcd_Chr(1,15,tens);
 Lcd_Chr(1,16,ones);
}
 
void Progress_Bar(int value)
{
 unsigned char j;
 if(value == 0)
 {
  Lcd_Chr(2,8,0);
  Lcd_Chr(2,9,1);
 }
 else if(value > 0)
 {
  value = value+16;
  Lcd_Chr(2,8,' ');
  for(j=16;j<value;j++)
  {
   if(j%2 == 0)
   {
    Lcd_Chr(2,j/2+1,2);
   }
   else
   {
    Lcd_Chr(2,j/2+1,0xFF);
   }
  }
  j=j+1;
  for(;j<32;j++)
  {
   if(j%2 == 0)
   {
    Lcd_Chr(2,j/2+1,' ');
   }
   else
   {
    Lcd_Chr(2,j/2+1,' ');
   }
  }
 }
 else if(value < 0)
 {
  value = value + 16;
  Lcd_Chr(2,9,' ');
 }
}
 
void main()
{
 unsigned char i;
 
 counter = 0;
 TRISB |= 0b11110000;
 Lcd_Init();
 Lcd_Cmd(_LCD_CLEAR);
 Lcd_Cmd(_LCD_CURSOR_OFF);
 Delay_ms(10);
 Lcd_Out(1,5,"EDA BOARD");
 Lcd_Out(2,1,"<-PROGRESS-BAR->");
 Delay_ms(1000);
 
 INTCON.RBIE = 1;
 INTCON.GIE = 1;
 INTCON.PEIE = 1;
 
 Lcd_Cmd(_LCD_CLEAR);
 Lcd_Out(1,1,"Progress Bar:");
 Display_Value(counter);
 Progress_Bar(counter);
 /********************************************/
 Lcd_Cmd(64);          //CGRAM Address
 for(i=0;i<8;i++)
 {
  Lcd_Chr_Cp(Less_Than[i]);
 }
 Lcd_Cmd(_LCD_RETURN_HOME);
 
 Lcd_Cmd(72);
 for(i=0;i<8;i++)
 {
  Lcd_Chr_Cp(Greater_Than[i]);
 }
 Lcd_Cmd(_LCD_RETURN_HOME);
 
 Lcd_Cmd(80);
 for(i=0;i<8;i++)
 {
  Lcd_Chr_Cp(Shaded_Block[i]);
 }
 Lcd_Cmd(_LCD_RETURN_HOME);
 /********************************************/
 while(1)
 {
  if(flag != 0)
  {
   Lcd_Out(1,1,"Progress Bar:");
   Display_Value(counter);
   Progress_Bar(counter);
   flag = 0;
  }
 }
}



Please help me, i am not able to write code for negative values pls help.
and also is there any method to reduce the flicker on lcd.
to see flicker have a look at this video also.
View attachment Progress Bar Problem.zip


Project Files
View attachment Progress_Bar.zip

Please some one help me
 
Last edited:

You have to create two custom characters for LCD. One is for one complete LCD character and another for half the character of LCD. First you display the half character on LCD then you display the full charcater. So it will get you 32 steps of Progress bar. each character of LCD takes two values (half and full).
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top