Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 62 lines (39 sloc) 1.29 KB
* Andy's Workshop Reflow Oven Controller.
* Copyright (c) 2014 Andy Brown. All rights reserved.
* Please see website ( for full details.
#include "Application.h"
namespace awreflow {
* Constructor
Pid::Pid(variable_t kp,variable_t ki,variable_t kd)
: _kp(kp),
_integral(0) {
* Update the algorithm with the current error and get a percentage value back
* that can be used as a PWM duty cycle (0..100). This method should be called at
* a fixed time interval.
uint8_t Pid::update(variable_t desiredTemperature,variable_t currentTemperature) {
variable_t error,pwm,derivative;
// current error term is the difference between desired and current temperature
// update the integral (historical error)
// the derivative term
// calculate the control variable
// save the last error
// return the control variable
return static_cast<uint8_t>(pwm);