Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

NEED suggestion and help in modified ADC.

Status
Not open for further replies.

yeh85

New Member
Hi^^..send my best regard to anyone here!.
I’m seeking for help in my project code..
I been thing about how to modify it for one month de, but still fail to get it…!!

The original code of the “adc” function from this project is merely able to display a sensor output at LCD from 0 to 255..

////////////////////////////////////////////////
ADGO=1;
while(ADGO);
result=ADRESH;
return result;
/////////////////////////////////////////////////

And I wish to display the output range from 0 to 500 or higher!!!! When 5V of output sensor, it can display for 500 or above, and display for 250 when the sensor output is 2.5V.

So when I’ modify the adc function to
////////////////////////////////////////////////////////////////
ADGO = 1;
while(ADGO);
result= ADRESL;
result+= (ADRESH << 8);
return (ADC_VALUE);
////////////////////////////////////////////////////////////////
The output display in LCD goes randomly from 255 to 90 then to 184 when the voltage increase………

Hope anyone here can give me a suggestion on how to modify it….
Here with my attachment full program..!!!



*i'm using HITech C and pic16f877 for this project
 

Attachments

  • manual modify 1.zip
    6.2 KB · Views: 173
To get your code to work you need to set the ADC to be right justified by setting bit 7 of ADCON1
Code:
ADCON1=0b[COLOR="Red"]1[/COLOR]1000100;					//configure ADC and ANx pin

Edit, you will also need to change TempA to a short and make read_ad return a short.

Mike.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top