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 segmented LCD
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Feb 14, 2011 6:35 pm     Reply with quote

Here's a demo program that I did for a static lcd (i.e., non-multiplexed)
with the 16F917, that displays decimal points. I compiled it with vs. 4.119.
The program shown below displays the following output on the LCD:
Quote:

1.23

It was also tested with the decimal points in two other locations, and it
successfully displayed them:
Quote:

.123 and 12.3


This code does not use your Mechatronics board LCD. That LCD is not
available for sale by any online retail sales company that I can find.
Therefore, you will have to study this code and modify it to make it work
with your board, PIC, and LCD. I don't really want to do any more work
on this problem.
Code:

#include <16F917.H>
#fuses INTRC_IO, NOWDT, BROWNOUT, PUT
#use delay(clock=8000000)

// The LCD digits are numbered in the following way,
// according to the Varitronix VI-422-DP data sheet.
//        _   _   _   _
//     ^ |_| |_|:|_| |_|
//       |_|.|_|.|_|.|_|
//         DP4 DP3 DP2
// Digit  4   3   2   1
//
// Note:  This lcd is NOT used on the Mechatronics board.

// Only digits 3,2,1 are supported for this demo program
// because the 16F917 only has 24 segment driver pins.

// Digit segments  A        B        C        D        E        F        G       
//                 b7       b6       b5       b4       b3       b2       b1       
#define DIGIT3  COM0+16, COM0+17, COM0+18, COM0+19, COM0+20, COM0+21, COM0+22
#define DIGIT2  COM0+8,  COM0+9,  COM0+10, COM0+11, COM0+12, COM0+13, COM0+14
#define DIGIT1  COM0+0   COM0+1,  COM0+2,  COM0+3,  COM0+4,  COM0+5,  COM0+6 


//                            0    1    2    3    4    5    6    7    8    9
int8 const Digit_Map[10] = {0xFC,0x60,0xDA,0xF2,0x66,0xB6,0xBE,0xE0,0xFE,0xE6};


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


#byte LCDDATA0 = 0x110
#byte LCDDATA1 = 0x111
#byte LCDDATA2 = 0x112


// These functions allow you to turn each decimal point On/Off.
#define display_DP2(x) x ? bit_set(LCDDATA0, 7) : bit_clear(LCDDATA0, 7)
#define display_DP3(x) x ? bit_set(LCDDATA1, 7) : bit_clear(LCDDATA1, 7) 
#define display_DP4(x) x ? bit_set(LCDDATA2, 7) : bit_clear(LCDDATA2, 7) 


int8 lcd_pos = 1;

//-----------------------------------------------
// This function was revised to add decimal points.

void lcd_putc(char c)
{
int8 segments;

if(c == '\f')
  {
   lcd_pos = 1;
   return;
  }

if(c == '.')
  {
   switch(lcd_pos) 
     {
      case 1:
        display_DP4(TRUE);
        display_DP3(FALSE);
        display_DP2(FALSE);
        break;

      case 2:
        display_DP4(FALSE);
        display_DP3(TRUE);
        display_DP2(FALSE);
        break;

      case 3:
        display_DP4(FALSE);
        display_DP3(FALSE);
        display_DP2(TRUE);
        break;
     }
  }

if(isamong(c, " 0123456789"))
  {
   if(c == ' ')
      segments = BLANK;
   else
      segments = Digit_Map[c - '0'];

   switch(lcd_pos) 
     {
      case 1: lcd_symbol(segments, DIGIT3); break; // 100's digit
      case 2: lcd_symbol(segments, DIGIT2); break; // 10's digit
      case 3: lcd_symbol(segments, DIGIT1); break; // 1's digit
     }

   lcd_pos++;
  }

}

//---------------------------
void clear_lcd(void)
{
LCDDATA0 = 0;
LCDDATA1 = 0;
LCDDATA2 = 0;
}


//===================================
void main()
{
// Setup for a static LCD and enable all 24 segment pins.
setup_lcd(LCD_STATIC, 0, 0xFFFFFF);
clear_lcd();

lcd_putc("\f1.23");

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
Goto page Previous  1, 2, 3
Page 3 of 3

 
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