LCD interfacing problem

Thread Starter

anandan003

Joined Mar 9, 2011
1
Hi friends,


I am using PIC18f4550 and is interfaced with LCD 16x2. I am printing continuously some ADC values on the LCD. program is working fine, but when the ADC gives 5 digit value first and reduces and comes to a 2 digit value. then the right most digits are not getting cleared up. I don't want to use LCD clear command since it gives a blinking type display.

problem example

ADC value :12345----- 5 digit

ADC value :67345----- 2 digit ( now ADC prints only 67 but 345 is not getting cleared ) pasting part of my code below,

Thanks in advance,

Rich (BB code):
 while(1)
                {
 
                  Vin = Adc_Read(0);
 
                   //Vin= vin*3.33;
                  // mv = (Vin) >> 10;  (0.0049)
 
                  mv = (Vin * 4004 ) >> 10; // mv = Vin x 5000 / 1024// error correction
                // mv= mv ;
                  LongToStr(mv,op); // Convert to string in "op"   //
                  j=0;
                      for(i=0;i<=11;i++)
 
                      {
 
                        if(op != ' ') // If a blank
                            {
 
                             lcd[j]=op;
                             j++;
 
                           }
                      }
 
 
                   }
 
 
                    // Lcd_Cmd(LCD_RETURN_HOME);
                   //Lcd_Cmd(Lcd_CLEAR);
 
 
                  Lcd_Out(2, 1 ,text2);
 
                  Lcd_Out(2, 4 ,lcd );


Cheers,
Anand
 
Last edited by a moderator:

spinnaker

Joined Oct 29, 2009
7,830
Hi friends,


I am using PIC18f4550 and is interfaced with LCD 16x2. I am printing continuously some ADC values on the LCD. program is working fine, but when the ADC gives 5 digit value first and reduces and comes to a 2 digit value. then the right most digits are not getting cleared up. I don't want to use LCD clear command since it gives a blinking type display.

problem example

ADC value :12345----- 5 digit

ADC value :67345----- 2 digit ( now ADC prints only 67 but 345 is not getting cleared ) pasting part of my code below,

Thanks in advance,

Rich (BB code):
 while(1)
                {
 
                  Vin = Adc_Read(0);
 
                   //Vin= vin*3.33;
                  // mv = (Vin) >> 10;  (0.0049)
 
                  mv = (Vin * 4004 ) >> 10; // mv = Vin x 5000 / 1024// error correction
                // mv= mv ;
                  LongToStr(mv,op); // Convert to string in "op"   //
                  j=0;
                      for(i=0;i<=11;i++)
 
                      {
 
                        if(op != ' ') // If a blank
                            {
 
                             lcd[j]=op;
                             j++;
 
                           }
                      }
 
 
                   }
 
 
                    // Lcd_Cmd(LCD_RETURN_HOME);
                   //Lcd_Cmd(Lcd_CLEAR);
 
 
                  Lcd_Out(2, 1 ,text2);
 
                  Lcd_Out(2, 4 ,lcd );
Cheers,
Anand


Just tack on some extra spaces to the end of your string. If your buffer is only 16 bytes, remember to make it a little bigger.
 
Top