If you have the MPLAB Hi-Tech PICC Project then zip it and pot it here. Looking at the circuit I can guess the code is small but I see menu system implemented in LCD. I am sure that strings used for menu system is placed in RAM and hence very less RAM is left for run time operation and I also suspect there are some functions used for LCD menu system which are large and eating up stack space and during this bank switching is not being done properly and hence the problem.
Some operation which happened only after eight months like a large function in the code executed only at that time based on some input condition might have resulted in the garbage after RAM data corrupted.
I see 3x NTC mentioned for 3x ADC channels ? Are these thermisters ? Are you measuring three different temperatures ? What is the device do ?
I see two relays and one solenoid valve ? Are you using one relay to turn ON/OFF heater of a boiler ? Are you using valve to control the inlet of water to boiler ?
Are you using LCD to set the relay turn ON/OFF temperatures ?
- - - Updated - - -
Compare the price of
PIC18F26K22-E/SP
https://www.microchipdirect.com/ProductSearch.aspx?keywords=PIC18F26K22
and price of
PIC16F876A-E/SP
https://www.microchipdirect.com/ProductDetails.aspx?Category=PIC16F876A&&keywords=PIC16F876A-I/SS
Also compare the features of the two devices from the datasheets
Just compare the RAM and ROM sizes of the 2 devices.
PIC18F is far more better device compared to PIC16F. Maybe you are using fake PIC16Fs and maybe you are getting it for less price. That is one of the reason I see for people using PIC16Fs.
Buy PIC18F26K22 from microchipDirect and use it.
If you have the C Code for the device then change your PIC to PIC18F26K22.
- - - Updated - - -
I suspect poorly written code. In Simulation I am not getting any data on LCD and it shows 460 errors. The simulation shows grayed out boxes for PORTB and error shows TRISB instruction deprecated. This is causing the problem. Maybe same problem in real hardware.
- - - Updated - - -
How many boards have you manufactured for this circuit ?
If few and if you can replace the boards then try PIC32MX170F256B-V/SP. I was searching for PIC32 devices in DIP package and found this. Cheaper than your PIC16F device. Lots of RAM and ROM. 3.3V device. Low power consumption and wide temperature range.
https://www.microchipdirect.com/ProductSearch.aspx?keywords=PIC32MX170F256B
If you can change to PIC32 then I can port the code for you.
- - - Updated - - -
How many boards have you manufactured for this circuit ?
If few and if you can replace the boards then try PIC32MX170F256B-V/SP. I was searching for PIC32 devices in DIP package and found this. Cheaper than your PIC16F device. Lots of RAM and ROM. 3.3V device. Low power consumption and wide temperature range.
https://www.microchipdirect.com/ProductSearch.aspx?keywords=PIC32MX170F256B
If you can change to PIC32 then I can port the code for you.
- - - Updated - - -
Sorry, I thought you were using PIC16F876A. You are using still older PIC16F876.
Compare the prices and temperature ranges here.
SPDIP 28 Pin Devices
https://www.microchipdirect.com/ProductDetails.aspx?Category=PIC16F876
PIC16F876-20/SP
PIC16F876-04/SP
PIC16F876-04I/SP
PIC16F876-10E/SP
PIC16F876-20I/SP
PIC16LF876-04/SP
https://www.microchipdirect.com/ProductSearch.aspx?keywords=PIC18F26K22
PIC18F26K22-E/SP
https://www.microchipdirect.com/ProductSearch.aspx?keywords=PIC32MX170F256B
PIC32MX170F256B-V/SP
PIC32MX170F256B-V/SP is cheaper than all versions of PIC16F876
https://www.microchip.com/wwwproducts/en/PIC16F876
https://www.microchip.com/wwwproducts/en/PIC18F26K22
https://www.microchip.com/wwwproducts/en/PIC32MX170F256B
- - - Updated - - -
I checked the datasheets of PIC16F876 and PIC18F26K22. They are pin compatible devices and hence you can replace the PIC16F device to PIC18F26K22. I can port the code to 18F device for you.
- - - Updated - - -
You are not using ADC. You are inputting some digital sensor data to J3 connector. I see that two relays are used and two different devices are controlled.
The devices connected to the relays have 4 states.
Device 1 and 2 OFF
Device 1 and 2 ON
Device 1 ON and Device 2 OFF
Device 1 OFF and Device 2 ON
The LCD you are using is HD44780 Compatible. The only thing I didn't understnad is the SMD component connected to MCLR pin. Is it for soft resetting the PIC ? I guess so.
- - - Updated - - -
There are a total of 5 PCBs in the design.
LCD board
Digital Sensors board
3 or 4 buttons board
main board
dual power supply board (24V and 5V)
TIP122 is heavy for the design. The design could have used 2N2222A for the LCD Backlight control.
If J10 jumper is not provided at the edge of the main board for user access then the device is calibrated at the factory by putting the J10 in set mode and using buttons to set the parameters and then the J10 is set into run mode. You are using internal eeprom to store the set parameters.
User doesn't have access to the buttons ? or is disbaled for user after factory settings ?
24V is used for the solenoid valve and relays and hence the device is a industrial device.
My previous device operation based on relay connections are incorrect.
There are three states
J9 device ON and J7 device OFF
J9 and J7 devices ON
J9 and J7 devices OFF
For K1 relay phase goes into relay COm pin and if relay turns ON then it goes to device through NO and J9 (1) and returns to neutral line through J9 (2)
If device 1 is ON then only device 2 connected to J7 turns ON. Return of J9 (2) goes to COM of K2 relay and if K2 is ON then connection completes through NO and J7 (1) and goes to device 2 and then returns to neutral through J7 (2)
You are not measuring RPM because you are not using counters or INT pins for sensors connected to J3.
What is connected to J3 ? Float Switches ?
Time needed to port the code to 18F26K22 is approx 1 hour.