1-Laboratoriya ishi



Yüklə 5,01 Mb.
səhifə2/6
tarix11.12.2023
ölçüsü5,01 Mb.
#144573
1   2   3   4   5   6
1-4

2-Laboratoriya ishi
Arduino PID rostlagichlarni tadqiq etish
Ishdan maqsad: PID-rostlagichlarni ishlash prinsipi bilan tanishish va ularni tadqiq etish
PID (proportsional, integral, differensial) – bu texnologik jarayondagi turli qurilmalarini ishini sifatli rostlash uchun xozirda qullanilayotgan barcha kontrollerlarni tarkibiy qismida mavjud bo’lgan rostlagichdir. Bunda uchta asosiy komponent mavjud PID boshqaruvida jarayonni o’rnatilgan qiymatlar (SP) chetga chiqishlari o’tish vaqtida ma’lum vaqt ko’zatilib, so’ngra o’rnatilgan qiymati erishadi. Har bir tarkibiy qism o’zining oldinga qo'yilgan vazifa bo’yicha birgalikda ishlaydi.
P – proportsional kuchaytirgich bo’lib o’rnatilgan qiymatdan chetga chiqishiga mutanosib ravishda xato (error) signal xosil qiladi.
I – integral kuchaytirgich bo’lib o’rnatilgan qiymatdan chetga chiqish tezligiga mutanosib ravishda xato (error) signal xosil qiladi.
D – differensial kuchaytirgich bo’lib o’rnatilgan qiymatdan chetga chiqish vaqtiga va kechikishiga mutanosib ravishda xato (error) signal xosil qiladi.

PID rostlagichlar uchun rostlovchi ta'sirning miqdori rostlanuvchi kattalikning berilgan qiymatidan chetga chiqishga, shu chetga chiqishning integrali va tezligiga proporsionaldir (1-rasm). Bu rostlagichlar darak beruvchi izodrom rostlagichlar deyiladi va ular uchta sozlash kattaligiga ega: kuchaytirish koeffisienti – Kr, izodrom vaqti Ti, darak berish vaqti- Td va ∆.
PID algoritmi tenglama (1.1) da keltirilgan.

tenglamaga mutanosib, integral va differentsial qism mavjud. Konstantalar Kp, Ki va Kd harfning har bir qismining belgisi va ulishi oshirish uchun ishlatiladi.
Odatda sanoatda PID kontrollerlari operasion kuchaytirgichlardan tashkil topgan bo’ladi.

2-rasm


2. Xaroratni PID rostlagich bilan boshqarish



Sanoat korxonalarida eng ko‘p boshqaraladigan jarayon bu xaroratdir. Shuning uchun biz PID rostlagich bilan tajriba o‘tkazishda xaroratni tanladik. Bizga buning uchun Arduino kontrolleri termopara, qizdirgich (keramik) 16x02 displey, tranzistorlar (S8050, IRFZ44N tranzistorlar), qarshiliklar (10 kOm 4ta), MAX6675 (ARO‘), Enkoder va 12V blok pitaniya.
Dastlab qo‘yidagi dasturni Arduino dastur yozamida kontrollerning xotirasiga yozamiz.
//LCD config (i2c LCD screen, you need to install the LiquidCrystal_I2C if you don't have it )
#include
#include
LiquidCrystal_I2C lcd(0x3f,20,4); //sometimes the adress is not 0x3f. Change to 0x27 if it dosn't work.
#include
//We define the SPI pìns
#define MAX6675_CS 10
#define MAX6675_SO 12
#define MAX6675_SCK 13

//Pins
int PWM_pin = 3;


//Variables
float temperature_read = 0.0;
float set_temperature = 100;
float PID_error = 0;
float previous_error = 0;
float elapsedTime, Time, timePrev;
int PID_value = 0;
//PID constants
int kp = 9.1; int ki = 0.3; int kd = 1.8;
int PID_p = 0; int PID_i = 0; int PID_d = 0;
void setup() {
pinMode(PWM_pin,OUTPUT);
TCCR2B = TCCR2B & B11111000 | 0x03; // pin 3 and 11 PWM frequency of 980.39 Hz
Time = millis();
lcd.begin();
lcd.backlight();
}
void loop() {
// First we read the real value of temperature
temperature_read = readThermocouple();
//Next we calculate the error between the setpoint and the real value
PID_error = set_temperature - temperature_read;
//Calculate the P value
PID_p = kp * PID_error;
//Calculate the I value in a range on +-3
if(-3 < PID_error <3)
{
PID_i = PID_i + (ki * PID_error);
}
//For derivative we need real time to calculate speed change rate
timePrev = Time; // the previous time is stored before the actual time read
Time = millis(); // actual time read
elapsedTime = (Time - timePrev) / 1000;
//Now we can calculate the D calue
PID_d = kd*((PID_error - previous_error)/elapsedTime);
//Final total PID value is the sum of P + I + D
PID_value = PID_p + PID_i + PID_d;
//We define PWM range between 0 and 255
if(PID_value < 0)
{ PID_value = 0; }
if(PID_value > 255)
{ PID_value = 255; }
//Now we can write the PWM signal to the mosfet on digital pin D3
analogWrite(PWM_pin,255-PID_value);
previous_error = PID_error; //Remember to store the previous error for next loop.
delay(300);
//lcd.clear();
lcd.setCursor(0,0);
lcd.print("PID TEMP control");
lcd.setCursor(0,1);
lcd.print("S:");
lcd.setCursor(2,1);
lcd.print(set_temperature,1);
lcd.setCursor(9,1);
lcd.print("R:");
lcd.setCursor(11,1);
lcd.print(temperature_read,1);
}
double readThermocouple() {
uint16_t v;
pinMode(MAX6675_CS, OUTPUT);
pinMode(MAX6675_SO, INPUT);
pinMode(MAX6675_SCK, OUTPUT);
digitalWrite(MAX6675_CS, LOW);
delay(1);
// Read in 16 bits,
// 15 = 0 always
// 14..2 = 0.25 degree counts MSB First
// 2 = 1 if thermocouple is open circuit
// 1..0 = uninteresting status
v = shiftIn(MAX6675_SO, MAX6675_SCK, MSBFIRST);
v <<= 8;
v |= shiftIn(MAX6675_SO, MAX6675_SCK, MSBFIRST);
digitalWrite(MAX6675_CS, HIGH);
if (v & 0x4)
{
// Bit 2 indicates if the thermocouple is disconnected
return NAN;
}
// The lower three bits (0,1,2) are discarded status bits
v >>= 3;
// The remaining bits are the number of 0.25 degree (C) counts
return v*0.25;
}
Yuklab bo‘lgandan so‘ng bu elementlarni yuqoridagi sxema bo‘yicha ulaymiz blok pitaniyaga ulaymiz va kontroller ishga tushgandan so‘ng PID sozlashlarni bajaramiz.


Yüklə 5,01 Mb.

Dostları ilə paylaş:
1   2   3   4   5   6




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə