Translate

Alat Penunjuk Arah Compass dengan Fitur Stabilizer Arah

Alat Penunjuk Arah Compass dengan Fitur Stabilizer Arah
 

        Pada kesempatan kali saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang bisa melakukan tracking titik menggunakan kompas sensor. jadi titik diinputkan menggunakan keypad lalu stepper akan mencari titik tersebut. setelah titik tersebut didapat maka sistem akan menjaga titik tersebut walaupun stepper digeser atau dirubah arahnya. untuk lebih jelasnya berikut adalah skema dan kodingnya.
 
 
 
a. Skema Alat

b. Program Arduino IDE

#include <Wire.h>
#include <Keypad.h>
#include <HMC5883L.h>
#include <LiquidCrystal.h>

#define dirPin 13
#define stepPin 12
#define stepsPerRevolution 800 // sesuaikan dengan settingan SW1-SW3 pada modul motor driver

LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

HMC5883L compass;

int nilaisudut = 0;
int nilaisudutfix;
int mark = 0;
char customKey;
const byte ROWS = 4;
const byte COLS = 4;

char keys[ROWS][COLS] = {
{'/', 'C', '-', '+'},
{'=', '9', '6', '3'},
{'0', '8', '5', '2'},
{'*', '7', '4', '1'}
};

byte rowPins[ROWS] = {8,9,10,11}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {A0,A1,A2,A3}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS);


void setup(){
 
  Wire.begin();
  lcd.begin(16, 2);
  lcd.clear();
  lcd.noCursor();
  Serial.begin(9600);
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);

  // Initialize Initialize HMC5883L
  Serial.println("Initialize HMC5883L");
  while (!compass.begin())
  {
    Serial.println("Could not find a valid HMC5883L sensor, check wiring!");
    delay(500);
  }
 

  // Set measurement range
  compass.setRange(HMC5883L_RANGE_1_3GA);

  // Set measurement mode
  compass.setMeasurementMode(HMC5883L_CONTINOUS);

  // Set data rate
  compass.setDataRate(HMC5883L_DATARATE_30HZ);

  // Set number of samples averaged
  compass.setSamples(HMC5883L_SAMPLES_8);

  // Set calibration offset. See HMC5883L_calibration.ino
  compass.setOffset(0, 0);

carititiknol();

}


void loop(){

customKey = customKeypad.getKey();

  if(customKey >= '0' && customKey <= '9')
  {
      nilaisudut = nilaisudut * 10 + (customKey - '0');
      lcd.setCursor(0,1);
      lcd.print("S:");
      lcd.print(nilaisudut);
      lcd.print("     ");
  }


  if(customKey == '*')
  {
   nilaisudutfix = nilaisudut;
   nilaisudut = 0;
   lcd.clear();
   mark = 1;
   delay(200);
  }

if(nilaisudutfix > 350){
nilaisudutfix = 350;
}

if(mark == 1){
delay(1000);
carititiknol();
carititik();
}

lcd.setCursor(0,1);
lcd.print("S:");
lcd.setCursor(8,1);
lcd.print("M:");
lcd.print(nilaisudutfix);
lcd.print("   ");

//============================================================================  
  Vector norm = compass.readNormalize();

  // Calculate heading
  float heading = atan2(norm.YAxis, norm.XAxis);

  float declinationAngle = (4.0 + (26.0 / 60.0)) / (180 / M_PI);
  heading += declinationAngle;

  // Correct for heading < 0deg and heading > 360deg
  if (heading < 0)
  {
    heading += 2 * PI;
  }

  if (heading > 2 * PI)
  {
    heading -= 2 * PI;
  }

  // Convert to degrees
  float headingDegrees = heading * 180/M_PI;

  lcd.setCursor(0,0);
  lcd.print("Sudut= ");
  lcd.print(headingDegrees);
  lcd.print("    ");


if((nilaisudutfix > 0)&&(headingDegrees < nilaisudutfix - 10)){
      digitalWrite(dirPin, LOW); // putar CW jarum jam
      digitalWrite(stepPin, HIGH);
      delayMicroseconds(1000); // ganti delay untuk mempercepat motor
      digitalWrite(stepPin, LOW);
      delayMicroseconds(1000); // ganti delay untuk mempercepat motor
}

if((nilaisudutfix > 0)&&(headingDegrees > nilaisudutfix + 10)){
      digitalWrite(dirPin, HIGH); // putar CCW jarum jam
      digitalWrite(stepPin, HIGH);
      delayMicroseconds(1000); // ganti delay untuk mempercepat motor
      digitalWrite(stepPin, LOW);
      delayMicroseconds(1000); // ganti delay untuk mempercepat motor
}

 
}


