fix IV & CV2 & CV3 ADC step
This commit is contained in:
+14
-21
@@ -37,6 +37,11 @@ static uint16_t CV3Curve(CV3Mode *CV3){
|
||||
|
||||
|
||||
static void CV3_Plot(CV3Mode *CV3){
|
||||
/**********************************************
|
||||
CURRENT_MODE->_VoVi_Switch : 1 read Vin volt
|
||||
->_VoVi_Switch : 0 read Vout volt
|
||||
|
||||
***********************************************/
|
||||
static uint8_t VoltCurrentSwitch = 0;
|
||||
static uint8_t PreviousGain = GAIN_200R;
|
||||
uint16_t ADC_measure = 0;
|
||||
@@ -55,9 +60,9 @@ static void CV3_Plot(CV3Mode *CV3){
|
||||
|
||||
// read Volt
|
||||
if(CV3->_VoVi_Switch == 0x01){
|
||||
ReadVolt(spi_ADC_rxbuf);// read vin volt
|
||||
ReadVolt(spi_ADC_rxbuf);
|
||||
}else if(CV3->_VoVi_Switch == 0x00){
|
||||
ReadVoutVolt(spi_ADC_rxbuf);// read vout volt
|
||||
ReadVoutVolt(spi_ADC_rxbuf);
|
||||
}
|
||||
|
||||
VoltCurrentSwitch++;
|
||||
@@ -65,9 +70,9 @@ static void CV3_Plot(CV3Mode *CV3){
|
||||
else if(VoltCurrentSwitch == 1){ /**read Vin**/
|
||||
// read Volt
|
||||
if(CV3->_VoVi_Switch == 0x01){
|
||||
ReadVolt(spi_ADC_rxbuf);// read vin volt
|
||||
ReadVolt(spi_ADC_rxbuf);
|
||||
}else if(CV3->_VoVi_Switch == 0x00){
|
||||
ReadVoutVolt(spi_ADC_rxbuf);// read vout volt
|
||||
ReadVoutVolt(spi_ADC_rxbuf);
|
||||
}
|
||||
|
||||
VoltCurrentSwitch++;
|
||||
@@ -76,35 +81,23 @@ static void CV3_Plot(CV3Mode *CV3){
|
||||
// read Volt
|
||||
if(CV3->_VoVi_Switch == 0x01){
|
||||
ReadVolt(spi_ADC_rxbuf);// read vin volt
|
||||
ADC_measure = (uint16_t) (spi_ADC_rxbuf[0] << 8) | (uint16_t) (spi_ADC_rxbuf[1]);
|
||||
CV3->MeasureVolt = DecodeADCVolt(ADC_measure);
|
||||
CV3->MeasureVolt = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_VOLT, spi_ADC_rxbuf);
|
||||
}else if(CV3->_VoVi_Switch == 0x00){
|
||||
ReadVoutVolt(spi_ADC_rxbuf);// read vout volt
|
||||
ADC_measure = (uint16_t) (spi_ADC_rxbuf[0] << 8) | (uint16_t) (spi_ADC_rxbuf[1]);
|
||||
CV3->MeasureVolt = DecodeADCVoutVolt(ADC_measure);
|
||||
CV3->MeasureVolt = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_DAC, spi_ADC_rxbuf);
|
||||
}
|
||||
|
||||
CV3Curve(CV3);
|
||||
|
||||
// read current
|
||||
if(INSTRUCTION.AutoGainEnable){
|
||||
CV3->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
|
||||
}else{
|
||||
ReadCurrent(spi_ADC_rxbuf);
|
||||
CV3->_MeasureData = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
|
||||
}
|
||||
ReadCurrent(spi_ADC_rxbuf);
|
||||
|
||||
VoltCurrentSwitch++;
|
||||
}
|
||||
else if(VoltCurrentSwitch == 3){ /**read Iin**/
|
||||
// read current
|
||||
if(INSTRUCTION.AutoGainEnable){
|
||||
CV3->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
|
||||
}
|
||||
else{
|
||||
ReadCurrent(spi_ADC_rxbuf);
|
||||
CV3->_MeasureData = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
|
||||
}
|
||||
ReadCurrent(spi_ADC_rxbuf);
|
||||
|
||||
VoltCurrentSwitch = 0;
|
||||
}
|
||||
}
|
||||
|
||||
+14
-21
@@ -141,6 +141,11 @@ static uint16_t CVCurve(CVMode *CV) {
|
||||
}
|
||||
|
||||
static void CV_Plot(CVMode *CV){
|
||||
/**********************************************
|
||||
CURRENT_MODE->_VoVi_Switch : 1 read Vin volt
|
||||
->_VoVi_Switch : 0 read Vout volt
|
||||
|
||||
***********************************************/
|
||||
static uint8_t VoltCurrentSwitch = 0;
|
||||
static uint8_t PreviousGain = GAIN_200R;
|
||||
uint16_t ADC_measure = 0;
|
||||
@@ -159,9 +164,9 @@ static void CV_Plot(CVMode *CV){
|
||||
|
||||
// read Volt
|
||||
if(CV->_VoVi_Switch == 0x01){
|
||||
ReadVolt(spi_ADC_rxbuf);// read vin volt
|
||||
ReadVolt(spi_ADC_rxbuf);
|
||||
}else if(CV->_VoVi_Switch == 0x00){
|
||||
ReadVoutVolt(spi_ADC_rxbuf);// read vout volt
|
||||
ReadVoutVolt(spi_ADC_rxbuf);
|
||||
}
|
||||
|
||||
VoltCurrentSwitch++;
|
||||
@@ -169,9 +174,9 @@ static void CV_Plot(CVMode *CV){
|
||||
else if(VoltCurrentSwitch == 1){ /**read Vin**/
|
||||
// read Volt
|
||||
if(CV->_VoVi_Switch == 0x01){
|
||||
ReadVolt(spi_ADC_rxbuf);// read vin volt
|
||||
ReadVolt(spi_ADC_rxbuf);
|
||||
}else if(CV->_VoVi_Switch == 0x00){
|
||||
ReadVoutVolt(spi_ADC_rxbuf);// read vout volt
|
||||
ReadVoutVolt(spi_ADC_rxbuf);
|
||||
}
|
||||
|
||||
VoltCurrentSwitch++;
|
||||
@@ -180,35 +185,23 @@ static void CV_Plot(CVMode *CV){
|
||||
// read Volt
|
||||
if(CV->_VoVi_Switch == 0x01){
|
||||
ReadVolt(spi_ADC_rxbuf);// read vin volt
|
||||
ADC_measure = (uint16_t) (spi_ADC_rxbuf[0] << 8) | (uint16_t) (spi_ADC_rxbuf[1]);
|
||||
CV->MeasureVolt = DecodeADCVolt(ADC_measure);
|
||||
CV->MeasureVolt = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_VOLT, spi_ADC_rxbuf);
|
||||
}else if(CV->_VoVi_Switch == 0x00){
|
||||
ReadVoutVolt(spi_ADC_rxbuf);// read vout volt
|
||||
ADC_measure = (uint16_t) (spi_ADC_rxbuf[0] << 8) | (uint16_t) (spi_ADC_rxbuf[1]);
|
||||
CV->MeasureVolt = DecodeADCVoutVolt(ADC_measure);
|
||||
CV->MeasureVolt = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_DAC, spi_ADC_rxbuf);
|
||||
}
|
||||
|
||||
InputNotify(NOTIFY_VOLT, CV->MeasureVolt);
|
||||
|
||||
// read current
|
||||
if(INSTRUCTION.AutoGainEnable){
|
||||
CV->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
|
||||
}else{
|
||||
ReadCurrent(spi_ADC_rxbuf);
|
||||
CV->_MeasureData = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
|
||||
}
|
||||
ReadCurrent(spi_ADC_rxbuf);
|
||||
|
||||
VoltCurrentSwitch++;
|
||||
}
|
||||
else if(VoltCurrentSwitch == 3){ /**read Iin**/
|
||||
// read current
|
||||
if(INSTRUCTION.AutoGainEnable){
|
||||
CV->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
|
||||
}
|
||||
else{
|
||||
ReadCurrent(spi_ADC_rxbuf);
|
||||
CV->_MeasureData = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
|
||||
}
|
||||
ReadCurrent(spi_ADC_rxbuf);
|
||||
|
||||
VoltCurrentSwitch = 0;
|
||||
}
|
||||
}
|
||||
|
||||
-4
@@ -1617,10 +1617,6 @@ static int32_t DecodeADCValue(uint8_t ADCGain, uint8_t ADCChannel, uint8_t *ADC_
|
||||
// return real current to controller
|
||||
else if(ADCChannel == ADC_CH_CURRENT){
|
||||
ADCRealCurrent = DecodeADCCurrent(ADCGain, ADC_measure);
|
||||
// NotifyCurrent[0] = (uint8_t) (ADCRealCurrent >> 24);
|
||||
// NotifyCurrent[1] = (uint8_t) ((ADCRealCurrent & 0x00FF0000) >> 16);
|
||||
// NotifyCurrent[2] = (uint8_t) ((ADCRealCurrent & 0x0000FF00) >> 8);
|
||||
// NotifyCurrent[3] = (uint8_t) (ADCRealCurrent & 0x000000FF);
|
||||
ret = ADCRealCurrent;
|
||||
}
|
||||
|
||||
|
||||
+16
-23
@@ -48,6 +48,11 @@ static uint16_t OneWayVoltScan() {
|
||||
}
|
||||
|
||||
static void IV_Plot(IVMode *IV) {
|
||||
/**********************************************
|
||||
CURRENT_MODE->_VoVi_Switch : 1 read Vin volt
|
||||
->_VoVi_Switch : 0 read Vout volt
|
||||
|
||||
***********************************************/
|
||||
static uint8_t VoltCurrentSwitch = 0;
|
||||
static uint8_t PreviousGain = GAIN_200R;
|
||||
uint16_t ADC_measure = 0;
|
||||
@@ -66,9 +71,9 @@ static void IV_Plot(IVMode *IV) {
|
||||
|
||||
// read Volt
|
||||
if(IV->_VoVi_Switch == 0x01){
|
||||
ReadVolt(spi_ADC_rxbuf);// read vin volt
|
||||
ReadVolt(spi_ADC_rxbuf);
|
||||
}else if(IV->_VoVi_Switch == 0x00){
|
||||
ReadVoutVolt(spi_ADC_rxbuf);// read vout volt
|
||||
ReadVoutVolt(spi_ADC_rxbuf);
|
||||
}
|
||||
|
||||
VoltCurrentSwitch++;
|
||||
@@ -76,9 +81,9 @@ static void IV_Plot(IVMode *IV) {
|
||||
else if(VoltCurrentSwitch == 1){ /**read Vin**/
|
||||
// read Volt
|
||||
if(IV->_VoVi_Switch == 0x01){
|
||||
ReadVolt(spi_ADC_rxbuf);// read vin volt
|
||||
ReadVolt(spi_ADC_rxbuf);
|
||||
}else if(IV->_VoVi_Switch == 0x00){
|
||||
ReadVoutVolt(spi_ADC_rxbuf);// read vout volt
|
||||
ReadVoutVolt(spi_ADC_rxbuf);
|
||||
}
|
||||
|
||||
VoltCurrentSwitch++;
|
||||
@@ -86,36 +91,24 @@ static void IV_Plot(IVMode *IV) {
|
||||
else if(VoltCurrentSwitch == 2){ /**read Vin(buffer),read Iin**/
|
||||
// read Volt
|
||||
if(IV->_VoVi_Switch == 0x01){
|
||||
ReadVolt(spi_ADC_rxbuf);// read vin volt
|
||||
ADC_measure = (uint16_t) (spi_ADC_rxbuf[0] << 8) | (uint16_t) (spi_ADC_rxbuf[1]);
|
||||
IV->MeasureVolt = DecodeADCVolt(ADC_measure);
|
||||
ReadVolt(spi_ADC_rxbuf);
|
||||
IV->MeasureVolt = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_VOLT, spi_ADC_rxbuf);
|
||||
}else if(IV->_VoVi_Switch == 0x00){
|
||||
ReadVoutVolt(spi_ADC_rxbuf);// read vout volt
|
||||
ADC_measure = (uint16_t) (spi_ADC_rxbuf[0] << 8) | (uint16_t) (spi_ADC_rxbuf[1]);
|
||||
IV->MeasureVolt = DecodeADCVoutVolt(ADC_measure);
|
||||
ReadVoutVolt(spi_ADC_rxbuf);
|
||||
IV->MeasureVolt = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_DAC, spi_ADC_rxbuf);
|
||||
}
|
||||
|
||||
InputNotify(NOTIFY_VOLT, IV->MeasureVolt);
|
||||
|
||||
// read current
|
||||
if(INSTRUCTION.AutoGainEnable){
|
||||
IV->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
|
||||
}else{
|
||||
ReadCurrent(spi_ADC_rxbuf);
|
||||
IV->_MeasureData = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
|
||||
}
|
||||
ReadCurrent(spi_ADC_rxbuf);
|
||||
|
||||
VoltCurrentSwitch++;
|
||||
}
|
||||
else if(VoltCurrentSwitch == 3){ /**read Iin**/
|
||||
// read current
|
||||
if(INSTRUCTION.AutoGainEnable){
|
||||
IV->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
|
||||
}
|
||||
else{
|
||||
ReadCurrent(spi_ADC_rxbuf);
|
||||
IV->_MeasureData = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
|
||||
}
|
||||
ReadCurrent(spi_ADC_rxbuf);
|
||||
|
||||
VoltCurrentSwitch = 0;
|
||||
}
|
||||
}
|
||||
|
||||
-57
@@ -29,9 +29,6 @@ static void ZT_Plot(RTMode *RT) {
|
||||
|
||||
|
||||
volt_32 = User2Real(INSTRUCTION.VoltConstant)*1e6;
|
||||
// ReadVolt(SPIVolt);
|
||||
// VoltMeasure = (uint16_t) (SPIVolt[0] << 8) | (uint16_t) (SPIVolt[1]);
|
||||
// volt_32 = DecodeADCVolt(VoltMeasure)*1e4;
|
||||
resister_32 = volt_32 / current_32;
|
||||
volt_32 = volt_32 / 1e3; //uV
|
||||
|
||||
@@ -46,60 +43,6 @@ static void ZT_Plot(RTMode *RT) {
|
||||
Elite 100000 = 100KR
|
||||
Elite 1000000 = 1MR
|
||||
*/
|
||||
|
||||
// set ADC GAIN
|
||||
// if(INSTRUCTION.ResisterMeter == RESISTER_METER_LARGE){
|
||||
// INSTRUCTION.ADCGainLevel = GAIN_200R;
|
||||
// }
|
||||
// else if(INSTRUCTION.ResisterMeter == RESISTER_METER_MIDDLE2){
|
||||
// INSTRUCTION.ADCGainLevel = GAIN_200R;
|
||||
// }
|
||||
// else if(INSTRUCTION.ResisterMeter == RESISTER_METER_MIDDLE1){
|
||||
// INSTRUCTION.ADCGainLevel = GAIN_10K;
|
||||
// }
|
||||
// else{
|
||||
// INSTRUCTION.ADCGainLevel = GAIN_200K;
|
||||
// }
|
||||
// ADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
|
||||
// Use 9-th measure value as real-measure value
|
||||
// because some value in the begin are garbage
|
||||
// if(VoltCurrentSwitch < 9){
|
||||
// ADCChannelSelect(ADC_CH_CURRENT);
|
||||
// CPUdelay(10);
|
||||
// ADC_read(SPICurrent);
|
||||
// VoltCurrentSwitch ++;
|
||||
// }
|
||||
// else if(VoltCurrentSwitch == 9){
|
||||
// // read current
|
||||
// ADCChannelSelect(ADC_CH_CURRENT);
|
||||
// CPUdelay(10);
|
||||
// ADC_read(SPICurrent);
|
||||
// CurrentMeasure = (uint16_t) (SPICurrent[0] << 8) | (uint16_t) (SPICurrent[1]);
|
||||
// VoltCurrentSwitch ++;
|
||||
// }
|
||||
// else if(VoltCurrentSwitch <18){
|
||||
// // read volt
|
||||
// ADCChannelSelect(ADC_CH_VOLT);
|
||||
// CPUdelay(10);
|
||||
// ADC_read(SPIVolt);
|
||||
// VoltCurrentSwitch++;
|
||||
// }
|
||||
// else if(VoltCurrentSwitch == 18){
|
||||
// // read volt
|
||||
// ADCChannelSelect(ADC_CH_VOLT);
|
||||
// CPUdelay(10);
|
||||
// ADC_read(SPIVolt);
|
||||
// VoltMeasure = (uint16_t) (SPIVolt[0] << 8) | (uint16_t) (SPIVolt[1]);
|
||||
// VoltCurrentSwitch++;
|
||||
// }
|
||||
// else{
|
||||
// VoltCurrentSwitch = 0;
|
||||
// }
|
||||
|
||||
// decode ADC value and put it into notify buffer
|
||||
// DecodeResister(INSTRUCTION.ADCGainLevel, CurrentMeasure, VoltMeasure);
|
||||
// Real_Resister = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -5,8 +5,8 @@
|
||||
#define VERSION_DATE_YEAR 20
|
||||
#define VERSION_DATE_MONTH 5
|
||||
#define VERSION_DATE_DAY 27
|
||||
#define VERSION_DATE_HOUR 14
|
||||
#define VERSION_DATE_MINUTE 36
|
||||
#define VERSION_DATE_HOUR 15
|
||||
#define VERSION_DATE_MINUTE 34
|
||||
|
||||
// this is NOT the version hash !!
|
||||
// it's the last version hash
|
||||
|
||||
Reference in New Issue
Block a user