0% found this document useful (0 votes)
215 views2 pages

Charging Circuit Code Guide

1) This code defines constants for full charging mode and standby mode. 2) It turns the MOSFET on or off using PORTD pins to control charging. 3) It reads the input voltage and temperature using an ADC, then calculates the corrected voltage. 4) It enters full charging mode if voltage is below 15,000mV or standby mode above that. In standby mode, it turns on between 13,000-13,800mV and off above 14,000mV.

Uploaded by

Raghavendra MB
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
215 views2 pages

Charging Circuit Code Guide

1) This code defines constants for full charging mode and standby mode. 2) It turns the MOSFET on or off using PORTD pins to control charging. 3) It reads the input voltage and temperature using an ADC, then calculates the corrected voltage. 4) It enters full charging mode if voltage is below 15,000mV or standby mode above that. In standby mode, it turns on between 13,000-13,800mV and off above 14,000mV.

Uploaded by

Raghavendra MB
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

15146_Code CHARGING CIRCUIT CODE LIST

#define #define #define #define FULL_MODE 1 // Full charging mode STAND_BY_MODE 0 Stand by mode // MosfetOf f ( )PORTD |= _BV(4) MosfetOn() PORTD &= ~_BV(4)

//ADC function unsigned int Adc(unsigned char input){ unsigned int result; // Reading ADC input ADMUX=0xC0+input; // Internal REF 2,56V, Right adjusted result ADCSRA=0XC7; // ADEN, ADSC, -ADATE, -ADIF, -ADIE, ADPS2, ADPS1, ADPS0 // Waiting for conversion end while(!(ADCSRA & _BV(ADIF))); // First read ADSL result = ADCL + (ADCH<<8); return(result); } //Charging algorithm void ChargerSubfunction(void){ int Voltage, temperature; // Input device voltage, static char ChargeMode=FULL_MODE; //ADC of input device voltage Voltage=Adc(1)*2.5*7.666; // 1LSB=2.5mV, divider (22K+3K3)/3K3= 7.666 //Temperature correction temperature=(518-Adc(0))*0.625; // 518 corresponds to 0oC //Two diodes gives 2*2mC/C, 1LSB=2.5mV => 2.5mV/4mV=0.645 Voltage += temperature*4*6; // 4mv/C/Cell, battery have six cells //Checking of input device voltage if(Voltage > 17000)MosfetOn(); // if V>17000mV MOSFET turns-on else { if(ChargeMode == FULL_MODE){ if(Voltage > 15000){ MosfetOff(); // if V>15000mV MOSFET turns-off ChargeMode = STAND_BY_MODE; } else MosfetOn(); } else if(ChargeMode == STAND_BY_MODE){ if(Voltage < 13000){ MosfetOn(); // if V<13000mV MOSFET turns-on ChargeMode = FULL_MODE; } else if(Voltage < 13800) MosfetOn();

else if(Voltage > 14000) MosfetOff(); } } }

You might also like