|
@@ -51,8 +51,8 @@ EEMEM struct settings eep_settings = {
|
|
|
.coeff_generator_volt_B = 1317.235211,
|
|
|
.coeff_generator_curr_A = 65535.0/20,
|
|
|
.coeff_generator_curr_B = 1310,
|
|
|
- .coeff_disch_curr_A = 65535.0/20,
|
|
|
- .coeff_disch_curr_B = 1000,
|
|
|
+ .coeff_disch_curr_A = 2996.00532623169,
|
|
|
+ .coeff_disch_curr_B = 4298.2689747004,
|
|
|
.coeff_volt_A = 1.55337778893448E-07,
|
|
|
.coeff_volt_B = -0.092784032021951,
|
|
|
.coeff_curr_A = -9.03353481586364E-08,
|
|
@@ -153,8 +153,9 @@ __flash const char text0[] = "stop";
|
|
|
__flash const char text1[] = "\x80""aduj";
|
|
|
__flash const char text2[] = "roz\x80""aduj";
|
|
|
__flash const char text3[] = "reset";
|
|
|
-__flash const char text4[] = "Uset = ";
|
|
|
-__flash const char text5[] = "Iset = ";
|
|
|
+__flash const char text4[] = "Uset(charg) = ";
|
|
|
+__flash const char text5[] = "Uset(disch) = ";
|
|
|
+__flash const char text6[] = "Iset = ";
|
|
|
|
|
|
__flash const char *main_menu_texts[] = {
|
|
|
text0,
|
|
@@ -163,9 +164,10 @@ __flash const char *main_menu_texts[] = {
|
|
|
text3,
|
|
|
text4,
|
|
|
text5,
|
|
|
+ text6,
|
|
|
};
|
|
|
|
|
|
-#define MENU_MAX 5
|
|
|
+#define MENU_MAX 6
|
|
|
|
|
|
#define MODE_STOP 0
|
|
|
#define MODE_CHARGE 1
|
|
@@ -176,7 +178,7 @@ void main(void){
|
|
|
unsigned char pos=0;
|
|
|
unsigned char k;
|
|
|
unsigned char mode = MODE_STOP;
|
|
|
- unsigned int volt_set = 126, curr_set = 8; // *0,1V/A
|
|
|
+ unsigned int volt_set = 365, disch_volt_set = 210, curr_set = 30; // *0,01V, *0,01V, *0,1A
|
|
|
signed long long int charge_counter = 0, energy_counter = 0; // *0,1µC, *10µJ
|
|
|
unsigned long int time_counter = 0; // *0,1s
|
|
|
/* unsigned char state = STATE_DEFAULT;
|
|
@@ -204,7 +206,7 @@ void main(void){
|
|
|
/* charge_on();
|
|
|
set_voltage(volt_set);
|
|
|
set_charge_curr(curr_set);*/
|
|
|
-
|
|
|
+
|
|
|
for(;;){
|
|
|
/* if((i = getkey())){
|
|
|
cursor(0,0);
|
|
@@ -238,8 +240,9 @@ void main(void){
|
|
|
default: break;
|
|
|
case 1: if(mode == MODE_CHARGE) puttext_P(PSTR("w\x80.")); break;
|
|
|
case 2: if(mode == MODE_DISCHARGE) puttext_P(PSTR("w\x80.")); break;
|
|
|
- case 4: disp_num(volt_set, 1); putchar('V'); break;
|
|
|
- case 5: disp_num(curr_set, 1); putchar('A'); break;
|
|
|
+ case 4: disp_num(volt_set, 2); putchar('V'); break;
|
|
|
+ case 5: disp_num(disch_volt_set, 2); putchar('V'); break;
|
|
|
+ case 6: disp_num(curr_set, 1); putchar('A'); break;
|
|
|
}
|
|
|
clearline();
|
|
|
}
|
|
@@ -257,6 +260,12 @@ void main(void){
|
|
|
volt_set -= 1;
|
|
|
break;
|
|
|
case 5:
|
|
|
+ if(mode != MODE_STOP)
|
|
|
+ break;
|
|
|
+ if(disch_volt_set > 0)
|
|
|
+ disch_volt_set -= 1;
|
|
|
+ break;
|
|
|
+ case 6:
|
|
|
if(mode != MODE_STOP)
|
|
|
break;
|
|
|
if(curr_set > 0)
|
|
@@ -269,10 +278,16 @@ void main(void){
|
|
|
case 4:
|
|
|
if(mode != MODE_STOP)
|
|
|
break;
|
|
|
- if(volt_set < 200) // 20V
|
|
|
+ if(volt_set < 2000) // 20V
|
|
|
volt_set += 1;
|
|
|
break;
|
|
|
case 5:
|
|
|
+ if(mode != MODE_STOP)
|
|
|
+ break;
|
|
|
+ if(disch_volt_set < 2000) // 20V
|
|
|
+ disch_volt_set += 1;
|
|
|
+ break;
|
|
|
+ case 6:
|
|
|
if(mode != MODE_STOP)
|
|
|
break;
|
|
|
if(curr_set < 100)
|
|
@@ -291,10 +306,15 @@ void main(void){
|
|
|
break;
|
|
|
mode = MODE_CHARGE;
|
|
|
charge_on();
|
|
|
- set_voltage((float)volt_set/10.0);
|
|
|
+ set_voltage((float)volt_set/100.0);
|
|
|
set_charge_curr((float)curr_set/10.0);
|
|
|
break;
|
|
|
case 2:
|
|
|
+ if(mode != MODE_STOP)
|
|
|
+ break;
|
|
|
+ mode = MODE_DISCHARGE;
|
|
|
+ discharge_on();
|
|
|
+ set_discharge_curr((float)curr_set/10.0);
|
|
|
break;
|
|
|
case 3:
|
|
|
if(mode != MODE_STOP)
|
|
@@ -317,14 +337,22 @@ void main(void){
|
|
|
tick = 0;
|
|
|
sei();
|
|
|
|
|
|
- cursor(0,6);
|
|
|
+ if(mode == MODE_DISCHARGE && meas[MEAS_VOLT] < (float)disch_volt_set/100.0){
|
|
|
+ mode = MODE_STOP;
|
|
|
+ output_off();
|
|
|
+ }
|
|
|
+
|
|
|
+ cursor(0,8);
|
|
|
disp_num(meas[MEAS_VOLT] * 1000, 3);
|
|
|
putchar('V');
|
|
|
putchar(' ');
|
|
|
disp_num(meas[MEAS_CURR] * 1000, 3);
|
|
|
putchar('A');
|
|
|
+ putchar(' ');
|
|
|
+ disp_num(meas[MEAS_CURR] * meas[MEAS_VOLT] * 10, 1);
|
|
|
+ putchar('W');
|
|
|
clearline();
|
|
|
- cursor(0,7);
|
|
|
+ cursor(0,9);
|
|
|
disp_num(charge_counter * 0.1e-6 * 10000 / 3600.0, 4);
|
|
|
puttext_P(PSTR("Ah "));
|
|
|
disp_num(energy_counter * 10e-6 * 10000 / 3600.0, 4);
|