void carititiknol(){
 
//============================================================================  
  Vector norm = compass.readNormalize();

  // Calculate heading
  float heading = atan2(norm.YAxis, norm.XAxis);

  float declinationAngle = (4.0 + (26.0 / 60.0)) / (180 / M_PI);
  heading += declinationAngle;

  // Correct for heading < 0deg and heading > 360deg
  if (heading < 0)
  {
    heading += 2 * PI;
  }

  if (heading > 2 * PI)
  {
    heading -= 2 * PI;
  }

  // Convert to degrees
  float headingDegrees = heading * 180/M_PI;

  lcd.setCursor(0,0);
  lcd.print("Sudut= ");
  lcd.print(headingDegrees);
  lcd.print("    ");

if((headingDegrees >= 150)&&(headingDegrees <= 360)){  
  digitalWrite(dirPin, LOW); // putar CW jarum jam
  digitalWrite(stepPin, HIGH);
  delayMicroseconds(700); // ganti delay untuk mempercepat motor
  digitalWrite(stepPin, LOW);
  delayMicroseconds(700); // ganti delay untuk mempercepat motor
}

if((headingDegrees >= 1)&&(headingDegrees < 150)){
  digitalWrite(dirPin, HIGH); // putar CCW jarum jam
  digitalWrite(stepPin, HIGH);
  delayMicroseconds(700); // ganti delay untuk mempercepat motor
  digitalWrite(stepPin, LOW);
  delayMicroseconds(700); // ganti delay untuk mempercepat motor
}

if((headingDegrees >= 0)&&(headingDegrees < 1)){
mark = 0;
lcd.clear();
delay(1000);  
return;  
}  
 
carititiknol();
}



void carititik(){
 
//============================================================================  
  Vector norm = compass.readNormalize();

  // Calculate heading
  float heading = atan2(norm.YAxis, norm.XAxis);

  float declinationAngle = (4.0 + (26.0 / 60.0)) / (180 / M_PI);
  heading += declinationAngle;

  // Correct for heading < 0deg and heading > 360deg
  if (heading < 0)
  {
    heading += 2 * PI;
  }

  if (heading > 2 * PI)
  {
    heading -= 2 * PI;
  }

  // Convert to degrees
  float headingDegrees = heading * 180/M_PI;

  lcd.setCursor(0,0);
  lcd.print("Sudut= ");
  lcd.print(headingDegrees);
  lcd.print("    ");

if((nilaisudutfix >= 0)&&(nilaisudutfix <= 175)){  
  digitalWrite(dirPin, LOW); // putar CW jarum jam
  digitalWrite(stepPin, HIGH);
  delayMicroseconds(1000); // ganti delay untuk mempercepat motor
  digitalWrite(stepPin, LOW);
  delayMicroseconds(1000); // ganti delay untuk mempercepat motor
}

if((nilaisudutfix >= 175)&&(nilaisudutfix < 350)){
  digitalWrite(dirPin, HIGH); // putar CCW jarum jam
  digitalWrite(stepPin, HIGH);
  delayMicroseconds(1000); // ganti delay untuk mempercepat motor
  digitalWrite(stepPin, LOW);
  delayMicroseconds(1000); // ganti delay untuk mempercepat motor
}

if((headingDegrees >= nilaisudutfix - 5)&&(headingDegrees < nilaisudutfix + 5)){
mark = 0;   
lcd.clear();
delay(1000);  
return;  
}

lcd.setCursor(0,1);
lcd.print("Cari Titik: ");
lcd.print(nilaisudutfix);
lcd.print("   ");  
 
carititik();
}


