Questions tagged [pid]

A PID controller is a control loop feedback mechanism (controller) commonly used in industrial control systems. Use this tag for discussions about PID algorithms and libraries.

What is a PID controller?

A PID controller continuously calculates an "error value" as the difference between a measured process variable and a desired setpoint.

The letters PID stand for:

  • Proportional
  • Integral
  • Derivative

Basically a PID algorithm takes two variables:

  • The current measured value (eg. current fish tank temperature)
  • The desired (target) temperature (eg. 25 °C)

The output is the manipulated variable (eg. in this case the amount of power to a heater).

For example, if the measured temperature was 20 °C and the target temperature was 25 °C, then the manipulated variable might be 5 (being the difference between the target and the actual).

The proportional configuration parameter simply multiplies the error by a fixed (proportional) amount. So in this case as the temperature of the tank approaches the target it would reduce the power to the heater.

The derivative configuration parameter multiplies the error by a derivative of the error (that is, the rate of change of the error). This means you might reduce the power as the temperature approaches the target, so as to not overshoot.

The integral configuration parameter multiplies the error by the accumulation of past errors, to compensate for the corrections being applied too slowly or too quickly.


Library

There is an Arduino PID library (see Reference below) which allows you to supply the appropriate variables (target, error) and your tuning parameters (P, I and D).

You call the Compute function from time to time (eg. when going through the main loop) and it calculates a new manipulated variable, which you would then use to control your heater / motor / cooler / light or whatever-it-is you are controlling.


Reference

57 questions
10
votes
1 answer

Controlling water temperature accurately

I have following setup: Arduino Duemilanove Small water heater connected with optical relay (PWM is ok) Waterproof DS18B20 temperature sensor Unknown amount of water (but temperature sensor and heater are always underwater). How can I accurately…
Olli
  • 265
  • 2
  • 10
6
votes
2 answers

What is the proper way to implement PID?

I'm having some trouble conceptualizing how to go about implementing PID into my drone. There are a few ways I'm thinking about implementing the pipeline: Having one PID Object for each of the six motors. Having one PID Object for each axis. How I…
tuskiomi
  • 205
  • 1
  • 11
4
votes
5 answers

Control Speed of DC FAN Using Arduino PID Library

I want to make a circuit that control speed of DC fan Using Arduino PID Library to get thing at specific temperature. The circuit looks like this but can be changed, The dc fan motor connected to PWM 3 and thermistor connected with pin A0. The…
ANKIT JAIN
  • 185
  • 2
  • 4
  • 12
4
votes
1 answer

Arduino timer interrupts for PID

I'm working on a robotics project where an arduino nano is acting as the motion controller. I'm trying to use a trapezoidal motion profile generator and PID loop to follow that profile, but I found out the motion was quite jerky and I assumed it's…
OM222O
  • 199
  • 1
  • 7
4
votes
1 answer

QuadCopter PID using MPU6050

I am using Arduino Uno, with PID library and Jeff Rowberg library for MPU6050 i.e I2Cdev.h, MPU6050_6Axis_MotionApps20.h. There is one PID for each axis i.e Pitch and Roll, I am getting output that wobbles and is unstable. I don't know whether my…
Aditya Raj
  • 49
  • 1
  • 5
3
votes
0 answers

HC05 and ELM327 NODATA sending PID codes

I am working on a project where I am using an HC05 connected to an Arduino to connect to an ELM327 Bluetooth scanner. I am using the SoftwareSerial Arduino library to send and read information from and too the HC05 using the following code. However…
3
votes
3 answers

How can an Arduino-Quadcopter be stabilized?

I have built an arduino quad-copter and I am using an MPU6050 to read the rotational position and velocity of the aircraft. The problem is that I cannot get the thing to stabilize. Watch this video here to get an idea of what I mean. So as you can…
Ember
  • 83
  • 2
  • 12
3
votes
0 answers

Why doesn't PWM work on arduino in this code?

I am trying to control a dc motor speed with PWM. When I test it with simple program like spin in one direction with set PWM value it works. If PWM>70 the motor will start spinning and max is 255. But when I try to do the same in code below it only…
Prsli
  • 31
  • 3
2
votes
0 answers

I need help making an arduino control system

My project is to use an Arduino to control two solenoid valves with pwm and receive an input signal from a sensor as feedback. As can be seen from the picture, the valves direct the flow of water which cause a hydraulic actuator to move which is…
2
votes
0 answers

Bug in code of Self-Balancing Bot

1)The values drifts to the extreme every time I run this , I guess this is due to my mistake in the calculation of angles or in the filter that I have applied which I have been trying to but can't find it. 2)I have tried to calibrate MPU many times…
Aditya Raj
  • 43
  • 4
2
votes
2 answers

Assistance with PID DC Motor Acceleration

I'm working on a project that uses an Arduino UNO and a motorized fader to send and receive MIDI data from my computer/musical keyboard. I'm trying to set up my motor with PID to control the position and speed of the motor - Been having some…
zRockafellow
  • 131
  • 7
2
votes
0 answers

Brushless ESC Recommendations

I've got a project in which I'll be controlling 8 24V/10A brushless DC motors with an Arduino Due on a quadrupedal robot. I've been having trouble finding ESCs that would work well for this application and was wondering if anyone could provide…
2
votes
2 answers

ESP32: How to run two independent PID controllers, one per core?

I want to control 2 independent processes with 2 PID controllers. Is it possible to run each controller on a separate core? I'm using this PID library. According to its documentation, the PID::Compute() function should be called once every loop().…
glamis
  • 61
  • 1
  • 7
2
votes
2 answers

Arduino PID controller for Triac

I am designing a new soldering station which will use a 24 V ac soldering iron. I started to make some research and I designed a few steps of the soldering station. I will use a 24Vac/100VA toroidal transformer. I will use a 24V/50W soldering iron…
beard999
  • 93
  • 8
2
votes
1 answer

Switch Control Between Two Different Techniques

I have implemented PID control of a generator governor to maintain a constant RPM using an Arduino Uno. It works pretty well, but there is a tradeoff between stabilty and response time. Using PID values that allow it to respond without oscillation…
1
2 3 4