Skip to content
Snippets Groups Projects
Commit a9cb79cb authored by Christos Gentsos's avatar Christos Gentsos
Browse files

Main: fix ADC channel scan misalignment

parent 0dea78ea
Branches
Tags
No related merge requests found
......@@ -244,7 +244,7 @@
// <id> adc_arch_inputscan
#ifndef CONF_ADC_0_INPUTSCAN
#ifdef MMRTSB
#define CONF_ADC_0_INPUTSCAN 18
#define CONF_ADC_0_INPUTSCAN 14
#else
#define CONF_ADC_0_INPUTSCAN 11
#endif
......
......@@ -43,10 +43,16 @@ void query_prp();
void query_cln();
uint8_t query_r;
#ifdef MMRTSB
#define MAX_PAGE 3
#else
#define MAX_PAGE 2
#endif
extern uint16_t volts_lin[MAX_PAGE+1];
extern uint16_t currs_lin[MAX_PAGE+1];
extern uint16_t powrs_lin[MAX_PAGE+1];
extern uint16_t temps_lin[3];
extern uint16_t volts_lin[3];
extern uint16_t currs_lin[3];
extern uint16_t powrs_lin[3];
extern uint16_t frpms_lin[3];
uint32_t TMR_ERROR_CNT;
......@@ -193,11 +199,6 @@ void boot_new_fw()
void __xMR page_chk()
{
#ifdef MMRTSB
#define MAX_PAGE 3
#else
#define MAX_PAGE 2
#endif
if (page_tmp > MAX_PAGE)
page = MAX_PAGE;
else
......
......@@ -73,12 +73,6 @@ float temp_curve_points_y[3][3] __xMR = {{1000, 2000, 5000}, {1000, 2000, 4000},
float temp_matrix[3][3] __xMR = {{1, 0, 0}, {0, 1, 0}, {1, 0, 0}};
uint16_t temp_control_on __xMR = 0;
uint16_t adc_ch __xMR;
uint16_t adc_vals[12];
float temps[3];
float volts[3];
float currs[3];
// V_ref and the readout it corresponds to
#define VREF 2.5
#define ADC_MAX 65535.0
......@@ -87,7 +81,7 @@ float currs[3];
// I[mA] = V_adc * scaling_coeff
// T[degC] = (V_adc + a) * b
#if defined MMRTSB
#define ADC_CH_MAX 19
#define ADC_CH_MAX 15
// Voltages: P12V, P1V2, P3V3, PPERIPH
const float volt_scaling_coeff[4] = {(10.0+2.0)/2.0, 1.0/(1.0+(1.0/1.0)), (4.7+10.0)/10.0, (4.7+2.0)/2.0};
// Current: P12V
......@@ -127,6 +121,12 @@ const float temp_coeff_a[3] = {0, 0, 0};
const float temp_coeff_b[3] = {0, 0, 0};
#endif
uint16_t adc_ch __xMR;
uint16_t adc_vals[ADC_CH_MAX];
float temps[3];
float volts[4];
float currs[3];
uint16_t trig_adc_next_second __xMR = 0;
#if defined(MMFANT) || defined(MMPROT)
......@@ -321,7 +321,10 @@ void __xMR adc_cb(const struct adc_async_descriptor *const descr, const uint8_t
powrs_lin[2] = float_to_linear(volts[2] * currs[2]);
break;
#ifdef MMRTSB
case 18:
case 14:
volts[3] = VREF*(adc_vals[adc_ch] / ADC_MAX)*volt_scaling_coeff[3];
volts_lin[3] = float_to_linear(volts[3]);
powrs_lin[3] = float_to_linear(0);
break;
#endif
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment