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.
Dependents: buttoncontrol includeair includeair Oudverslag
controlandadjust.h
- Committer:
 - Gerth
 - Date:
 - 2015-10-06
 - Revision:
 - 2:a1b6930947a9
 - Parent:
 - 1:ece12a295ce3
 - Child:
 - 3:8e6dacabe898
 
File content as of revision 2:a1b6930947a9:
#ifndef MBED_CONTROLANDADJUST_H
#define MBED_CONTROLANDADJUST_H
#include "mbed.h"
#include <string>
/** A library with a P-, PI- and PID-controller, useful for the module biorobotics
*Example
*@code
*#include "mbed.h"
*#include "controlandadjust.h"
*#include "QEI.h" //This is found at https://developer.mbed.org/users/aberk/code/QEI/
*
*QEI Encoder (D13, D12, NC, 32); //Encoder with X2 encoding and 32 counts per revolution
*Ticker controlticker;
*controlandadjust mycontroller; //NO () AT THE END!!
*AnalogIn pot1(A0);
*
*/
class controlandadjust
{
public:
///Instantiate the controller
    controlandadjust(void);
   /**P controller 
   *@param error1 : Error from motor 1
   *@param error2 : Error from motor 2
   *@param Kp : Desired value of Kp for your controller*/
    void P(float error1, float error2 ,float Kp );
    void PI(float error1, float error2, float Kp, float Ki,float Ts, float &error1_int, float &error2_int);
    void PID(float error1, float error2, float Kp, float Ki,float Kd,float Ts,
             float &error1_int, float &error2_int, float &error1_prev, float &error2_prev);
    float motor1pwm();
    float motor2pwm();
private:
    void verwerksignaal(float , float );
};
#endif