PIC16F877A C CODE:
#include<16f877a.h>
#fuses HS,NOWDT,NOLVP,NOPROTECT
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
#include<16f877a.h>
#fuses HS,NOWDT,NOLVP,NOPROTECT
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
void main()
{
unsigned char load_cell_var;
{
unsigned char load_cell_var;
setup_port_A(ALL_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
output_c(0×01);
// printf(”Welcome To PC based Weight Scale System \n”);
// delay_ms(1000);
setup_adc(ADC_CLOCK_INTERNAL);
output_c(0×01);
// printf(”Welcome To PC based Weight Scale System \n”);
// delay_ms(1000);
while(TRUE)
{
{
set_adc_channel(0);
delay_us(100);
load_cell_var=READ_ADC();
printf(”\r Digital value=%u\r\n”,load_cell_var);
delay_us(100);
load_cell_var=READ_ADC();
printf(”\r Digital value=%u\r\n”,load_cell_var);
if((load_cell_var>=76)&&(load_cell_var<=77))
{
output_c(0×01);
printf(”PRODUCT IS GOOD”);
delay_ms(1500);
{
output_c(0×01);
printf(”PRODUCT IS GOOD”);
delay_ms(1500);
}
else
{
output_c(0×00);
printf(”PRODUCT IS DEFECT “);
delay_ms(1500);
output_c(0×01);
}
}
}
{
output_c(0×00);
printf(”PRODUCT IS DEFECT “);
delay_ms(1500);
output_c(0×01);
}
}
}
No comments:
Post a Comment