c. VIDEO HASILNYA
 

 
 

TENSIMETER,BPM,SPO2,SUHU ARDUINO

TENSIMETER,BPM,SPO2,SUHU ARDUINO

       Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang menggunakan beberapa sensor yaitu sensor tekanan MPX5050GP, sensor suhu DS18B20, sensor BPM dan SPO MAX30100/30102 dan arduino sebagai mikrokontrollernya. untuk lebih jelasnya berikut adalah koding dan komponennya.


 

a. Komponen dan Skema


 

b. Skema


 

c. Program Arduino IDE

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <MAX30100_PulseOximeter.h>
#define REPORTING_PERIOD_MS 5000
#include "MAX30100.h" //library sensor
LiquidCrystal_I2C lcd(0x27, 20, 4);

#define ONE_WIRE_BUS 7

MAX30100* pulseOxymeter;   //library

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

int btset = 8;
int btup = 9;
int btdown = 10;
int btsetx;
int btupx;
int btdownx;
int buzzer = 11;

float suhu;
int spo;
float bpm;
int counter;
int pompa1 = 4;
int pompa2 = 5;
int solenoid1 = 2;
int solenoid2 = 3;
int dataadc;
int tombol = 6;
int tombolx;
int hitung;
float vol;
float mmhg;
float mmhgx;
float sistole;
float diastole;
int sistolex;
int diastolex;
int mark = 0;
int bpmku;
int spoku;
int suhuku;
int countup;

int suhuatas;
int suhubawah;
int spoatas;
int spobawah;
int hratas;
int hrbawah;
int sistolatas;
int sistolbawah;
int diastolatas;
int diastolbawah;

PulseOximeter pox;

uint32_t tsLastReport = 0;
String hrData = "";
void onBeatDetected()
{
//    Serial.println("Beat!");
}


void setup()
{
  lcd.begin();
  lcd.clear();
  lcd.noCursor();
  Serial.begin(9600);

  pinMode(pompa1,OUTPUT);
  pinMode(pompa2,OUTPUT);
  pinMode(solenoid1,OUTPUT);
  pinMode(solenoid2,OUTPUT);
  digitalWrite(solenoid1,LOW);
  digitalWrite(solenoid2,LOW);
  pinMode(tombol,INPUT_PULLUP);
  pinMode(btset,INPUT_PULLUP);
  pinMode(btup,INPUT_PULLUP);
  pinMode(btdown,INPUT_PULLUP);
  pinMode(buzzer,OUTPUT);
 
  setsuhuatas();
  setsuhubawah();
  setspoatas();
  setspobawah();
  sethratas();
  sethrbawah();
  setsistolatas();
  setsistolbawah();
  setdiastolatas();
  setdiastolbawah();

    sensors.begin();
    Wire.begin();  

     //Serial.print("Initializing pulse oximeter..");
 
    if (!pox.begin()) {
        //Serial.println("FAILED");
        for(;;);
    } else {
        //Serial.println("SUCCESS");
    }
 
   pox.setIRLedCurrent(MAX30100_LED_CURR_11MA);
   pox.setOnBeatDetectedCallback(onBeatDetected);
 
}

