Compare commits

...

10 Commits

Author SHA1 Message Date
alan e71894a2ad Merge remote-tracking branch 'remotes/origin/Elite_GPTimer' into Elite_SmallZTcurve 2019-09-27 10:40:35 +08:00
YiChin 7bf7727b90 smallZ-T curve 2019-09-25 17:50:15 +08:00
YiChin 969523bea4 fix error 2019-09-25 17:16:44 +08:00
YiChin b671e2feaf fix error 2019-09-25 16:50:32 +08:00
alan 65bdb4fc52 Elite 1.4-re genius correction test 2019-09-25 16:10:23 +08:00
alan 98c4a62130 Elite 1.4-re genius correction test 2019-09-25 12:18:03 +08:00
alan 7bf8620baf Elite 1.4-re genius correction test 2019-09-25 12:11:33 +08:00
Benny Liu 3ac1d77651 Genius calibration data 2019-09-25 11:59:13 +08:00
Benny Liu 0b365f098d Elite Genius board calibration data 2019-09-25 10:30:39 +08:00
YiChin 54e1aab5fc RT class leader 2019-09-24 18:50:37 +08:00
9 changed files with 50 additions and 42 deletions
@@ -73,28 +73,28 @@ static int32_t CCModeOutputDAC(){
static void SetCCModeGain(CURRENT_USER_CODE CurrentUserCode){
switch(CurrentUserCode.lv){
case CURRENT_LV_FOUR:{
INSTRUCTION.ADCGainLevel = GAIN_200K;
INSTRUCTION.ADCGainLevel = GAIN_100K;
break;
}
case CURRENT_LV_THREE:{
INSTRUCTION.ADCGainLevel = GAIN_10K;
INSTRUCTION.ADCGainLevel = GAIN_200R;
break;
}
case CURRENT_LV_TWO:{
INSTRUCTION.ADCGainLevel = GAIN_10K;
INSTRUCTION.ADCGainLevel = GAIN_200R;
break;
}
case CURRENT_LV_ONE:{
INSTRUCTION.ADCGainLevel = GAIN_200R;
INSTRUCTION.ADCGainLevel = GAIN_10R;
break;
}
case CURRENT_LV_ZERO:{
INSTRUCTION.ADCGainLevel = GAIN_200R;
INSTRUCTION.ADCGainLevel = GAIN_10R;
break;
}
default :{
INSTRUCTION.ADCGainLevel = GAIN_200R;
INSTRUCTION.ADCGainLevel = GAIN_10R;
break;
}
}
@@ -29,7 +29,7 @@
*/
#define BOARD_CLASS_LEADER
#define BOARD_BAY_BAY
typedef struct _formula{
@@ -201,23 +201,23 @@ struct _correction{
#ifdef BOARD_BAY_BAY
{
.ADC_volt.coeff = (-6219797),
.ADC_volt.offset = 148596702982,
.ADC_volt.coeff = (-6236652),
.ADC_volt.offset = 101533279052,
.ADC_current[0].coeff = 309083900,
.ADC_current[0].offset = (-7414775955140),
.ADC_current[1].coeff = 661271310,
.ADC_current[1].offset = (-15864495597969),
.ADC_current[1].coeff = 31218018,
.ADC_current[1].offset = (-508593562044),
.ADC_current[2].coeff = 31183513,
.ADC_current[2].offset = (-748178468530),
.ADC_current[2].coeff = 557826631,
.ADC_current[2].offset = (-9088752534070),
.DAC2RealV.coeff = (-18988046),
.DAC2RealV.offset = 642080522322,
.DAC2RealV.coeff = (-18990774),
.DAC2RealV.offset = 570886531263,
.Usercode2DAC.coeff = (-10532941),
.Usercode2DAC.offset = 601473393000,
.Usercode2DAC.coeff = (-10532558),
.Usercode2DAC.offset = 563868774469,
.Gain0Boundary[0] = 0x5D96,
.Gain0Boundary[1] = 0x5DD9,
@@ -303,7 +303,7 @@ static int32_t DecodeADCCurrent(uint8_t ADCGain, uint16_t ADC_measure){
ADCRealCurrent = (Correction.ADC_current[ADCGain].coeff * ADC_measure + Correction.ADC_current[ADCGain].offset)/1e7;
// Current unit is pA;
// If ADCGain is GAIN_200R unit is nA
// If ADCGain is GAIN_10R unit is nA
return (int32_t) (ADCRealCurrent);
}
@@ -321,21 +321,21 @@ static int32_t DecodeResister(uint8_t ADCGainLevel, uint16_t CurrentMeasure, uin
ADCRealVolt = ADCRealVolt / 1e4;
volt_32 = (int32_t) (ADCRealVolt);
if (INSTRUCTION.ADCGainLevel == GAIN_200R){
if (INSTRUCTION.ADCGainLevel == GAIN_10R){
resister_32 = (int32_t) ((ADCRealVolt) / (ADCRealCurrent/1e3)); // nV / uA = mV
}
else{
resister_32 = (int32_t) ((ADCRealVolt) / (ADCRealCurrent/1e6)); // nV / uA = mV
}
// NotifyVolt[0] = (uint8_t) (volt_32 >> 24);
// NotifyVolt[1] = (uint8_t) ((volt_32 & 0x00FF0000) >> 16);
// NotifyVolt[2] = (uint8_t) ((volt_32 & 0x0000FF00) >> 8);
// NotifyVolt[3] = (uint8_t) (volt_32 & 0x000000FF);
//
// NotifyCurrent[0] = (uint8_t) (current_32 >> 24);
// NotifyCurrent[1] = (uint8_t) ((current_32 & 0x00FF0000) >> 16);
// NotifyCurrent[2] = (uint8_t) ((current_32 & 0x0000FF00) >> 8);
// NotifyCurrent[3] = (uint8_t) (current_32 & 0x000000FF);
NotifyVolt[0] = (uint8_t) (volt_32 >> 24);
NotifyVolt[1] = (uint8_t) ((volt_32 & 0x00FF0000) >> 16);
NotifyVolt[2] = (uint8_t) ((volt_32 & 0x0000FF00) >> 8);
NotifyVolt[3] = (uint8_t) (volt_32 & 0x000000FF);
NotifyCurrent[0] = (uint8_t) (current_32 >> 24);
NotifyCurrent[1] = (uint8_t) ((current_32 & 0x00FF0000) >> 16);
NotifyCurrent[2] = (uint8_t) ((current_32 & 0x0000FF00) >> 8);
NotifyCurrent[3] = (uint8_t) (current_32 & 0x000000FF);
NotifyImpedance[0] = (uint8_t) (resister_32 >> 24);
NotifyImpedance[1] = (uint8_t) ((resister_32 & 0x00FF0000) >> 16);
@@ -407,7 +407,7 @@ static void ADC_overflow(uint8_t gain, uint8_t *rawdata){
uint16_t U16Rawdata = 0;
U16Rawdata = (((uint16_t) (rawdata[0]))<<8) | ((uint16_t) (rawdata[1]));
if(gain == GAIN_200K){
if(gain == GAIN_100K){
if( U16Rawdata <= Correction.Gain0Boundary[0]){
rawdata[0] = Correction.Gain0Boundary[0] >> 4;
rawdata[1] = (uint8_t) (Correction.Gain0Boundary[0] & 0x00FF);
@@ -417,7 +417,7 @@ static void ADC_overflow(uint8_t gain, uint8_t *rawdata){
rawdata[1] = (uint8_t) (Correction.Gain0Boundary[1] & 0x00FF);
}
}
else if(gain == GAIN_10K){
else if(gain == GAIN_200R){
if( U16Rawdata <= Correction.Gain1Boundary[0]){
rawdata[0] = Correction.Gain1Boundary[0] >> 4;
rawdata[1] = (uint8_t) (Correction.Gain1Boundary[0] & 0x00FF);
@@ -452,7 +452,6 @@ static int32_t DAC_to_realV(uint16_t DACcode)
usercode_32 = ((DACcode * 1e7) - Correction.Usercode2DAC.offset) / Correction.Usercode2DAC.coeff;
// RealV = (int32_t) ((Correction.DAC2RealV.coeff * DACcode + Correction.DAC2RealV.offset)/1e8); //(mV)
RealV = (int32_t) (usercode_32 / 5) - 5000;
// return mV
@@ -3,9 +3,9 @@
#define ELITEINSTRUCTION
/** ADC gain level **/
#define GAIN_200K 0x00 // largest gain
#define GAIN_10K 0x01
#define GAIN_200R 0x02 // the least gain
#define GAIN_100K 0x00 // largest gain
#define GAIN_200R 0x01
#define GAIN_10R 0x02 // the least gain
#define GAIN_AUTO 0x03
/** Resister meter **/
@@ -80,7 +80,7 @@ static void InitEliteInstruction(){
INSTRUCTION.Step = 0x0005; // 0x0005 = 1mV
INSTRUCTION.StepTime = STEPTIME_HALF_SEC; // about 0.5 sec
INSTRUCTION.VoltConstant = 24999; // is about 0V
INSTRUCTION.ADCGainLevel = GAIN_200K;
INSTRUCTION.ADCGainLevel = GAIN_100K;
INSTRUCTION.ResisterMeter = RESISTER_METER_SMALL;
INSTRUCTION.CurrentLV = 0x00;
INSTRUCTION.ConstantCurrent = 0x0000;
@@ -17,16 +17,16 @@ static void ZT_Plot() {
// set ADC GAIN
if(INSTRUCTION.ResisterMeter == RESISTER_METER_SMALL){
INSTRUCTION.ADCGainLevel = GAIN_200R;
INSTRUCTION.ADCGainLevel = GAIN_10R;
}
else if(INSTRUCTION.ResisterMeter == RESISTER_METER_MIDDLE1){
INSTRUCTION.ADCGainLevel = GAIN_200R;
}
else if(INSTRUCTION.ResisterMeter == RESISTER_METER_MIDDLE2){
INSTRUCTION.ADCGainLevel = GAIN_10K;
INSTRUCTION.ADCGainLevel = GAIN_200R;
}
else{
INSTRUCTION.ADCGainLevel = GAIN_200K;
INSTRUCTION.ADCGainLevel = GAIN_100K;
}
ADCGainControl(INSTRUCTION.ADCGainLevel);
@@ -54,6 +54,7 @@ static void ZM_init() {
InitCurrentUserCode();
elite_gptimer_open();
// PIN_registerIntCb(pin_handle, switch_on_callback);
// PIN_setInterrupt(pin_handle, switch_on | PIN_IRQ_POSEDGE);
}
@@ -130,13 +131,18 @@ static void EliteDACControl() {
}
else if (INSTRUCTION.eliteFxn == ZT_CURVE){
if(INSTRUCTION.ResisterMeter == RESISTER_METER_SMALL){
// output 5mV
INSTRUCTION.VoltConstant = 24999 + 50;
// output 50mV
INSTRUCTION.VoltConstant = 24999 + 500;
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant));
}
else if(INSTRUCTION.ResisterMeter == RESISTER_METER_MIDDLE1){
// output 50mV
INSTRUCTION.VoltConstant = 24999 + 250;
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant));
}
else{
// output 100mV
INSTRUCTION.VoltConstant = 24999 + 500;
// output 500 mV
INSTRUCTION.VoltConstant = 24999 + 2500;
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant));
}
}
@@ -552,6 +552,9 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
ZM_init();
Elite_SPI_init();
// init DAC
DAC_outputV(Usercode_Correction_to_DAC(24999));
uint8_t key = 0;
uint16_t counter6994 = 0;
bool EliteOn = 0;