Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to use typical 16X2 LCD? (Some Deep Questions)

Status
Not open for further replies.

Qaisar Azeemi

Full Member level 5
Joined
Feb 11, 2011
Messages
315
Helped
16
Reputation
32
Reaction score
15
Trophy points
1,298
Location
Peshawar, Pakistan, Pakistan
Activity points
3,829
Hi every one,

I am using ADC0808, microcontroller 89C51, and 16X2 Alpha-numeric LCD to display the sensed data using sensors connected to ADC0808.

Problem:
1) what will be the data formate of output of ADC, is it binary or BCD?
2) what should be the data output of 89c51 that is acceptable for LCD?
3) what is the acceptable data formate for LCD , Binary , BCD or Ascii? i know about commands that are in hex form to be given to
LCD. also i know about display of alphabets on lcd but The problem is that i want to display the data sensed by sensors connected to the ADC.

Procedure will be like that..... the output of ADC is Inputted to 89c51 and the same feeded input to 89c51 is then displayed on LCD.

can any one please guide me about that. I will be very thankful to u.

sincere regards

M Qaisar Azeemi
 

Have a look on this site...
Basically you have to convert the Data Coming from the ADC into the appropriate ASCII Format

**broken link removed**
Basically you have to convert the Data Coming from the ADC into the appropriate ASCII Format

---------- Post added at 21:31 ---------- Previous post was at 21:29 ----------

Have a look on this site...
Basically you have to convert the Data Coming from the ADC into the appropriate ASCII Format
http://sites.google.com/site/matlabacademy/home/atmega-8/adc-interfacing
 

Code:
void lcd_print_value(u32 val)
{
	u8 buffer[10] = {0};
	u8* head = buffer;
	u8 cnt=0;
	if (val!=0)
	{
		while( val )
		{
    		*head++ = (val % 10)["0123456789"];
    		val /= 10;
			cnt++;
		}
		while (cnt!=0){ cnt--; lcd_print_char(buffer[cnt]); }
	}
	else
	{
		lcd_print_char('0');
	}
}
This routine prints the positive 32 bit value to the screen using print_char(char value);
Example:
Code:
lcd_print_value(32768);
Will print '32768' on current screen position.
 

1) what will be the data formate of output of ADC, is it binary or BCD?

It is binary

2) what should be the data output of 89c51 that is acceptable for LCD?

ASCII

3) what is the acceptable data formate for LCD , Binary , BCD or Ascii?

ASCII

The binary data in 8 bit is expected to be in the range of 0 - 255 (decimal).
In addition to what is shown above, the other alternative is that you have to separate these three digits 2,5 and 5 in this example (or what ever 247 -> 1,4,7).
Take one digit at a time (may be from left for convenience), add 48 (decimal) to convert it to BCD and send it to LCD as data.
 
thank you easyrider,

it really helped me . can you please provid me its assembly code.

i will be very thankful to u.

---------- Post added at 18:39 ---------- Previous post was at 18:23 ----------

Thank you very much for your kind reply ark. it helped me alot. but i still feeling confusion. can you please explain the conversion algorithm?

also if data to be sent to LCD should be askii, then why you wrote that "Take one digit at a time (may be from left for convenience), add 48 (decimal) to convert it to BCD and send it to LCD as data."

waiting for your reply.

thank you
 

Qaisar Azeemi said:
can you please explain the conversion algorithm?

If you have 356 for example, you can split this to three digits as follows:

356/100=3
(356/10)%10=35%10=5
356%10=6

To understand this, keep in mind that if a value is not float, then the result will cut all decimal points and will keep only the integer part.

Hope this helps.
 
here is a table which will gv u an understanding

HEX --> ASCII
1 --> 31
2 --> 32
3 --> 33
4 --> 34
5 --> 35
this means to covert ant digit to an ASCII value you have to simply ADD 30(H) to that digit..
BUT be careful..
you can do this only to a single digit not 2 or more digits

so to covert 25 to ASCII what u do is
2--> 32(H)
5--> 35(H)

now the ascii value of 25 is --> 3235(ASCII)
 
shabazmondal said:
this means to covert ant digit to an ASCII value you have to simply ADD 30(H) to that digit..

This is correct. An even more effective way, is to OR with 0x30 (48 decimal as pointed out by ark5230), or simply '0':

asciiValue = value|'0';
 
As Alexxx suggested the procedure is like this with the only addition that with your ADC the numbers will be ranging from 0 to 255 decimal (for 10 bit ADC the highest value could be 1023 decimal)

If you have 356 for example, you can split this to three digits as follows:

356/100=3
(356/10)%10=35%10=5
356%10=6
Once you have the procedure, you can devise a suitable algorithm and code.
After you extract the tree digits of the ADC output, to display each digit it is to be sent to the LCD as ASCII code. As has been shown above
to display 0 the corresponding ASCII code is 30Hex or 48 decimal.
to display 1 the corresponding ASCII code is 31Hex or 49 decimal.
to display 2 the corresponding ASCII code is 32Hex or 50 decimal.
.
.
and so forth.
This means to the single digit number if you add 30Hex or 48 decimal, you get the ASCII code for that single digit number. This addition of 30H or 48d can be implemented by addition or ORing.
This procedure is to be repeated for each single digit being sent to LCD display.
A R Khan
 
Last edited:
With the above mentioned replies you must have been able to understand by now,how is the data format in LCD.
If there are any more doubts about ASCII and conversion algorithms, u can ask refer the first few chapters of d book on embedded systems by mazidi.This will help u a lot.
Shabaz
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top