Electronic – PIC16F877A (with LCD) not working

lcdmicrocontrollerpicserial

I have designed a PIC18F877A micro controller project to read temperature from an LM35 using ADC, display it on an LCD and transmit it to a serial port.

When the program starts, sometimes it shows a startup message – sometimes it doesn't display anything. Also, the serial port connection is not working. Can anyone help – am I missing something? Are there any ground connections missing?

Circuit Diagram
solded circuit
circuit working but stopped here
circuit not working

My code:

#include <16F877A.h>
#device adc=10
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232 (baud=9600,rcv=PIN_C7, xmit=PIN_C6)
#include <lcd.c>
float value;
float temp;
float temp2;
float temp3;
float temp4;
float temp5[14];
float count[14];
int c;
void main(void)
{
//setup_adc_ports( ALL_ANALOG );//Initialize and Configure ADC
//setup_adc(ADC_CLOCK_INTERNAL );
while(1)
{
lcd_init();
lcd_gotoxy (1,1);
delay_ms(1000);
printf(lcd_putc,"   WELCOME TO\n Micro Tech Sol.");
delay_ms(3000);
lcd_gotoxy (1,1);
printf(lcd_putc,"  Fuel Monitoring \n     PROJECT   ");
delay_ms(3000);
}

}

Best Answer

  1. Your comment "Its working some times which may mean code is working." means (to me) that the hardware isn't fried (it wouldn't work at all otherwise) and that your software needs adjustment.

  2. You might want to use an unused GPIO pin as a 'heartbeat' signal, and toggle it through various places in your while loop. This allows you to not only make sure your code isn't getting lost (with your simple program, it shouldn't be) but also whether or not your overall timing is valid. For example, you can set the pin before one of your delays then clear it afterwards. If you see the pin change state for 1 second, you know that your crystal is working, the PIC oscillator is set properly and that your delays are working.

  3. There may be some incompatibility between the LCD driver you're using and the specific LCD that you're working with. You may need to tweak that LCD code - add extra delays, etc. until your LCD cooperates.

  4. lcd_init() and a delay(1000) need to go outside the while loop, as others have said. You need that delay(1000) after calling lcd_init() before any commands are sent - you may need a slightly longer delay depending on your specific LCD hardware.

  5. If you've added decoupling capacitors per the comments, please update your schematic sketch showing where you've added them. If you've updated your code, please update your code section.