Translate

Membuat ETU (Engine Telegraph Unit) Menggunakan Mikrokontroller dan Bascom AVR (Interrupt serial UART) Master - Slave

Membuat ETU (Engine Telegraph Unit) Menggunakan Mikrokontroller dan Bascom AVR (Interrupt serial UART) Master - Slave


         Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana membuat sebuah ETU (Engine Telegraph Unit) yang biasanya difungsikan pada kapal untuk memerintahkan kepada abk kapal untuk melakukan sesuatu yang jaraknya jauh atau beda ruangan, jadi dari control room dapat memerintahkan abk yang berada pada posisinya untuk mengerjakan sesuatu sesuai dengan perintah pada ETU. disini yang dipakai hanya 3 buah push button, 3 buah led dan satu buzzer pada master, kemudian pada slave menggunakan 3 buah led, 2 push button dan satu buzzer. untuk lebih jelasnya berikut adalah komponen dan programnya.




a. Minimum Sistem ATMega




b. LED 




c. Buzzer




d. Push Button





e. Program Bascom AVR Master

$regfile = "m16def.dat"
$crystal = 11059200
$baud = 9600

Ddra.0 = 1
Ddra.1 = 1
Ddra.2 = 1
Ddrc.4 = 1

Ddrb.0 = 0
Ddrb.1 = 0
Ddrb.2 = 0


On Urxc Getchar

Dim Inchar As Word
Dim Tanda As Integer
Dim X As Integer
Dim Y As Integer

Dim Aa As Byte
Dim Bb As Byte
Dim Cc As Byte
Dim Dd As Byte

Aa = 1
Bb = 2
Cc = 3
Dd = 4


Enable Interrupts
Enable Urxc


Tanda = 0
X = 0
Y = 0

Goto Blinking


Blinking:
Do

Porta.0 = 1
Porta.1 = 1
Porta.2 = 1
Portc.4 = 1
Waitms 500

Porta.0 = 0
Porta.1 = 0
Porta.2 = 0
Portc.4 = 0
Waitms 500

Loop Until Tanda = 1

Porta.0 = 0
Porta.1 = 0
Porta.2 = 0
Portc.4 = 0



Utama:
Do

If Pinb.0 = 0 Then
Waitms 200
Printbin Aa
X = 1
Y = 0
Porta.0 = 0
Porta.1 = 0
Porta.2 = 0
Portc.4 = 0
End If

If Pinb.1 = 0 Then
Waitms 200
Printbin Bb
X = 2
Y = 0
Porta.0 = 0
Porta.1 = 0
Porta.2 = 0
Portc.4 = 0
End If

If Pinb.2 = 0 Then
Waitms 200
Printbin Cc
X = 3
Y = 0
Porta.0 = 0
Porta.1 = 0
Porta.2 = 0
Portc.4 = 0
End If

If X = 1 Then
Porta.0 = 1
Porta.1 = 0
Porta.2 = 0
Portc.4 = 1
Waitms 500
Porta.0 = 0
Porta.1 = 0
Porta.2 = 0
Portc.4 = 0
Waitms 500
End If


If X = 2 Then
Porta.0 = 0
Porta.1 = 1
Porta.2 = 0
Portc.4 = 1
Waitms 500
Porta.0 = 0
Porta.1 = 0
Porta.2 = 0
Portc.4 = 0
Waitms 500
End If


If X = 3 Then
Porta.0 = 0
Porta.1 = 0
Porta.2 = 1
Portc.4 = 1
Waitms 500
Porta.0 = 0
Porta.1 = 0
Porta.2 = 0
Portc.4 = 0
Waitms 500
End If


If Y = 1 Then
Porta.0 = 1
Porta.1 = 0
Porta.2 = 0
Portc.4 = 0
End If


If Y = 2 Then
Porta.0 = 0
Porta.1 = 1
Porta.2 = 0
Portc.4 = 0
End If


If Y = 3 Then
Porta.0 = 0
Porta.1 = 0
Porta.2 = 1
Portc.4 = 0
End If


Waitms 200

Loop




Getchar:

  Inchar = Waitkey()
  Select Case Inchar

    Case 4:
    Tanda = 1

    Case 1:
    X = 0
    Y = 1

    Case 2:
    X = 0
    Y = 2


    Case 3:
    X = 0
    Y = 3


  End Select
Return

End





f. Program Bascom AVR Slave

$regfile = "m16def.dat"
$crystal = 11059200
$baud = 9600

Ddra.0 = 1
Ddra.1 = 1
Ddra.2 = 1
Ddrc.4 = 1

'reset
Ddrb.0 = 0
'ack
Ddrb.1 = 0


On Urxc Getchar

Dim Inchar As Word
Dim Tanda As Integer

Enable Interrupts
Enable Urxc

Cls
Cursor Off

Dim Z As Integer
Dim N As Integer

Dim Aa As Byte
Dim Bb As Byte
Dim Cc As Byte
Dim Dd As Byte

Aa = 1
Bb = 2
Cc = 3
Dd = 4

Z = 0
N = 0

Tanda = 0

Goto Blinking


Blinking:
Do

'reset
If Pinb.0 = 0 Then
Waitms 200
Printbin Dd
Tanda = 1
End If


Porta.0 = 1
Porta.1 = 1
Porta.2 = 1
Portc.4 = 1
Waitms 500

Porta.0 = 0
Porta.1 = 0
Porta.2 = 0
Portc.4 = 0
Waitms 500

Loop Until Tanda = 1

Porta.0 = 0
Porta.1 = 0
Porta.2 = 0
Portc.4 = 0



Utama:
Do


'ack
If Pinb.1 = 0 And Z = 1 Then
Waitms 200
Z = 0
Porta.0 = 0
Porta.1 = 0
Porta.2 = 0
Portc.4 = 0
Printbin Aa
N = 1
End If

'ack
If Pinb.1 = 0 And Z = 2 Then
Waitms 200
Z = 0
Porta.0 = 0
Porta.1 = 0
Porta.2 = 0
Portc.4 = 0
Printbin Bb
N = 2
End If

'ack
If Pinb.1 = 0 And Z = 3 Then
Waitms 200
Z = 0
Porta.0 = 0
Porta.1 = 0
Porta.2 = 0
Portc.4 = 0
Printbin Cc
N = 3
End If


If Z = 0 Then
Porta.0 = 0
Porta.1 = 0
Porta.2 = 0
Portc.4 = 0
End If


If N = 1 Then
Porta.0 = 1
Porta.1 = 0
Porta.2 = 0
Portc.4 = 0
End If

If N = 2 Then
Porta.0 = 0
Porta.1 = 1
Porta.2 = 0
Portc.4 = 0
End If

If N = 3 Then
Porta.0 = 0
Porta.1 = 0
Porta.2 = 1
Portc.4 = 0
End If


If Z = 1 Then
Porta.0 = 1
Porta.1 = 0
Porta.2 = 0
Portc.4 = 1
Waitms 500
Porta.0 = 0
Porta.1 = 0
Porta.2 = 0
Portc.4 = 0
Waitms 500
End If


If Z = 2 Then
Porta.0 = 0
Porta.1 = 1
Porta.2 = 0
Portc.4 = 1
Waitms 500
Porta.0 = 0
Porta.1 = 0
Porta.2 = 0
Portc.4 = 0
Waitms 500
End If


If Z = 3 Then
Porta.0 = 0
Porta.1 = 0
Porta.2 = 1
Portc.4 = 1
Waitms 500
Porta.0 = 0
Porta.1 = 0
Porta.2 = 0
Portc.4 = 0
Waitms 500
End If


Loop




Getchar:

  Inchar = Waitkey()
  Select Case Inchar

    Case 1:
    Z = 1

    Case 2:
    Z = 2

    Case 3:
    Z = 3

  End Select
Return

End





g. VIDEO HASILNYA









Membuat Light Cure Berbasis Arduino LCD OLED dan Kendali Intensitas LED Untuk Alat Bantu Penambalan Gigi Berlubang / Mematikan Bakteri Mulut

Membuat Light Cure Berbasis Arduino LCD OLED dan Kendali Intensitas LED Untuk Alat Bantu Pengeringan Saat Penambalan Gigi Berlubang / Mematikan Bakteri Mulut


            Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat untuk membantu dalam pengeringan gigi saat melakukan penambalan, alat ini menggunakan kontroller arduino sebagai kendali intensitas cahayanya dan juga menggunakan interface OLED LCD. terdapat berbagai macam variasi led yang bisa diberikan oleh alat ini. untuk kualitas dari alat ini tergantung pada jenis led yang digunakan. untuk lebih jelasnya berikut adalah komponen dan programnya.     




a. Arduino Nano




b. LCD OLED




c. LED / Laser  + Rangkaian Driver







d. Program Arduino IDE

#include "U8glib.h"
#include <PWM.h>
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK); 

unsigned long waktu,waktusekarang;
int x;
char tmp_string1[8];
char tmp_string2[8];
int dataadc;
int z;

int btstart = 8;
int btnext = 7;
int btup = 4;
int btdown = 2;

int btstartx = 0;
int btnextx = 0;
int btupx = 0;
int btdownx = 0;

int ledx = 9;
int tema;
int counter;
int cacah;
int count;

int zx;
int hitung;

void setup(void) {

 pinMode(ledx,OUTPUT);
 digitalWrite(ledx,LOW);

 pinMode(btstart,INPUT);
 pinMode(btnext,INPUT);
 pinMode(btup,INPUT);
 pinMode(btdown,INPUT);
  
  if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
    u8g.setColorIndex(255);     // white
  }
  else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
    u8g.setColorIndex(3);         // max intensity
  }
  else if ( u8g.getMode() == U8G_MODE_BW ) {
    u8g.setColorIndex(1);         // pixel on
  }
  else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
    u8g.setHiColorByRGB(255,255,255);
  }
}


void draw(void) {


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

 if(btnextx == 1){
 count++;
 }

 if(count > 2){
 count = 0;
 }

 if(count < 0){
 count = 2;
 }

 if (tema == 0){
  // graphic commands to redraw the complete screen should be placed here
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(25, 13, "LIGHT CURE");
 }


 if(count == 0){
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(80, 28, "-");
 
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(80, 43, "x");
 
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(80, 58, "x");

 
 }

 if(count == 1){
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(80, 28, "x");
 
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(80, 43, "-");
 
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(80, 58, "x");

 }


 if(count == 2){
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(80, 28, "x");
 
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(80, 43, "x");
 
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(80, 58, "-");

 }


 if((btupx == 1)&&(count == 0)){
   delay(50);
   counter++;  
 }

 if((btdownx == 1)&&(count == 0)){
   delay(50);
   counter--;
 }


 if((btupx == 1)&&(count == 1)){
   delay(50);
   cacah++;  
 }

 if((btdownx == 1)&&(count == 1)){
   delay(50);
   cacah--;
 }


 if((btupx == 1)&&(count == 2)){
   delay(50);
   hitung++;  
 }

 if((btdownx == 1)&&(count == 2)){
   delay(50);
   hitung--;
 }



if(cacah > 2){
cacah = 0;
}
if(cacah < 0){
cacah = 2;
}


if(hitung > 3){
hitung = 0;
}
if(hitung < 0){
hitung = 3;
}


 if(counter > 2){
 counter = 0;
 }

 if(counter < 0){
 counter = 2;
 }
 
 if(counter == 0){
  // graphic commands to redraw the complete screen should be placed here
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(0, 28, "Waktu= 20");
 }

 if(counter == 1){
  // graphic commands to redraw the complete screen should be placed here
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(0, 28, "Waktu= 40");
 }

 if(counter == 2){
  // graphic commands to redraw the complete screen should be placed here
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(0, 28, "Waktu= 60");
 }


if(cacah == 0){
  // graphic commands to redraw the complete screen should be placed here
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(0, 43, "Mode = 1");
 }

 if(cacah == 1){
  // graphic commands to redraw the complete screen should be placed here
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(0, 43, "Mode = 2");
 }

 if(cacah == 2){
  // graphic commands to redraw the complete screen should be placed here
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(0, 43, "Mode = 3");
 }


if(hitung == 0){
  // graphic commands to redraw the complete screen should be placed here
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(0, 58, "Inten= 0");
 }

 if(hitung == 1){
  // graphic commands to redraw the complete screen should be placed here
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(0, 58, "Inten= T");
 }

 if(hitung == 2){
  // graphic commands to redraw the complete screen should be placed here
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(0, 58, "Inten= R");
 }


 if(hitung == 3){
  // graphic commands to redraw the complete screen should be placed here
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(0, 58, "Inten= S");
 }
 
}

void loop(void) {

 
  btstartx = digitalRead(btstart);
 
 if(btstartx == 1){
 mulai();
 }
 
  // picture loop
  u8g.firstPage();
  do {
    draw();
  } while( u8g.nextPage() );

  // rebuild the picture after some delay
  delay(500);
}

void mulai(){

if(hitung == 0){
 
if((counter == 0)&&(cacah == 0)&&(hitung == 0)){
analogWrite(ledx,64);
delay(10000);
analogWrite(ledx,255);
delay(10000);
analogWrite(ledx,0);
berhenti();
}

if((counter == 1)&&(cacah == 0)&&(hitung == 0)){
analogWrite(ledx,64);
delay(10000);
analogWrite(ledx,255);
delay(20000);
analogWrite(ledx,0);
berhenti();
}

if((counter == 2)&&(cacah == 0)&&(hitung == 0)){
analogWrite(ledx,64);
delay(10000);
analogWrite(ledx,255);
delay(30000);
analogWrite(ledx,0);
berhenti();
}

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

if((counter == 0)&&(cacah == 1)&&(hitung == 0)){
analogWrite(ledx,64);
delay(5000);
analogWrite(ledx,127);
delay(2500);
analogWrite(ledx,191);
delay(2500);
analogWrite(ledx,255);
delay(10000);
analogWrite(ledx,0);
berhenti();
}

if((counter == 1)&&(cacah == 1)&&(hitung == 0)){
analogWrite(ledx,64);
delay(5000);
analogWrite(ledx,127);
delay(5000);
analogWrite(ledx,191);
delay(5000);
analogWrite(ledx,255);
delay(20000);
analogWrite(ledx,0);
berhenti();
}

if((counter == 2)&&(cacah == 1)&&(hitung == 0)){
analogWrite(ledx,64);
delay(5000);
analogWrite(ledx,127);
delay(7500);
analogWrite(ledx,191);
delay(7500);
analogWrite(ledx,255);
delay(20000);
analogWrite(ledx,0);
berhenti();
}

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

if((counter == 0)&&(cacah == 2)&&(hitung == 0)){
zx = 20;
  kedip();
  berhenti();
}

if((counter == 1)&&(cacah == 2)&&(hitung == 0)){
zx = 40;
  kedip();
  berhenti();
}

if((counter == 2)&&(cacah == 2)&&(hitung == 0)){
zx = 60;
  kedip();
  berhenti();
}

}



if((hitung == 1)&&(counter == 0)){
  analogWrite(ledx,255);
  delay(20000);   
  berhenti();
}

if((hitung == 1)&&(counter == 1)){
  analogWrite(ledx,255);
  delay(40000);   
  berhenti();
}

if((hitung == 1)&&(counter == 2)){
  analogWrite(ledx,255);
  delay(60000);   
  berhenti();
}


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

if((hitung == 2)&&(counter == 0)){
  analogWrite(ledx,64);
  delay(20000);   
  berhenti();
}

if((hitung == 2)&&(counter == 1)){
  analogWrite(ledx,64);
  delay(40000);   
  berhenti();
}

if((hitung == 2)&&(counter == 2)){
  analogWrite(ledx,64);
  delay(60000);   
  berhenti();
}


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

if((hitung == 3)&&(counter == 0)){
  analogWrite(ledx,128);
  delay(20000);   
  berhenti();
}

if((hitung == 3)&&(counter == 1)){
  analogWrite(ledx,128);
  delay(40000);   
  berhenti();
}

if((hitung == 3)&&(counter == 2)){
  analogWrite(ledx,128);
  delay(60000);   
  berhenti();
}


mulai();
}

