Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
pid.cpp
- Committer:
- ahmedallibhoy
- Date:
- 2015-12-02
- Revision:
- 1:45f1f67eab62
- Child:
- 4:d59328f14363
File content as of revision 1:45f1f67eab62:
#include "pid.h" void PIDController::onLoop() { float error = (m_error)(); (m_out)(m_Kp * error + m_Ki * iController(error) + m_Kd * dController(error)); wait(m_dt); } float PIDController::iController(float error) { m_integral += error; return m_integral; } float PIDController::dController(float error) { float derivative = error - m_pError; m_pError = error; return derivative; } void PIDController::reset() { m_integral = 0; }