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.

pic16f877a with KS0108 GLCD DISPLAY PROBLEM

Status
Not open for further replies.

sresam89

Member level 2
Joined
Sep 9, 2009
Messages
48
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,576
dear all,
am having a tough time interfacing pic16f877a with Glcd 128x64 running in KS0108. am getting all the data being send displayed the problem is only half the display is always displayed i cant make the full display to show any content given am attaching the screenshot and the program.
am using ccs compiler and the example programs and default drivers.
Code:
#include <HDM64GS12.c>
#include <graphics.c>
#include <math.h>

#byte trisa=0x85
#byte trisb=0x86
#byte trisc=0x87
#byte trisd=0x88
#byte trise=0x89
#byte porta=0x05
#byte portb=0x06
#byte portc=0x07
#byte portd=0x08

void displayVoltage(int adc) {
   char voltage[9];
   sprintf(voltage, "%f", (float)adc * .01960784); // Converts adc to text
   voltage[4] = '\0';                              // Limit shown digits to 3
   glcd_rect(45, 18, 69, 25, YES, OFF);            // Clear the old voltage
   glcd_text57(45, 18, voltage, 1, ON);            // Write the new voltage
}

void main() {
   int1  warn = FALSE;
   int8  adc = 0, adc_old = 0;
   char  voltText[] = "VoLtS\0", warning[] = "Warning";
   float theta = 0;

   setup_adc_ports(RA0_ANALOG);
   setup_adc(ADC_CLOCK_INTERNAL);
   set_adc_channel(0);
   
   TRISA = 0x00;
   TRISB = 0x00; 
   TRISC = 0x00;
   TRISD = 0x00;
   TRISE = 0x00;
   porta=0x00;
while(1)
{
   glcd_init(ON);                               // Must initialize the LCD
   //glcd_rect(1, 1, 126, 126, YES, ON);            // Outline the bar
   glcd_text57(50, 100, voltText, 1, ON);        // Display "Volts"
   glcd_circle(30,47, 10, NO, ON);             // Draw the clock circle
  porta=~porta;
  delay_ms(300);
 //  for(;;) {
      adc = read_adc();                         // Read a value from the ADC
      displayVoltage(adc);                      // Display the reading
      adc = (adc > 249) ? 249 : adc;            // Keep the value 249 or less

      if(adc != adc_old) {
         glcd_rect(adc/2+1, 6, adc_old/2+1, 14, YES, OFF);  // Clears the old bar
         glcd_rect(1, 6, adc/2+1, 14, YES, ON);             // Draws a new bar
         adc_old = adc;                                     // Set old value to new

         if(adc > 200 && !warn) {                  // Check if over 4 volts
            glcd_rect(45, 38, 124, 55, YES, ON);   // Draw a filled black rectangle
            glcd_text57(47, 40, warning, 2, OFF);  // Write "Warning" on the LCD
            warn = TRUE; }
         else if(adc <=200 && warn) {
            glcd_rect(45, 37, 125, 55, YES, OFF);  // Draw a filled white rectangle
            warn = FALSE; }
      }

      // The following 3 lines make the clock hand spin around
      glcd_line(30, 47, 30+(int)(8*sin(theta)+.5), 47-(int)(8*cos(theta)+.5), OFF);
      theta = (theta > 5.9) ? 0 : (theta += .3);
      glcd_line(30, 47, 30+(int)(8*sin(theta)+.5), 47-(int)(8*cos(theta)+.5), ON);

      #ifdef FAST_GLCD
      glcd_update();
      #else
      delay_ms(100);    // Reduces flicker by allowing pixels to be on
                        // much longer than off
      #endif 
   }
}
 

Attachments

  • Photo-0012.jpg
    Photo-0012.jpg
    154.7 KB · Views: 161
  • Photo-0003.jpg
    Photo-0003.jpg
    177 KB · Views: 135

none there mods at-least you could help me please refer me to someone
 