void kedip(){
zx--;
digitalWrite(ledx,LOW);
delay(500);
digitalWrite(ledx,HIGH);
delay(500);

if(zx < 0){
  zx = 0;
digitalWrite(ledx,LOW);
berhenti();
}
 
kedip();
}

void berhenti(){
digitalWrite(ledx,LOW);
berhenti();
}




e. VIDEO HASILNYA










Alat Kendali Suhu Menggunakan 5 Buah Sensor Suhu DS18B20 Kendali PID Control

Alat Kendali Suhu Menggunakan 5 Buah Sensor Suhu DS18B20 Kendali PID Control


        Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat alat kontrol suhu dengan menggunakan 5 buah sensor suhu DS18b20, alat ini menggunakan Arduino + program PID sebagai kontrollernya, sehingga alat ini sangat cocok untuk pemula yang ingin membuat alat dengan kendali suhu dan PID. untuk lebih jelasnya berikut adalah komponen dan programnya.  




a. Arduino Uno




b. Sensor Suhu DS18b20




c. LCD 20 x 4






d. Program Arduino IDE

#include <OneWire.h>
#include <Wire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>
#define suhu_kaki 7

OneWire sh(suhu_kaki);
DallasTemperature sensors(&sh);
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

float suhu1;
float suhu2;
float suhu3;
float suhu4;
float suhu5;

int btup = A4;
int btdown = A3;
int btenter = A2;
int btmonitor = A1;
int waktu;

int btupx = 0;
int btdownx = 0;
int btenterx = 0;
int btmonitorx = 0;

int levlow = 9;
int levhigh = 8;
int buzzer = A5;

int levlowx = 0;
int levhighx = 0;
int cacah = 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;

int detik = 60;
int menit;
int jam;

void setup()
{

  pinMode(btup,INPUT);
  pinMode(btdown,INPUT);
  pinMode(btenter,INPUT);
 
  pinMode(levlow,INPUT);
  pinMode(levhigh,INPUT);
  pinMode(buzzer,OUTPUT);
  digitalWrite(buzzer,HIGH);

  Serial.begin (9600);
  lcd.begin(20,4);

sensors.begin();
lcd.clear();
ceklevel();
menu();
}


void loop()
{
  ambilsuhu();
 
  analogWrite(10,pid);
 
  error = sp - suhu1;
  p = error * kp;
  sumerr = error + errorx;
  i = ki * sumerr;
  d = kd * (error - errorx) ;
  pid = p + i + d;
  //pid = sp - pid;
  //pid = 255.0 - pid;

  if(pid < 1){
  pid = 0;
  }
 
  if(pid > 255){
  pid = 255;
  }

lcd.setCursor(0,0);
lcd.print("SP:");
lcd.print(sp);
lcd.print(" P:");
lcd.print(pid);
lcd.print("       ");
 
lcd.setCursor(0,1);
lcd.print("T:");
lcd.print(suhu1);
lcd.print(" W:");
lcd.print(jam);
lcd.print(":");
lcd.print(menit);
lcd.print(":");
lcd.print(detik);
lcd.print("  ");
       

 btmonitorx = digitalRead(btmonitor);

if(btmonitorx == 1){
  monitorx();
  }

 
if(btmonitorx == 0){
    lcd.setCursor(0,2);
    lcd.print("                    ");
    lcd.setCursor(0,3);
    lcd.print("                    ");
   
  }


if(menit == 0){
 lcd.clear();
 delay(1000);
 selesai();
}
 
errorx = error;


detik--;

if(detik < 0){
detik = 60;
menit--;
}

delay(1000); 
}



void selesai(){
 
digitalWrite(buzzer,LOW); 
lcd.setCursor(0,0);
lcd.print("PROSES SELESAI");

analogWrite(10,0);
       
selesai(); 
}

void monitorx(){
 
    lcd.setCursor(0,2);
    lcd.print("T1:");
    lcd.setCursor(4,2);
    lcd.print(suhu2);
    lcd.setCursor(0,3);
    lcd.print("T2:");
    lcd.setCursor(4,3);
    lcd.print(suhu3);
    lcd.setCursor(11,2);
    lcd.print("T3:");
    lcd.setCursor(15,2);
    lcd.print(suhu4);
    lcd.setCursor(11,3);
    lcd.print("T4:");
    lcd.setCursor(15,3);
    lcd.print(suhu5); 
 
}


void ambilsuhu(){

  sensors.requestTemperatures();

  suhu1 = sensors.getTempCByIndex(0);
  suhu2 = sensors.getTempCByIndex(1);
  suhu3 = sensors.getTempCByIndex(2);
  suhu4 = sensors.getTempCByIndex(3);
  suhu5 = sensors.getTempCByIndex(4);
    
}


void ceklevel(){
 
levlowx = digitalRead(levlow);
levhighx = digitalRead(levhigh);

if(levlowx == 0){
  digitalWrite(buzzer,LOW);
}

if(levlowx == 1){
  digitalWrite(buzzer,HIGH);
}

if(levhighx == 1){
  lcd.clear();
  delay(1000);
  return;
}
    
lcd.setCursor(0,0);
lcd.print("SENSOR1 = ");
lcd.print(levlowx);
 
lcd.setCursor(0,1);
lcd.print("SENSOR2 = ");
lcd.print(levhighx);

ceklevel();  
}


