Is there a problem with using delay functions when using internal oscillator in PIC ?
Summary:

You need to set OSCF (bit 3) to 0 in the PCON register in your code (i.e. during runtime) when you want the PIC INTOSC (Internal Oscillator) to run at a nominal 48&nbsp;kHz (actually anywhere between 31.4&nbsp;kHz and 78.62&nbsp;kHz) instead of the power-on INTOSC default frequency of 4&nbsp;MHz.

Details:


  I did choose to set the internal oscillator to the minimum possible frequency (48khz) to decrease power consumption and I specified that in the wizard and so the .h file have the line #use delay(internal=48kHz).


The problem is that none of the things you list actually set the INTOSC hardware to 48&nbsp;kHz. Based on what you said, it seems your software assumes the CPU will run at 48&nbsp;kHz, but your hardware will still run at the default 4&nbsp;MHz INTOSC frequency.


  the program ran as intended in Proteus but it ran about 85 times faster that that when I tried it on the board .


Yes, that's what I expect.

85 faster x 48&nbsp;kHz = 4&nbsp;MHz (approx.)

This result suggests that your MCU was actually still running at the default INTOSC frequency of 4&nbsp;MHz.

The important point is that you cannot configure that PIC to run at 48&nbsp;kHz from power-on. If you set the CONFIG BITS (a.k.a. Fuses) to one of the two variants of INTOSC setting, then the MCU will use the internal 4&nbsp;MHz frequency at power-on.

Then, when you want to switch it to 48&nbsp;kHz (perhaps at the start of your main() but perhaps elsewhere in your code - it's up to you to choose) you then set OSCF (bit 3) to 0 in the PCON register - that bit is what switches the INTOSC frequency from 4&nbsp;MHz to 48&nbsp;kHz (after a short switchover transition).






See section 14.2.8 "SPECIAL FEATURE: DUAL-SPEED OSCILLATOR MODES" on page 101 of the PIC16F628A datasheet for more details.






Also note that the datasheet does not specify the accuracy of the 48&nbsp;kHz clock (only the 4&nbsp;MHz clock accuracy is specified there). However the PIC16F628A errata shows that the 48&nbsp;kHz clock can actually vary between 31.4&nbsp;kHz to 78.62&nbsp;kHz.