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.

[SOLVED] program ADC and LCD using PIC18f4580

Status
Not open for further replies.

danjorokanada

Newbie level 6
Joined
Dec 5, 2010
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,360
hi, i have some problem about ADC and LCD.. I am trying to display voltage on ADC on LCD display (in degree). I have not found any examples on how to do this.
How about if i have 10bit and the lcd port only 8bit.
I'm hoping someone can point me somewhere so I can try to understand this.
But the way, i use pic18f4580 and c-language..
Thanks for any help,
 

ok..actually the number of bit is doesnt matter..because the adc value will store in the variable..then u display the variable at LCD..it have two way to use LCD connection..first is by use 4bit..second is 8bit..

just like u said, u are going to use c-language..what software u use? mikro c or MPLAB?
 

    V

    Points: 2
    Helpful Answer Positive Rating
Hi,
That doesn't matter. That's because the ADC value is read and stored in a register ADRES[H:L] (2 registers actually - ADRESH and ADRESL). This is then sent to the PORT as required to the LCD port to tell the LCD what to show. The LCD routine will vary from compiler to compiler and most will usually have built-in LCD functions, however the basic principal in using LCD remains the same. For basic LCD commands and instructions take a look at:
LCD Commands and Instructions: LCD Tutorial for interfacing with Microcontrollers : 8051 Microcontroller Projects AVR PIC Projects Tutorials Ebooks Libraries codes

Take a look at these excellent tutorials and simulation useful for learning LCD interfacing:

LCD Info
Introduction
HD44780 Commands
Initialization Issues
Defining Custom Characters
Creating Simple Animations
Bitmap Calculator
Final Words

LCD Simulator {/JavaScipt} - the simulator

Hope this helps.
Tahmid.
 

ok..actually the number of bit is doesnt matter..because the adc value will store in the variable..then u display the variable at LCD..it have two way to use LCD connection..first is by use 4bit..second is 8bit..

just like u said, u are going to use c-language..what software u use? mikro c or MPLAB?



i use MPLAB.. i know about that..but how?i mean their command because i got some error to display data to lcd

---------- Post added at 03:29 ---------- Previous post was at 03:27 ----------

Hi,
That doesn't matter. That's because the ADC value is read and stored in a register ADRES[H:L] (2 registers actually - ADRESH and ADRESL). This is then sent to the PORT as required to the LCD port to tell the LCD what to show. The LCD routine will vary from compiler to compiler and most will usually have built-in LCD functions, however the basic principal in using LCD remains the same. For basic LCD commands and instructions take a look at:
LCD Commands and Instructions: LCD Tutorial for interfacing with Microcontrollers : 8051 Microcontroller Projects AVR PIC Projects Tutorials Ebooks Libraries codes

Take a look at these excellent tutorials and simulation useful for learning LCD interfacing:

LCD Info
Introduction
HD44780 Commands
Initialization Issues
Defining Custom Characters
Creating Simple Animations
Bitmap Calculator
Final Words

LCD Simulator {/JavaScipt} - the simulator

Hope this helps.
Tahmid.




thankz for the info..i will check and try understanding it..

---------- Post added at 03:44 ---------- Previous post was at 03:29 ----------

i think i understand about ADRESL and ADRESH.. 8bit to ARDESL and 2bit at ADRESH... right..my problems are that i cannot seem to get the pic to correctly display the adresh and adresl registers simultaneously because the conversion is 10bit resolution...anyone have idea to solve it??
 
Last edited:

like i said before, create one variable, let the variable store the 10bit resolution data..then display the variable..
5V = 1023bit
so every 1bit is equal to 0.0049V
 

like i said before, create one variable, let the variable store the 10bit resolution data..then display the variable..
5V = 1023bit
so every 1bit is equal to 0.0049V



yes,i already do that but my problem how to compute the 10bit data resolution from ADRESH and ADRESL to LCD...??
 

mean u want to display the binary value?



