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 CCS Technical Support

Help on PICDEM LCD display configuration

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



Joined: 01 Oct 2003
Posts: 172
Location: Punta Gorda, Florida USA

View user's profile Send private message Send e-mail

Help on PICDEM LCD display configuration
PostPosted: Sun Jan 20, 2008 4:15 pm     Reply with quote

Hi,
I have recently acquired a PICDEM LCD development board which comes with the PIC18F8490 device installed, the display is an eight character by 14 segment star type display. I have been trying to make sense of the segment mapping configuration and can't make heads or tails from the info I have, I tried looking at the declares from the Microchip included asm files, as well as EX_92lcd.c from CCS, but so far I have not been able to understand it. What I am looking for is the following definition:

/////////////////////////////////////////////////////////////////////////////////////////
// LCD Configuration //
/////////////////////////////////////////////////////////////////////////////////////////
*/
// Digit segments A B C D E F G DP
// b7 b6 b5 b4 b3 b2 b1 b0
#define DIGIT4 COM1+26, COM1+17, COM2+17, COM3+26, COM2+25, COM1+25, COM2+26, COM3+17
#define DIGIT3 COM1+24, COM1+16, COM2+16, COM3+24, COM2+23, COM1+23, COM2+24, COM3+16
#define DIGIT2 COM1+22, COM1+19, COM2+19, COM3+22, COM2+21, COM1+21, COM2+22, COM3+19
#define DIGIT1 COM1+20, COM1+18, COM2+18, COM3+20, COM2+28, COM1+28, COM2+20, COM3+18
//
// character 0 1 2 3 4 5 6 7 8 9
byte const Digit_Map[10] = {0xFC,0x60,0xDA,0xF2,0x66,0xB6,0xBE,0xE0,0xFE,0xE6};

#define BLANK 0
#define DASH 11

I realize the above seems to be based on a seven segment type display rather than a 14 segment. Perhaps someone in this forum has already decoded what I am looking for, but in any case I believe I should be able to just use only seven out of the fourteen segments and be able to use this board.

Thank you
Sad
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jan 20, 2008 5:34 pm     Reply with quote

The LCD is 8x1 with 14 segments per character. It appears to be
this Varitronix LCD. I'm not 100% sure on that.
http://www.varitronix.com/Product/LCD/VIM-878-DP(R0).pdf

The ASM source code for the PicDem LCD board can be downloaded
on this page:
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en021939

The CCS manual says lcd_symbol() function can accept up to 16 segments.

To create a driver written in CCS, you need to look at the sample
ASM code in the LCD.asm and LCD.inc files, given in the Microchip
PicDem LCD driver source code (downloadable on the page given above).

You need to look at the LCDinit routine in LCD.c, and then select the
parameters in the CCS setup_lcd() function, so that the .LST file code
for setup_lcd() has the same effect as the ASM code in LCD.c
i.e., it must load LCDCON and other registers with the same values.

Here's a driver that I did for the PicDem Mechatronics board, but it's
got a 7-segment LCD on it. The driver for yours will be quite different
since you have a 14-segment LCD.
http://www.ccsinfo.com/forum/viewtopic.php?p=89595

I don't have anymore time to work on this (at least right now) but the
information above should be enough to get you started.
cbarberis



Joined: 01 Oct 2003
Posts: 172
Location: Punta Gorda, Florida USA

View user's profile Send private message Send e-mail

PostPosted: Mon Jan 21, 2008 10:15 am     Reply with quote

Thank you PCM Programmer!

I gues what I need to understand is what is the relationship of the lcd.inc file definitions to the CCS defines, that is where I am getting lost, i.e:

Microchip asm inc defines for the demo code on the PICDEM-LCD:

#define D1A LCDDATA3,4 ; DIGIT 1 (Left Side)
#define D1B LCDDATA9,4
#define D1C LCDDATA15,4
#define D1D LCDDATA21,7
........etc.

Versus the CCS defines:
////////////////////////////////////////////////////////////////////////////////////////
// LCD Configuration //
/////////////////////////////////////////////////////////////////////////////////////////
// Digit segments A B C D E F G DP
// b7 b6 b5 b4 b3 b2 b1 b0
#define DIGIT1 COM1+38, COM0+31, COM1+31, COM1+37, COM0+37, COM0+35, COM0+47, COM1+36


or in other words: how does; COM1+38 translate to; LCDDATA3,4 Question Question


I also looked at the Varitronix VIM-878 you sent me, but it appears that that is not the same display as in this board, I'll have to contact Microchip and ask about that.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jan 21, 2008 12:38 pm     Reply with quote

