Skip to content

Commit

Permalink
Send signed value of Peltier drive instead of absolute value #11
Browse files Browse the repository at this point in the history
  • Loading branch information
maripo committed Nov 10, 2018
1 parent 459d5a4 commit 343d678
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
9 changes: 5 additions & 4 deletions arduino/NinjaPCR/communicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,17 @@ void Communicator::SendStatus() {
//statusPtr = AddParam(statusPtr, 'n', tc.GetProgName());
if (tc.GetCurrentStep() != NULL)
statusPtr = AddParam(statusPtr, 'p', tc.GetCurrentStep()->GetName());

}

else if (state == Thermocycler::EIdle) {
statusPtr = AddParam(statusPtr, 'v', OPENPCR_FIRMWARE_VERSION_STRING);
} else if (state == Thermocycler::EError) {
statusPtr = AddParam(statusPtr, 'w', tc.GetErrorCode());
}
statusPtr = AddParam(statusPtr, 'x', tc.getAnalogValueLid());
statusPtr = AddParam(statusPtr, 'y', tc.getAnalogValuePeltier());
statusPtr = AddParam(statusPtr, 'z', tc.GetTemp(), 1, false);

statusPtr = AddParam(statusPtr, 'x', tc.getAnalogValueLid()); // Hardware output
statusPtr = AddParam(statusPtr, 'y', tc.getAnalogValuePeltier()); // Hardware output
statusPtr = AddParam(statusPtr, 'z', tc.GetTemp(), 1, false); // Sample temp
statusPtr++; //to include null terminator

int statusBufLen = statusPtr - statusBuf;
Expand Down
11 changes: 5 additions & 6 deletions arduino/NinjaPCR/thermocycler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,6 @@ void Thermocycler::SetPeltier(ThermalDirection dir, int pwm /* Signed value of p
pwmActual = 0;
dirActual = prevActualDirection;
}

} else {
// No need of switching direction.
dirActual = dir;
Expand All @@ -853,12 +852,12 @@ void Thermocycler::SetPeltier(ThermalDirection dir, int pwm /* Signed value of p
digitalWrite(PIN_WELL_INA, PIN_WELL_VALUE_OFF);
digitalWrite(PIN_WELL_INB, PIN_WELL_VALUE_OFF);
}
analogValuePeltier = (dir==COOL)?-pwmActual:pwmActual;
analogValuePeltier = pwmActual;
int absOutput = (dir==COOL)?-pwmActual:pwmActual;
#ifdef PIN_WELL_PWM_ACTIVE_LOW
analogWrite(PIN_WELL_PWM, MAX_PELTIER_PWM-analogValuePeltier);
analogWrite(PIN_WELL_PWM, MAX_PELTIER_PWM-absOutput);
#else
analogWrite(PIN_WELL_PWM, analogValuePeltier);
analogWrite(PIN_WELL_PWM, absOutput);
#endif /* PIN_WELL_PWM_ACTIVE_LOW */
statusBuff[statusIndex].wellOutput = pwm;

Expand All @@ -868,7 +867,7 @@ void Thermocycler::SetPeltier(ThermalDirection dir, int pwm /* Signed value of p
prevActualPWMDuty = pwmActual;
}
#else
void Thermocycler::SetPeltier(Thermocycler::ThermalDirection dir, int pwm) {
void Thermocycler::SetPeltier(Thermocycler::ThermalDirection dir, int pwm /* Signed value of peltier */) {
if (dir == COOL) {
digitalWrite(PIN_WELL_INA, HIGH);
digitalWrite(PIN_WELL_INB, LOW);
Expand Down

0 comments on commit 343d678

Please sign in to comment.