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.
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.

regards



ok..tq..i will try understand it..tq very much for ur help...

---------- Post added at 13:57 ---------- Previous post was at 13:55 ----------

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.

regards



ok..tq..i will try understand it..tq very much for ur help...know i understand about it even not 2 much...;-)
 

Sorry, I was buissy this afternoon. Here it is complete project for 18F452 and also for 18F458. Simulation is made with proteus 7.7

regards
 

Attachments

  • ADC-LCD.rar
    436.2 KB · Views: 79
Hello i read this post and help me very much.
This help me to display the right values to LCD
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

In my circuit i also want to send the digital output to a DAC from PORTD. The DAC that i use have 8 pins for input. So i must lost 2 bits every time.
When i work with RIGHT JUSTIFIED and
Code:
PORTD=ADRESL;
my LCD work fine. But with this way i lost the 2 MSB of the digital output.
I change the RIGHT JUSTIFIED with LEFT JUSTIFIED and
Code:
PORTD=ADRESH;
With this way i lost the 2 LSB But the LCD, display negative or very big numbers.

The problem is here
Code:
result = ReadADC(); // Read result
step=5/1023;
Dout = result/step;
degrees=72*Dout;        /*Y = k * X + n
                                   so: Y = 360, X = 5, n = 0
                                        k = 360 / 5 = 72
                                     in my case: Y = 72 * X*/
I am using C18. Can anyone help me?
 
Last edited:

Finally i found the solution.

I make this changes
Code:
OpenADC( ADC_FOSC_32 & ADC_LEFT_JUST & ADC_3ANA_0REF,
ADC_CH0 & ADC_INT_OFF );

.....
......
result = ADRESH;
step=5/255;
Dout = result/step;
degrees=72*Dout;        /*Y = k * X + n
                                   so: Y = 360, X = 5, n = 0
                                        k = 360 / 5 = 72
                                     in my case: Y = 72 * X*

Now it work fine. I hope this help someone that have the same problem
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top