https://github.com/vedantparanjape/pid-plotter-component
ESP-IDF component for pid plotter
https://github.com/vedantparanjape/pid-plotter-component
c esp-idf-framework esp32 freertos
Last synced: 10 months ago
JSON representation
ESP-IDF component for pid plotter
- Host: GitHub
- URL: https://github.com/vedantparanjape/pid-plotter-component
- Owner: VedantParanjape
- License: mit
- Created: 2020-03-15T12:04:58.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-13T16:39:40.000Z (over 5 years ago)
- Last Synced: 2025-01-14T00:49:45.226Z (12 months ago)
- Topics: c, esp-idf-framework, esp32, freertos
- Language: C
- Homepage: https://vedantparanjape.github.io/pid-plotter-component/
- Size: 1.23 MB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PID-Plotter
* ESP-IDF component for [pid-tuning-gui](https://github.com/VedantParanjape/pid-tuning-gui). This transports data, between the plotter and esp device.
Example App: 
# Requirements
* [logger](https://github.com/VedantParanjape/logger)
# Installation
cd
mkdir components
cd components
cp $IDF_PATH/examples/common_components/protocol_examples_common . -r
git clone https://github.com/VedantParanjape/logger
git clone https://github.com/VedantParanjape/pid-plotter-component pid_plotter
*Change CMakeList.txt to add the line given below:*
set(EXTRA_COMPONENT_DIRS )
# How to use
* Set UDP and TCP server IP address and port in menuconfig, under component config
* Set wifi ssid and password to use.
* include "pid_plotter.h"
* `plotter()` must be called in app_main
* `send_to_queue(pid_data_struct)` must be used to push pid_data struct to the message queue, by passing such a struct to this function, this data will be sent to client for plotting.
* `pid_const_read()` returns the pid_const struct received from user.
# Working
* PID Constants (Kp, Ki, Kd, and setpoint) are received by esp32, by connecting to a tcp server.
* TCP server should send the values as a json string.
```
{
"Kp" : 1.0,
"Ki" : 2.0,
"Kd" : 3.0,
"SetPoint" : 4.0
}
PID constants json format
```
* Calculated PID values (P, I, D, current, error) are sent by esp32 through udp, sent to a udp server.
* Values are sent as a json string through UDP.
```
{
"P" : 1.0,
"I" : 2.0,
"D" : 3.0,
"current" : 4.0,
"error" : 5.0
}
PID data json format
```
# Example Code
* Detailed Example App: 
```C
#include "pid_plotter.h"
void broad()
{
struct pid_terms dt;
dt.current = 1.00;
dt.error = 2.00;
dt.P = 3.00;
dt.I = 4.00;
dt.D = 5.00;
while(1)
{
esp_err_t err = send_to_queue(dt);
err = send_to_queue(dt);
logD("main", "%f", pid_const_read().setpoint);
vTaskDelay(10);
}
}
void app_main(void)
{
xTaskCreate(broad, "send", 4096, NULL, 1, NULL);
plotter();
}
```
# Detailed documentation
* https://vedantparanjape.github.io/pid-plotter-component/