Sign In

Code Works In Proteus Software But Not In A Circuit

Sabthavi sabthavi@gmail.com Sri Lanka

Hardware: PIC16F877A (4MHz) Software: MPLAB X IDE XC8 Compiler

Hi sir,
Our following code works in proteus software correctly. but in the circuit it works in the opposite way(when we power up the circuit the LED which has to blink after reaching 75 degree blinks at room temperature )
we have to submit our project within 1 week.Help us as soon as possible sir.
Thanks.

Images

Program

#define _XTAL_FREQ 4000000
#include<xc.h>
#include<pic16f877a.h>
#include <stdio.h>
#include <stdlib.h>
#pragma config FOSC = HS       // Oscillator Selection bits (HS oscillator)
#pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF      // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = OFF       // Brown-out Reset Enable bit (BOR enabled)
#pragma config LVP = OFF        // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3/PGM pin has PGM function; low-voltage programming enabled)
#pragma config CPD = OFF

void main()     // main program begins
{
    double value;
    //TRISD=0b00000000;
    TRISA = 0b11111111; // initialize Port A as an input port
    TRISC = 0b00000000; // initialize Port C as an Output port
    PORTC = 0b00001100;// exhaust fan switches on 
    
  
    
    while(1) 
    {
       
        ADCON0 = 0b11000001; 
      
        ADCON1 = 0b10000000;
        __delay_ms(2);        
       GO_nDONE=1; 
        while(GO_DONE);
       
        value = (ADRESH << 8) + ADRESL; 
        
        
        value = (value * 5.0)/ 1023.0;  // Equivalent voltage for the temperature
        value = value * 100.0;            // Temperature in Celcius 
        
	if(value>75.0)
        {  
        PORTC = 0b00000011;     
        }
         
    }
    
}

Post a reply to Sabthavi

Think you can help Sabthavi ? Then post your thoughts that might help Sabthavi. You will earn a lot of reputation in the technical community.

If your program is in multiple files, then ZIP the entire folder and attach below

Images and Screenshots

These helps other better understand your suggestion.