void loop(){     

lcd.setCursor(0,2);
lcd.print("Sis/Dia= ");
lcd.print(sistolex);
lcd.print("/");
lcd.print(diastolex);
lcd.print("    ");
   
   pox.update();
    
   if (millis() - tsLastReport > REPORTING_PERIOD_MS) {

       bpm = pox.getHeartRate();
       spo = pox.getSpO2();
       bpmku = bpm;
       spoku = spo;
       
       lcd.setCursor(0,1);
       lcd.print("B/S:");
       lcd.print(pox.getHeartRate());
       lcd.print("/");
       lcd.print(pox.getSpO2());
       lcd.print("     ");
       
    tsLastReport = millis();
}

 lcd.setCursor(0,1);
 lcd.print("B/S= ");

if((bpm > 50)&&(spo > 0)){
 ceksuhu();
}

 tombolx = digitalRead(tombol);

 if(tombolx == LOW){
  mark = 0;
  lcd.clear();
  delay(1000);
  digitalWrite(pompa1,HIGH);
  digitalWrite(pompa2,LOW);
  digitalWrite(solenoid1,HIGH);
  digitalWrite(solenoid2,LOW);
  mulai();
  }

Serial.print("*");
Serial.print(suhuku);
Serial.print(",");
Serial.print(bpmku);
Serial.print(",");
Serial.print(spoku);
Serial.print(",");
Serial.print(sistolex);
Serial.print(",");
Serial.print(diastolex);
Serial.println("#");
 
if(suhu > 0){
if(spo > spoatas){
  digitalWrite(buzzer,HIGH);
}

if((spo > 0)&&(spo < spobawah)){
  digitalWrite(buzzer,HIGH);
}

if((spo >= spobawah)&&(spo <= spoatas)){
  digitalWrite(buzzer,LOW);
}

//=============================================

if(bpm > hratas){
  digitalWrite(buzzer,HIGH);
}

if((bpm > 0)&&(bpm < hrbawah)){
  digitalWrite(buzzer,HIGH);
}

if((bpm >= hrbawah)&&(bpm <= hratas)){
  digitalWrite(buzzer,LOW);
}

//=============================================

if(sistolex > sistolatas){
  digitalWrite(buzzer,HIGH);
}

if((sistolex > 0)&&(sistolex < sistolbawah)){
  digitalWrite(buzzer,HIGH);
}

if((sistolex >= sistolbawah)&&(sistolex <= sistolatas)){
  digitalWrite(buzzer,LOW);
}

//=============================================

if(diastolex > diastolatas){
  digitalWrite(buzzer,HIGH);
}

if((diastolex > 0)&&(diastolex < diastolbawah)){
  digitalWrite(buzzer,HIGH);
}

if((diastolex >= diastolbawah)&&(diastolex <= diastolatas)){
  digitalWrite(buzzer,LOW);
}

//=============================================================
}

delay(1);
}


void ceksuhu(){
 
 sensors.requestTemperatures();
 suhu = sensors.getTempCByIndex(0);
 suhuku = suhu;
 
 lcd.setCursor(0,0);
 lcd.print("Suhu= ");     
 lcd.print(suhu);
 lcd.print(" C  ");

if(suhu > suhuatas){
  digitalWrite(buzzer,HIGH);
}

if((suhu > 0)&&(suhu < suhubawah)){
  digitalWrite(buzzer,HIGH);
}

if((suhu >= suhubawah)&&(suhu <= suhuatas)){
  digitalWrite(buzzer,LOW);
}

}


void mulai(){
 
 dataadc = analogRead(A0);
 mmhg = (dataadc - 33.222) / 3.2;

if((mmhg >= mmhgx + 10)&&(mmhg > 100)&&(mark == 0)){
Serial.println("SISTOLE");
sistole = mmhg;
mark = 2;
digitalWrite(pompa1,LOW);
digitalWrite(pompa2,LOW);
}

if((mmhg >= mmhgx + 5)&&(mmhg > 50)&&(mmhg < 90)&&(mark == 2)){
Serial.println("DIASTOLE");
diastole = mmhg;
mark = 3;
}

 lcd.setCursor(0,0);
 lcd.print("adc= ");
 lcd.print(dataadc);
 lcd.print("     ");
 lcd.setCursor(0,1);
 lcd.print("mmhg= ");
 lcd.print(mmhg);
 lcd.print("     ");

if(mmhg >= 150)
{
 digitalWrite(pompa1,LOW);
 digitalWrite(pompa2,LOW);
}

mmhgx = mmhg;

Serial.println(mmhg);

if((mark == 2)&&(mmhg < 50)){
lcd.clear();
delay(1000);
mark = 0;
sistolex = sistole;
diastolex = 60;
digitalWrite(solenoid1,LOW);
digitalWrite(solenoid2,LOW);
return;  
}

if((mark == 3)&&(mmhg < 50)){
lcd.clear();
delay(1000);
mark = 0;
sistolex = sistole;
diastolex = diastole;
digitalWrite(solenoid1,LOW);
digitalWrite(solenoid2,LOW);
return;  
}

delay(100);   
mulai();  
}


