|
|
View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Feb 07, 2011 3:54 pm |
|
|
Add the 3 lines (in bold) above the #bit lines, as shown below:
Quote: |
#byte LCDSE0 = 0x11C
#byte LCDSE1 = 0x11D
#byte LCDSE2 = 0x11E
#bit SEG0 = LCDSE0.0
#bit SEG1 = LCDSE0.1
#bit SEG16 = LCDSE2.0 |
|
|
|
pic_micro
Joined: 07 Feb 2011 Posts: 26
|
special symbol on mechatronic LCD |
Posted: Mon Feb 07, 2011 7:41 pm |
|
|
It works.
Can you explain the following? I just want to understand see if I can put others symbols on the LCD
#byte LCDSE0 = 0x11C
#byte LCDSE1 = 0x11D
#byte LCDSE2 = 0x11E
0x11C, etc. are these the addresses?
Thanks in advance. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
pic_micro
Joined: 07 Feb 2011 Posts: 26
|
How to display the DP (decimal point) on the mechatronic LCD |
Posted: Mon Feb 07, 2011 10:26 pm |
|
|
PCM,
Thanks so much,
I would like to ask you one more question, how about the DP
Any suggestion? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Feb 07, 2011 11:58 pm |
|
|
Why don't you try to write the code for the DP's. |
|
|
pic_micro
Joined: 07 Feb 2011 Posts: 26
|
display DP on mechatronic board |
Posted: Tue Feb 08, 2011 12:33 pm |
|
|
FILE NAME: mech_seg_driver.c
Code: | /*
FILE NAME mech_seg_driver.c
I increase the Digit_Map to 11 and I add 0x01 to represent DP
It is the LCD driver for LCD VIM-332-DP that mount on the
mechatronic board
*/
// The LCD digits are numbered in the following way,
// according to the Varitronix VIM-332-DP data sheet.
// _ _ _
// | |_| |_| |_|
// | |_| |_| |_|
//
// Digit 4 3 2 1
//
// The CCS lcd_symbol() function will be used to display digits
// 1, 2, and 3. The following define statements tell the
// lcd_symbol() function which PIC pins are connected to the
// LCD segment pins.
// There is a table on page 58 of the PicDem Mechatronics
// Demonstration Board data sheet which lists the connections
// that are used to make these define statements.
//
// Digit segments A B C D E F G DP
// b7 b6 b5 b4 b3 b2 b1 b0
#define DIGIT3 COM0+3, COM0+11, COM2+11, COM3+3 , COM2+3, COM1+3, COM1+11, COM3+2
#define DIGIT2 COM0+6, COM0+21, COM2+21, COM3+6, COM2+6, COM1+6, COM1+21, COM3+11
#define DIGIT1 COM0+22, COM0+23, COM2+23, COM3+22, COM2+22, COM1+22, COM1+23, COM3+21
// special symbols
#define display_diode(x) x ? bit_set(LCDDATA5, 0) : bit_clear(LCDDATA5, 0)
#define display_batt(x) x ? bit_set(LCDDATA3, 1) : bit_clear(LCDDATA3, 1)
#define display_volt(x) x? bit_set(LCDDATA3, 0) : bit_clear(LCDDATA3,0)
#define display_ohm(x) x ? bit_set(LCDDATA9, 0) : bit_clear(LCDDATA9, 0)
#define display_satellite(x) x ? bit_set(LCDDATA2, 0) : bit_clear(LCDDATA2, 0)
#define display_minus(x) x ? bit_set(LCDDATA6, 1) : bit_clear(LCDDATA6, 1);
#define display_AC(x) x ? bit_set(LCDDATA9, 1) : bit_clear(LCDDATA9, 1);
#define display_m(x) x ? bit_set(LCDDATA8, 0) : bit_clear(LCDDATA8, 0);
#define display_A(x) x ? bit_set(LCDDATA0, 0) : bit_clear(LCDDATA0, 0);
#define display_K(x) x ? bit_set(LCDDATA6, 0 ) : bit_clear(LCDDATA6, 0);
#define display_M(x) x ? bit_set(LCDDATA11, 0 ) : bit_clear(LCDDATA11, 0);
#define display_RC(x) x ? bit_set(LCDDATA0, 1 ) : bit_clear(LCDDATA0, 1);
#define display_RH(x) x ? bit_set(LCDDATA3, 2 ) : bit_clear(LCDDATA3, 2);
#define display_DH(x) x ? bit_set(LCDDATA0, 2 ) : bit_clear(LCDDATA0, 2);
// The following array tells the CCS lcd_symbol() function which
// segments to turn on, to display the numbers from 0 to 9.
// 0 1 2 3 4 5 6 7 8 9 DP
byte const Digit_Map[11] = {0xFC,0x60,0xDA,0xF2,0x66,0xB6,0xBE,0xE0,0xFE,0xE6,0x01};
#define BLANK 0 // For a blank digit, don't turn on any segments.
#byte LCDDATA0 = 0x110
#byte LCDDATA1 = 0x111
#byte LCDDATA2 = 0x112
#byte LCDDATA3 = 0x113
#byte LCDDATA4 = 0x114
#byte LCDDATA5 = 0x115
#byte LCDDATA6 = 0x116
#byte LCDDATA7 = 0x117
#byte LCDDATA8 = 0x118
#byte LCDDATA9 = 0x119
#byte LCDDATA10 = 0x11A
#byte LCDDATA11 = 0x11B
#byte LCDSE0 = 0x11C
#byte LCDSE1 = 0x11D
#byte LCDSE2 = 0x11E
#bit SEG0 = LCDSE0.0
#bit SEG1 = LCDSE0.1
#bit SEG16 = LCDSE2.0
#bit seg_4bc = LCDDATA6.2 // Controls left-most digit ("1")
int8 lcd_pos;
//-----------------------------------------------
void lcd_putc(char c)
{
int8 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: // 1000's digit (left-most digit on lcd)
if(c == '1') // Is the top digit = 1 ?
seg_4bc = 1; // If so, display it
else // If it's not = 1, don't display it.
seg_4bc = 0;
break;
case 2: lcd_symbol(segments, DIGIT3); break; // 100's digit
case 3: lcd_symbol(segments, DIGIT2); break; // 10's digit
case 4: lcd_symbol(segments, DIGIT1); break; // 1's digit
}
}
lcd_pos++;
}
|
FILENAME main.c
I can display the dp into the LCD with the "lcd_symbol(0x01, DIGIT1); " but I am out of ideal how to implement it into the void lcd_putc(char c) function.
Code: | #include <mechatronic.h>
#define enable_symbol_segments(x) SEG0 = x; SEG1 = x; SEG16 = x
void main()
{
unsigned int16 value;
unsigned int temp;
// initial lcd
setup_lcd(LCD_MUX14 | LCD_BIAS_PINS, 0);
enable_symbol_segments(TRUE);
while(1)
{
/*
value = 1234;
display_diode(FALSE);
if(value < 600)
{
output_high(LED);
output_low(LED2);
display_batt(TRUE); // Batt symbol
display_volt(TRUE); // V symbol
display_ohm(FALSE); // Ohm symbol
display_satellite(TRUE); // Satellite symbol
display_minus(TRUE); // - sign symbol
display_AC(TRUE); // AC symbol
display_m(TRUE); // m symbol
display_A(TRUE); // A symbol
display_K(TRUE); // K symbol
display_M(TRUE); // M symbol
display_RC(TRUE); // RC symbol
display_RH(TRUE); // RH symbol
display_DH(TRUE); // DH symbol
display_diode(TRUE); // diode symbol
}
if(value >600)
{
output_high(LED2);
output_low(LED);
display_batt(FALSE);
display_volt(FALSE);
display_ohm(TRUE);
}
*/
// printf(lcd_putc,"\f%4lu",value); // Always send 4 digits
lcd_symbol(0x01, DIGIT1); // display s2dp
lcd_symbol(0x01, DIGIT2); // display s3dp
lcd_symbol(0x01, DIGIT3); // display s4dp
/* I can display the dp into the LCD with the above lines, but I don't know now to map or use it without the "lcd_symbol(0x01, DIGIT1); "
*/
}
}
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Feb 08, 2011 3:08 pm |
|
|
Quote: | I can display the dp into the LCD with the above lines, but I don't
know now to map or use it without the "lcd_symbol(0x01,DIGIT1); |
You were able to make code to display all the other symbols, as shown
below. Try to do the same thing for the 2DP, 3DP, and 4DP symbols:
Code: | // special symbols
#define display_diode(x) x ? bit_set(LCDDATA5, 0) : bit_clear(LCDDATA5, 0)
#define display_batt(x) x ? bit_set(LCDDATA3, 1) : bit_clear(LCDDATA3, 1) |
Quote: | but I am out of ideas how to implement it into the void lcd_putc(char c) function. |
You're giving lcd_putc() a sequence of ASCII numbers, one character at a
time, for example, "1.234". So clearly at some point, the lcd_putc()
routine will get the '.' character as a parameter. You need to add code to
lcd_putc() to handle it. Add an "if" (or "else if") statement for it. Make
sure you don't increment the lcd_pos variable if you are handling the
decimal point. |
|
|
pic_micro
Joined: 07 Feb 2011 Posts: 26
|
display 7-seg DP |
Posted: Wed Feb 09, 2011 9:01 am |
|
|
Here is what I've done and it always display " 1 . " no matter what the value is:
Code: | #include <mechatronic.h>
#define enable_symbol_segments(x) SEG0 = x; SEG1 = x; SEG16 = x
void main()
{
double value;
unsigned int temp;
// initial lcd
setup_lcd(LCD_MUX14 | LCD_BIAS_PINS, 0);
enable_symbol_segments(TRUE);
value = 12.3;
while(1)
{
printf(lcd_putc,"\f%4f1u", value);
}
}
|
File name: mech_seg_driver.c
Code: | /*
FILE NAME mech_seg_driver.c
It is the LCD driver for LCD VIM-332-DP that mount on the
mechatronic board
*/
// The LCD digits are numbered in the following way,
// according to the Varitronix VIM-332-DP data sheet.
// _ _ _
// | |_| |_| |_|
// | |_| |_| |_|
//
// Digit 4 3 2 1
//
// The CCS lcd_symbol() function will be used to display digits
// 1, 2, and 3. The following define statements tell the
// lcd_symbol() function which PIC pins are connected to the
// LCD segment pins.
// There is a table on page 58 of the PicDem Mechatronics
// Demonstration Board data sheet which lists the connections
// that are used to make these define statements.
//
// Digit segments A B C D E F G DP
// b7 b6 b5 b4 b3 b2 b1 b0
#define DIGIT3 COM0+3, COM0+11, COM2+11, COM3+3 , COM2+3, COM1+3, COM1+11, COM3+2
#define DIGIT2 COM0+6, COM0+21, COM2+21, COM3+6, COM2+6, COM1+6, COM1+21, COM3+11
#define DIGIT1 COM0+22, COM0+23, COM2+23, COM3+22, COM2+22, COM1+22, COM1+23, COM3+21
// special symbols
#define display_diode(x) x ? bit_set(LCDDATA5, 0) : bit_clear(LCDDATA5, 0)
#define display_batt(x) x ? bit_set(LCDDATA3, 1) : bit_clear(LCDDATA3, 1)
#define display_volt(x) x? bit_set(LCDDATA3, 0) : bit_clear(LCDDATA3,0)
#define display_ohm(x) x ? bit_set(LCDDATA9, 0) : bit_clear(LCDDATA9, 0)
#define display_satellite(x) x ? bit_set(LCDDATA2, 0) : bit_clear(LCDDATA2, 0)
#define display_minus(x) x ? bit_set(LCDDATA6, 1) : bit_clear(LCDDATA6, 1);
#define display_AC(x) x ? bit_set(LCDDATA9, 1) : bit_clear(LCDDATA9, 1);
#define display_m(x) x ? bit_set(LCDDATA8, 0) : bit_clear(LCDDATA8, 0);
#define display_A(x) x ? bit_set(LCDDATA0, 0) : bit_clear(LCDDATA0, 0);
#define display_K(x) x ? bit_set(LCDDATA6, 0 ) : bit_clear(LCDDATA6, 0);
#define display_M(x) x ? bit_set(LCDDATA11, 0 ) : bit_clear(LCDDATA11, 0);
#define display_RC(x) x ? bit_set(LCDDATA0, 1 ) : bit_clear(LCDDATA0, 1);
#define display_RH(x) x ? bit_set(LCDDATA3, 2 ) : bit_clear(LCDDATA3, 2);
#define display_DH(x) x ? bit_set(LCDDATA0, 2 ) : bit_clear(LCDDATA0, 2);
#define display_s2DP(x) ? bit_set(LCDDATA11, 5) : bit_clear(LCDDATA11, 5);
// The following array tells the CCS lcd_symbol() function which
// segments to turn on, to display the numbers from 0 to 9.
// 0 1 2 3 4 5 6 7 8 9 DP
byte const Digit_Map[11] = {0xFC,0x60,0xDA,0xF2,0x66,0xB6,0xBE,0xE0,0xFE,0xE6,0x01};
#define BLANK 0 // For a blank digit, don't turn on any segments.
#byte LCDDATA0 = 0x110
#byte LCDDATA1 = 0x111
#byte LCDDATA2 = 0x112
#byte LCDDATA3 = 0x113
#byte LCDDATA4 = 0x114
#byte LCDDATA5 = 0x115
#byte LCDDATA6 = 0x116
#byte LCDDATA7 = 0x117
#byte LCDDATA8 = 0x118
#byte LCDDATA9 = 0x119
#byte LCDDATA10 = 0x11A
#byte LCDDATA11 = 0x11B
#byte LCDSE0 = 0x11C
#byte LCDSE1 = 0x11D
#byte LCDSE2 = 0x11E
#bit SEG0 = LCDSE0.0
#bit SEG1 = LCDSE0.1
#bit SEG16 = LCDSE2.0
#bit seg_4bc = LCDDATA6.2 // Controls left-most digit ("1")
int8 lcd_pos;
//-----------------------------------------------
void lcd_putc(char c)
{
int8 segments;
if(c == '\f')
{
lcd_pos = 0;
}
else
{
if((c >= '0') && (c <= '9'))
segments = Digit_Map[c - '0'];
if(c == '.')
segments = 0x01; else
segments = BLANK;
switch(lcd_pos)
{
case 1: // 1000's digit (left-most digit on lcd)
if(c == '1') // Is the top digit = 1 ?
seg_4bc = 1; // If so, display it
else // If it's not = 1, don't display it.
seg_4bc = 0;
break;
case 2: lcd_symbol(segments, DIGIT3); break; // 100's digit
case 3: lcd_symbol(segments, DIGIT2); break; // 10's digit
case 4: lcd_symbol(segments, DIGIT1); break; // 1's digit
// default: lcd_symbol(
}
}
lcd_pos++;
}
|
I also try add this in mech_seg_driver.c file(similar to the symbol) and it got error when compile
Code: |
#define display_s2DP(x) ? bit_set(LCDDATA11, 5) : bit_clear(LCDDATA11, 5);
|
Added this to main.c file
Code: |
display_s2DP(TRUE);
|
Code: | Executing: "C:\CCS_PIC\PCM\PICC\Ccsc.exe" "main.c" +FM +DF +LN +T -A +M +Z +Y=9 +EA
>>> Warning 225 "C:\chai\CProjects\PICC Experiment\CCS\mechatronic\battery_symbol\mech_seg_driver.c" Line 41(18,75): Duplicate #define
>>> Warning 203 "C:\chai\CProjects\PICC Experiment\CCS\mechatronic\battery_symbol\main.c" Line 19(1,1): Condition always TRUE
*** Error 51 "C:\chai\CProjects\PICC Experiment\CCS\mechatronic\battery_symbol\main.c" Line 21(20,21): A numeric expression must appear here
1 Errors, 2 Warnings.
Halting build on first failure as requested.
BUILD FAILED: Wed Feb 09 09:57:57 2011
| [/code] |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Feb 09, 2011 10:58 pm |
|
|
I can't really work on this during the week. Maybe I can work on it
during the weekend sometime. |
|
|
pic_micro
Joined: 07 Feb 2011 Posts: 26
|
LCD |
Posted: Mon Feb 14, 2011 7:26 am |
|
|
PCM,
Any update? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Feb 14, 2011 6:35 pm |
|
|
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:
It was also tested with the decimal points in two other locations, and it
successfully displayed them:
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);
}
|
|
|
|
|
|
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
|