|
@@ -51,10 +51,12 @@ EEMEM struct settings eep_settings = {
|
|
|
.coeff_generator_curr_B = 1310,
|
|
|
.coeff_disch_curr_A = 65535.0/20,
|
|
|
.coeff_disch_curr_B = 1000,
|
|
|
- .coeff_volt_A = 1,
|
|
|
- .coeff_volt_B = 0,
|
|
|
- .coeff_curr_A = 1,
|
|
|
- .coeff_curr_B = 0,
|
|
|
+ .coeff_volt_A = 1.55337778893448E-07,
|
|
|
+ .coeff_volt_B = -0.092784032021951,
|
|
|
+ .coeff_curr_A = 9.03353481586364E-08,
|
|
|
+ .coeff_curr_B = -0.124868806047484,
|
|
|
+// .coeff_curr_A = .001,
|
|
|
+// .coeff_curr_B = 0,
|
|
|
};
|
|
|
|
|
|
unsigned int vdac = 0;
|
|
@@ -114,9 +116,39 @@ void discharge_on(void){
|
|
|
DISCH_ON();
|
|
|
}
|
|
|
|
|
|
+#define MEAS_VOLT 0
|
|
|
+#define MEAS_CURR 1
|
|
|
+
|
|
|
+float meas[2];
|
|
|
+signed long int adc_results[2];
|
|
|
+
|
|
|
+unsigned char adc_process_data(void){
|
|
|
+ static unsigned char adc_channel = AIN1;
|
|
|
+ static signed long int adc;
|
|
|
+ if(adc_data_ready){
|
|
|
+ atomic_set_slint(&adc, adc_val);
|
|
|
+ switch(adc_channel){
|
|
|
+ case AIN1:
|
|
|
+ adc_results[MEAS_VOLT] = adc;
|
|
|
+ meas[MEAS_VOLT] = adc * settings.coeff_volt_A + settings.coeff_volt_B;
|
|
|
+ adc_channel = AIN2;
|
|
|
+ ads1224_mux(AIN2);
|
|
|
+ break;
|
|
|
+ case AIN2: default:
|
|
|
+ adc_results[MEAS_CURR] = adc;
|
|
|
+ meas[MEAS_CURR] = adc * settings.coeff_curr_A + settings.coeff_curr_B;
|
|
|
+ adc_channel = AIN1;
|
|
|
+ ads1224_mux(AIN1);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ adc_data_ready = 0;
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
void main(void){
|
|
|
unsigned char i=0;
|
|
|
- static signed long int adc;
|
|
|
/* unsigned char state = STATE_DEFAULT;
|
|
|
unsigned char oldstate = state;*/
|
|
|
|
|
@@ -141,7 +173,7 @@ void main(void){
|
|
|
|
|
|
charge_on();
|
|
|
set_voltage(12.6);
|
|
|
- set_charge_curr(1.0);
|
|
|
+ set_charge_curr(.8);
|
|
|
|
|
|
for(;;){
|
|
|
_delay_ms(1);
|
|
@@ -152,11 +184,15 @@ void main(void){
|
|
|
}
|
|
|
dac_update();
|
|
|
|
|
|
- if(adc_data_ready){
|
|
|
- adc_data_ready = 0;
|
|
|
- atomic_set_slint(&adc, adc_val);
|
|
|
+ if(adc_process_data()){
|
|
|
cursor(0,1);
|
|
|
- disp_num((adc * 1.55337778893448E-07 + -0.092784032021951) * 1000, 3);
|
|
|
+ disp_num(meas[MEAS_VOLT] * 1000, 3);
|
|
|
+ putchar('V');
|
|
|
+ clearline();
|
|
|
+ cursor(0,2);
|
|
|
+ disp_num(meas[MEAS_CURR] * 1000, 3);
|
|
|
+ // disp_num(adc_results[MEAS_CURR], 0);
|
|
|
+ putchar('A');
|
|
|
clearline();
|
|
|
}
|
|
|
// dac8571_set(++dac1, VOLT_DAC);
|