• Rezultati Niso Bili Najdeni

Priloga A - koda_temperatura

N/A
N/A
Protected

Academic year: 2022

Share "Priloga A - koda_temperatura"

Copied!
2
0
0

Celotno besedilo

(1)

Priloga A - koda_temperatura

#include <DallasTemperature.h>

#include <OneWire.h>

#include <AutoPID.h>

#include <LiquidCrystal_I2C.h>

//PRIKLOPI

#define POT_PIN A0

#define IZHOD_PWM 6

#define TEMP_SENZOR 4 //PID NASTAVITVE

#define IZHOD_MIN 0

#define IZHOD_MAX 255

#define KP 30

#define KI 1.6

#define KD 0

#define TEMP_BRANJE_ZAMIK 800

#define odstopek 2 //SPREMENLJIVKE

double temperatura, izhodna_vrednost, nastavljena_vrednost;

float T;

int temp_pot,

unsigned long posodobitev_temp;

OneWire oneWire(TEMP_SENZOR);

DallasTemperature sensors(&oneWire);

AutoPID myPID(&temperatura, &nastavljena_vrednost, &izhodna_vrednost, IZHOD_MIN, IZHOD_MAX, KP, KI, KD);

LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 16, 2);

bool updateTemperature() {

if ((millis() - posodobitev_temp) > TEMP_BRANJE_ZAMIK) { temperatura = sensors.getTempCByIndex(0); //get temp reading posodobitev_temp = millis();

(2)

sensors.requestTemperatures();

Serial.print("DATA,TIME,TIMER,");//request reading for next time Serial.print(izhodna_vrednost);

Serial.print(",");

Serial.print(temperatura);

Serial.print(",");

Serial.println(nastavljena_vrednost);

return true;

}

return false;

}

void setup() {

pinMode(POT_PIN, INPUT);

pinMode(IZHOD_PWM, OUTPUT);

pinMode(TEMP_SENZOR, INPUT);

Serial.begin(9600);

sensors.begin();

sensors.requestTemperatures();

Serial.println("CLEARDATA");

Serial.println("LABEL,Ura,Pretekel cas,PWM,Temperatura, Nastavljena temperatura");

Serial.println("RESETTIMER");

lcd.init();

lcd.backlight();

while (!updateTemperature()) {} //wait until temp sensor updated

//if temperatura is more than 2 degrees below or above setpoint, OUTPUT will be set to min or max respectively

myPID.setBangBang(odstopek);

//set PID update interval to 1000ms myPID.setTimeStep(1000);

}

void loop() {

updateTemperature();

temp_pot = analogRead(POT_PIN);

temp_pot = map(temp_pot, 0, 1023, -9, 85);

nastavljena_vrednost = temp_pot;

T = round(temperatura*10.0)/10.0;

lcd.setCursor(0,0);

lcd.print("Nastavljena T:");

lcd.print(nastavljena_vrednost);

lcd.print(" ");

lcd.setCursor(0,1);

lcd.print("Izmerjena T:");

lcd.print(T);

myPID.run(); //call every loop, updates automatically at certain time interval analogWrite(IZHOD_PWM, izhodna_vrednost);

}

Reference

POVEZANI DOKUMENTI

a) Temperatura vode se poveča. b) Temperatura vode se zmanjša. c) Temperatura vode se ne spremeni. Pri kateri temperaturi potekata taljenje ledu in zmrzovanje vode pri normalnem

Priloga D1: Ulovi metuljev koruzne vešče, povprečna dnevna temperatura zraka (°C), skupaj s priporočenimi datumi (J d ) škropljenj proti škodljivcem in predlaganimi

Priloga D: Koncentracije žvepla (mg SO 4 -S /l) na treh globinah (0 - 10cm, 10 -30 cm in 30 - 60cm), na laboratorijskem polju Biotehniške fakultete v Ljubljani Priloga E:

If the word was used only once by Blake, I don’t think there’s any doubt after reading Fallon’s book, that apotheosis provides a very useful way to approach Blake’s

If we compare the distributions of voleanites and uranium mineralizations contained in the Permian sandstone, we observe a close connection; this connection is obviously

Young people with fewer opportunities may be more open to the idea of EVS Short Term if they understand how the programme responds to their needs and how it

Ekonomsko integracijo smo opredelili kot stanje, v katerem imajo primerljive skupine prebivalstva, ne glede na etnično, versko ali kulturno pripadnost, enake možnosti in

Even if you don’t need help, it’s good to know you can get it if you need it.. This is what solidarity means