void setsuhuatas(){

 btupx = digitalRead(btup);
 btdownx = digitalRead(btdown);
 btsetx = digitalRead(btset);
 
 lcd.setCursor(0,0);
 lcd.print("SET SUHU");
 lcd.setCursor(0,1);
 lcd.print("ATAS: ");
 lcd.print(suhuatas);  
 lcd.print("      ");

if(btupx == 0){
delay(200);
suhuatas++;
}

if(btdownx == 0){
delay(200);
suhuatas--;
}

if(suhuatas < 26){
  suhuatas = 26;
}

if(suhuatas > 41){
  suhuatas = 41;
}

if(btsetx == 0){
delay(3000);  
return;
}

delay(200);
setsuhuatas();
}



void setsuhubawah(){

 btupx = digitalRead(btup);
 btdownx = digitalRead(btdown);
 btsetx = digitalRead(btset);
 
 lcd.setCursor(0,2);
 lcd.print("BAWAH: ");
 lcd.print(suhubawah);  
 lcd.print("      ");

if(btupx == 0){
delay(200);
suhubawah++;
}

if(btdownx == 0){
delay(200);
suhubawah--;
}

if(suhubawah < 26){
  suhubawah = 26;
}

if(suhubawah > 41){
  suhubawah = 41;
}

if(btsetx == 0){
lcd.clear();
delay(3000);  
return;
}

delay(200);
setsuhubawah();
}


void setspoatas(){

 btupx = digitalRead(btup);
 btdownx = digitalRead(btdown);
 btsetx = digitalRead(btset);
 
 lcd.setCursor(0,0);
 lcd.print("SET SPO2");
 lcd.setCursor(0,1);
 lcd.print("ATAS: ");
 lcd.print(spoatas);  
 lcd.print("      ");

if(btupx == 0){
delay(200);
spoatas++;
}

if(btdownx == 0){
delay(200);
spoatas--;
}

if(spoatas < 70){
  spoatas = 70;
}

if(spoatas > 100){
  spoatas = 100;
}


if(btsetx == 0){
delay(3000);  
return;
}

delay(200);
setspoatas();
}



void setspobawah(){

 btupx = digitalRead(btup);
 btdownx = digitalRead(btdown);
 btsetx = digitalRead(btset);
 
 lcd.setCursor(0,2);
 lcd.print("BAWAH: ");
 lcd.print(spobawah);  
 lcd.print("      ");

if(btupx == 0){
delay(200);
spobawah++;
}

if(btdownx == 0){
delay(200);
spobawah--;
}

if(spobawah < 70){
  spobawah = 70;
}

if(spobawah > 100){
  spobawah = 100;
}


if(btsetx == 0){
lcd.clear();  
delay(3000);  
return;
}

delay(200);
setspobawah();
}



void sethratas(){

 btupx = digitalRead(btup);
 btdownx = digitalRead(btdown);
 btsetx = digitalRead(btset);
 
 lcd.setCursor(0,0);
 lcd.print("SET HR");
 lcd.setCursor(0,1);
 lcd.print("ATAS: ");
 lcd.print(hratas);  
 lcd.print("      ");

if(btupx == 0){
delay(200);
hratas++;
}

if(btdownx == 0){
delay(200);
hratas--;
}

if(hratas < 30){
  hratas = 30;
}

if(hratas > 235){
  hratas = 235;
}


if(btsetx == 0){
delay(3000);  
return;
}

delay(200);
sethratas();
}


