View previous topic :: View next topic |
Author |
Message |
Guest
|
What are the functions to output to a LCD Display? |
Posted: Sun Oct 04, 2009 11:26 am |
|
|
Hi people,
Can anybody tell me what are the functions to output data from the memory to the LCD Display ?
Thank you. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Oct 04, 2009 1:45 pm |
|
|
Use the printf function, and re-direct the output to the lcd, as shown
below. The printf function will format the variable so it will display
properly on the LCD. Using the lcd_putc function at the beginning
of printf will cause the output of printf to go to the LCD.
Code: |
#include <16F877.H>
#fuses XT, NOWDT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#include<flex_lcd.c> // LCD driver from CCS code library forum
//======================================
void main()
{
int16 value;
lcd_init(); // Always call this function first
value = 1234;
printf(lcd_putc, "Value: %lu", value); // Display 'value' on the lcd
while(1);
} |
|
|
|
Guest
|
|
Posted: Sun Oct 04, 2009 9:54 pm |
|
|
Is the lcd_putc function only for internal LCD screens ?
If i am using external LCD, am i still able to use this function ?
Thanks for your help. |
|
|
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Sun Oct 04, 2009 11:15 pm |
|
|
What exactly do you mean by 'internal' and 'external' LCD screens? Do you, instead, mean 'PICs with internal (built-in) LCD driver' and 'other PICs'?
All PICs are capable of driving external LCD displays, ie, those LCDs that have an external display driver. The display driver is a chip on the LCD module which communicates with the PIC, using a simple parallel or serial interface. An example is the HD44780-based character LCD, which uses a parallel interface.
On the other hand, simple LCD panels are also available in the market. The panels do not have a display driver chip. All display voltages and timing signals need to be generated by a driver chip. PICs with a built-in LCD driver are capable of generating these voltages and timing signals. Thus, these PICs can act as customized LCD drivers.
Quote: | Is the lcd_putc function only for internal LCD screens | The lcd_putc function provided in the FlexLCD sends character data to an HD44780-compatible LCD. So you can say it is for 'external' LCDs only.
Rohit |
|
|
Guest
|
|
Posted: Sun Oct 04, 2009 11:43 pm |
|
|
Thanks for your reply Rohit de Sa,
What I mean by external and internal LCD is:
Internal LCD are LCDs that are built in with the PIC board, whereas External LCD are LCDs that are seperate from the PIC board, you have to buy them and fix the connection by yourself.
If I want to display a waveform on my LCD, do I just add in this after my A2D conversion?
Example:
Code: |
printf(lcd_putc, "Value: %lu", value); // Display 'value' on the lcd
|
I am really new to CCS, the way of coding is so different. |
|
|
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Mon Oct 05, 2009 12:46 am |
|
|
Which development board are you using? Post a link, or give additional details. Which LCD are you using? Post a link/details.
Quote: | If I want to display a waveform on my LCD | For this you will need a graphical LCD, not a character LCD. The lcd_putc function found in the FlexLCD driver file can only be used for HD44780-compatible *character* LCDs.
Rohit |
|
|
fr0stb0iz
Joined: 29 Sep 2009 Posts: 13
|
|
|
fr0stb0iz
Joined: 29 Sep 2009 Posts: 13
|
|
Posted: Mon Oct 05, 2009 9:23 am |
|
|
yes there are other sample codings, but none of the codes are in CCS, and i have no idea how to translate them. |
|
|
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Mon Oct 05, 2009 11:22 am |
|
|
Quote: | yes there are other sample codings, but none of the codes are in CCS | Umm....yes there are....you've just not checked.
http://gravitech.us/MicroResearch/Others/LCD6100/PICC_NOKIA6610.zip
The code uses an 18F458. To use it with any other PIC all you'd need to do is modify a few of the preprocessor directives.
Rohit |
|
|
Guest
|
|
Posted: Mon Oct 05, 2009 7:29 pm |
|
|
Yes I know Rohit, but there are no codes that teach you how to display a waveform!
I am currently using that person's code. But in order to display a waveform, I do not know what must be done.
Sorry, not that I am lazy, but I really do not know anything. |
|
|
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Mon Oct 05, 2009 9:01 pm |
|
|
A simple algorithm for a very crude oscilloscope would be:
Code: | while(1)
{
LCD_Fill_Screen(WHITE,0,0,131,131); //blank the entire screen
for (x=0;x<131;x++)
{
read the adc;
scale the adc reading if necessary using simple maths;
pset(RED, x, scaled_adc);
}
//you may need to add a small delay here
} |
You need to insert the correct code. Also remember to initialize the ADC and the LCD properly.
Rohit |
|
|
fr0stb0iz
Joined: 29 Sep 2009 Posts: 13
|
|
Posted: Mon Oct 05, 2009 9:37 pm |
|
|
Thx alot Rohit, What do you mean by scale the ADC? |
|
|
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Mon Oct 05, 2009 9:56 pm |
|
|
The function 'pset' is defined in the source file (ie nokial6610_ccs_c.c) given in this zip http://gravitech.us/MicroResearch/Others/LCD6100/PICC_NOKIA6610.zip
This is the function prototype: Code: | void pset(unsigned char color, unsigned char x, unsigned char y); |
By 'scale the ADC reading' I mean 'perform some math functions on it if necessary'. Analog readings from some sensors are not linear; ie, the sensor output does not vary directly with the changing environmental variable. Also, you may need to adjust the ADC output for proper display. An 8-bit ADC will read from 0-255. The LCD screen can only display from 0-131. You need to use a scaling factor of (131/255) for the ADC readings to fit properly on the screen.
Rohit |
|
|
fr0stb0iz
Joined: 29 Sep 2009 Posts: 13
|
|
Posted: Mon Oct 05, 2009 10:18 pm |
|
|
Thank you very much Rohit, I will work on it and get back to you. Cheers! |
|
|
fr0stb0iz
Joined: 29 Sep 2009 Posts: 13
|
|
Posted: Mon Oct 05, 2009 11:51 pm |
|
|
Sorry Rohit,
The term x in the following code is refering to the X axis, or is it an unsigned int x ?
Code: |
for(x=0;x<131;x++)
{
read the adc;
scale the adc reading if necessary using simple maths;
pset(RED, x, scaled_adc);
}
|
|
|
|
|