@@ -5,7 +5,8 @@ PID Controller library for ARM Cortex M (STM32)
55
66> #### Download Arduino Library : [ Arduino-PID-Library] ( https://github.com/br3ttb/Arduino-PID-Library )
77
8- ### Version : 1.0.0
8+ ## Release
9+ - #### Version : 1.0.0
910
1011- #### Type : Embedded Software.
1112
@@ -21,13 +22,14 @@ PID Controller library for ARM Cortex M (STM32)
2122- #### Required Library/Driver :
2223
2324
25+ ## Overview
2426### Initialization and de-initialization functions:
2527``` c++
2628void PID (PID_TypeDef * uPID, double * Input, double * Output, double * Setpoint, double Kp, double Ki, double Kd, PIDPON_TypeDef POn, PIDCD_TypeDef ControllerDirection);
2729void PID2(PID_TypeDef * uPID, double * Input, double * Output, double * Setpoint, double Kp, double Ki, double Kd, PIDCD_TypeDef ControllerDirection);
2830```
2931
30- ### PID operation functions:
32+ ### Operation functions:
3133```c++
3234/* ::::::::::: Computing ::::::::::: */
3335uint8_t PID_Compute(PID_TypeDef *uPID);
@@ -57,33 +59,67 @@ double PID_GetKd(PID_TypeDef *uPID);
5759```
5860
5961### Macros:
62+ ``` diff
63+ non
64+ ```
65+
66+ ## Guide
67+
68+ #### This library can be used as follows:
69+ #### 1. Add pid.h header
70+ #### 2. Create PID struct and initialize it, for example:
71+ * Initializer:
72+ ``` c++
73+ PID (PID_TypeDef * uPID, double * Input, double * Output, double * Setpoint, double Kp, double Ki, double Kd, PIDPON_TypeDef POn, PIDCD_TypeDef ControllerDirection);
74+ ```
75+ * Parameters:
76+ * uPID : Pointer to pid struct
77+ * Input : The variable we're trying to control (double)
78+ * Output : The variable that will be adjusted by the pid (double)
79+ * Setpoint : The value we want to Input to maintain (double)
80+ * Kp,Ki,Kd : Tuning Parameters. these affect how the pid will change the output (double>=0)
81+ * POn : Either P_ON_E (Default) or P_ON_M. Allows Proportional on Measurement to be specified.
82+ * ControllerDirection : Either DIRECT or REVERSE. determines which direction the output will move when faced with a given error. DIRECT is most common
83+
84+
85+ * Example:
86+ ```c++
87+ PID_TypeDef TPID;
88+
89+ double Temp, PIDOut, TempSetpoint;
6090
61- ## How to use this library
62-
63- ### The PID library can be used as follows:
64- 1.1 Add pid.h header
65-
66- 2.1 Initialize:
67-
68- ``` c++
69- PID_TypeDef TPID;
70-
71- double Temp, PIDOut, TempSetpoint;
72-
73- PID (&TPID, &Temp, &PIDOut, &TempSetpoint, 2, 5, 1, _ PID_P_ON_E, _ PID_CD_DIRECT);
74-
75- PID_SetMode(&TPID, _ PID_MODE_AUTOMATIC);
76- PID_SetSampleTime(&TPID, 500);
77- PID_SetOutputLimits(&TPID, 1, 100);
78- ```
79-
80- 3.1 Using Compute function, for example:
91+ PID(&TPID, &Temp, &PIDOut, &TempSetpoint, 2, 5, 1, _PID_P_ON_E, _PID_CD_DIRECT);
92+ ```
93+ #### 3. Set 'mode', 'sample time' and 'output limit', for example:
94+ * Functions:
95+ ``` c++
96+ void PID_SetMode (PID_TypeDef * uPID, PIDMode_TypeDef Mode);
97+ void PID_SetOutputLimits(PID_TypeDef * uPID, double Min, double Max);
98+ void PID_SetSampleTime(PID_TypeDef * uPID, int32_t NewSampleTime);
99+ ```
100+ * Parameters:
101+ * uPID : Pointer to pid struct
102+ * Mode : _PID_MODE_AUTOMATIC or _PID_MODE_MANUAL
103+ * Min : Low end of the range. must be < max (double)
104+ * Max : High end of the range. must be > min (double)
105+ * NewSampleTime : How often, in milliseconds, the PID will be evaluated. (int>0)
106+
107+ * Example:
108+ ```c++
109+ PID_SetMode(&TPID, _PID_MODE_AUTOMATIC);
110+ PID_SetSampleTime(&TPID, 500);
111+ PID_SetOutputLimits(&TPID, 1, 100);
112+ ```
113+
114+ #### 4. Using Compute function, for example:
81115
82116``` c++
83117PID_Compute (&TPID);
84118```
85119
86- ##### Example 1:
120+ ## Examples
121+
122+ #### Example 1: PID Compute for temperature
87123```c++
88124#include "main.h"
89125#include "pid.h"
@@ -121,8 +157,8 @@ int main(void)
121157```
122158
123159## Tests performed:
124- - [ ] Run on AVR
125160- [x] Run on STM32 Fx cores
126161
127- #### Developer: Majid Derhambakhsh
162+ ## Developers:
163+ - ### Majid Derhambakhsh
128164
0 commit comments