Coder Social home page Coder Social logo

lrklochek / control_system Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 33.15 MB

Software and Hardware to Build and Program a PID Controller for a Miniature Thermal Chamber

C++ 100.00%
pid-temperature-control pid pid-controller thermal-chamber process-control pid-algorithm-implementation process-dynamics education

control_system's Introduction

PID Temperature Control of a Miniature Thermal Chamber

Block Diagram

The PID Temperature Control of a miniature thermal chamber is a system designed for educational purposes. It can be used as an inexpensive lab for developing an understanding of process control and the effects of process dynamics on selecting the optimum PID (proportional, integral, and derivative) tuning constants. The system can be implemented inexpensively and would be ideal for a student doing an on-line course in process control systems. The system allows operating, PI, or PID control with reverse or forward (direct) acting control., by using selectable final control elements (resistive heater, or variable fan speed). The system provides 2 sets of process dynamics by tightly coupling a temperature sensor to the resistive heater or alternatively using a sensor in the centre of the chamber. These very different process dynamics require very different sets of PID tuning.

The system hardware consists of the miniature (100x68x50mm) thermal chamber, a control board and an interface board.

The control board consists of an Arduino Nano, a setpoint potentiometer for setting desire temperature in deg C and a disturbance potentiometer, selectable for either heater or fan. The outputs from the Nano are 2 pulse width modulated signals that produce a variable DC voltage that drives the fan and heater.

The interface board utilizes 2 N Channel power Mosfets and uses the PWM signals from the Nano to produce a PWM output with a maximum voltage of 12VDC to supply the thermal chamber heaters and fan.

The thermal chamber consists or 2 Cement resistor heaters of 5 watts each, a 12VDC fan, and 2 LM35DZ temperature sensors. One of the sensors measures the air temperature of the Chamber, while the other sensor is firmly attached to one of the temperature resistor heaters.

Thermal Chamber

The following image shows the open chamber, with the 2 cement resistor heaters. The resistor on the right has the sensor affixed to the resistor.

Chamber

The Schematic for the System is shown below:

Schematic

Hardware Components

  • LM35D Temeperature Sensors, Qty 2
  • Arduino Nano Microcontroller
  • 10Kohm Potentiometers
  • 5Kohm Potentiometer
  • 36 ohm 5 watt Cement Resistor – purchased from Digi Key
  • 30 ohm 5 watt Cement Resistor – purchased from Digi Key
  • IRF540N N channel Power Mosfets, Qty 2
  • 1N4001 Diodes, Qty 2
  • Red LED
  • Yellow LED
  • 220 ohm ¼ watt Resistors, Qty 2
  • 10K ohm ¼ watt Resistor *I2CLCD2004 20x4 LCD Display
  • Project Box LeMotech (100 x 68 x 50 mm)
  • Fan -50 * 50 * 10mm 2pin DC 12V Mini Silent
  • Gikfun 2 Pin (Qty 9) and 3 Pin (Qty 2) Screw Terminal Block Connector 5mm Pitch
  • YUNGUI 12Pcs 50X100mm 2-3-5 Joint Hole Universal PCB Boards Single Side, Qty 2
  • Binding Posts (4 different colours), Qty 4
  • Dupont Jumper wires

The block diagram below shows the interconnection of the boards and thermal chamber. Note that the Arduino Serial Plotter is used to display the Temperatures and Setpoints and is also used to generate commands to the Arduino PID Controller.

Block Diagram

LM35_1 - Sets the PID controlled variable as the temperature of one of the cement resistor heaters. In the phot, it is the cement resistor on the right. Tuning Constants are optimal using Ziegler Nichols Open Loop method.

LM35_2 - Sets the PID Controlled variable as the temperature of the sensor in the middle of the chamber. Tuning Constants are optimal using Ziegler Nichols Open Loop method.

LM35_1Fast - Sets PID controlled variable to heater temperature sensor, PID tuning constants for a fast oscillatory response

LM35_1Slow - Sets PID controlled variable to heater temperature sensor, PID tuning constants for a slow stable response

LM35_2Fast - Sets PID controlled variable to air temperature sensor, PID tuning constants for a fast oscillatory response

LM35_2Slow - Sets PID controlled variable to air temperature sensor, PID tuning constants for a slow stable response

Reverse sets the PID controller to Reverse acting, where the temperature is controlled by the PID adjusting the voltage to the cement resistor heater. The fan then can be manually adjusted by the potentiometer to act as a disturbance.

Forward sets the PID controller to Forward(Direct) acting where the temperature is controlled by adjusting the fan voltage, and therefor air flow to the chamber. The heater then can be manually adjusted by the potentiometer to act as a disturbance.

Manual disables the PID controller and allows the the setpoint potentiometer to fix either the heater or fan setting from 0 to 100%. There is no feed back. This is referred to as open loop.

Auto enables the PID controller, either Reverse or Forward acting.

