CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

How to drive GLCD with Controller AVANT SBN0064G

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
seme1



Joined: 13 Jun 2009
Posts: 21

View user's profile Send private message

How to drive GLCD with Controller AVANT SBN0064G
PostPosted: Mon Jun 29, 2009 8:47 am     Reply with quote

I have a graphics lcd with the controller AVANT SBN0064G. I have seen the example code provided with CCS, but it was for a different controller.

The GLCD datasheet is
http://download.maritex.com.pl/pdfs/op/TG12864B-31.pdf

And for the controller, it is:
http://www.allshore.com/pdf/Avant%20SBN0064G.pdf

Can anybody please give me hints on how to start working with this GLCD ? I need to display simply English characters/words first.

Any help is very much appreciated.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 29, 2009 1:30 pm     Reply with quote

Here is how find a driver for your controller:

Search for the following terms in http://www.google.com
Quote:
SBN0064G compatible

This will find information on which "standard" controllers are compatible
with your controller.
Result:
http://www.marketa.com/eng/semicon_pro_avant.html
This page shows that your controller is compatible with the KS0108.
Next, search the CCS drivers directory for that driver. Result:
Quote:
c:\program files\picc\drivers\ks0108.c
seme1



Joined: 13 Jun 2009
Posts: 21

View user's profile Send private message

PostPosted: Mon Jun 29, 2009 5:22 pm     Reply with quote

Thanks for the response.

I tried running a simple software on to see if I got the right driver, but screen is showing nothing (blank), not even garbage characters.
Code:

#include <18F46K20.h>


#fuses  XT, NOWDT, PUT ,BROWNOUT, NOLVP
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)

#use delay(clock=8000000)

//#define FAST_GLCD
#include <HDM64GS12.c>
#include <graphics.c>
#include <math.h>
// #device adc=8
#include <stdio.h>
#include <stdlib.h>

void main() {
   char  voltText[] = "Volts", warning[] = "Warning";

   glcd_init(ON);                               // Must initialize the LCD
   glcd_rect(1, 5, 126, 15, NO, ON);            // Outline the bar
   glcd_text57(70, 18, voltText, 1, ON);        // Display "Volts"
   glcd_circle(30, 47, 10, NO, ON);             // Draw the clock circle
     
    #ifdef FAST_GLCD
      glcd_update();
      #else
      delay_ms(100);    // Reduces flicker by allowing pixels to be on
                        // much longer than off
      #endif

   for(;;) {
   }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 29, 2009 5:32 pm     Reply with quote

Quote:
#fuses XT, NOWDT, PUT ,BROWNOUT, NOLVP
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)

#use delay(clock=8000000)

Look in this section of the 18F46K20 data sheet:
Quote:
TABLE 26-6: EXTERNAL CLOCK TIMING REQUIREMENTS

It's on page 382 in the Acrobat reader:
http://ww1.microchip.com/downloads/en/DeviceDoc/41303E.pdf

It shows the maximum crystal frequency for the XT mode is 4 MHz.
You need to change the fuse to HS for an 8 MHz crystal.
seme1



Joined: 13 Jun 2009
Posts: 21

View user's profile Send private message

PostPosted: Mon Jun 29, 2009 5:49 pm     Reply with quote

I don't think that is the cause of the problem as I tried to get some text displayed on a basic 2-line LCD, and it worked perfectly fine.

I changed the fuse to HS anyway to see if it would make any difference. The GLCD is still not showing anything (blank screen with nothing on it)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 29, 2009 7:52 pm     Reply with quote

Post a list of the connections between your PIC and the LCD.
Post the actual pin numbers.
seme1



Joined: 13 Jun 2009
Posts: 21

View user's profile Send private message

PostPosted: Mon Jun 29, 2009 8:29 pm     Reply with quote

GLCD ----------- PIC
4 (RS) ---------- 35 (B2)
5 (RW) ---------- 37 (B4)
6 (E) ------------- 38 (B5)
7 ------------- 19 (D0)
8 ------------- 20 (D1)
9 --------------- 21 (D2)
10 ------------- 22 (D3)
11 ------------- 23 (D4)
12 ------------- 24 (D5)
13 ------------- 25 (D6)
14 -------------- 26 (D7)
15 (CS1) ------------- 33 (B0)
16 (CS2) -------------- 34 (B1)
17 (RST) --------------- 15 (C0)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 29, 2009 9:07 pm     Reply with quote

I assume you're using the 40-pin DIP package for the PIC.
There are some wiring errors. The data bus is supposed to
be completely on Port D, but the upper 4 bits are are Port C
by mistake. See the lines shown in bold below:
Quote:

GLCD ----------- PIC
++++++++++
4 (RS) ---------- 35 (B2)
5 (RW) ---------- 37 (B4)
6 (E) ------------- 38 (B5)
7 ------------- 19 (D0)
8 ------------- 20 (D1)
9 --------------- 21 (D2)
10 ------------- 22 (D3)
11 ------------- 23 (D4) *** Is pin C4, should be RD4, pin 27
12 ------------- 24 (D5) *** Is pin C5, should be RD5, pin 28
13 ------------- 25 (D6) *** Is pin C6, should be RD6, pin 29
14 -------------- 26 (D7) *** Is pin C7, should be RD7, pin 30
15 ------------- 33 (B0)
16 -------------- 34 (B1)
17 --------------- 15 (C0)
seme1



Joined: 13 Jun 2009
Posts: 21

View user's profile Send private message

PostPosted: Tue Jun 30, 2009 5:09 am     Reply with quote

Thanks again for the response. I fixed the wiring as you suggested (4 wires), and it's still showing nothing (screen is blank)

What else could be the reason ?
seme1



Joined: 13 Jun 2009
Posts: 21

View user's profile Send private message

PostPosted: Tue Jun 30, 2009 9:14 am     Reply with quote

To try and figure out what could be wrong, I wrote the following routine:

Code:

#include <18F46K20.h>


#fuses  XT, NOWDT, PUT ,BROWNOUT, NOLVP
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)

#use delay(clock=8000000)

#define FAST_GLCD
#include <HDM64GS12.c>
#include <graphics.c>
#include <math.h>
// #device adc=8
#include <stdio.h>
#include <stdlib.h>


void main() {
   char  voltText[] = "Volts", warning[] = "Warning";

   output_high(PIN_A1);
   glcd_init(ON);                               // Must initialize the LCD
   glcd_rect(1, 5, 126, 15, NO, ON);            // Outline the bar
   glcd_text57(70, 18, voltText, 1, ON);        // Display "Volts"
   glcd_circle(30, 47, 10, NO, ON);             // Draw the clock circle
   glcd_fillScreen(ON);   
      output_high(PIN_A0);
    #ifdef FAST_GLCD
      glcd_update();
      #else
      delay_ms(100);    // Reduces flicker by allowing pixels to be on
                        // much longer than off
      #endif
     

   for(;;) {
   glcd_fillScreen(ON);   
   glcd_update();
   output_toggle(PIN_A0); // an LED is connected to A0
   delay_ms(1000);
   glcd_fillScreen(OFF);   
   glcd_update();
   output_toggle(PIN_A0);
   delay_ms(1000);
   }
}


And the results are as follows:

WHEN LED is HIGH

GLCD ----------- Voltage
4 (RS) ---------- 2.61 (not stable)
5 (RW) ---------- 0.78
6 (E) ------------- goes to 0.1 for a moment then 0
7 ------------- 0
8 ------------- 0
9 --------------- 0
10 ------------- 0
11 ------------- 0
12 ------------- 0
13 ------------- 0
14 -------------- 0.01
15 (CS1) ------------- goes to 0.1 for a moment then 0
16 (CS2) -------------- goes to 0.1 for a moment then 0
17 (RST) --------------- 2.71


LED LOW:

GLCD ----------- Voltage
4 (RS) ---------- 2.67 (not stable,, goes to 3 sometimes)
5 (RW) ---------- 0.64
6 (E) ------------- goes to 0.1 for a moment then 0
7 ------------- 3.04
8 ------------- 3.08
9 --------------- 3.07
10 ------------- 3.07
11 ------------- 3
12 ------------- 3
13 ------------- 3
14 -------------- 0.01
15 (CS1) ------------- goes to 0.1 for a moment then 0
16 (CS2) -------------- goes to 0.1 for a moment then 0
17 (RST) --------------- 3.05

The screen of the LCD is still blank. In one occasion while I was measuring the voltage values for some of the lcd pins, half of the right side of the screen went fully black except for random dots in the top which kept going on and off with the LED going on/off. The rest of the screen stayed intact. This kept me wondering about the voltage values and maybe the GLCD needs higher voltage than what is currently fed into it. I am supplying 5V to pin 2 (VDD) of the glcd, and I don't see how this could be the problem.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jun 30, 2009 12:14 pm     Reply with quote

Using a voltmeter won't help. You need an oscilloscope.

1. Delete the following line. It adds complexity that you don't need at
this point.
Quote:
#define FAST_GLCD