dear all,
am having a tough time interfacing pic16f877a with Glcd 128x64 running in KS0108. am getting all the data being send displayed the problem is only half the display is always displayed i cant make the full display to show any content given am attaching the screenshot and the program.
am using ccs compiler and the example programs and default drivers.
Code:
#include <HDM64GS12.c>
#include <graphics.c>
#include <math.h>

#byte trisa=0x85
#byte trisb=0x86
#byte trisc=0x87
#byte trisd=0x88
#byte trise=0x89
#byte porta=0x05
#byte portb=0x06
#byte portc=0x07
#byte portd=0x08

void displayVoltage(int adc) {
   char voltage[9];
   sprintf(voltage, "%f", (float)adc * .01960784); // Converts adc to text
   voltage[4] = '\0';                              // Limit shown digits to 3
   glcd_rect(45, 18, 69, 25, YES, OFF);            // Clear the old voltage
   glcd_text57(45, 18, voltage, 1, ON);            // Write the new voltage
}

void main() {
   int1  warn = FALSE;
   int8  adc = 0, adc_old = 0;
   char  voltText[] = "VoLtS\0", warning[] = "Warning";
   float theta = 0;

   setup_adc_ports(RA0_ANALOG);
   setup_adc(ADC_CLOCK_INTERNAL);
   set_adc_channel(0);
   
   TRISA = 0x00;
   TRISB = 0x00; 
   TRISC = 0x00;
   TRISD = 0x00;
   TRISE = 0x00;
   porta=0x00;
while(1)
{
   glcd_init(ON);                               // Must initialize the LCD
   //glcd_rect(1, 1, 126, 126, YES, ON);            // Outline the bar
   glcd_text57(50, 100, voltText, 1, ON);        // Display "Volts"
   glcd_circle(30,47, 10, NO, ON);             // Draw the clock circle
  porta=~porta;
  delay_ms(300);
 //  for(;;) {
      adc = read_adc();                         // Read a value from the ADC
      displayVoltage(adc);                      // Display the reading
      adc = (adc > 249) ? 249 : adc;            // Keep the value 249 or less

      if(adc != adc_old) {
         glcd_rect(adc/2+1, 6, adc_old/2+1, 14, YES, OFF);  // Clears the old bar
         glcd_rect(1, 6, adc/2+1, 14, YES, ON);             // Draws a new bar
         adc_old = adc;                                     // Set old value to new

         if(adc > 200 && !warn) {                  // Check if over 4 volts
            glcd_rect(45, 38, 124, 55, YES, ON);   // Draw a filled black rectangle
            glcd_text57(47, 40, warning, 2, OFF);  // Write "Warning" on the LCD
            warn = TRUE; }
         else if(adc <=200 && warn) {
            glcd_rect(45, 37, 125, 55, YES, OFF);  // Draw a filled white rectangle
            warn = FALSE; }
      }

      // The following 3 lines make the clock hand spin around
      glcd_line(30, 47, 30+(int)(8*sin(theta)+.5), 47-(int)(8*cos(theta)+.5), OFF);
      theta = (theta > 5.9) ? 0 : (theta += .3);
      glcd_line(30, 47, 30+(int)(8*sin(theta)+.5), 47-(int)(8*cos(theta)+.5), ON);

      #ifdef FAST_GLCD
      glcd_update();
      #else
      delay_ms(100);    // Reduces flicker by allowing pixels to be on
                        // much longer than off
      #endif 
   }
}
Hope pins cs1 and cs2 were connected correctly, ensure it by checking continuity. Then write a simple fillscreen program to test your glcd than this lengthy codes. You can also try Proteus before burning the actual firmware to pic.



Good luck. :)
 


Hope pins cs1 and cs2 were connected correctly, ensure it by checking continuity. Then write a simple fillscreen program to test your glcd than this lengthy codes. You can also try Proteus before burning the actual firmware to pic.



Good luck. :)

thanks for the suggestion anand. i did glcd_fillscreen() only. just posted the whole code. double checked the continuity its fine. anything thing else that am missing..?
?
 

Simulate your program using Proteus, post the result.



Good luck :)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top