Skip to content

Commit

Permalink
Optimize PID control at low increasing temps, decrease max steps to 2…
Browse files Browse the repository at this point in the history
…5 to free memory
  • Loading branch information
jperfetto committed Jun 26, 2011
1 parent 8a1aafc commit 24effef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions arduino/OpenPCR/thermocycler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ PROGMEM const unsigned int LID_RESISTANCE_TABLE[] = {
#define PLATE_PID_INC_I 250
#define PLATE_PID_INC_D 250

#define PLATE_PID_INC_LOW_THRESHOLD 40
#define PLATE_PID_INC_LOW_P 2000
#define PLATE_PID_INC_LOW_I 1000
#define PLATE_PID_INC_LOW_D 800

#define PLATE_PID_DEC_HIGH_THRESHOLD 70
#define PLATE_PID_DEC_HIGH_P 800
#define PLATE_PID_DEC_HIGH_I 700
Expand Down Expand Up @@ -418,7 +423,10 @@ void Thermocycler::SetPlateTarget(double target) {
if (iRamping) {
if (iTargetPlateTemp >= iPlateTemp) {
iDecreasing = false;
iPlatePid.SetTunings(PLATE_PID_INC_P, PLATE_PID_INC_I, PLATE_PID_INC_D);
if (iTargetPlateTemp < PLATE_PID_INC_LOW_THRESHOLD)
iPlatePid.SetTunings(PLATE_PID_INC_LOW_P, PLATE_PID_INC_LOW_I, PLATE_PID_INC_LOW_D);
else
iPlatePid.SetTunings(PLATE_PID_INC_P, PLATE_PID_INC_I, PLATE_PID_INC_D);
} else {
iDecreasing = true;
if (iTargetPlateTemp > PLATE_PID_DEC_HIGH_THRESHOLD)
Expand Down Expand Up @@ -464,7 +472,7 @@ void Thermocycler::ControlPeltier() {
iPlatePid.ResetI();
else
iDecreasing = false;
}
}

if (iPeltierPwm > 0)
newDirection = HEAT;
Expand Down
4 changes: 2 additions & 2 deletions arduino/OpenPCR/thermocycler.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Thermocycler {
const char* GetProgName() { return iszProgName; }
Display* GetDisplay() { return ipDisplay; }
ProgramComponentPool<Cycle, 4>& GetCyclePool() { return iCyclePool; }
ProgramComponentPool<Step, 20>& GetStepPool() { return iStepPool; }
ProgramComponentPool<Step, 30>& GetStepPool() { return iStepPool; }

boolean Ramping() { return iRamping; }
int GetPeltierPwm() { return iPeltierPwm; }
Expand Down Expand Up @@ -107,7 +107,7 @@ class Thermocycler {
Display* ipDisplay;
SerialControl* ipSerialControl;
ProgramComponentPool<Cycle, 4> iCyclePool;
ProgramComponentPool<Step, 20> iStepPool;
ProgramComponentPool<Step, 30> iStepPool;

// state
ProgramState iProgramState;
Expand Down

0 comments on commit 24effef

Please sign in to comment.