Elite 1.4-re ADC current correction
This commit is contained in:
+7
-1
@@ -58,11 +58,17 @@ static void DAC_outputV(uint16_t voltLV) {
|
||||
// User will enter -5V~+5V in UI.
|
||||
// websever and controler use 0~50000 represent -5~+5V
|
||||
// this function should turn 0~50000 into DACcode which output the exactly voltage user want
|
||||
static uint16_t DACCorrectionDecode(uint16_t usercode){
|
||||
|
||||
static uint16_t DACCorrectionDecode(uint16_t usercode)
|
||||
{
|
||||
// DACcode to real_voltage correction function
|
||||
int32_t usercode_32;
|
||||
uint16_t DACcode = 0;
|
||||
int16_t coeff = (-1054), offset = 60597718;
|
||||
|
||||
usercode_32 = (int32_t)(usercode);
|
||||
|
||||
DACcode = (uint16_t) (coeff * usercode_32 + offset)/1000;
|
||||
|
||||
return DACcode;
|
||||
}
|
||||
|
||||
+35
-54
@@ -129,21 +129,17 @@ static void VoltScan(){
|
||||
DAC_outputV(VoltOrigin);
|
||||
|
||||
// record the output voltage
|
||||
float VoltValue;
|
||||
int16_t decode = (int16_t)(ramp1 << 8) | (uint16_t)(ramp0);
|
||||
int32_t Vout = 0;
|
||||
VoltValue = decode * (-2.9780379) + 5920.324416;
|
||||
Vout = (int32_t) (VoltValue / 1);
|
||||
// VoltValue = (ramp1*16 + ramp0/16) * 3.05;
|
||||
|
||||
NotifyVolt[0] = (uint8_t) (Vout >> 24) & (0xFF);
|
||||
NotifyVolt[1] = (uint8_t) (Vout >> 16) & (0xFF);
|
||||
NotifyVolt[2] = (uint8_t) (Vout >> 8) & (0xFF);
|
||||
NotifyVolt[3] = (uint8_t) (Vout) & (0xFF);
|
||||
|
||||
NotifyImpedance[1] = ramp0;
|
||||
NotifyImpedance[2] = ramp1;
|
||||
|
||||
/*
|
||||
* int32_t RealVolt = 0;
|
||||
* RealVolt = DACCode2RealVolt(VoltOrigin);
|
||||
*
|
||||
* NotifyVolt[0] = (uint8_t) (RealVolt >> 24);
|
||||
* NotifyVolt[1] = (uint8_t) ((RealVolt & 0x00FF0000) >> 16);
|
||||
* NotifyVolt[2] = (uint8_t) ((RealVolt & 0x0000FF00) >> 8);
|
||||
* NotifyVolt[3] = (uint8_t) (RealVolt & 0x000000FF);
|
||||
*
|
||||
* SendNotify();
|
||||
*/
|
||||
PeriodicEvent = false;
|
||||
}
|
||||
else if (INSTRUCTION.eliteFxn == squarewavevoltammetry) {
|
||||
@@ -627,27 +623,18 @@ static void IVCurve_T(){
|
||||
ramp = (int16_t)(ramp1 << 8) | (uint16_t)(ramp0);
|
||||
DAC_outputV(ramp);
|
||||
|
||||
// record the output voltage
|
||||
int32_t Vout = 0;
|
||||
int16_t decode = (int16_t)(ramp1 << 8) | (uint16_t)(ramp0);
|
||||
VoltValue = decode * (-2.9780379) + 5920.324416;
|
||||
Vout = (int32_t) (VoltValue / 1);
|
||||
// VoltValue = (ramp1*16 + ramp0/16) * 3.05;
|
||||
|
||||
|
||||
NotifyVolt[0] = (uint8_t) (Vout >> 24) & (0xFF);
|
||||
NotifyVolt[1] = (uint8_t) (Vout >> 16) & (0xFF);
|
||||
NotifyVolt[2] = (uint8_t) (Vout >> 8) & (0xFF);
|
||||
NotifyVolt[3] = (uint8_t) (Vout) & (0xFF);
|
||||
|
||||
NotifyImpedance[1] = ramp0;
|
||||
NotifyImpedance[2] = ramp1;
|
||||
|
||||
|
||||
// NotifyVolt[0] = VoltValue/1000;
|
||||
// NotifyVolt[1] = VoltValue/100 - NotifyVolt[0]*10;
|
||||
// NotifyVolt[2] = VoltValue/10 - NotifyVolt[0]*100 - NotifyVolt[1]*10;
|
||||
// NotifyVolt[3] = VoltValue/1 - NotifyVolt[0]*1000 - NotifyVolt[1]*100 - NotifyVolt[2]*10;
|
||||
// record the output voltage
|
||||
/*
|
||||
* int32_t RealVolt = 0;
|
||||
* RealVolt = DACCode2RealVolt(ramp);
|
||||
*
|
||||
* NotifyVolt[0] = (uint8_t) (RealVolt >> 24);
|
||||
* NotifyVolt[1] = (uint8_t) ((RealVolt & 0x00FF0000) >> 16);
|
||||
* NotifyVolt[2] = (uint8_t) ((RealVolt & 0x0000FF00) >> 8);
|
||||
* NotifyVolt[3] = (uint8_t) (RealVolt & 0x000000FF);
|
||||
*
|
||||
* SendNotify();
|
||||
*/
|
||||
|
||||
// check if we reach the final volt
|
||||
ramp = ( (uint16_t) (ramp1)<<8 ) | ( (uint16_t) (ramp0) );
|
||||
@@ -692,24 +679,18 @@ static void IVCurve_T2(){
|
||||
ramp = (int16_t)(ramp1 << 8) | (uint16_t)(ramp0);
|
||||
DAC_outputV(ramp);
|
||||
|
||||
// record the output voltage
|
||||
int32_t Vout = 0;
|
||||
int16_t decode = (int16_t)(ramp1 << 8) | (uint16_t)(ramp0);
|
||||
VoltValue = decode * (-2.9780379) + 5920.324416;
|
||||
Vout = (int32_t) (VoltValue / 1);
|
||||
// VoltValue = (ramp1*16 + ramp0/16) * 3.05;
|
||||
|
||||
NotifyVolt[0] = (uint8_t) (Vout >> 24) & (0xFF);
|
||||
NotifyVolt[1] = (uint8_t) (Vout >> 16) & (0xFF);
|
||||
NotifyVolt[2] = (uint8_t) (Vout >> 8) & (0xFF);
|
||||
NotifyVolt[3] = (uint8_t) (Vout) & (0xFF);
|
||||
|
||||
NotifyImpedance[1] = ramp0;
|
||||
NotifyImpedance[2] = ramp1;
|
||||
// NotifyVolt[0] = VoltValue/1000;
|
||||
// NotifyVolt[1] = VoltValue/100 - NotifyVolt[0]*10;
|
||||
// NotifyVolt[2] = VoltValue/10 - NotifyVolt[0]*100 - NotifyVolt[1]*10;
|
||||
// NotifyVolt[3] = VoltValue/1 - NotifyVolt[0]*1000 - NotifyVolt[1]*100 - NotifyVolt[2]*10;
|
||||
// record the output voltage
|
||||
/*
|
||||
* int32_t RealVolt = 0;
|
||||
* RealVolt = DACCode2RealVolt(ramp);
|
||||
*
|
||||
* NotifyVolt[0] = (uint8_t) (RealVolt >> 24);
|
||||
* NotifyVolt[1] = (uint8_t) ((RealVolt & 0x00FF0000) >> 16);
|
||||
* NotifyVolt[2] = (uint8_t) ((RealVolt & 0x0000FF00) >> 8);
|
||||
* NotifyVolt[3] = (uint8_t) (RealVolt & 0x000000FF);
|
||||
*
|
||||
* SendNotify();
|
||||
*/
|
||||
|
||||
// check if we reach the final volt
|
||||
ramp = ( (uint16_t) (ramp1)<<8 ) | ( (uint16_t) (ramp0) );
|
||||
|
||||
Reference in New Issue
Block a user