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.

Pic16f877a Adc Help

Status
Not open for further replies.
Adc Help In Pic16f877a

hi,
MY PROJECT IS TO MONITOR A WEIGHT AND ALERT A PERSON IN A REMOTE PLACE IF IT GOES BELOW A PARTICULAR LEVEL....
i have a load celll with me.. which generates a voltage of 2mV/kg.... my PIC16f877a`s ADC`S(10bit) resolution is minimun of 5mV.. so i need to get a message in my serial port window when this voltage supplied to analog channel of ADC goes below 5mV.. saying that.. PLEASE REFILL YOUR MACHINE!!..what shuld be the logic involved in the coding?? am programming in EMBEDDED C.. using a CCS compiler....
ananth05 is online now Add to ananth05's Reputation Edit/Delete Message
how to calculate the count of my ADC.. tat is with respect to my input analog signal!!!!!!... so that i can put an IF statement and i can print somethin in the serial port!!!!!!.. this is the codin i did.. but its not workin.. wat i have to do now!!!

#include<16F877a.h>
#use delay(clock=600000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

//ports
#byte TRISA=0X85
#byte TRISB=0X86
#byte TRISC=0X87
#byte PORTA=0X05
#byte PORTB=0X06
#byte PORTC=0X07
#byte PORTD=0X08
#byte TRISD=0X88
#byte T2CON=0X12
#byte PR2=0X92
//ADC
#byte ADRESH=0X1E
#byte ADRESL=0X9E
#byte ADCON0=0X1F
#byte ADCON1=0X9F
#bit adgo=0X1F.2
#bit ADIF=0X0C.6
//serial port
#BYTE TXSTA=0x98
#BYTE RCSTA=0x18
#BYTE SPBRG=0x99
#BYTE TXREG=0x19
#BYTE RCREG=0x1A
#BIT RCIF=0x0c.5
#BYTE PIR1=0x0c
int b,k;

void main()
{
TRISB=0X00;
//while(1)
{
ADCON0 =0X05;
ADCON1 =0X0E;
b=ADRESH;
if(ADRESH=0X00)
{
printf("please refill ur machine");
}
delay_ms(1000);
}
}
ananth05 is online now Add to ananth05's Reputation Edit/Delete Message
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top