void menu(){

btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btenterx = digitalRead(btenter);
 
lcd.setCursor(0,0);
lcd.print("PILIH MENU ");

if(btupx == 1){
  delay(200);
  cacah++;
}

if(btdownx == 1){
  delay(200);
  cacah--;
}

if(cacah > 6){
cacah = 1; 
}


if(btenterx == 1){
lcd.clear();
delay(3000); 
return; 
}

if(cacah == 1){ 
lcd.setCursor(0,1);
lcd.print("Suhu = 37 C");
lcd.setCursor(0,2);
lcd.print("Waktu = 10 Menit");
sp = 37;
menit = 10;


if(cacah == 2){ 
lcd.setCursor(0,1);
lcd.print("Suhu = 40 C");
lcd.setCursor(0,2);
lcd.print("Waktu = 15 Menit");
sp = 40;
menit = 15;
}

if(cacah == 3){ 
lcd.setCursor(0,1);
lcd.print("Suhu = 45 C");
lcd.setCursor(0,2);
lcd.print("Waktu = 10 Menit");
sp = 45;
menit = 10;
}

if(cacah == 4){ 
lcd.setCursor(0,1);
lcd.print("Suhu = 50 C");
lcd.setCursor(0,2);
lcd.print("Waktu = 10 Menit");
sp = 50;
menit = 10;
}

if(cacah == 5){
lcd.setCursor(0,1);
lcd.print("Suhu = 55 C");
lcd.setCursor(0,2);
lcd.print("Waktu = 10 Menit");
sp = 55;
menit = 10;
}

if(cacah == 6){
lcd.setCursor(0,1);
lcd.print("Suhu = 60 C");
lcd.setCursor(0,2);
lcd.print("Waktu = 10 Menit");
sp = 60;
menit = 10;
}
  
menu(); 
}





e. Cara Kerja Alat

       Pertama yang harus dilakukan yaitu memilih waktu untuk pemanasannya, ada menu 10 menit dan suhu yang diinginkan 60 derajat celcius adapula yang lain tergantung pilih menu yang mana, kemudian tekan tombol start untuk memulai maka alat akan berjalan sesuai setting yang diberikan, untuk merubah setting PID maka rubahlah nilai pada Kp, Ki dan Kd disesuaikan dengan plan yang dibuat. jika alat telah selesai maka buzzer akan berbunyi dan heater akan off.








                                                         

Membuat Alat Mesin Antrian Menggunakan ARDUINO dan Printer Thermal + RTC DS3231 + LED Panel DMD P10 Counter Up

Membuat Alat Mesin Antrian Menggunakan ARDUINO dan Printer Thermal + RTC DS3231 + LED Panel DMD P10 Counter Up


          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang berjudul "MESIN ANTRIAN BERBASIS ARDUINO". alat ini menggunakan led panel dmd p10 sebagai interface angka kemudian terdapat printer thermal untuk mencetak kertas antriannya, alat ini dilengkapi dengan RTC DS1307 atau DS3231. untuk lebih jelasnya berikut adalah komponen dan programnya. 




a. Arduino Uno




b. Led Panel DMD P10




c. Printer Thermal





d. Modul RTC DS1307 / DS3231





e. Program Arduino IDE

#include <SPI.h>        //SPI.h must be included as DMD is written by SPI (the IDE complains otherwise)
#include <DMD.h>        //Library DMD yang menyediakan fungsi penampilan teks, gambar dsb
#include <TimerOne.h>   //Library peripheral Timer1 untuk menjalankan prosedur pindai panel DMD
#include <Time.h>     //Library waktu yang menyediakan tipe data, struktur, dan obyek waktu
#include <DS1307RTC.h>  // Library RTC
// Font yang digunakan
#include <SPI.h>      
#include <DMD.h>      
#include <TimerOne.h> 
#include "Arial_black_16.h"
#include "Arial_Black_16_ISO_8859_1.h"
#include "Arial14.h"
#include "DejaVuSans9.h"
#include "DejaVuSansBold9.h"
#include "DejaVuSansItalic9.h"
#include "Droid_Sans_12.h"
#include "Droid_Sans_16.h"
#include "Mono5x7.h"
#include "SystemFont5x7.h"
#include <SoftwareSerial.h>

#include "Wire.h"
#include "Adafruit_Thermal.h"

SoftwareSerial Thermal(2, 3);
Adafruit_Thermal printer(&Thermal);

#define WAKTU_TAMPIL_JAM      10    //detik
#define WAKTU_TAMPIL_KALENDAR 5     //detik

#define DISPLAY_COLUMN_COUNT  2
#define DISPLAY_ROW_COUNT     1

#define PIXELS_PER_COLUMN  32
#define PIXELS_PER_ROW    16

#define DS3231_I2C_ADDRESS 0x68

int zero=0;
int heatTime = 80;
int heatInterval = 255;
char printDensity = 15;
char printBreakTime = 15;

int antri = 0;

int cacah;
int angka = 0;
int satuan = 0;
int puluhan = 0;
int ratusan = 0;

char angkax;
char satuanx;
char puluhanx;
char ratusanx;

int btprint = A0;
int btnext = A2;
int btprintx;
int btnextx;


DMD dmd(DISPLAY_COLUMN_COUNT, DISPLAY_ROW_COUNT);
unsigned char show = 0;

const char namaHari[7][7] PROGMEM = { "MINGGU", "SENIN", "SELASA",
                                      "RABU", "KAMIS", "JUMAT", "SABTU"
                                    };
const char namaBulan[12][10] PROGMEM = { "01", "02", "03",
                                        "04", "05", "06", "07",
                                        "08", "09", "10",
                                        "11", "12"
                                      };

void AturWaktuRTC();
void (*restart)(void) = 0x00;
void print2digits(int number);

unsigned char DetikTerakhir, MenitTerakhir, JamTerakhir,
         HariTerakhir, TanggalTerakhir, BulanTerakhir;
unsigned int TahunTerakhir;
tmElements_t wkt;
unsigned char SecCount = 0;
bool Mode = false; // false = tampilan Jam, true = tampilan hari,tanggal,bulan,tahun

//Fire up the DMD library as dmd
//DMD dmd(2, 1);

/*--------------------------------------------------------------------------------------
  Interrupt handler for Timer1 (TimerOne) driven DMD refresh scanning, this gets
  called at the period set in Timer1.initialize();
  --------------------------------------------------------------------------------------*/
void ScanDMD()
{
  dmd.scanDisplayBySPI();
}

/*--------------------------------------------------------------------------------------
  Show clock numerals on the screen from a 4 digit time value, and select whether the
  flashing colon is on or off
  --------------------------------------------------------------------------------------*/
void DisplayHour(unsigned char Hour)
{
  dmd.drawChar(  34,  2, ' ', GRAPHICS_NORMAL );
  dmd.drawChar(  34,  2, '0' + (Hour / 10), GRAPHICS_NORMAL );
  dmd.drawChar(  40,  2, ' ', GRAPHICS_NORMAL );
  dmd.drawChar(  40,  2, '0' + (Hour % 10), GRAPHICS_NORMAL );
}

void DisplayMinute(unsigned char Minute)
{
  dmd.drawChar( 49,  2, ' ', GRAPHICS_NORMAL );
  dmd.drawChar( 49,  2, '0' + (Minute / 10), GRAPHICS_NORMAL );
  dmd.drawChar( 55,  2, ' ', GRAPHICS_NORMAL );
  dmd.drawChar( 55,  2, '0' + (Minute % 10), GRAPHICS_NORMAL );
}


void DisplayDate(unsigned char DayOfWeek,
                 unsigned char Day,
                 unsigned char Month,
                 unsigned int Year)
{
  char DayName[7];
  char MonthName[10];

  memset(DayName, 0, 7);
  memset(MonthName, 0, 10);
  strcpy_P(DayName, namaHari[DayOfWeek - 1]);
  strcpy_P(MonthName, namaBulan[Month - 1]);
  char lineBuff[20];

  //dmd.drawString(32, 3, lineBuff, strlen(lineBuff), GRAPHICS_NORMAL);
  //dmd.drawString(0, 3, DayName, strlen(DayName), GRAPHICS_NORMAL);
  sprintf(lineBuff, "%s %02d/%s/%d", DayName, Day, MonthName, Year - 2000);


  ShowMarquee(lineBuff,false);
}

void ShowDateTime(unsigned char Day,
                  unsigned char Date,
                  unsigned char Month,
                  unsigned int Year,
                  unsigned char Hour,
                  unsigned char Minute,
                  bool bColonOn)
{
  dmd.clearScreen(true);

  // units

}


byte decToBcd(byte val)
{
  return( (val/10*16) + (val%10) );
}

byte bcdToDec(byte val)
{
  return( (val/16*10) + (val%16) );
}


void initPrinter()
{
 //Modify the print speed and heat
 Thermal.write(27);
 Thermal.write(55);
 Thermal.write(7); //Default 64 dots = 8*('7'+1)
 Thermal.write(heatTime); //Default 80 or 800us
 Thermal.write(heatInterval); //Default 2 or 20us
 //Modify the print density and timeout
 Thermal.write(18);
 Thermal.write(35);
 int printSetting = (printDensity<<4) | printBreakTime;
 Thermal.write(printSetting); //Combination of printDensity and printBreakTime

}


/*--------------------------------------------------------------------------------------
  setup
  Called by the Arduino architecture before the main loop begins
  --------------------------------------------------------------------------------------*/
void setup(void)
{

  Wire.begin();
  Thermal.begin(9600);
 
  pinMode(btprint,INPUT_PULLUP);
  pinMode(btnext,INPUT_PULLUP);

  pinMode(A1,OUTPUT);
  pinMode(A3,OUTPUT);

  digitalWrite(A1,LOW);
  digitalWrite(A3,LOW);
 
  bool aturRTC = false;
 
  // Inisialisai komunikasi serial dengan PC
  Serial.begin(9600);
  delay(1000);
  if ((!(RTC.read(wkt))) || (aturRTC)) { // Jika fresh run
    AturWaktuRTC();
  }
  else {
    Serial.println("Ketik 'ATUR' Untuk mengatur ulang waktu RTC");
  }

  // inisialisasi awal nilai waktu
  DetikTerakhir = 99;
  MenitTerakhir = 99;
  JamTerakhir = 99;
  HariTerakhir = 99;
  TanggalTerakhir = 99;
  BulanTerakhir = 99;
  TahunTerakhir = 99999;

  //initialize TimerOne's interrupt/CPU usage used to scan and refresh the display
  Timer1.initialize( 1000 );           //period in microseconds to call ScanDMD. Anything longer than 5000 (5ms) and you can see flicker.
  Timer1.attachInterrupt( ScanDMD );   //attach the Timer1 interrupt to ScanDMD which goes to dmd.scanDisplayBySPI()

  //clear/init the DMD pixels held in RAM
  dmd.clearScreen( true );   //true is normal (all pixels off), false is negative (all pixels on)
  //delay(1500);
}

/*--------------------------------------------------------------------------------------
  loop
  Arduino architecture main loop
  --------------------------------------------------------------------------------------*/
void loop(void)
{
  int i;
  unsigned char DetikSekarang, MenitSekarang, JamSekarang,
           HariSekarang, TanggalSekarang, BulanSekarang;
  unsigned int TahunSekarang;

  // Lihat apakah input serial dari pengguna
  // lebih besar atau sama dg 4 byte
  if (Serial.available() >= 4) {
    char buff[5];

    Serial.readBytes(buff, 4);
    // Jika input serial dari pengguna adalah ATUR, maka lakukan prosedur
    // pengaturan waktru RTC
    if ((buff[0] == 'A') && (buff[1] == 'T') && (buff[2] == 'U') && (buff[3] == 'R')) {
      AturWaktuRTC();
    }
  }

  if (!RTC.read(wkt)) {
    Serial.println("RTC error!");
    delay(500);
    restart();
  }


btprintx = digitalRead(btprint);
btnextx = digitalRead(btnext);

if(btprintx == 0){
  delay(200);
  antri++;
  printx();
  }

if(btnextx == 0){
  delay(200);
  angka++;
  }

ratusan = angka /100;
angka = angka % 100;
puluhan = angka / 10;
satuan = angka % 10;

ratusanx = ratusan;
puluhanx = puluhan;
satuanx = satuan;

      dmd.selectFont(Arial_Black_16);
      dmd.drawChar(  34,  1, '0' + (ratusanx), GRAPHICS_NORMAL );

      dmd.selectFont(Arial_Black_16);
      dmd.drawChar(  44,  1, '0' + (puluhanx), GRAPHICS_NORMAL );

      dmd.selectFont(Arial_Black_16);
      dmd.drawChar(  54,  1, '0' + (satuanx), GRAPHICS_NORMAL );

    HariSekarang = wkt.Wday;
    TanggalSekarang = wkt.Day;
    BulanSekarang = wkt.Month;
    TahunSekarang = wkt.Year;

   
  cacah++;  
  delay(200);

//untuk tanggal dan hari berjalan
/*
if(cacah > 150){
      dmd.selectFont(Arial_Black_16);
      dmd.selectFont(Mono5x7);
      DisplayDate(HariSekarang, TanggalSekarang,
                  BulanSekarang, tmYearToCalendar(TahunSekarang));
     cacah = 0;
  }
*/


}

void AturWaktuRTC()
{
  int input;
  char buff[10];
  tmElements_t wkt;

  Serial.println(F("-------------------------\nAtur ulang waktu RTC"));

  // Minta pengguna memasukan hari
  Serial.println(F("\nMasukkan 2 digit kode hari\n01: Minggu\n02: Senin\n03: " \
                   "Selasa\n04: Rabu\n05: Kamis\n06: Jumat\n07: Sabtu\n>>>"));
  while (Serial.available() < 2);
  Serial.readBytes(buff, 2);
  sscanf(buff, "%02d", &input);
  if ((input >= 1) && (input <= 7)) {
    wkt.Wday = input;
    Serial.print("Sekarang hari: ");
    strcpy_P(buff, (const char*)namaHari[wkt.Wday - 1]);
    Serial.println(buff);
  }
  else {
    Serial.print("Input salah! Restarting...");
    restart();
  }

  // Minta pengguna memasukan tanggal
  Serial.println(F("\nMasukkan 2 digit tanggal (01-31)\n>>>"));
  while (Serial.available() < 2);
  Serial.readBytes(buff, 2);
  sscanf(buff, "%02d", &input);
  if ((input >= 1) && (input <= 31)) {
    wkt.Day = input;
    Serial.print("Sekarang tanggal: ");
    Serial.println(wkt.Day, DEC);
  }
  else {
    Serial.print("Input salah! Restarting...");
    restart();
  }

  // Minta pengguna memasukan bulan
  Serial.println(F("\nMasukkan 2 digit kode bulan\n01: Jan\n02: Feb\n03: " \
                   "Mar\n04: Apr\n05: Mei\n06: Jun\n07: Jul\n08: Ags\n09: Sep\n10: Okt\n"
                   "11: Nov\n12: Des\n>>>"));
  while (Serial.available() < 2);
  Serial.readBytes(buff, 2);
  sscanf(buff, "%02d", &input);
  if ((input >= 1) && (input <= 12)) {
    wkt.Month = input;
    Serial.print("Sekarang bulan: ");
    strcpy_P(buff, (const char*)namaBulan[wkt.Month - 1]);
    Serial.println(buff);
  }
  else {
    Serial.print("Input salah! Restarting...");
    restart();
  }

  // Minta pengguna memasukan tahun
  Serial.println(F("\nMasukkan 4 digit tahun (2000-2100)\n>>>"));
  while (Serial.available() < 4);
  Serial.readBytes(buff, 4);
  sscanf(buff, "%4d", &input);
  if (input >= 2000 && input <= 2100) {
    wkt.Year = CalendarYrToTm(input);
    Serial.print("Sekarang tahun: ");
    Serial.println(tmYearToCalendar(wkt.Year), DEC);
  }
  else {
    Serial.print(F("Input salah!, tahun akan diatur ke 2015 secara default"));
    wkt.Year = CalendarYrToTm(2015);
  }

  // Minta pengguna memasukan jam
  Serial.println(F("\nMasukkan 2 digit jam (00-23)\n>>>"));
  while (Serial.available() < 2);
  Serial.readBytes(buff, 2);
  sscanf(buff, "%02d", &input);
  wkt.Hour = input;
  Serial.println(F("\nMasukkan 2 digit menit (00-59)\n>>>"));
  while (Serial.available() < 2);
  Serial.readBytes(buff, 2);
  sscanf(buff, "%02d", &input);
  wkt.Minute = input;
  Serial.print(F("Sekarang pukul "));
  sprintf(buff, "%02d:%02d", wkt.Hour, wkt.Minute);
  Serial.println(buff);

  Serial.print(F("\nMengkonfigurasi waktu RTC..."));
  if (RTC.write(wkt)) {
    Serial.println(F("OK"));
    Serial.print(F("Membaca waktu RTC..."));
    if (RTC.read(wkt)) {
      Serial.println(F("OK"));
      Serial.print("Pukul = ");
      print2digits(wkt.Hour);
      Serial.write(':');
      print2digits(wkt.Minute);
      Serial.write(':');
      print2digits(wkt.Second);
      Serial.print(", Date (D/M/Y) = ");
      Serial.print(wkt.Day);
      Serial.write('/');
      Serial.print(wkt.Month);
      Serial.write('/');
      Serial.print(tmYearToCalendar(wkt.Year));
      Serial.println();
    }
    else {
      Serial.println(F("FAILED"));
    }

  }
  else {
    Serial.println(F("FAILED"));
  }
  Serial.println(F("-------------------------"));
}

void print2digits(int number) {
  if (number >= 0 && number < 10) {
    Serial.write('0');
  }
  Serial.print(number);
}


void ShowMarquee(char *Text, bool LeftToRight)
{
  long start=millis();
  long timer=start;
  boolean ret=false;

  if (LeftToRight) {
    dmd.drawMarquee(Text,strlen(Text),
          -(dmd.fontWidth()*(strlen(Text)-1)),3);
  }
  else
    dmd.drawMarquee(Text,strlen(Text),
          (PIXELS_PER_COLUMN*DISPLAY_COLUMN_COUNT)-1,3); 

  while(!ret){
   if ((timer+100) < millis()) {
     if (LeftToRight)
        ret=dmd.stepMarquee(1,0); // Geser 1 karakter ke kiri
     else
        ret=dmd.stepMarquee(-1,0); // Geser 1 karakter ke kanan
     timer=millis();
   }
  }      
}



void setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, byte dayOfMonth, byte month, byte year)
{
  // sets time and date data to DS3231
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0); // set next input to start at the seconds register
  Wire.write(decToBcd(second)); // set seconds
  Wire.write(decToBcd(minute)); // set minutes
  Wire.write(decToBcd(hour)); // set hours
  Wire.write(decToBcd(dayOfWeek)); // set day of week (1=Sunday, 7=Saturday)
  Wire.write(decToBcd(dayOfMonth)); // set date (1 to 31)
  Wire.write(decToBcd(month)); // set month
  Wire.write(decToBcd(year)); // set year (0 to 99)
  Wire.endTransmission();
}

