ADC Gain level instructino

This commit is contained in:
YiChin
2019-08-20 22:50:53 +08:00
parent 837055cc29
commit 63b4c19d67
2 changed files with 24 additions and 25 deletions
@@ -25,39 +25,39 @@ static int32_t DecodeADCVolt(uint16_t ADC_measure){
// unit should be pA
// Decode ADC current for class leader
//static int32_t DecodeADCCurrent(uint8_t ADCGain, uint16_t ADC_measure){
// int32_t ADCRealCurrent = 0;
// int32_t coeff[3] = {0}, offset[3] = {0};
//
// coeff[0] = 3056; // 200k resister, I < 100nA
// coeff[1] = 65461; // 10k resister, 100nA < I < 100uA
// coeff[2] = 3369; // 200R resister, I > 100uA
//
// offset[0] = -74771591;
// offset[1] = -1601786957;
// offset[2] = -82598293;
//
// ADCRealCurrent = (coeff[ADCGain] * ADC_measure + offset[ADCGain]);
// return ADCRealCurrent;
//}
// Decode ADC current for CHAO-I
static int32_t DecodeADCCurrent(uint8_t ADCGain, uint16_t ADC_measure){
int32_t ADCRealCurrent = 0;
int32_t coeff[3] = {0}, offset[3] = {0};
coeff[0] = 2929; // 200k resister, I < 100nA
coeff[1] = 66009; // 10k resister, 100nA < I < 100uA
coeff[2] = 3120; // 200R resister, I > 100uA
coeff[0] = 3056; // 200k resister, I < 100nA
coeff[1] = 65461; // 10k resister, 100nA < I < 100uA
coeff[2] = 3369; // 200R resister, I > 100uA
offset[0] = -70261951;
offset[1] = -1583533494;
offset[2] = -74847651;
offset[0] = -74771591;
offset[1] = -1601786957;
offset[2] = -82598293;
ADCRealCurrent = (coeff[ADCGain] * ADC_measure + offset[ADCGain]);
ADCRealCurrent = (coeff[ADCGain] * ADC_measure + offset[ADCGain])/1000;
return ADCRealCurrent;
}
// Decode ADC current for CHAO-I
//static int32_t DecodeADCCurrent(uint8_t ADCGain, uint16_t ADC_measure){
// int32_t ADCRealCurrent = 0;
// int32_t coeff[3] = {0}, offset[3] = {0};
//
// coeff[0] = 2929; // 200k resister, I < 100nA
// coeff[1] = 66009; // 10k resister, 100nA < I < 100uA
// coeff[2] = 3120; // 200R resister, I > 100uA
//
// offset[0] = -70261951;
// offset[1] = -1583533494;
// offset[2] = -74847651;
//
// ADCRealCurrent = (coeff[ADCGain] * ADC_measure + offset[ADCGain]);
// return ADCRealCurrent;
//}
// Decode ADC measure value (could be a volt or current) and put it into notify buffer
static int32_t DecodeADCValue(uint8_t ADCGain, uint8_t ADCChannel, uint8_t *ADC_raw){
@@ -930,7 +930,6 @@ static void update_ZM_instruction(uint8 *ins) {
}
case SetADCGain:{
ADCGainControl(ins[3]);
ADCGainLevel = ins[3];
break;
}