Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

solar charge controller using pic16f877a

Status
Not open for further replies.

swtbbert

Newbie level 5
Newbie level 5
Joined
Nov 24, 2013
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
11
Visit site
Activity points
54
help me please!!
my code doesn't run.....

Code:
sbit LED at RC3_bit;
sbit SOLAR_PRESENT at RA4_bit;
sbit Base_ON at RA5_bit;
unsigned int Battery_Value;
int temp1, temp2;

void main() {

//Configuring Microcontroller
CMCON = 0X07 ; // Disbale comparatorss digital
ANSEL  = 0x10;  // Configure AN4 pin as analog for battery
TRISC3_bit = 0; // PORTC3 (7th Pin) as output
TRISC0_bit = 1; // PORTC0 (10th Pin) as input
TRISA4_bit = 1; // PORTA4 (3rd Pin) as input
TRISA5_bit = 0; // PORTA5 (2nd Pin) as output
//Configuration complete


Delay_ms(200);


//Initializing ADC
ADC_Init();

while(1)
{
     //Reading Battery Voltage from 10th pin Port C0
     Battery_Value = ADC_Read(4);
       LED = 1;
       temp1 = 0;
       temp2 = 0;


     while((SOLAR_PRESENT==0) && (Battery_Value<440))
     {
          if(!temp1) {
             Base_ON = 1;
             temp1 = 1;
          }
          LED = 1;
          Delay_ms(500);
          LED = 0;
          Delay_ms(500);
          Battery_Value = ADC_Read(4);
     }

     while((SOLAR_PRESENT==0) && (Battery_Value>=440))
        {
            if(!temp2) {
             temp2 = 1;
           }
           Base_ON = 1;
           LED = 1;
           Delay_ms(2000);
           Base_ON = 0;
           LED = 0;
           Delay_ms(2000);
           Battery_Value = ADC_Read(4);
        }
        

     if (SOLAR_PRESENT==1)
      {
        Base_ON = 0;
      }


} //while loop end
} //Main Program end
 

Where is the header file? If you are using hitec ansi c compiler you must use #include<htc.h>
Post the error report
 

help me out with simple codes using mikroC pro......
 

what is the error you are getting...
change
ANSEL = 0x10; // Configure AN4 pin as analog for battery
to
ADCON1 = 0x10; // Configure AN4 pin as analog for battery
and check
 

give appropriate delay after A/D conversion and after A/D module channel or settings change . Refer 138 page of pic 16f877 datasheet.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top