no..actually i want to trnsfer 10bit to lcd..my lcd will display in voltage as my result..but my ADC data is 10bit..how come i can transfer to lcd with 10bit data because lcd only have 8bit port...
 

8bit data port is not an issue.. it just the way you connect the LCD..u can even use 4bit from 8.. did u understand how LCD works?
 

Can you share your circuit scheme with us (analog input pin, LCD PORT)? It's quite easy to do what you are looking for.

Also you said display in degrees, so we need
1. value of degree at 0V
2. value of degree at 5V

Regards
 

Can you share your circuit scheme with us (analog input pin, LCD PORT)? It's quite easy to do what you are looking for.

Also you said display in degrees, so we need
1. value of degree at 0V
2. value of degree at 5V




Regards





ok..i will send the circuit..

 

Ok, I'll help you. Can you pack your Proteus project with WinRAR here, so I can test it. Also if you want to display degrees on LCD, I need two diferent values for degree in volts ( in range 0 - 5 volts).
By the way, if you want to meassure the temperature, there is much simpliest way to do it with one wire sensor DS18S20 (DS18B20) and result is quite real?

Regards
 

Ok, I'll help you. Can you pack your Proteus project with WinRAR here, so I can test it. Also if you want to display degrees on LCD, I need two diferent values for degree in volts ( in range 0 - 5 volts).
By the way, if you want to meassure the temperature, there is much simpliest way to do it with one wire sensor DS18S20 (DS18B20) and result is quite real?

Regards




thank u very much for ur willing to help me...i can't attach my file to this forum..i don't know y...can i attach that file to ur email??
for my project..actually i want to display the volt and degree on LCD...

this is some value voltage and degree...

0 volt--> 0 degree
0.07 volt-->5 degree
0.19 volt-->14 degree
1 volt-->72 degree
3.33 volt-->240 degree
4.81 volt-->346 degree
4.86 volt-->350 degree
5 volt-->360 degree

all this value i got from that calculation

Vref= 5V

step size= vref/1024
step size=5/1024
=4.88mv

Dout=V/step size

Vmin/Vmax=Xmin/Xmax :where V=voltage and X=angles(degree)
 
Last edited:

Just pack your Proteus project with Rar, then press button Manage Attachments and folow the rules.
I'll take 0 volt --> 0 degree and 5 volt --> 360 degree.

Y = k * X + n
so: Y = 360, X = 5, n = 0
k = 360 / 5 = 72
so in your case: Y = 72 * X

Regards
 
Last edited:
tq...i get it..
 

Attachments

  • circuit.rar
    17.9 KB · Views: 137

I made it for 18F452. Is there any secial reason to use 18F4580. For this MCU data sheet should be studied.

Regards
 

Attachments

  • ADC-LCD.rar
    42 KB · Views: 156

I made it for 18F452. Is there any secial reason to use 18F4580. For this MCU data sheet should be studied.

Regards



tq very much...but can u save in format proteus 7 because i cant open it..and also the program to me...??
 

It is saved with proteus 7.

regards



but y i can't open it...can u send example program for ur design to me??
tq very much..

---------- Post added at 10:53 ---------- Previous post was at 09:00 ----------

anyone please explain to me how ADRESL and ADRESH function...and how can ADRESL and ADRESH functioning to transfer in LCD?? when the value read for low byte and when the value read for high byte?? i have read some book and internet but i can't understanding it..so pls someone explain to me with example??
 

This afternoon you will got my example program, which was written in mikroBasic v.7.2; it is actualy modified example from Mikroelektronika and I am sure mikroC has exactly the same example in it's example folder ( I saw you with the same question on their forum), so I don't understand why you care about ADRESL and ADRESH.
Take a close look into my example, thera are explanations for every line.

About 18F4580: it has more analog inputs then 18F458, so you have to find a way to disable them on PORTB, the best way to do it is to studie datasheet for it.
My suggestion is: if this is complete idea for your project, then use my example. It is finished and it works as expected, otherwise you should build your project step by step.
This is the best way to learn programming.

regards
 
Last edited:
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top