Just before soon had a PID, part of the procedure is as follows, for reference only
/*==============================================================================
In the use of single-chip microcomputer as the control of the CPU, please simplify, the specific PID parameters must be determined by the concrete object through the experiment.
Because of the processing speed and the limitation of RAM resource, the floating-point arithmetic is not used, but all the parameters are all integers.
Computation to the last divided by a 2 of the n-th square data (equivalent to shift), for similar fixed-point number operations, can greatly improve the speed of operation,
According to the different requirements of control precision, when the precision requirement is high, pay attention to retain the "remainder" caused by the shift, and do well the remainder compensation.
This program is only the basic structure of commonly used PID algorithm, does not include the input and output processing part.
==============================================================================*/
#include <string.h>
#include <stdio.h>
/*===============================================================================
PID Function
The PID function is used in mainly
Control applications. PID Calc performs one iteration of the PID
Algorithm.
While the PID function works, main was just a dummy program showing
A typical usage.
PID function
The PID function is mainly used for control applications. The PID calculator performs a PID iterative algorithm. Although the PID function works,
Mostly just a virtual program that shows a typical use.
================================================================================*/
typedef struct PID {
Double setpoint; Set Target desired Value
Double proportion; Proportional constant Proportional Const
Double Integral; Integral constant Integral Const
Double derivative; Differential constant derivative Const
Double LastError; ERROR[-1]
Double Preverror; Error[-2]
Double Sumerror; Sums of Errors
} PID;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.