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.

ADC not giving proper output

Status
Not open for further replies.

ecaits

Member level 4
Joined
Jan 16, 2014
Messages
76
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
579
Dear All Friends,

I am using pin RA.0 as analog input pin (0-5V) and display on LCD in PIC16F877 using Hi-Tech C compiler.

But as per my input voltage, I am not getting output. I have interface 4-bit LCD with Port D and control bit of LCD with Port A.

I am using Right Justified output in ADRES registers.

As per 0-5V input, I should get 0-1023 in ADRES register but it is not giving. LCD is working properly.

I have attached code for reference.
 

Attachments

  • ADC output problem.txt
    4.3 KB · Views: 71

How about configuration bits
Does LCD display some thing?
 

Hi,

+ what PA3040 has just asked plus show your circuit diagram.

Not a C person but your use of ADCON1 and ADCON0 looks strange.

In LCD_init your ADCON1 0x06 which makes all ports Digital, assuming your adc input is RA0/AN0 ? then make it so with the other pins Digital using ADCON1 0x0E, but also add in Right Justify so it becomes 0x8E
You correctly make RA0 input with TRISA 0x01

In the ADC_init you use ADCON0 seemingly ok, but follow it with another ADCON1 which actually selects RA0, RA1 and VREF+ & VREF-.
You do not, for now need Vrefs and using those pins throws your port allocation out for the LCD control Pins, so I would remove that instruction all together.
 

The OP has already been answered in his previous thread here. https://www.edaboard.com/threads/312181/#post1336314

He has opened another thread. He was provided links which has Hi-Tech C code for 16F877 ADC and LCD which he is using.


Edit: Explain which adc inputs you are using and measuring what? Do you want to display adc value as int or float value? See attached code and Proteus simulation.

It is MPLAB 8.92, Hi-Tech PICC 9.83 Code.
 

Attachments

  • PIC16F877A ADC LCD.rar
    141.3 KB · Views: 73
Last edited:

Thank you very much. I have solve the problem.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top