Arduino battery charger withtwo TL431 voltage detectors.
Fig. 1 Arduino battery charger with two TL431 voltage detectors.

TL431 Battery Charger Voltage Detector Circuits Schematics

by Lewis Loflin


Arduino with TL431 voltage detectors control battery charge current with LM317-MJ2955.
Fig. 2 Arduino with TL431 voltage detectors control
battery charge current with LM317-MJ2955.
Click for larger image.

Opto-isolated constant current source using an LM317 and LM358 current monitor.
Fig. 3
Click for larger image.

Arduino battery charger with opto-isolated CCS and 2 TL431 voltage comparators.
Fig. 4 Arduino battery charger with opto-isolated
CCS and 2 TL431 voltage comparators.
Click for larger image.

Note: Indicator LEDs DP9, DP10, and DP11 not shown.

TL431 shunt regulator circuit configured as a voltage comparator.
Fig. 5 A TL431 shunt regulator circuit configured
as a voltage comparator.

TL431 over voltage detector with optocoupler output.
Fig. 6 TL431 over voltage detector with optocoupler output.

Arduino Code for Above Circuits


/*
  Use pwm to control output current
  for constant current source for battery charger
*/

#define TL431A 4 // HIGH out V = set
#define TL431B 5 // HIGH out V = set
#define pwmOut 6

// 1K resistor to GRD.
#define redLed 11
#define yellowLed 10
#define greenLed 9

#define ccsHigh 255 // 100%
#define ccsMed 144 // 50%
#define ccsLow 45 // 25%
#define ccsOff 0 // 0% or OFF

int temp = 0;

void setup() {

  // High from TL431 Vin > Rset
  pinMode(TL431A, INPUT);  // Rset = 12.6V
  pinMode(TL431B, INPUT);  // Rset = 13.6V

  pinMode(redLed, OUTPUT);
  pinMode(yellowLed, OUTPUT);
  pinMode(greenLed, OUTPUT);

  pinMode(pwmOut, OUTPUT); // CCS optocoupler
  Serial.begin(9600);
  Serial.println("Serial OK");
}

void loop() {
  // battery voltage less than 12.6V
  if (digitalRead(TL431A) == 0 && digitalRead(TL431B) == 0) {
    digitalWrite(redLed, HIGH); // high charge rate
    digitalWrite(yellowLed, LOW);
    digitalWrite(greenLed, LOW);
    delay(500);
    temp = ccsHigh;
  }   // 1 Amp

  // battery voltage 12.6V to 13.6V
  if (digitalRead(TL431A) == 1 && digitalRead(TL431B) == 0) {
    digitalWrite(redLed, LOW);
    digitalWrite(yellowLed, HIGH); // medium charge rate
    digitalWrite(greenLed, LOW);
    delay(500);
    temp = ccsMed; // slow charge rate can use ccsLow
  }   // 0.5 Amps

  // battery voltage V > 13.6V
  if (digitalRead(TL431A) == 1 && digitalRead(TL431B) == 1) {
    digitalWrite(redLed, LOW);
    digitalWrite(yellowLed, LOW);
    digitalWrite(greenLed, HIGH); // charged
    delay(500);
    temp = ccsOff; // charged turn off
  }   // 0 Amps

  analogWrite(pwmOut, temp);
  Serial.print("PWM value = ");
  Serial.println(temp);
  delay(5000);  // delay 5 Sec.
}

Related see TL431 Battery Charger Voltage Detector Circuits Schematics


Related YouTube videos.


Other Circuits


 

Web site Copyright Lewis Loflin, All rights reserved.
If using this material on another site, please provide a link back to my site.