Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

PIC16F877 ADC EXAMPLES assembly

Status
Not open for further replies.

faraz101

Full Member level 1
Joined
Mar 7, 2007
Messages
97
Helped
7
Reputation
14
Reaction score
5
Trophy points
1,288
Activity points
1,888
pic16f877 adc

i need pic adc examples code and projects.
i want to use pic16f877 for checking 4 analog quantities.
any references?
 

Kurenai_ryu

Advanced Member level 2
Joined
Jun 10, 2006
Messages
671
Helped
159
Reputation
316
Reaction score
99
Trophy points
1,308
Location
Bolivia
Activity points
5,913
pic adc example

wich language? compiler?
in ccs...
Code:
#include "16f877.h"
#device ADC=8
#use delay(clock=4000000)
#use fast_io(B)
void main(void)
{
	set_tris_b(0);
	setup_adc_ports(ALL_ANALOG);
	setup_adc(ADC_CLOCK_DIV_8);
	set_adc_channel(5);
	while(1)
	{
		output_b(read_adc()); //read data
		delay_us(20);
	}

}
 

faraz101

Full Member level 1
Joined
Mar 7, 2007
Messages
97
Helped
7
Reputation
14
Reaction score
5
Trophy points
1,288
Activity points
1,888
pic16f877a adc

thanx friend
please give me the examples in mikro c if u can.
have a nice day
 

blastronics

Member level 3
Joined
Jul 4, 2005
Messages
64
Helped
4
Reputation
8
Reaction score
1
Trophy points
1,288
Location
Between heaven and earth
Activity points
1,761
adc pic16f877

sir,

You can find lots of sample program at PIClist.com
I have used sample programs here as a reference for my ADC programs.

blastronics

:D
 

faraz101

Full Member level 1
Joined
Mar 7, 2007
Messages
97
Helped
7
Reputation
14
Reaction score
5
Trophy points
1,288
Activity points
1,888
mikroc adc

ok friends i have written the code in mikro c for pic16f877 adc using read adc command.
i connect the pot on adc input and drive led on o/p port.now i want to read analog voltage on serial port.
any idaes please.
 

aandavan

Advanced Member level 4
Joined
Aug 31, 2006
Messages
106
Helped
8
Reputation
16
Reaction score
7
Trophy points
1,298
Location
india
Activity points
1,932
pic16f877 example

U might get the output from ADRESL and ADRESH register. You have to move the value from those register to TXREG register. The digital value will be transferred automatically
 

faraz101

Full Member level 1
Joined
Mar 7, 2007
Messages
97
Helped
7
Reputation
14
Reaction score
5
Trophy points
1,288
Activity points
1,888
adc example

actuallly i have barrometric pressure sensor mpx4115.it has output analog voltge
from 0 to 5v.i want to measure these voltage and display the pressure on the hyper terminal like this.
PRESSURE = 56kPa
how i can do this?
 

Kurenai_ryu

Advanced Member level 2
Joined
Jun 10, 2006
Messages
671
Helped
159
Reputation
316
Reaction score
99
Trophy points
1,308
Location
Bolivia
Activity points
5,913
ccs adc example

