FV regulator pro nabijeni LiIon a Pb baterii
Napsal: 21 pro 2015, 22:12
Prosim o vaš názor. LiIon odladěno na prkénku, s olovem bych to neviděl na větši problém. Jsem samouk a uvítám každý předmětný názor.
Děkuji
#include <Wire.h>
#include <LiquidCrystal_SR2W.h>
#include <LiquidCrystal_SR3W.h>
#include <LiquidCrystal.h>
#include <LCD.h>
#include <I2CIO.h>
#include <FastIO.h>
#include <LiquidCrystal_I2C.h>
#include <LiquidCrystal_SR.h>
LiquidCrystal_I2C lcd(0x3F, 2,1,0,4,5,6,7,3, POSITIVE);
float voltpb=0; //napeti Pb baterie
float voltli=0; //napeti Li baterie
float voltfv=0; //napeti FV panelu
float ampli=0; //proud do Li baterie
float adjA=0; //nastaveni proudu do Li baterie ???
float sample1=0;
float sample2=0;
float sample3=0;
float sample4=0;
float sample5=0;
int IRFli = 9; //MOSFET nabijeni Li
int IRFpb = 10; //MOSFET nabijeni Pb
int IRFliv = 7; //MOSFET zateze Li
int IRFpbv = 8; //MOSFET zateze Pb
int pwm = 0; //regulace Li
int pwm1 = 0; //regulace Pb
void setup()
{
TCCR1B = TCCR1B & 0b11111000 | 0x05;//nastaveni kmitoctu pwm 61.03Hz
Serial.begin(9600);
lcd.begin(20,4);
pinMode(IRFpb, OUTPUT); //vystupy pro spinac P-MOSFET
pinMode(IRFli, OUTPUT);
pinMode(IRFliv, OUTPUT);
pinMode(IRFpbv, OUTPUT);
}
void loop()
{
for(int i=0;i<150;i++)
{
sample1+=analogRead(A0);
sample2+=analogRead(A1);
sample3+=analogRead(A2);
sample4+=analogRead(A3);
delay(2);
}
sample1=sample1/150;
sample2=sample2/150;
sample3=sample3/150;
sample4=sample4/150;
voltpb = (sample1 * (5.0/1023.0)*8.4);//prepocet podle delice napeti
voltli = (sample2 * (5.0/1023.0)*8.4);
voltfv = (sample3 * (5.0/1023.0)*8.4);
ampli = ((sample4-512)*46)/1000; //pro ACS712 20A ???
int Vpb=voltpb*100;
int Vli=voltli*100;
int Vfv=voltfv*100;
int Ali=ampli*100;
int r=Vfv-Vli;
int r1=Vfv-Vpb;
Serial.println(voltli);
Serial.println(voltpb);
Serial.println(voltfv);
Serial.println(ampli);
Serial.println(pwm);
lcd.setCursor(0,0);
lcd.print("Li ");
lcd.print(voltli);
lcd.print("V");
lcd.setCursor(10,0);
lcd.print("Li ");
lcd.print(ampli);
lcd.print("A");
lcd.setCursor(0,1);
lcd.print("Pb ");
lcd.print(voltpb);
lcd.print("V");
lcd.setCursor(0,2);
lcd.print("Fv ");
lcd.print(voltfv);
lcd.print("V");
lcd.setCursor(0,3);
lcd.print("PWM ");
lcd.print(pwm);
/////////////////////nabijeni Li baterie
if (r<=50)
{
analogWrite(IRFli, pwm=0);
}
if ((r>50)&&(Vli<1230))
{
analogWrite(IRFli, pwm=220);
}
if ((r>50)&&(Vli<1240))
{
analogWrite(IRFli, pwm++);
}
if((r>50)&&(Vli>=1240))
{
analogWrite(IRFli, pwm--);
}
if ((Vli>=1235)&&(Ali<30))
{
analogWrite(IRFli, pwm=0);
}
//////////////////////nabijeni Pb baterie
if((r1<50)||(Vpb>1380)||(Vli<1230))
{
analogWrite(IRFpb, pwm1=0);
}
if((r1>50)&&(Vpb<1260)&&(Vli>1230))
{
analogWrite(IRFpb, pwm1=255);
}
if((r1>50)&&(Vpb>1320)&&(Vpb<1365)&&(Vli>1230))
{
analogWrite(IRFpb, pwm1=128);
}
if((r1>50)&&(Vpb>1365)&&(Vpb<1380)&&(Vli>1230))
{
analogWrite(IRFpb, pwm1=64);
}
//////////////////////ochrana pred podvybitim baterii
if(Vli>1130)
{
digitalWrite(IRFliv, HIGH);
}
if(Vpb>1200)
{
digitalWrite(IRFpbv, HIGH);
}
if(Vli<1080)
{
digitalWrite(IRFliv, LOW);
}
if(Vpb<1080)
{
digitalWrite(IRFpbv, LOW);
}
}
Děkuji
#include <Wire.h>
#include <LiquidCrystal_SR2W.h>
#include <LiquidCrystal_SR3W.h>
#include <LiquidCrystal.h>
#include <LCD.h>
#include <I2CIO.h>
#include <FastIO.h>
#include <LiquidCrystal_I2C.h>
#include <LiquidCrystal_SR.h>
LiquidCrystal_I2C lcd(0x3F, 2,1,0,4,5,6,7,3, POSITIVE);
float voltpb=0; //napeti Pb baterie
float voltli=0; //napeti Li baterie
float voltfv=0; //napeti FV panelu
float ampli=0; //proud do Li baterie
float adjA=0; //nastaveni proudu do Li baterie ???
float sample1=0;
float sample2=0;
float sample3=0;
float sample4=0;
float sample5=0;
int IRFli = 9; //MOSFET nabijeni Li
int IRFpb = 10; //MOSFET nabijeni Pb
int IRFliv = 7; //MOSFET zateze Li
int IRFpbv = 8; //MOSFET zateze Pb
int pwm = 0; //regulace Li
int pwm1 = 0; //regulace Pb
void setup()
{
TCCR1B = TCCR1B & 0b11111000 | 0x05;//nastaveni kmitoctu pwm 61.03Hz
Serial.begin(9600);
lcd.begin(20,4);
pinMode(IRFpb, OUTPUT); //vystupy pro spinac P-MOSFET
pinMode(IRFli, OUTPUT);
pinMode(IRFliv, OUTPUT);
pinMode(IRFpbv, OUTPUT);
}
void loop()
{
for(int i=0;i<150;i++)
{
sample1+=analogRead(A0);
sample2+=analogRead(A1);
sample3+=analogRead(A2);
sample4+=analogRead(A3);
delay(2);
}
sample1=sample1/150;
sample2=sample2/150;
sample3=sample3/150;
sample4=sample4/150;
voltpb = (sample1 * (5.0/1023.0)*8.4);//prepocet podle delice napeti
voltli = (sample2 * (5.0/1023.0)*8.4);
voltfv = (sample3 * (5.0/1023.0)*8.4);
ampli = ((sample4-512)*46)/1000; //pro ACS712 20A ???
int Vpb=voltpb*100;
int Vli=voltli*100;
int Vfv=voltfv*100;
int Ali=ampli*100;
int r=Vfv-Vli;
int r1=Vfv-Vpb;
Serial.println(voltli);
Serial.println(voltpb);
Serial.println(voltfv);
Serial.println(ampli);
Serial.println(pwm);
lcd.setCursor(0,0);
lcd.print("Li ");
lcd.print(voltli);
lcd.print("V");
lcd.setCursor(10,0);
lcd.print("Li ");
lcd.print(ampli);
lcd.print("A");
lcd.setCursor(0,1);
lcd.print("Pb ");
lcd.print(voltpb);
lcd.print("V");
lcd.setCursor(0,2);
lcd.print("Fv ");
lcd.print(voltfv);
lcd.print("V");
lcd.setCursor(0,3);
lcd.print("PWM ");
lcd.print(pwm);
/////////////////////nabijeni Li baterie
if (r<=50)
{
analogWrite(IRFli, pwm=0);
}
if ((r>50)&&(Vli<1230))
{
analogWrite(IRFli, pwm=220);
}
if ((r>50)&&(Vli<1240))
{
analogWrite(IRFli, pwm++);
}
if((r>50)&&(Vli>=1240))
{
analogWrite(IRFli, pwm--);
}
if ((Vli>=1235)&&(Ali<30))
{
analogWrite(IRFli, pwm=0);
}
//////////////////////nabijeni Pb baterie
if((r1<50)||(Vpb>1380)||(Vli<1230))
{
analogWrite(IRFpb, pwm1=0);
}
if((r1>50)&&(Vpb<1260)&&(Vli>1230))
{
analogWrite(IRFpb, pwm1=255);
}
if((r1>50)&&(Vpb>1320)&&(Vpb<1365)&&(Vli>1230))
{
analogWrite(IRFpb, pwm1=128);
}
if((r1>50)&&(Vpb>1365)&&(Vpb<1380)&&(Vli>1230))
{
analogWrite(IRFpb, pwm1=64);
}
//////////////////////ochrana pred podvybitim baterii
if(Vli>1130)
{
digitalWrite(IRFliv, HIGH);
}
if(Vpb>1200)
{
digitalWrite(IRFpbv, HIGH);
}
if(Vli<1080)
{
digitalWrite(IRFliv, LOW);
}
if(Vpb<1080)
{
digitalWrite(IRFpbv, LOW);
}
}