When you find the manufacturer and part number of the LCD, post it.
I'll look at it and try to give some more help.
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Mon Jan 21, 2008 12:55 pm     Reply with quote

Hola Carlos & PCM,

The LCD display is a 14 Segment LCD display from Pacific Display Devices.
All the info I found is:

http://pacificdisplay.com/glass/PD-878.pdf

but I can't realize how was done the CCS #defines.

Hmberto


Last edited by Humberto on Mon Jan 21, 2008 1:01 pm; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jan 21, 2008 12:56 pm     Reply with quote

Thanks Humberto. I'll look at it later today.
cbarberis



Joined: 01 Oct 2003
Posts: 172
Location: Punta Gorda, Florida USA

View user's profile Send private message Send e-mail

PostPosted: Mon Jan 21, 2008 1:56 pm     Reply with quote

Humberto Y PCM, MUCHISIMAS GRACIAS!!!!!

That is the correct display! they are using. The interesting thing is, in their board documentation they only refer to DCI and Varitronix as the suppliers, no reference to Pacific displays. I kept looking at the schematic and pin out in reference to all the models in Varitronix, did not match any of them, but this is the correct display..THANK YOU mi querido amigo Humberto!
But I am still puzzled as to how the defines really work Question Question
cbarberis



Joined: 01 Oct 2003
Posts: 172
Location: Punta Gorda, Florida USA

View user's profile Send private message Send e-mail

PostPosted: Mon Jan 21, 2008 4:54 pm     Reply with quote

I found out with a little help from CCS that the way this works is by looking at table 22-6 (registers associated with LCD)of the PIC data sheet using this table and the defines from the asm file from microchip you can then construct the defines in CCS, for example:

from microchip inc file: #define D1A LCDDATA3,4 and #define D1B LCDDATA9,4

Translates to COM1+26 and COM1+28 for the CCS digit defines...and so on.

However, I still get all kind of garbled characters on the PICDEM LCD display, I am not sure as to why, but I suspect that I am not defining or constructing the digits in the following correctly;
character 0 1 2 3 4 5 6 7 8 9
//byte const Digit_Map[10] = {0xFC,0x60,0xDA,0xF2,0x66,0xB6,0xBE,0xE0,0xFE,0xE6};


I am finding out that working with these multisegment lcd's is a big pain in the butt!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jan 22, 2008 12:48 am     Reply with quote

This is going to take longer than I have time for on a weekday. I'm
very busy at work. If you haven't figured it out by Sunday, I can work
on it then. I have some free time on Sunday afternoon.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jan 28, 2008 2:43 am     Reply with quote

I looked at the .LST file code for the lcd_symbol() function for the
18F8490 (with vs. 4.066). There's a bug in the code. One of the
segments is not written correctly if you use 16-bit mode. I think
I can fix it by doing two calls to lcd_symbol() with 8-bit segment data
instead of one call with 16-bit data. I have more work to do on it, so it's
going to be later this week before I can post it.
cbarberis



Joined: 01 Oct 2003
Posts: 172
Location: Punta Gorda, Florida USA

View user's profile Send private message Send e-mail

PostPosted: Tue Jan 29, 2008 7:04 am     Reply with quote

Thank you for all your help PCM, I had to put this project on the side for now because of other imediate jobs. I got the display to work using only seven segments, for the exception of segment K, for some reason no matter what I do, I can't seem to get this segment running. I also did use 16 bit vars to pass the info to the display as you needed more than eight bits to get all these segments running, but things got totally screwed up, I also noticed that there must be some other timing issue as the segments seem to blink when you look at them at an angle. All in all, I think I am not close yet.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jan 31, 2008 6:18 pm     Reply with quote

Here is the driver that I did for the PicDem LCD board. It's based on
the CCS example driver file, Ex_92lcd.c. I don't have that board, so
I can't test this driver in hardware. But I looked at all the documentation
available, so I think it has a good chance to work.

The #define statements for the digits (DIGIT8_H, etc.) were determined
by looking at the #defines in lcdboard.inc (from the PicDem LCD sample
files) and Table 22-6 in the 18F8490 data sheet. I had to make two
#define statements for each digit in the LCD (_H and _L) because the
lcd_symbol() function has a bug in 16-bit mode in vs. 4.066. But it
works if you use 8-bit mode. That's why in the switch-case statement
you'll see two calls to lcd_symbol for each digit. Half of the segments
in each digit are done in each call.