easy! but can you tell us your voltaje-pressure ratio? (maybe I can get an answer next day- my USB-stick just died today... :(
 

faraz101

Full Member level 1
Joined
Mar 7, 2007
Messages
97
Helped
7
Reputation
14
Reaction score
5
Trophy points
1,288
Activity points
1,888
pic16f877 examples

i want to use mpx4115 motorolla sensor to measure altitude of my plane.this is barrometric pressure sensor which o/p the 0.2v to 5v.its pressure range is 2.2 to 16.7 psi.
i want to measure 0.2v to 5v with pic adc and display the altitude on hyper terminal after calculations.
 

faraz101

Full Member level 1
Joined
Mar 7, 2007
Messages
97
Helped
7
Reputation
14
Reaction score
5
Trophy points
1,288
Activity points
1,888
usart_write

i have written the code in MIKRO C which is as follows



void main() {
float volt,press,calc,adc_value;
ADCON1 = 0x80; // Configure analog inputs and Vref
TRISA = 0xFF; // PORTA is input
TRISB = 0x3F; // Pins RB7, RB6 are outputs
TRISD = 0; // PORTD is output
usart_init(2400);


do {

adc_value = Adc_Read(2); // Get results of AD conversion
press = adc_value*0.005;
volt = press+48.0;
usart_write(86);
usart_write(79);
usart_write(76);
usart_write(84);
usart_write(61);
usart_write(volt);
usart_write(13);
delay_ms(1000);
} while(1);
}


and the result on the hyper terminal are the
VOLT = 1
OR
VOLT = 2 ETC
but the hyper terminal do not shoew the decimal point
for example if i give the i/p of 1.5v at the i/p it still shows the 1v.
and if i give any voltage b/w 2 to 3 volt it shows 2v and on reaching 3v it shows 3v.
what the problem with that.
thanx
 

Kurenai_ryu

Advanced Member level 2
Joined
Jun 10, 2006
Messages
671
Helped
159
Reputation
316
Reaction score
99
Trophy points
1,308
Location
Bolivia
Activity points
5,913
pic adc sample code

it`s very strange! why do you add 48 (30h)??? of course if you are converting the number to ASCII in some poor way it can`t display float numbers! did you think that usart_write can convert numbers to float???
mmmmm
well, i can suggest something like this
Code:
void main() { 
float volt,press,calc,adc_value; 
char inter, deci;
ADCON1 = 0x80; // Configure analog inputs and Vref 
TRISA = 0xFF; // PORTA is input 
TRISB = 0x3F; // Pins RB7, RB6 are outputs 
TRISD = 0; // PORTD is output 
usart_init(2400); 


do { 

adc_value = Adc_Read(2); // Get results of AD conversion 
press = adc_value*0.005; 
inter = (int) press;
deci= (int) (press*10.0) - inter*10;
usart_write('V'); 
usart_write('O'); 
usart_write('L'); 
usart_write('T'); 
usart_write('='); 
usart_write(inter | 0x30);
usart_write('.'); 
usart_write(deci | 0x30);
usart_write(13);
usart_write(10); 
delay_ms(1000); 
} while(1); 
}
 

faraz101

Full Member level 1
Joined
Mar 7, 2007
Messages
97
Helped
7
Reputation
14
Reaction score
5
Trophy points
1,288
Activity points
1,888
adc pic 16f877

thanx brother
actually i dont know much about c language and mikro c.will u please sugges or give me the manual of mikro c to know about such commands about mikro.
thanx again for the help.
FARAZ
 

Bilal_Rahim

Newbie level 3
Joined
Oct 29, 2010
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
PAKISTAN
Activity points
1,293
pic16f877 as adc

guys i m new in micro controllers so i need your help.

i want to use PIC16F877 for my new project please give me some use full tips.
i acquire the audio signal from mic and want to convert in digital form using above mentioned PIC, but i don't know how i do this because i am totally blank about micro controllers but i want to do that project please help me out thanks........
 

Tahmid

Advanced Member level 5
Joined
Jun 17, 2008
Messages
4,758
Helped
1,791
Reputation
3,574
Reaction score
1,649
Trophy points
1,393
Location
Silicon Valley, California, USA (from Dhaka, Bangl
Activity points
30,545
Hi Bilal,
The output voltage from the mic is very very low. I think you should first amplify this with an amplifier stage and then send this amplified output to the PIC ADC input to be read.
What compiler are you using?
In mikroBASIC or mikroC there is a command ADC_Read which is very easy.
Code:
'mikroBASIC:
dim ADR as word
ADR = ADC_Read(0) 'Read from channel 0 and copy digital value to ADR
Code:
'mikroC:
unsigned int word;
ADR = ADC_Read(0);
Hope this helps.
Tahmid.
 

Bilal_Rahim

Newbie level 3
Joined
Oct 29, 2010
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
PAKISTAN
Activity points
1,293
ok i'll use mikroC for it thanks for your help.
if i need some help then i will ask you...
 

bogusmeister

Junior Member level 2
Joined
Nov 3, 2010
Messages
21
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,283
Activity points
1,452
hi guys. actually im having a related problem.. im using PIC16F877 and i want to convert the analog voltage coming from my analog reflectance sensor. could you give me a sample ADC assembly program for MPLAB IDE that could help me. THANKS
 

vinodstanur

Advanced Member level 3
Joined
Oct 31, 2009
Messages
750
Helped
114
Reputation
234
Reaction score
114
Trophy points
1,333
Location
Kerala (INDIA)
Activity points
7,049
STUDY ABOUT THE FOUR REGISTERS RELATED TO ADC;
1> ADCON0
2>ADCON1
3>ADRESH
4>ADRESL
This is available in data sheet..
Then using a C compiler 'like HIGH TECH C' try 2 write a program...
I am sure u could do it....
 
Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top