From 343d67882190ba1696709094198a895abbed31bc Mon Sep 17 00:00:00 2001 From: Mariko Hisakawa Date: Sat, 10 Nov 2018 11:14:51 +0900 Subject: [PATCH] Send signed value of Peltier drive instead of absolute value #11 --- arduino/NinjaPCR/communicator.cpp | 9 +++++---- arduino/NinjaPCR/thermocycler.cpp | 11 +++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/arduino/NinjaPCR/communicator.cpp b/arduino/NinjaPCR/communicator.cpp index 70b130b..f1b4839 100644 --- a/arduino/NinjaPCR/communicator.cpp +++ b/arduino/NinjaPCR/communicator.cpp @@ -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; diff --git a/arduino/NinjaPCR/thermocycler.cpp b/arduino/NinjaPCR/thermocycler.cpp index eb6c710..6733d9e 100644 --- a/arduino/NinjaPCR/thermocycler.cpp +++ b/arduino/NinjaPCR/thermocycler.cpp @@ -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; @@ -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; @@ -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);