void sethrbawah(){

 btupx = digitalRead(btup);
 btdownx = digitalRead(btdown);
 btsetx = digitalRead(btset);
 
 lcd.setCursor(0,2);
 lcd.print("BAWAH: ");
 lcd.print(hrbawah);  
 lcd.print("      ");

if(btupx == 0){
delay(200);
hrbawah++;
}

if(btdownx == 0){
delay(200);
hrbawah--;
}

if(hrbawah < 30){
  hrbawah = 30;
}

if(hrbawah > 235){
  hrbawah = 235;
}


if(btsetx == 0){
lcd.clear();
delay(3000);  
return;
}

delay(200);
sethrbawah();
}


void setsistolatas(){

 btupx = digitalRead(btup);
 btdownx = digitalRead(btdown);
 btsetx = digitalRead(btset);
 
 lcd.setCursor(0,0);
 lcd.print("SET SISTOLE");
 lcd.setCursor(0,1);
 lcd.print("ATAS: ");
 lcd.print(sistolatas);  
 lcd.print("      ");

if(btupx == 0){
delay(200);
sistolatas++;
}

if(btdownx == 0){
delay(200);
sistolatas--;
}

if(sistolatas < 30){
  sistolatas = 30;
}

if(sistolatas > 290){
  sistolatas = 290;
}


if(btsetx == 0){
delay(3000);  
return;
}

delay(200);
setsistolatas();
}


void setsistolbawah(){

 btupx = digitalRead(btup);
 btdownx = digitalRead(btdown);
 btsetx = digitalRead(btset);
 
 lcd.setCursor(0,2);
 lcd.print("BAWAH: ");
 lcd.print(sistolbawah);  
 lcd.print("      ");

if(btupx == 0){
delay(200);
sistolbawah++;
}

if(btdownx == 0){
delay(200);
sistolbawah--;
}

if(sistolbawah < 30){
  sistolbawah = 30;
}

if(sistolbawah > 290){
  sistolbawah = 290;
}


if(btsetx == 0){
lcd.clear();
delay(3000);  
return;
}

delay(200);
setsistolbawah();
}


void setdiastolatas(){

 btupx = digitalRead(btup);
 btdownx = digitalRead(btdown);
 btsetx = digitalRead(btset);
 
 lcd.setCursor(0,0);
 lcd.print("SET DIASTOLE");
 lcd.setCursor(0,1);
 lcd.print("ATAS: ");
 lcd.print(diastolatas);  
 lcd.print("      ");

if(btupx == 0){
delay(200);
diastolatas++;
}

if(btdownx == 0){
delay(200);
diastolatas--;
}

if(diastolatas < 10){
  diastolatas = 10;
}

if(diastolatas > 220){
  diastolatas = 220;
}


if(btsetx == 0){
delay(3000);  
return;
}

delay(200);
setdiastolatas();
}


void setdiastolbawah(){

 btupx = digitalRead(btup);
 btdownx = digitalRead(btdown);
 btsetx = digitalRead(btset);
 
 lcd.setCursor(0,2);
 lcd.print("BAWAH: ");
 lcd.print(diastolbawah);  
 lcd.print("      ");

if(btupx == 0){
delay(200);
diastolbawah++;
}

if(btdownx == 0){
delay(200);
diastolbawah--;
}

if(diastolbawah < 10){
  diastolbawah = 10;
}

if(diastolbawah > 220){
  diastolbawah = 220;
}


if(btsetx == 0){
lcd.clear();
delay(3000);  
return;
}

delay(200);
setdiastolbawah();
}




 d. VIDEO HASILNYA


Turbidity NTU TDS Sensor Arduino