Thermal Chamber Temperature Control System Features.

Chamber

  • Small volume chamber 100mmx68mmx50mm
  • Heater Temperature sensor affixed to resistive heater
  • Air temperature sensor
  • 2 resistive heaters (30 and 36 ohms), 12 VDC supply to heaters
  • Maximum heater temperature approx. 135 deg C
  • Maximum air temp about 60 deg C
  • 2 distinctly different sets of process dynamics

PID Controller

  • Standard (sometimes called Mixed) algorithm
  • Most commonly used in industry
  • Select Reverse or Forward (Direct) acting
  • Reverse uses heater as final control element
  • Forward uses fan as final control element
  • 2 sets of PID tuning constants for 2 different process dynamic cases
  • Auto/Manual selection

Display

  • Runs independently with LCD display or along with Arduino Serial Plotter
  • LCD
  • Heater temperature deg C
  • Air temperature deg C
  • Setpoint in deg C
  • Fan or Heater manual setting 0 to 100%
  • PID components displayed in real time
  • Proportional component
  • Integral component
  • Derivative component
  • Cout - total of three PID components

Plotting

  • Uses Arduino IDE serial plotter
  • Plots Heater and air temperatures
  • Plots Setpoint or Manual setting
  • Generates the following commands
  • Auto – sets PID controller to automatic
  • Manual – sets system to manual open loop operation
  • Reverse – sets PID to reverse acting using heater as controller output
  • Forward – sets PID to forward acting using fan as controller output
  • LM35_1 – sets PID controlled variable to heater temperature sensor
  • LM35_2 – sets PID controlled variable to air temperature sensor  

Electronics

  • Arduino Nano microcontroller*Connects to LCD Display via I2C bus
  • Generates 2 PWM outputs to Power Mosfet Interface board
  • C Code generated from Arduino IDE
  • Setpoint and disturbance generated from 2 potentiometers connected to Nano analog inputs
  • Temperature sensors – LM35 – generate 0 to 1.5 volts for 0 to 150 deg C
  • Power Mosfets IRF540N are switched at 490 Hz and operate via Pulse Width Modulation to vary the voltage on the heaters

How Does the PID Work?

Before the use of microcontrollers and computers PID controllers were implemented with analog electronic devices, the principle one being the operational amplifier. Implementing PID control digitally uses an algorithm. There are several versions of the PID controller. The one implemented in this project is sometimes referred to as the Mixed or Standard implementation. The mathematics of the mixed PID controller can be represented as the following.

Math

Where: Kc is the controller gain, Ti is the integral time, Td is the derivative time, and e is the error. Sometimes controller gain is represented as Kc = 100%/PB where PB is referred to as Proportional Band. A smaller PB then results in a larger gain . The following is pseudo code for implementing the PID algorithm. It is not in the form of an actual programming language but more in the form of a flow diagram.

Pseudo Code

The following is a simplified implementation for PID using C language:

Simplified PID Code

Open Loop Response for the Thermal Chamber.

When the PID Controller is put into Manual mode, that is the PID controller is disabled and a fixed value set by the potentiometer, an open loop response can be generated. This is very useful, because the open loop response yields valuable information about the dynamics of the process.

For the Thermal Chamber suddenly changing the fixed heater setting to another fixed heater setting (called a Step Change), we can observe how, and how quickly the temperature changes.

For the Air temperature, we would expect a much slower and smaller response than for the cement resistor temperature.

These different responses characterize the process dynamics of the system. Getting the best response by our PID controller will require different Proportional Band, Integral time and Derivative time settings. Theses settings are known as the tuning constants. Using the open loop response, and a method called Ziegler Nichols we can generate a set of tuning constants by analyzing the plot of the open loop response.

The following plot is an open loop response for the temperature sensor attached to the cement resistor heater. Superimposed on the plot is the Ziegler Nichols calculations for determining the 'best" tuning constants.

Open Loop Response Dec 7

The following chart is from an Excel spread sheet for using the information from the plot to calculate a set of PID and PI tuning constants:

Tuning Constant Spread Sheet.jpg

When these tuning constants are used they yield a response sometimes referred to as Quarter Decay. That is, the temperature will overshoot and undershoot several times with each successive overshoot being reduce to a quarter of the previous cycle. After several of these cycles, the temperature will reach the desired setpoint, referred to as steady state.

Why is the PID Temperature Control of a Miniature Thermal Chamber So Useful as an Educational Platform?

Because of the flexibility of the system ( 2 sets of very different process dynamics, a reverse and forward acting controller, open loop and closed loop control) many labs can be set up to calculate tuning constants and then demonstrate operation of a process control system using these tuning constants for the 2 processes and for Reverse and Forward acting controllers. This would enable a student to have a working knowledge of process control and make adapting to controlling industrial processes much more quickly and confidently.

control_system's People

Contributors

lrklochek avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.