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.

PIC16F877 ADC EXAMPLES assembly

Status
Not open for further replies.

faraz101

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

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

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);
	}

}
 

pic16f877a adc

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

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
 

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.
 

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
 

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?
 

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

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.
 

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
 

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); 
}
 

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
 

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

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.
 

It depends on your understanding of either C or BASIC language. I personally use mikroBASIC, but if you can use C go for mikroC, if you can use BASIC, go for mikroBASIC.
 

ok i'll use mikroC for it thanks for your help.
if i need some help then i will ask you...
 

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
 

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.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top