void readDS3231time(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0); // set DS3231 register pointer to 00h
  Wire.endTransmission();
  Wire.requestFrom(DS3231_I2C_ADDRESS, 7);
  // request seven bytes of data from DS3231 starting from register 00h
  *second = bcdToDec(Wire.read() & 0x7f);
  *minute = bcdToDec(Wire.read());
  *hour = bcdToDec(Wire.read() & 0x3f);
  *dayOfWeek = bcdToDec(Wire.read());
  *dayOfMonth = bcdToDec(Wire.read());
  *month = bcdToDec(Wire.read());
  *year = bcdToDec(Wire.read());
}
void displayTime()
{
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  // retrieve data from DS3231
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month,
  &year);
  // send it to the serial monitor
  Serial.print(hour, DEC);
  // convert the byte variable to a decimal number when displayed
  Serial.print(":");
  if (minute<10)
  {
    Serial.print("0");
  }
  Serial.print(minute, DEC);
  Serial.print(":");
  if (second<10)
  {
    Serial.print("0");
  }
  Serial.print(second, DEC);
  Serial.print(" ");
  Serial.print(dayOfMonth, DEC);
  Serial.print("/");
  Serial.print(month, DEC);
  Serial.print("/");
  Serial.print(year, DEC);
  Serial.print(" Hari : ");
  switch(dayOfWeek){
  case 1:
    Serial.println("MINGGU");
    break;
  case 2:
    Serial.println("SENIN");
    break;
  case 3:
    Serial.println("SELASA");
    break;
  case 4:
    Serial.println("RABU");
    break;
  case 5:
    Serial.println("KAMIS");
    break;
  case 6:
    Serial.println("JUM'AT");
    break;
  case 7:
    Serial.println("SABTU");
    break;
  }
}




