test CV curve
This commit is contained in:
+47
-4
@@ -604,7 +604,7 @@ static void DPVCurve(){
|
||||
return;
|
||||
}
|
||||
|
||||
static void CVCurve(){
|
||||
static void CVCurve_tmp(){
|
||||
static uint8_t ramp0;
|
||||
static uint8_t ramp1;
|
||||
static int16_t outputV = VoltOrigin;
|
||||
@@ -635,7 +635,6 @@ static void CVCurve(){
|
||||
|
||||
|
||||
// check if we reach the final volt
|
||||
/*
|
||||
if ( ramp >= VoltFinal) {
|
||||
Step = !Step; // reverse the Step direction
|
||||
}
|
||||
@@ -665,8 +664,52 @@ static void CVCurve(){
|
||||
}
|
||||
ramp0 = ramp0 - Step;
|
||||
|
||||
*/
|
||||
if((outputV == VoltFinal) || (outputV == VoltFinal) ) Step = !Step;
|
||||
|
||||
}
|
||||
|
||||
static void CVCurve(){
|
||||
static uint8_t ramp0;
|
||||
static uint8_t ramp1;
|
||||
static int16_t outputV = VoltOrigin;
|
||||
static bool first_cycle = true;
|
||||
uint16_t ramp = 0;
|
||||
float VoltValue;
|
||||
|
||||
// reset origin volt at the begin
|
||||
if (DACreset){
|
||||
if(!PeriodicEvent) PeriodicEvent = true;
|
||||
ramp0 = (uint8_t) (VoltOrigin & 0x00FF); //right byte
|
||||
ramp1 = (uint8_t) ((VoltOrigin>>8) & 0x00FF); //left byte
|
||||
DACreset = false;
|
||||
|
||||
}
|
||||
|
||||
// output a certain volt
|
||||
ramp = ( (uint16_t) (ramp1)<<8 ) | ( (uint16_t) (ramp0) );
|
||||
|
||||
DAC_outputV(outputV);
|
||||
|
||||
// record the output voltage
|
||||
int32_t Vout = 0;
|
||||
int16_t decode = (int16_t)(ramp1 << 8) | (uint16_t)(ramp0); //ramp1 ramp0
|
||||
VoltValue = decode * (-2.9780379) + 5920.324416;
|
||||
Vout = (int32_t) (VoltValue / 1);
|
||||
// VoltValue = (ramp1*16 + ramp0/16) * 3.05;
|
||||
|
||||
|
||||
if ( ramp >= VoltFinal) {
|
||||
Step = !Step; // reverse the Step direction
|
||||
}
|
||||
else if (ramp <= VoltOrigin) {
|
||||
Step = !Step;
|
||||
if (INSTRUCTION.CycleNumber == 0) {
|
||||
PeriodicEvent = false; //periodic event end
|
||||
first_cycle = true;
|
||||
DACreset = true;
|
||||
return;
|
||||
}
|
||||
INSTRUCTION.CycleNumber--;
|
||||
}
|
||||
|
||||
outputV = outputV + Step;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user