Turbidity NTU TDS Sensor Arduino  

        Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang menggunakan sensor TDS Sensor dengan menggunakan arduino. pada alat ini digunakan sistem mapping sehingga nilai ADC rane 0 - 1023 dijadikan range dari 0 sampai 100. untuk lebih jelasnya berikut adalah koding dan komponennya.


a. Arduino Uno
 

b. TDS Sensor



c. Program Arduino IDE

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

float ntu;
int ntunew;
int adcntu;

void setup()
{
  Serial.begin(9600);
  lcd.begin();
  lcd.clear();
  lcd.noCursor();
}

void loop()
{
 
adcntu = analogRead(A0);             
ntunew = map(adcntu, 765, 1, 0, 100);

   lcd.setCursor (0,0);
   lcd.print ("NTU=");
   lcd.print (ntunew);
   lcd.print ("    ");
   lcd.setCursor (0,1);
   lcd.print ("ADC=");
   lcd.print (adcntu);
   lcd.print ("    ");

delay(200);
}


d. VIDEO HASILNYA


Alat Stabilisator dan kalibrator Suhu

Alat Stabilisator dan kalibrator Suhu 

           Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat digunakan untuk stabilisator suhu dan juga untuk kalibrator suhu non contact. alat ini menggunakan pemanas yaitu peltier dengan sensor yang dipakai adalah ds18b20. alat ini bisa disetting untuk naik turunnya suhu yang diinginkan dengan menggunakan 2 buah pushbutton. untuk lebih jelasnya berikut adalah komponen dan programnya. 



a. Arduino Uno
 

 
 
b. Peltier
 

 

c. Sensor Ds18b20
 

 
 

d. Program Arduino IDE

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <OneWire.h>
#include <DallasTemperature.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

#define ONE_WIRE_BUS 2

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

float suhu;
int pwmout = 9;

int btup = 3;
int btdown = 4;
int btupx;
int btdownx;
int sp = 32;

void setup()
{
  lcd.begin();
  lcd.clear();
  lcd.noCursor();
  Serial.begin(9600);
  sensors.begin();
  pinMode(pwmout,OUTPUT);
  pinMode(btup,INPUT_PULLUP);
  pinMode(btdown,INPUT_PULLUP);
}

void loop()
{

btupx = digitalRead(btup);
btdownx = digitalRead(btdown);

 sensors.requestTemperatures();
 suhu = sensors.getTempCByIndex(0);

if(btupx == 0){
sp++;
}

if(btdownx == 0){
sp--;
}

if(sp < 32){
sp = 32;  
}

if(sp > 42){
sp = 42;  
}

if(suhu < sp){
 digitalWrite(pwmout,HIGH);
}

if(suhu >= sp){
 digitalWrite(pwmout,LOW);
}
 
 lcd.setCursor(0,0);
 lcd.print("Suhu= ");     
 lcd.print(suhu);
 lcd.print(" C     ");
 lcd.setCursor(0,1);
 lcd.print("SP= ");     
 lcd.print(sp);
 lcd.print(" C     ");

}



e. VIDEO HASILNYA




ALAT KENDALI SUHU / TEMPERATURE PANAS MENGGUNAKAN DIMMER DAN PID CONTROL

ALAT KENDALI SUHU / TEMPERATURE PANAS MENGGUNAKAN DIMMER DAN PID CONTROL
 
       
         Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang bisa digunakan untuk mengendalikan suhu dengan menggunakan pid control untuk pengaturan panasnya. alat ini menggunakan modul dimmer dan servo untuk kendali pemanasnya. untuk lebih jelasnya berikut adalah komponen dan kodingnya.
 
 
a. Arduino Uno



 
b. Modul Dimmer
 

 
 
c. Sensor Thermocouple Tipe K dan Max6675
 

 
 
d. Program Arduino IDE
 
#include<Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
#include <DS3231.h>
#include <max6675.h>

LiquidCrystal_I2C lcd(0x27, 16,2);
Servo myservo;

int thermoDO = 4; //bisa juga S0
int thermoCS = 5;
int thermoCLK = 6; //bisa juga SCK
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);