void printTime()
{
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  // retrieve data from DS3231
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month,
  &year);
  // send it to the serial monitor
  Thermal.print(hour, DEC);
  // convert the byte variable to a decimal number when displayed
  Thermal.print(":");
  if (minute<10)
  {
    Thermal.print("0");
  }
 Thermal.print(minute, DEC);
  Thermal.print(":");
  if (second<10)
  {
    Thermal.print("0");
  }
  Thermal.print(second, DEC);
  Thermal.print(" ");
  Thermal.print(dayOfMonth, DEC);
  Thermal.print("/");
  Thermal.print(month, DEC);
  Thermal.print("/");
  Thermal.print(year, DEC);
  Thermal.print(" Hari : ");
  switch(dayOfWeek){
  case 1:
    Thermal.println("MINGGU");
    break;
  case 2:
    Thermal.println("SENIN");
    break;
  case 3:
    Thermal.println("SELASA");
    break;
  case 4:
    Thermal.println("RABU");
    break;
  case 5:
    Thermal.println("KAMIS");
    break;
  case 6:
    Thermal.println("JUM'AT");
    break;
  case 7:
    Thermal.println("SABTU");
    break;
  }
}




void printx(){

//NORMAL MODE
  printer.setSize('M');
  Thermal.println("MESIN ANTRIAN");
  Thermal.write(10);

  //print waktu
  printer.setSize('S');
  printTime();
  Thermal.write(10);

  //print nomer
  printer.setSize('L');
  Thermal.print("NOMOR = ");
  Thermal.print(antri);
  Thermal.write(10);
  Thermal.write(10); 
  Thermal.write(10); 
  Thermal.write(10); 
  Thermal.write(10); 
  Thermal.write(10);     
  }






f. VIDEO HASILNYA










GRAFIK LINE VISUAL BASIC 6.0 INPUT TEXT BOX

GRAFIK LINE VISUAL BASIC 6.0 INPUT TEXT BOX


           Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah aplikasi yang bisa menampilkan grafik menggunakan software visual basic 6.0. grafik yang dibuat bukanlah grafik yang berjalan secara realtime namun grafik ini bersifat statis yang mana inputnya tergantung pada nilai yang diberikan pada text box. untuk lebih jelasnya berikut adalah programnya.




a. Step Import Chart





b. Program VB 6.0 Menampilkan Grafik

Dim numa As Single
Dim numb As Single
Dim numc As Single
Dim numd As Single
Dim nume As Single

Dim stra As String
Dim strb As String
Dim strc As String
Dim strd As String
Dim stre As String

Dim straa As String
Dim strbb As String
Dim strcc As String
Dim strdd As String
Dim stree As String

Private Sub Command1_Click()

straa = Text1.Text
strbb = Text2.Text
strcc = Text3.Text
strdd = Text4.Text
stree = Text5.Text

stra = Text6.Text
strb = Text7.Text
strc = Text8.Text
strd = Text9.Text
stre = Text10.Text

numa = Val(stra)
numb = Val(strb)
numc = Val(strc)
numd = Val(strd)
nume = Val(stre)

strf = Text11.Text
strg = Text12.Text
strh = Text13.Text
stri = Text14.Text
strj = Text15.Text

numf = Val(strf)
numg = Val(strg)
numh = Val(strh)
numi = Val(stri)
numj = Val(strj)

MSChart1.chartType = Combo1.ListIndex

'2D array --> chart values
Dim x(1 To 6, 1 To 3) As Variant
x(1, 2) = "ARGO BROMO"
x(1, 3) = "ARGO ANGGREK"

x(2, 1) = straa
x(2, 2) = numa
x(2, 3) = numf

x(3, 1) = strbb
x(3, 2) = numb
x(3, 3) = numg

x(4, 1) = strcc
x(4, 2) = numc
x(4, 3) = numh

x(5, 1) = strdd
x(5, 2) = numd
x(5, 3) = numi

x(6, 1) = stree
x(6, 2) = nume
x(6, 3) = numj


'2D array --> chart data
MSChart1.ChartData = x
End Sub

Private Sub Form_Load()
'List Combo: chart types
With Combo1
.AddItem "3D Bar"
.AddItem "2D Bar"
.AddItem "3D Line"
.AddItem "2D LIne"
.AddItem "3D Area"
.AddItem "2D Area"
.AddItem "3D Step"
.AddItem "2D Step"
.AddItem "3D Combination"
.AddItem "2D Combination"

