mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.1.2 PID_RT
This commit is contained in:
parent
e83ffeb82e
commit
d4372b1341
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// FILE: PID_RT.h
|
// FILE: PID_RT.h
|
||||||
// AUTHOR: Rob Tillaart
|
// AUTHOR: Rob Tillaart
|
||||||
// VERSION: 0.1.1
|
// VERSION: 0.1.2
|
||||||
// PURPOSE: PID library for Arduino
|
// PURPOSE: PID library for Arduino
|
||||||
// URL: https://github.com/RobTillaart/PID
|
// URL: https://github.com/RobTillaart/PID
|
||||||
//
|
//
|
||||||
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "PID_RT.h"
|
#include "PID_RT.h"
|
||||||
|
|
||||||
|
|
||||||
PID_RT::PID_RT()
|
PID_RT::PID_RT()
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
@ -140,4 +141,5 @@ bool PID_RT::setInterval(uint32_t interval)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -- END OF FILE --
|
// -- END OF FILE --
|
||||||
|
@ -2,12 +2,14 @@
|
|||||||
//
|
//
|
||||||
// FILE: PID_RT.h
|
// FILE: PID_RT.h
|
||||||
// AUTHOR: Rob Tillaart
|
// AUTHOR: Rob Tillaart
|
||||||
// VERSION: 0.1.1
|
// VERSION: 0.1.2
|
||||||
// PURPOSE: PID library for Arduino
|
// PURPOSE: PID library for Arduino
|
||||||
// URL: https://github.com/RobTillaart/PID_RT
|
// URL: https://github.com/RobTillaart/PID_RT
|
||||||
|
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
|
|
||||||
|
|
||||||
class PID_RT
|
class PID_RT
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -87,4 +89,5 @@ private:
|
|||||||
bool _POI = true; // Proportional On Input - Error
|
bool _POI = true; // Proportional On Input - Error
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// -- END OF FILE --
|
// -- END OF FILE --
|
||||||
|
@ -7,10 +7,12 @@
|
|||||||
|
|
||||||
Arduino library for PID controller
|
Arduino library for PID controller
|
||||||
|
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
|
||||||
The PID_RT class allows the user to instantiate a PID controller.
|
The PID_RT class allows the user to instantiate a PID controller.
|
||||||
|
|
||||||
|
|
||||||
## Interface
|
## Interface
|
||||||
|
|
||||||
### Constructor
|
### Constructor
|
||||||
@ -18,6 +20,7 @@ The PID_RT class allows the user to instantiate a PID controller.
|
|||||||
- **PID_RT()** minimal constructor.
|
- **PID_RT()** minimal constructor.
|
||||||
- **PID_RT(float sp, float Kp, float Ki, float Kd)** constructor that sets minimal parameters to get started.
|
- **PID_RT(float sp, float Kp, float Ki, float Kd)** constructor that sets minimal parameters to get started.
|
||||||
|
|
||||||
|
|
||||||
### Core
|
### Core
|
||||||
|
|
||||||
- **void reset()** resets internals to startup.
|
- **void reset()** resets internals to startup.
|
||||||
@ -27,12 +30,14 @@ The PID_RT class allows the user to instantiate a PID controller.
|
|||||||
- **float getOutput()** get the last calculated output value.
|
- **float getOutput()** get the last calculated output value.
|
||||||
- **bool setK(float Kp, float Ki, float Kd)** Set the initial P I D parameters as a group.
|
- **bool setK(float Kp, float Ki, float Kd)** Set the initial P I D parameters as a group.
|
||||||
|
|
||||||
|
|
||||||
### Start Stop
|
### Start Stop
|
||||||
|
|
||||||
- **void start()** // enable the PID controller to compute new output values.
|
- **void start()** // enable the PID controller to compute new output values.
|
||||||
- **void stop()** disable the PID controller **compute()**.
|
- **void stop()** disable the PID controller **compute()**.
|
||||||
- **bool isRunning()**
|
- **bool isRunning()**
|
||||||
|
|
||||||
|
|
||||||
### Additional parameters
|
### Additional parameters
|
||||||
|
|
||||||
- **bool setInterval(uint32_t interval)** set the interval between 2 **compute()** calls. Returns **true** if changed, otherwise **false**.
|
- **bool setInterval(uint32_t interval)** set the interval between 2 **compute()** calls. Returns **true** if changed, otherwise **false**.
|
||||||
@ -53,6 +58,7 @@ The PID_RT class allows the user to instantiate a PID controller.
|
|||||||
- **bool isPropOnInput()** read back setting.
|
- **bool isPropOnInput()** read back setting.
|
||||||
- **bool isPropOnError()** read back setting.
|
- **bool isPropOnError()** read back setting.
|
||||||
|
|
||||||
|
|
||||||
### debugging calls
|
### debugging calls
|
||||||
|
|
||||||
Might be obsolete in future.
|
Might be obsolete in future.
|
||||||
@ -61,6 +67,7 @@ Might be obsolete in future.
|
|||||||
- **float getLastError()** read the last error.
|
- **float getLastError()** read the last error.
|
||||||
- **uint32_t getLastTime()** read the last.
|
- **uint32_t getLastTime()** read the last.
|
||||||
|
|
||||||
|
|
||||||
## Operations
|
## Operations
|
||||||
|
|
||||||
See examples.
|
See examples.
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
// connect a potmeter to A0
|
// connect a potmeter to A0
|
||||||
// play :)
|
// play :)
|
||||||
|
|
||||||
|
|
||||||
#include "PID_RT.h"
|
#include "PID_RT.h"
|
||||||
|
|
||||||
PID_RT PID;
|
PID_RT PID;
|
||||||
@ -20,6 +21,7 @@ const int PWM_PIN = 3; // UNO PWM pin
|
|||||||
int op = 0;;
|
int op = 0;;
|
||||||
float input = 0;
|
float input = 0;
|
||||||
|
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
@ -34,6 +36,7 @@ void setup()
|
|||||||
op = analogRead(A0);
|
op = analogRead(A0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
input = analogRead(A0);
|
input = analogRead(A0);
|
||||||
@ -48,4 +51,5 @@ void loop()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- END OF FILE --
|
|
||||||
|
// -- END OF FILE --
|
||||||
|
@ -3,22 +3,27 @@
|
|||||||
# Datatypes (KEYWORD1)
|
# Datatypes (KEYWORD1)
|
||||||
PID_RT KEYWORD1
|
PID_RT KEYWORD1
|
||||||
|
|
||||||
|
|
||||||
# Methods and Functions (KEYWORD2)
|
# Methods and Functions (KEYWORD2)
|
||||||
reset KEYWORD2
|
reset KEYWORD2
|
||||||
setPoint KEYWORD2
|
setPoint KEYWORD2
|
||||||
getSetPoint KEYWORD2
|
getSetPoint KEYWORD2
|
||||||
compute KEYWORD2
|
compute KEYWORD2
|
||||||
getOutput KEYWORD2
|
getOutput KEYWORD2
|
||||||
|
|
||||||
start KEYWORD2
|
start KEYWORD2
|
||||||
stop KEYWORD2
|
stop KEYWORD2
|
||||||
isRunning KEYWORD2
|
isRunning KEYWORD2
|
||||||
|
|
||||||
setReverse KEYWORD2
|
setReverse KEYWORD2
|
||||||
getReverse KEYWORD2
|
getReverse KEYWORD2
|
||||||
setInterval KEYWORD2
|
setInterval KEYWORD2
|
||||||
getInterval KEYWORD2
|
getInterval KEYWORD2
|
||||||
|
|
||||||
setOutputRange KEYWORD2
|
setOutputRange KEYWORD2
|
||||||
getOutputMin KEYWORD2
|
getOutputMin KEYWORD2
|
||||||
getOutputMax KEYWORD2
|
getOutputMax KEYWORD2
|
||||||
|
|
||||||
setK KEYWORD2
|
setK KEYWORD2
|
||||||
setKp KEYWORD2
|
setKp KEYWORD2
|
||||||
setKi KEYWORD2
|
setKi KEYWORD2
|
||||||
@ -26,10 +31,12 @@ setKd KEYWORD2
|
|||||||
getKp KEYWORD2
|
getKp KEYWORD2
|
||||||
getKi KEYWORD2
|
getKi KEYWORD2
|
||||||
getKd KEYWORD2
|
getKd KEYWORD2
|
||||||
|
|
||||||
setPropOnInput KEYWORD2
|
setPropOnInput KEYWORD2
|
||||||
setPropOnError KEYWORD2
|
setPropOnError KEYWORD2
|
||||||
isPropOnInput KEYWORD2
|
isPropOnInput KEYWORD2
|
||||||
isPropOnError KEYWORD2
|
isPropOnError KEYWORD2
|
||||||
|
|
||||||
getInput KEYWORD2
|
getInput KEYWORD2
|
||||||
getLastError KEYWORD2
|
getLastError KEYWORD2
|
||||||
getLastTime KEYWORD2
|
getLastTime KEYWORD2
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/RobTillaart/PID_RT"
|
"url": "https://github.com/RobTillaart/PID_RT"
|
||||||
},
|
},
|
||||||
"version":"0.1.1",
|
"version": "0.1.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"frameworks": "arduino",
|
"frameworks": "arduino",
|
||||||
"platforms": "*"
|
"platforms": "*"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name=PID_RT
|
name=PID_RT
|
||||||
version=0.1.1
|
version=0.1.2
|
||||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||||
sentence=Arduino PID library
|
sentence=Arduino PID library
|
||||||
|
@ -28,6 +28,7 @@ unittest_setup()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unittest_teardown()
|
unittest_teardown()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -97,6 +98,8 @@ unittest(test_compute)
|
|||||||
assertEqual(1, 1);
|
assertEqual(1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unittest_main()
|
unittest_main()
|
||||||
|
|
||||||
|
|
||||||
// --------
|
// --------
|
||||||
|
Loading…
Reference in New Issue
Block a user