The Digit_Map values were determined by realizing that CCS left-justifies
the digit segments in a 16-bit word, with segment 'a' being in bit 15.
As you can see below, I made a drawing of a 14-segment digit and then
added the bit numbers in place of the letter names for the segments.
This page shows what 14-segment numbers should look like (0 to 9).
See the middle drawing on this page:
http://www.altia.com/demos/libraries/infotainment/infotainment_fonts.htm
While looking at that drawing, I was able to determine what segments
to "turn on" for each digit. I wrote them down in binary format, as
shown below. Then I converted the binary values into 16-bit hex, and
put those values into the Digit_Map[] array.

This program uses INTRC_IO oscillator mode, at 8 MHz. That's because
the PicDem LCD board also does that. The values that are calculated for
the setup_lcd() statement depend upon the oscillator frequency. The
sample ASM code for the PicDem LCD board (from Microchip) calculates
the values at compile-time with several equations. I didn't want to
bother with that, so I just hard-coded the setup_lcd() value for the 8 MHz
internal oscillator.
Code:

#include <18F8490.h>
#fuses INTRC_IO,NOWDT,NOPROTECT
#use delay(clock=8000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

//                   A        B        C        D        E        F        G        H       
#define DIGIT8_H   COM0+28, COM1+28, COM2+28, COM3+31, COM2+31, COM1+31, COM1+30, COM0+30
#define DIGIT8_L   COM0+29, COM1+29, COM2+29, COM2+30, COM3+30, COM3+29, COM3+28, COM0+31
//                   I        J        K        L        M        N        8DP      9X

#define DIGIT7_H   COM0+24, COM1+24, COM2+24, COM3+27, COM2+27, COM1+27, COM1+26, COM0+26
#define DIGIT7_L   COM0+25, COM1+25, COM2+25, COM2+26, COM3+26, COM3+25, COM3+24, COM0+27

#define DIGIT6_H   COM0+20, COM1+20, COM2+20, COM3+23, COM2+23, COM1+23, COM1+22, COM0+22
#define DIGIT6_L   COM0+21, COM1+21, COM2+21, COM2+22, COM3+22, COM3+21, COM3+20, COM0+23

#define DIGIT5_H   COM0+16, COM1+16, COM2+16, COM3+19, COM2+19, COM1+19, COM1+18, COM0+18
#define DIGIT5_L   COM0+17, COM1+17, COM2+17, COM2+18, COM3+18, COM3+17, COM3+16, COM0+19

#define DIGIT4_H   COM0+12, COM1+12, COM2+12, COM3+15, COM2+15, COM1+15, COM1+14, COM0+14
#define DIGIT4_L   COM0+13, COM1+13, COM2+13, COM2+14, COM3+14, COM3+13, COM3+12, COM0+15

#define DIGIT3_H   COM0 +8, COM1 +8, COM2 +8, COM3+11, COM2+11, COM1+11, COM1+10, COM0+10
#define DIGIT3_L   COM0 +9, COM1 +9, COM2 +9, COM2+10, COM3+10, COM3 +9, COM3 +8, COM0+11

#define DIGIT2_H   COM0 +4, COM1 +4, COM2 +4, COM3 +7, COM2 +7, COM1 +7, COM1 +6, COM0 +6
#define DIGIT2_L   COM0 +5, COM1 +5, COM2 +5, COM2 +6, COM3 +6, COM3 +5, COM3 +4, COM0 +7

#define DIGIT1_H   COM0 +0, COM1 +0, COM2 +0, COM3 +3, COM2 +3, COM1 +3, COM1 +2, COM0 +2
#define DIGIT1_L   COM0 +1, COM1 +1, COM2 +1, COM2 +2, COM3 +2, COM3 +1, COM3 +0, COM0 +3