.ListIndex = 3
End With
Check1.Caption = "&Show Legends"

End Sub
   
Private Sub Check1_Click()
If Check1.Value = 1 Then
'Show Legends
MSChart1.ShowLegend = True
Check1.Caption = "&Hide Legends"
Else
'Hide Legends
MSChart1.ShowLegend = False
Check1.Caption = "&Show Legends"
End If
End Sub




c. Cara Menjalankan Program


  
1. Input nilai pada text box yang tersedia
2. Tekan tombol start untuk memulai
3. Jika ingin melihat deskripsi grafik maka cek list pada "legend"
4. Jika ingin merubah jenis grafik maka pilih pada combo box
5. Jika ingin close tekan tombol close pada pojok atas 







ARDUINO Monitoring 5 SUHU Thermocouple Tipe K DATALOGGER EEPROM (Multiple Sensor)

ARDUINO Monitoring 5 SUHU Thermocouple Tipe K DATALOGGER EEPROM (Multiple Sensor)


           Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang berfungsi untuk memonitor suhu menggunakan sensor thermocouple sebanyak 5 buah dan dimonitoring secara bersamaan. alat ini menggunakan sistem penyimpanan EEPROM sebagai dataloggernya dan juga terdapat tombol konversi yang dapat merubah dari celsius ke reamur ataupun ke kelvin atau fahrenheit. untuk lebih jelasnya berikut adalah komponen dan programnya,



a. Arduino Uno




b. Sensor Thermocouple Tipe K (5 pcs)




c. LCD + I2C






d. Program Arduino IDE

#include <max6675.h> 
#include <EEPROM.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>

int thermoS01 = 6; //bisa juga S0
int thermoCS1 = 7;
int thermoCLK1 = 3; //bisa juga SCK
int thermoS02 = 6; //bisa juga S0
int thermoCS2 = 8;
int thermoCLK2 = 3; //bisa juga SCK
int thermoS03 = 6; //bisa juga S0
int thermoCS3 = 9;
int thermoCLK3 = 3; //bisa juga SCK
int thermoS04 = 6; //bisa juga S0
int thermoCS4 = 10;
int thermoCLK4 = 3; //bisa juga SCK
int thermoS05 = 6; //bisa juga S0
int thermoCS5 = 11;
int thermoCLK5 = 3; //bisa juga SCK
MAX6675 thermo1(thermoCLK1,thermoCS1,thermoS01);
MAX6675 thermo2(thermoCLK2,thermoCS2,thermoS02);
MAX6675 thermo3(thermoCLK3,thermoCS3,thermoS03);
MAX6675 thermo4(thermoCLK4,thermoCS4,thermoS04);
MAX6675 thermo5(thermoCLK5,thermoCS5,thermoS05);
#include <SPI.h>
#include <SD.h>

int mark = 0;

int addr1 = 0;
int addr2 = 1;
int addr3 = 2;
int addr4 = 3;
int addr5 = 4;
int addr6 = 5;
int addr7 = 6;
int addr8 = 7;
int addr9 = 8;
int addr10 = 9;

LiquidCrystal_I2C lcd(0x27, 20,4);
uint8_t degree[8]  = {140, 146, 146, 140, 128, 128, 128, 128}; // untuk membuat simbol derajat

int btsave = 10;
int btkonv = 9;
int btmemori = 11;

int btsavex = 0;
int btkonvx = 0;
int btmemorix = 0;

float val1;
float val2;
float val3;
float val4;
float val5;
int hitung;

float simpan1;
float simpan2;
float simpan3;
float simpan4;
float simpan5;
float simpan6;
float simpan7;
float simpan8;
float simpan9;
float simpan10;



void setup() {
  pinMode(btsave,INPUT);
  pinMode(btkonv,INPUT);
  pinMode(btmemori,INPUT);
 
  lcd.begin();

  lcd.noCursor();
  lcd.clear();
  //lcd.init();
  lcd.setBacklight(HIGH);
  lcd.createChar(0, degree);
 
  delay(1000);
  lcd.noCursor();
  lcd.clear();
  //lcd.init();
  lcd.setBacklight(HIGH);
  lcd.createChar(0, degree);
  lcd.clear();
 delay(1000);
}

