0% found this document useful (0 votes)
39 views18 pages

Arduino PID Brightness Control Guide

The document discusses the implementation of a brightness control system using a Proportional Integral Derivative (PID) controller with Arduino. It details the setup, including the necessary libraries and components, as well as two tests to evaluate the system's response to controlled and uncontrolled environments. The document also provides links for further resources and insights into PID control processes.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views18 pages

Arduino PID Brightness Control Guide

The document discusses the implementation of a brightness control system using a Proportional Integral Derivative (PID) controller with Arduino. It details the setup, including the necessary libraries and components, as well as two tests to evaluate the system's response to controlled and uncontrolled environments. The document also provides links for further resources and insights into PID control processes.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Brightness control using PID controller

(Proportional Integral Derivative).

Proportional integral derivative controller, PID controller PID or simply, is a


technique for process control that binds the actions derivative, integral and
proportional, thus causing the error signal is minimized by proportional
action, integral action for zero and got with a Speed anticipative by
derivative action.
It is based on mathematical modeling of the response of a loop process to be
controlled.
In practice the PID are found inside electronic controllers called "single-
loop", often with microprocessors, and also through software programmable
controllers and other control equipment.

In this project, we simulate a brightness control with Arduino, turning the


PID library which can be found at:

[Link]

For this we need to download besides the PID library for Arduino, also the
PID Front End for processing, which is a graphical interface so we can set
the parameters: P, I, D, set point, operating modes, etc. ...; interfacing with
the Arduino.
You can download the Front End on the link above.

How we work with Arduino and Processing, need to have the Arduino IDE
and Processing 1.0.1 2.0b8 installed on your computer.
For Processing, need the library for processing ContorlP5 installed. Download
the library at:

[Link] # installation
Mairoes For details on PID control processes, advise to visit the creator's
website PID_V1 Library.

[Link]
introduction/

And the Control Guru site for more details on automation and control.

[Link]

Details on control systems:

[Link]

Let us now turn to the constructive aspects of our


project:

We will do two tests, one with the simulated environment by a dark tube,
which admits no outside interference, and the other where we can intervene
externally and check the system response.

Test - 1
The environment is simulated by a black tube with a Bright White LED on
one end (to illuminate the "environment") and the other end an LDR (so we
can manage the amount of light in the "environment").
The connection with the Arduino is very simple:
Pin D3 (as output) connected to the LED that has a resistor R220 to control
the current.
Pin A0 connected to LDR that has a pull-down resistor of 10K.
Below the circuit designed with Fritzing and photos of the actual system.

Between the LED and LDR there is a black tube sealed, simulating totally dark environment
Detail of the black tube (we used a spool of thread, sealed by two passers rubber thread

Detail side LED


Detail side LDR

Test - 2

Now the environment can suffer from external actions, called our system
disorders such as excessive light and shadows and the environment.
The disturbances are automatically controlled by Arduino PID.

Another detail is that the Setpoint value, is controlled by a potentiometer, no


longer need to use the setpoint PID_FrontEnd.

Below the circuit drawing and photos fritizing real system.


SetPoint control done by pot
Control via Software:
1 - Download and unzip the libraries;
PID_V1 the library directory of the Arduino IDE
Front End PID in a folder on your PC
ControlP5 in the library directory of Processing

2 - Start the Arduino IDE and open the file


"PID_FrontEnd_ArduinoSampleCode" folder PID_FrontEnd.
Send this scketch for arduino.

3 - Start Processing and open the file "PID_FrontEnd_v03" folder


PID_FrontEnd.
Run the application.
Below are some figures:

Folders belonging to PID_FrontEnd.


The PID file-FrontEnd_v03, should be opened and run in Processing
PID_FrontEnd_ArduinoSampleCode The file must be opened in the Arduino IDE and sent
Processing and Arduino IDE, just send and execute.

When running the application in Processing, PID_FrontEnd window will open.


SetPoint = 950, Kp = 0.01, Ki = 0.28 and Kd = 0

In this window, we can see:


TOGGLE_AM - changes the mode to automatic or manual PID;
SETPOINT - desired amount of light in the environment;
INPUT - actual value of the ambient brightness (measured by LDR and
returned as feedback measured on pin A0);
OUTPUT - control value returned by the Arduino as a PID controller (control
brightness of the LED on pin D3);
KP - constant proportional control;
KI - constant control Integral;
KD - Constant control Derivatives;
TOOGLE_DR - changes the direction (if output grows as grows the entry or
the reverse);
SEND_TO_ARDUINO - send data to the Arduino;

PID Input / Setpoint - Window of turns setpoint (desired value for


brightness) and input (measure of brightness LDR)
PID Output - Graphic window curve control output LED

Green line = Set Point SP, Red Line = Controlled Variable PV; Blue Line Composite Variable =
MV

In this figure, we can notice the setpoint set to 950 (green line), the input
variable (red line) suffering and PID control output variable (blue line) to
control brightness.

We also understand the information described acimas through a block


diagram (figure below).
Where we can notice that the Error = SP - PV and error is applied to the PID
controller that generates the MV for process control.

Each controller P, I and D can be used independently or jointly as:


P controller (very used)
PI controller (very used)
PD controller (rarely used)
PID controller (most used)
Example of PI controller with direct feedback
Here in this figure, we observe a change in the setpoint value (from 950 to
700 and 950) and the performance of PID control on the input variable.
You see there was a bit of oscillation in control (characteristic of each
controlled system, first or second order).

For the second test, we will send to the Arduino, the sketch below:
(This will be used in place of the file
"PID_FrontEnd_ArduinoSampleCode")

[Link]

Recalling that the control is done by Setpoint potentiometer.


As a source of disorder, we can use a flashlight to focus more light or a
screen to shade the LDR.
When we have a disturbance in the process (eg shadow), the controller will
increase / decrease the brightness of the LED to try to keep the output
under control and at the level set by the setpoint (in the case of making a
"shadow of the LDR, the controller will increase light intensity of the LED),
we can see these changes in PID_FrontEnd graphically.

Below are some figures related.

Kp = 0, Ki = 10, Kd = 0 - application of disturbance and variations in SP


Kp = 0, Ki = 10, Kd = 0 - application of disturbance (with blocking and non-blocking)
The arrow indicates the change of parameters Kp = 0.01, Ki = 0.28, Kd = 0 (note that the action
was slower and less overshoot)
When testing parameters, similar behavior was observed for the two tests.

You might also like