//   Digit numbers:
//    8     7     6     5     4     3     2     1
//  ----- ----- ----- ----- ----- ----- ----- -----
//  |\|/| |\|/| |\|/| |\|/| |\|/| |\|/| |\|/| |\|/| 
//  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --       
//  |/|\| |/|\| |/|\| |/|\| |/|\| |/|\| |/|\| |/|\| 
//  ----- ----- ----- ----- ----- ----- ----- ----- 
//
//    Segment       Segment bit     
//    letters:      numbers:
//
//       a              15   
//    -------        -------
//   |\ i|  /|      |\ 7|  /|
//  f| \ | / |b   10| \ | / |14
//   | h\|/j |      | 8\|/6 |   
//   g--- ---k      9--- ---5 
//   | l/|\n |      | 4/|\2 | 
//  e| / | \ |c   11| / | \ |13
//   |/ m|  \|      |/ 3|  \|
//    -------        ------- 
//       d              12 
//
//            Segment bit numbers:              Segment
//    15 14 13 12  11 10 9 8  7 6 5 4  3 2 1 0  hex code:
// 0   1  1  1  1   1  1 - -  - 1 - 1  - - - -  0xFC50 
// 1   -  1  1  -   -  - - -  - - - -  - - - -  0x6000
// 2   1  1  -  1   1  - 1 -  - - 1 -  - - - -  0xDA20
// 3   1  1  1  1   -  - 1 -  - - 1 -  - - - -  0xF220
// 4   -  1  1  -   -  1 1 -  - - 1 -  - - - -  0x6620
// 5   1  -  1  1   -  1 1 -  - - 1 -  - - - -  0xB620   
// 6   1  -  1  1   1  1 1 -  - - 1 -  - - - -  0xBE20
// 7   1  1  1  -   -  - - -  - - - -  - - - -  0xE000
// 8   1  1  1  1   1  1 1 -  - - 1 -  - - - -  0xFE20
// 9   1  1  1  1   -  1 1 -  - - 1 -  - - - -  0xF620
//
//
int16 const Digit_Map[10] =
{0xFC50,0x6000,0xDA20,0xF220,0x6620,0xB620,0xBE20,0xE000,0xFE20,0xF620};
//  0      1      2      3      4      5      6      7      8      9


#define BLANK 0  // For a blank digit, don't turn on any segments.


int8 lcd_pos = 0;

//-----------------------------------------------
void lcd_putc(char c)
{
int16 segments;


if(c=='\f')
  {
   lcd_pos = 0;
  }
else
  {
   if((c >= '0') && (c <= '9'))
      segments = Digit_Map[c - '0'];
   else
      segments = BLANK;

   switch(lcd_pos)
     {
      case 1:   // Digit on left side of LCD.   
        lcd_symbol(segments >> 8, DIGIT8_H); 
        lcd_symbol(segments, DIGIT8_L);
        break;

      case 2:
        lcd_symbol(segments >> 8, DIGIT7_H);   
        lcd_symbol(segments, DIGIT7_L);
        break;

      case 3:
        lcd_symbol(segments >> 8, DIGIT6_H);   
        lcd_symbol(segments, DIGIT6_L);
        break;

      case 4:
        lcd_symbol(segments >> 8, DIGIT5_H);   
        lcd_symbol(segments, DIGIT5_L);     
        break;

      case 5:
        lcd_symbol(segments >> 8, DIGIT4_H);   
        lcd_symbol(segments, DIGIT4_L);
        break;

      case 6:
        lcd_symbol(segments >> 8, DIGIT3_H);   
        lcd_symbol(segments, DIGIT3_L);
        break;

      case 7:
        lcd_symbol(segments >> 8, DIGIT2_H);   
        lcd_symbol(segments, DIGIT2_L);
        break;

      case 8:  // Digit on right side of LCD.
        lcd_symbol(segments >> 8, DIGIT1_H);
        lcd_symbol(segments, DIGIT1_L);
        break;

     }
  }

lcd_pos++;

}


//-------------------------------------------
void clear_lcd(void)
{
int16 addr;
int8 i;

addr = 0xF60;   // LCDDATA0 register address

for(i=0; i < 24; i++)  // Clear the LCD data registers
    *addr++ = 0;
}


//==================================

void main(void)
{
int32 number;

clear_lcd();
       
setup_lcd(LCD_MUX14 | LCD_INTRC, 2); 

number = 12345678;

printf(lcd_putc,"\f%8lu", number);

while(1);
}
cbarberis



Joined: 01 Oct 2003
Posts: 172
Location: Punta Gorda, Florida USA

View user's profile Send private message Send e-mail

PostPosted: Fri Feb 01, 2008 10:38 am     Reply with quote

PCM programmer, I don't know how to thank you for all the time you have invested to solve and answer the above, I really appreciate this and I am sure many others like me, who first experience using the PICDEM LCD with the CCS compiler will also be thankful to you............THANK YOU Very Happy Very Happy Very Happy
cbarberis



Joined: 01 Oct 2003
Posts: 172
Location: Punta Gorda, Florida USA

View user's profile Send private message Send e-mail

PostPosted: Fri Feb 01, 2008 12:34 pm     Reply with quote

BTW I tested it on the PICDEM LCD board and it all works fine! Very Happy
SolarGuy
Guest







Thanks PCM
PostPosted: Sat Mar 06, 2010 7:06 pm     Reply with quote

Thanks a million for this source code for the PicDem LCD.

I have a project in which I am trying to use the LCD.

These routines work perfect with the included 18F8490.

SG
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