void loop()
{  
 
     val1 = thermo1.readCelsius();
     val2 = thermo2.readCelsius();
     val3 = thermo3.readCelsius();
     val4 = thermo4.readCelsius();
     val5 = thermo5.readCelsius();
   
  //celcius
  if(mark == 0){
      //lcd.clear();// clear previous values from screen (1)
      lcd.setCursor(0,0);// set cursor at character 0, line 0      
      lcd.print("T1:");
      lcd.setCursor(3,0);// set cursor at character 0, line 1
      lcd.print(thermo1.readCelsius()); // print temperature in Celsius
      lcd.print(" ");
      lcd.setCursor(8,0);// set cursor at character 9, line 1
      //lcd.print("C");   

      lcd.setCursor(11,0);// set cursor at character 0, line 0      
      lcd.print("T2:");
      lcd.setCursor(14,0);// set cursor at character 0, line 1
      lcd.print(thermo2.readCelsius()); // print temperature in Celsius
      lcd.print(" ");
      lcd.setCursor(19,0);// set cursor at character 9, line 1
      //lcd.print("C");   

      lcd.setCursor(8,1);// set cursor at character 0, line 0      
      lcd.print("T3:");
      lcd.setCursor(11,1);// set cursor at character 0, line 1
      lcd.print(thermo3.readCelsius()); // print temperature in Celsius
      lcd.print(" ");
      lcd.setCursor(16,1);// set cursor at character 9, line 1
      //lcd.print("C");   

      lcd.setCursor(0,2);// set cursor at character 0, line 0      
      lcd.print("T4:");
      lcd.setCursor(3,2);// set cursor at character 0, line 1
      lcd.print(thermo4.readCelsius()); // print temperature in Celsius
      lcd.print(" ");
      lcd.setCursor(8,2);// set cursor at character 9, line 1
      //lcd.print("C");   

      lcd.setCursor(11,2);// set cursor at character 0, line 0      
      lcd.print("T5:");
      lcd.setCursor(14,2);// set cursor at character 0, line 1
      lcd.print(thermo5.readCelsius()); // print temperature in Celsius
      lcd.print(" ");     
      lcd.setCursor(19,2);// set cursor at character 9, line 1
      lcd.setCursor(0,3);
      lcd.print("Celsius          "); 
  }             


  //reamur
  if(mark == 1){
      //lcd.clear();// clear previous values from screen (1)
      lcd.setCursor(0,0);// set cursor at character 0, line 0      
      lcd.print("T1:");
      lcd.setCursor(3,0);// set cursor at character 0, line 1
      lcd.print(thermo1.readCelsius() * 0.8); // print temperature in Celsius
      lcd.print(" ");
      lcd.setCursor(8,0);// set cursor at character 9, line 1
      //lcd.print("C");   

      lcd.setCursor(11,0);// set cursor at character 0, line 0      
      lcd.print("T2:");
      lcd.setCursor(14,0);// set cursor at character 0, line 1
      lcd.print(thermo2.readCelsius() * 0.8); // print temperature in Celsius
      lcd.print(" ");
      lcd.setCursor(19,0);// set cursor at character 9, line 1
      //lcd.print("C");   

      lcd.setCursor(8,1);// set cursor at character 0, line 0      
      lcd.print("T3:");
      lcd.setCursor(11,1);// set cursor at character 0, line 1
      lcd.print(thermo3.readCelsius() * 0.8); // print temperature in Celsius
      lcd.print(" ");
      lcd.setCursor(16,1);// set cursor at character 9, line 1
      //lcd.print("C");   

      lcd.setCursor(0,2);// set cursor at character 0, line 0      
      lcd.print("T4:");
      lcd.setCursor(3,2);// set cursor at character 0, line 1
      lcd.print(thermo4.readCelsius() * 0.8); // print temperature in Celsius
      lcd.print(" ");
      lcd.setCursor(8,2);// set cursor at character 9, line 1
      //lcd.print("C");   

      lcd.setCursor(11,2);// set cursor at character 0, line 0      
      lcd.print("T5:");
      lcd.setCursor(14,2);// set cursor at character 0, line 1
      lcd.print(thermo5.readCelsius() * 0.8); // print temperature in Celsius
      lcd.print(" ");     
      lcd.setCursor(19,2);// set cursor at character 9, line 1
      lcd.setCursor(0,3);
      lcd.print("Reamur           "); 
  }             


  //Fahrenheit
  if(mark == 2){
      //lcd.clear();// clear previous values from screen (1)
      lcd.setCursor(0,0);// set cursor at character 0, line 0      
      lcd.print(" T1:");
      lcd.setCursor(4,0);// set cursor at character 0, line 1
      lcd.print(thermo1.readCelsius() * 1.8 + 32); // print temperature in Celsius
      lcd.print(" ");
      lcd.setCursor(8,0);// set cursor at character 9, line 1
      //lcd.print("C");   

      lcd.setCursor(11,0);// set cursor at character 0, line 0      
      lcd.print("T2:");
      lcd.setCursor(14,0);// set cursor at character 0, line 1
      lcd.print(thermo2.readCelsius() * 1.8 + 32); // print temperature in Celsius
      lcd.print(" ");
      lcd.setCursor(19,0);// set cursor at character 9, line 1
      //lcd.print("C");   

      lcd.setCursor(8,1);// set cursor at character 0, line 0      
      lcd.print("T3:");
      lcd.setCursor(11,1);// set cursor at character 0, line 1
      lcd.print(thermo3.readCelsius() * 1.8 + 32); // print temperature in Celsius
      lcd.print(" ");
      lcd.setCursor(16,1);// set cursor at character 9, line 1
      //lcd.print("C");   

      lcd.setCursor(0,2);// set cursor at character 0, line 0      
      lcd.print("T4:");
      lcd.setCursor(3,2);// set cursor at character 0, line 1
      lcd.print(thermo4.readCelsius() * 1.8 + 32); // print temperature in Celsius
      lcd.print(" ");
      lcd.setCursor(8,2);// set cursor at character 9, line 1
      //lcd.print("C");   

      lcd.setCursor(11,2);// set cursor at character 0, line 0      
      lcd.print("T5:");
      lcd.setCursor(14,2);// set cursor at character 0, line 1
      lcd.print(thermo5.readCelsius() * 1.8 + 32); // print temperature in Celsius
      lcd.print(" ");     
      lcd.setCursor(19,2);// set cursor at character 9, line 1
      lcd.setCursor(0,3);
      lcd.print("Fahrenheit           "); 
  }             



  //Kelvin
  if(mark == 3){
      //lcd.clear();// clear previous values from screen (1)
      lcd.setCursor(0,0);// set cursor at character 0, line 0      
      lcd.print("T1:");
      lcd.setCursor(3,0);// set cursor at character 0, line 1
      lcd.print(thermo1.readCelsius() * 1.8 + 32); // print temperature in Celsius
      lcd.print(" ");
      lcd.setCursor(8,0);// set cursor at character 9, line 1
      //lcd.print("C");   

      lcd.setCursor(11,0);// set cursor at character 0, line 0      
      lcd.print("T2:");
      lcd.setCursor(14,0);// set cursor at character 0, line 1
      lcd.print(thermo2.readCelsius() * 1.8 + 32); // print temperature in Celsius
      lcd.print(" ");
      lcd.setCursor(19,0);// set cursor at character 9, line 1
      //lcd.print("C");   

      lcd.setCursor(8,1);// set cursor at character 0, line 0      
      lcd.print("T3:");
      lcd.setCursor(11,1);// set cursor at character 0, line 1
      lcd.print(thermo3.readCelsius() * 1.8 + 32); // print temperature in Celsius
      lcd.print(" ");
      lcd.setCursor(16,1);// set cursor at character 9, line 1
      //lcd.print("C");   

      lcd.setCursor(0,2);// set cursor at character 0, line 0      
      lcd.print("T4:");
      lcd.setCursor(3,2);// set cursor at character 0, line 1
      lcd.print(thermo4.readCelsius() * 1.8 + 32); // print temperature in Celsius
      lcd.print(" ");
      lcd.setCursor(8,2);// set cursor at character 9, line 1
      //lcd.print("C");   

      lcd.setCursor(11,2);// set cursor at character 0, line 0      
      lcd.print("T5:");
      lcd.setCursor(14,2);// set cursor at character 0, line 1
      lcd.print(thermo5.readCelsius() * 1.8 + 32); // print temperature in Celsius
      lcd.print(" ");     
      lcd.setCursor(19,2);// set cursor at character 9, line 1
      lcd.setCursor(0,3);
      lcd.print("Fahrenheit"); 
  }             
   
   delay(1000);

btsavex = digitalRead(btsave);
btkonvx = digitalRead(btkonv);
btmemorix = digitalRead(btmemori);



if(btmemorix == 1){
delay(200);
lcd.clear();
simpan1 = EEPROM.read(addr1);
simpan2 = EEPROM.read(addr2);
simpan3 = EEPROM.read(addr3);
simpan4 = EEPROM.read(addr4);
simpan5 = EEPROM.read(addr5);
simpan6 = EEPROM.read(addr6);
simpan7 = EEPROM.read(addr7);
simpan8 = EEPROM.read(addr8);
simpan9 = EEPROM.read(addr9);
simpan10 = EEPROM.read(addr10);

lcd.setCursor(0,0);
lcd.print("T1/6= ");
lcd.print(simpan1);
lcd.print("/");
lcd.print(simpan6);
lcd.print("    ");

lcd.setCursor(0,1);
lcd.print("T2/7= ");
lcd.print(simpan2);
lcd.print("/");
lcd.print(simpan7);
lcd.print("    ");

lcd.setCursor(0,2);
lcd.print("T3/8= ");
lcd.print(simpan3);
lcd.print("/");
lcd.print(simpan8);
lcd.print("    ");

lcd.setCursor(0,3);
lcd.print("T4/9= ");
lcd.print(simpan4);
lcd.print("/");
lcd.print(simpan9);
lcd.print("    ");

delay(5000);
lcd.clear();

lcd.setCursor(0,0);
lcd.print("T5/10= ");
lcd.print(simpan5);
lcd.print("/");
lcd.print(simpan10);
lcd.print("    ");

delay(5000);
lcd.clear();


}


if((btsavex == 1)&&(hitung == 0)){
   EEPROM.write(addr1, val1);
   EEPROM.write(addr2, val2);
   EEPROM.write(addr3, val3);
   EEPROM.write(addr4, val4); 
   EEPROM.write(addr5, val5);
 hitung = 1;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("SAVING 1");
delay(3000);
lcd.clear();
btsavex = 0;
 }


if((btsavex == 1)&&(hitung == 1)){
   EEPROM.write(addr6, val1);
   EEPROM.write(addr7, val2);
   EEPROM.write(addr8, val3);
   EEPROM.write(addr9, val4);
   EEPROM.write(addr10, val5);
hitung = 0;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("SAVING 2");
delay(3000);
lcd.clear();
btsavex = 0;  
}


if(btkonvx == 1){
delay(200);
  mark++;
}

if(mark > 3){
mark = 0;
}


}






e. Cara Menjalankan Alat

       Cara menjalankan alat ini yang pertama yaitu hubungkan alat dengan power supply atau adaptor kemudian pastikan semua komponen sudah terpasang secara tepat, untuk pin arduino yang terhubung ke sensor bisa dilihat pada program di bagian atas. selanjutnya tekan tombol untuk konversi, simpan data ke EEPROM dan baca data yang ada di EEPROM.