DS3231  rtc(SDA, SCL);
Time  t;

int btset = A0;
int btok = A1;
int btup = A2;
int btdown = A3;
int btsetx;
int btokx;
int btupx;
int btdownx;

float dataku;
int setpoint = 30;
int durasi = 1;
float kp = 1.15;
float ki = 0.67;
float kd = 0.15;

float p,i,d,suhu,pid;
float error,errorx,sumerr;
float sp;

//servo full on = 200;
//servo full off = 30;

void setup(){
lcd.clear();
lcd.begin();
lcd.noCursor();
Serial.begin(9600);
myservo.attach(9);
myservo.write(30);
rtc.begin();
//rtc.setDOW(FRIDAY);     // Set Day-of-Week to SUNDAY
rtc.setTime(0, 0, 0);     // Set the time to 12:00:00 (24hr format)
//rtc.setDate(13, 5, 2022);   // Set the date to January 1st, 2014
pinMode(btset,INPUT_PULLUP);
pinMode(btok,INPUT_PULLUP);
pinMode(btup,INPUT_PULLUP);
pinMode(btdown,INPUT_PULLUP);
delay(500);
}

void loop(){  

btsetx = digitalRead(btset);
btokx = digitalRead(btok);

if(btsetx == 0){
delay(200);
lcd.clear();
menuset();  
menujam();
}

if(btokx == 0){
delay(200);
lcd.clear();
rtc.setTime(0, 0, 0);
utama();  
}

 lcd.setCursor(0,0);
 lcd.print("TEKAN MULAI");

 lcd.setCursor(0,1);
 lcd.print("SP/D= ");
 lcd.print(setpoint);
 lcd.print("/");
 lcd.print(durasi);
 lcd.print("    ");
 
delay(200);
}

void menuset(){

btsetx = digitalRead(btset);
btokx = digitalRead(btok);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);

lcd.setCursor(0,0);
lcd.print("SP Suhu= ");
lcd.print(setpoint);
lcd.print("    ");

if(btupx == 0){
delay(200);
setpoint++;
}

if(btdownx == 0){
delay(200);
setpoint--;
}

if(btokx == 0){
lcd.clear();  
delay(2000);
btokx = 1;
return;
}

if(setpoint > 1000){
  setpoint = 0;
}

if(setpoint < 0){
  setpoint = 1000;
}
   
menuset();  
}

void menujam(){

btsetx = digitalRead(btset);
btokx = digitalRead(btok);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);

lcd.setCursor(0,0);
lcd.print("Durasi= ");
lcd.print(durasi);
lcd.print(" jam    ");

if(btupx == 0){
delay(200);
durasi++;
}

if(btdownx == 0){
delay(200);
durasi--;
}

if(btokx == 0){
lcd.clear();
delay(2000);
return;
}

if(durasi > 12){
  durasi = 0;
}

if(durasi < 0){
  durasi = 12;
}
   
menujam();  
}

void utama(){
t = rtc.getTime();
dataku = thermocouple.readCelsius();

  error = setpoint - dataku;
  p = error * kp;
  sumerr = error + errorx;
  i = ki * sumerr;
  d = kd * (error - errorx) ;
  pid = p + i + d;

  if(pid < 30){
  pid = 30;
  }
 
  if(pid > 200){
  pid = 200;
  }

myservo.write(pid);
 
lcd.setCursor(0,0);
lcd.print("T/SP= ");
lcd.print(dataku);
lcd.print("/");
lcd.print(setpoint);
lcd.print("     ");

lcd.setCursor(0,1);
lcd.print("D= ");
lcd.print(t.hour);
lcd.print(":");
lcd.print(t.min);
lcd.print(":");
lcd.print(t.sec);
lcd.print("/");
lcd.print(pid);
lcd.print("   ");

if(t.hour >= durasi){
 lcd.clear();
 delay(1000);
 myservo.write(30);
 return;
}

errorx = error;
delay(200);
utama();
}



e. VIDEO HASILNYA