Elite 1.4-re try to fix IV plot

This commit is contained in:
alan
2019-08-20 14:31:02 +08:00
parent 317305dbcd
commit d0f1cb5db0
2 changed files with 17 additions and 15 deletions
@@ -78,12 +78,13 @@ static int32_t DAC_to_realV(uint16_t DACcode)
//volt = (DAC -6.4893275)/(-0.0001896)
int32_t RealV = 0;
int32_t volt_32 = DACcode*10e7;
int32_t volt_32 = 0;
int32_t coeff = (-1896), offset = 64893275;//*10e7
RealV = ((int32_t)(volt_32) - offset)/coeff;
volt_32 = DACcode * 10e7;
RealV = (volt_32 ) - offset) / coeff;
RealV = RealV/10e7;
RealV = RealV / 10e7;
return RealV;
}
@@ -150,23 +150,18 @@ static uint16_t VoltScan(){
return Voltage;
}
static void Notify_IV(uint16_t Voltage, uint16_t Current)
static void Notify_IV(uint16_t Voltage)
{
int32_t RealV;
int32_t RealC;
RealV = DAC_to_realV(Voltage);
RealC = DecodeADCCurrent( (uint8_t)(2), Current);
NotifyVolt[0] = (uint8_t) (RealV >> 24);
NotifyVolt[1] = (uint8_t) ((RealV & 0x00FF0000) >> 16);
NotifyVolt[2] = (uint8_t) ((RealV & 0x0000FF00) >> 8);
NotifyVolt[3] = (uint8_t) (RealV & 0x000000FF);
NotifyCurrent[0] = (uint8_t) (RealC >> 24);
NotifyCurrent[1] = (uint8_t) ((RealC & 0x00FF0000) >> 16);
NotifyCurrent[2] = (uint8_t) ((RealC & 0x0000FF00) >> 8);
NotifyCurrent[3] = (uint8_t) (RealC & 0x000000FF);
}
static void fxn_Gen() {}
@@ -905,6 +900,16 @@ static void SimpleBLEPeripheral_performPeriodicTask() {
// Control ADC to sample rate
EliteADCControl();
uint16_t Current = 0x3FFF;
uint8_t GainLevel = 1;
RealC = DecodeADCCurrent( GainLevel, Current);
NotifyCurrent[0] = (uint8_t) (RealC >> 24);
NotifyCurrent[1] = (uint8_t) ((RealC & 0x00FF0000) >> 16);
NotifyCurrent[2] = (uint8_t) ((RealC & 0x0000FF00) >> 8);
NotifyCurrent[3] = (uint8_t) (RealC & 0x000000FF);
// Notify control, check if we need to send notify
EliteNotifyControl();
}
@@ -913,17 +918,14 @@ static void SimpleBLEPeripheral_performPeriodicTask() {
static void EliteDACControl(){
uint16_t OutputV;
uint16_t Current;
Current = 0x3fff;
if (INSTRUCTION.eliteFxn == ITCurve) { return; }
if (INSTRUCTION.eliteFxn == VTCurve) { return; }
if (StepTimeCounter == StepTime) {
OutputV = VoltScan(); // output a certain voltage
Notify_IV(OutputV, Current);
Notify_IV(OutputV);
}
}
static void EliteADCControl(){
@@ -971,7 +973,6 @@ static void SendNotify(){
not_buf[17] = INSTRUCTION.CycleNumber;
SimpleProfile_SetParameter(BLE_DAT_BUFF_CHAR, BLE_DAT_BUFF_SIZE, not_buf);
}
#endif /* IMPEDANCE_METER_H_ */