2. Post a detailed description of your contrast control circuit (connected
to pin 3 on the LCD). Measure the contrast voltage on pin 3 of the LCD.
What is it ?

3. Post the #define statements for the LCD pins, that are near the top
of the HDM64GS12.c file.
seme1



Joined: 13 Jun 2009
Posts: 21

View user's profile Send private message

PostPosted: Sat Jul 04, 2009 3:11 pm     Reply with quote

Hi,

I commented out the line #define FAST_GLCD, and it didn't make any difference.

I did notice though that sometimes the lcd displays partly the text "Volts:" and the text shakes for few seconds before the led goes on and the screen picture changes.

The code I ran is the following:
Code:

#include <18F46K20.h>

#fuses  XT, NOWDT, PUT ,BROWNOUT, NOLVP
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)

#use delay(clock=8000000)

//#define FAST_GLCD
#include <HDM64GS12.c>
#include <graphics.c>

void main() {
   char  voltText[] = "Volts", warning[] = "Warning";

   glcd_init(ON);                               // Must initialize the LCD
   output_high(PIN_A0);   

   for(;;) {
   glcd_fillScreen(ON);   
    #ifdef FAST_GLCD
    glcd_update();
      #else
      delay_ms(100);    // Reduces flicker by allowing pixels to be on much longer than off
      #endif
   output_toggle(PIN_A0);
   delay_ms(1000);
   
   glcd_fillScreen(OFF);   
       #ifdef FAST_GLCD
      glcd_update();
      #else
      delay_ms(100);    // Reduces flicker by allowing pixels to be on much longer than off
      #endif
   output_toggle(PIN_A0);
   delay_ms(1000);
   
   glcd_rect(1, 5, 126, 15, NO, ON);            // Outline the bar
   glcd_text57(70, 18, voltText, 1, ON);        // Display "Volts"
   glcd_circle(30, 47, 10, NO, ON);             // Draw the clock circle
   output_toggle(PIN_A0);
       #ifdef FAST_GLCD
      glcd_update();
      #else
      delay_ms(100);    // Reduces flicker by allowing pixels to be on much longer than off
      #endif
   delay_ms(1000);

   }
}


The difference in the voltage between pins 3 and 18 (VEE) is about 1.5v. On pin 3, the voltage is about 3.2V.



The define statements you asked for are:
Code:


#ifndef HDM64GS12
#define HDM64GS12

#ifndef GLCD_WIDTH
#define GLCD_WIDTH   128
#endif

#ifndef GLCD_CS1
#define GLCD_CS1     PIN_B0   // Chip Selection 1
#endif

#ifndef GLCD_CS2
#define GLCD_CS2     PIN_B1   // Chip Selection 2
#endif

#ifndef GLCD_DI
#define GLCD_DI      PIN_B2   // Data or Instruction input
#endif

#ifndef GLCD_RW
#define GLCD_RW      PIN_B4   // Read/Write
#endif

#ifndef GLCD_E
#define GLCD_E       PIN_B5   // Enable
#endif

#ifndef GLCD_RST
#define GLCD_RST     PIN_C0   // Reset
#endif

#define GLCD_LEFT    0
#define GLCD_RIGHT   1

#ifndef ON
#define ON           1
#endif

#ifndef OFF
#define OFF          0
#endif


Last edited by seme1 on Sat Jul 04, 2009 6:43 pm; edited 1 time in total
seme1



Joined: 13 Jun 2009
Posts: 21

View user's profile Send private message

PostPosted: Sat Jul 04, 2009 3:23 pm     Reply with quote

I uploaded a video showing exactly what I am getting now. The "Volts" text no longer appears !! (note the blinking green LED in the bottom right corner, that is PIN_A0)



http://tinypic.com/r/24y0e1j/5
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jul 05, 2009 2:56 pm     Reply with quote

Your video is out of focus, so it's difficult to see any detail.
Your test program is too complicated. You're doing too many tests.
The screen is filled with many different results, so it's difficult to
trouble-shoot the problem.

I would try a test that just draws a single vertical line (full height)
in the middle of the display:
Code:

#include <18F46K20.h>
#fuses  HS, NOWDT, PUT, BROWNOUT, NOLVP, NOPBADEN
#use delay(clock=8000000)

#include <HDM64GS12.c>
#include <graphics.c>

//================================
void main()
{
glcd_init(1);                     

// syntax: glcd_line(x1, y1, x2, y2, color)
// Draw a vertical line down the middle of the screen

glcd_line(63, 0, 63, 63, 1);

while(1);
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group