Sistem Pemantauan dan Pengukuran Suhu Tinggi Secara Real Time dengan Jarak Jauh Berbasis Mikrokontroler dan Tampilan PC

Lampiran 1
Listing program dari seluruh sistem .
/*****************************************************
This program was produced by the
CodeWizardAVR V2.04.9 Evaluation
Automatic Program Generator
© Copyright 1998-2010 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project :
Version :
Date
: 11/04/2016
Author : Freeware, for evaluation and non-commercial use
only
Company :
Comments:
Chip type
:
Program type
:
AVR Core Clock frequency:

Memory model
:
External RAM size
:
Data Stack size
:

ATmega8535
Application
4,000000 MHz
Small
0
128

*****************************************************/
#include
#include
#include
#define ADC_VREF_TYPE 0x00
unsigned int Temperature,Data,c;

// Read the AD conversion result
unsigned int read_adc(unsigned char adc_input)
{
ADMUX=adc_input | (ADC_VREF_TYPE & 0xff);
// Delay needed for the stabilization of the ADC input
voltage
delay_us(10);
// Start the AD conversion
ADCSRA|=0x40;

Universitas Sumatera Utara

// Wait for the AD conversion to complete
while ((ADCSRA & 0x10)==0);
ADCSRA|=0x10;
return ADCW;
}
void main(void)
{
// Input/Output Ports initialization

// Port A initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In
Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T
State1=T State0=T
PORTA=0x00;
DDRA=0x00;
// Port B initialization
// Func7=In Func6=In Func5=In
Func1=In Func0=In
// State7=T State6=T State5=T
State1=T State0=T
PORTB=0x00;
DDRB=0x00;
// Port C initialization
// Func7=In Func6=In Func5=In
Func1=In Func0=In
// State7=T State6=T State5=T
State1=T State0=T
PORTC=0x00;

DDRC=0x00;
// Port D initialization
// Func7=In Func6=In Func5=In
Func1=In Func0=In
// State7=T State6=T State5=T
State1=T State0=T
PORTD=0x00;
DDRD=0x00;
// USART initialization
// USART Baud Rate: 19200
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x0C;

Func4=In Func3=In Func2=In
State4=T State3=T State2=T

Func4=In Func3=In Func2=In

State4=T State3=T State2=T

Func4=In Func3=In Func2=In
State4=T State3=T State2=T

Universitas Sumatera Utara

// ADC initialization
ADMUX=ADC_VREF_TYPE & 0xff;
ADCSRA=0x82;
SFIOR&=0xEF;
c = 0;
while (1)
{
Temperature = read_adc(0);
while (c < 20){ Data = Data + Temperature;
delay_ms(50);
c++;
}
Temperature = Data/20;

printf("%i",Temperature);
Data = 0;
c = 0;
}
}

Universitas Sumatera Utara

Lampiran 2
Listing program visual basic untuk menampilkan grafik suhu dan alarm pada
PC
Dim Xd(0 To 18000), Yd1(0 To 18000), Yd2(0 To 18000),
Yd3(0 To 18000) As Integer
Dim TIMES(0 To 18000) As String
Dim j As Integer
Dim Temp, x, y2, y1, L1, L2, R, S, y10, y20, y30, x0,
Data As Integer
Dim Sampling_Time As Single
Dim oXL As Excel.Application
Private Declare Function sndPlaySound Lib "Winmm.dll"

Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, ByVal
uflags As Long) As Long
Private Const snd_sync = &H0
Private Const snd_Async = &H1
Private Const snd_loop = &H8
Private Sub Command4_Click()
Timer4.Enabled = True
Trace.Enabled = False
Command7.Enabled = False
MSComm1.PortOpen = True
x = 0
Timer5.Enabled = True
Grids
Open "C:\Data\" + Text5 + ".DAT" For Output As #1
End Sub
Private Sub Command5_Click()
sndPlaySound vbNullString, snd_Async
End Sub
Private Sub Command7_Click()

Timer3.Enabled = False
Set oXL = New Excel.Application
Set oxlbook = oXL.Workbooks.Add
FileName = "C:\Data\" + Text5 + ".xls"
oxlbook.Worksheets(1).Range("A1") = " Time

"

Universitas Sumatera Utara

oxlbook.Worksheets(1).Range("B1") = " Temperature

"

oxlbook.SaveAs FileName
For i = 2 To j
oxlbook.Worksheets(1).Range("A" & i) = TIMES(i)
oxlbook.Worksheets(1).Range("B" & i) = Yd1(i)
Next i
On Error GoTo 1

oxlbook.SaveAs FileName
oxlbook.Close
1:
End Sub
Private Sub Command1_Click()
Close #1
Line2(5).BorderColor = &HFF0000
Line2(4).BorderColor = &HFF&
Line2(2).BorderColor = &HFF0000
Grids
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Command3_Click()
If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
Timer5.Enabled = False
Timer4.Enabled = False
Trace.Enabled = True
Command7.Enabled = True

Close #1
End Sub
Private Sub Timer4_Timer()
y1 = 6280 - Temp * 10
Picture1.Line (x0, y10)-(x, y1), QBColor(12) 'R
x0 = x

Universitas Sumatera Utara

y10 = y1
x = x + 10
If Sampling_Time = (Timebase * 1) Then
Xd(j) = x
Yd1(j) = Temp / 2
TIMES(j) = Text1
j = j + 1
Sampling_Time = 0
End If
Sampling_Time = Sampling_Time + 1
If x > (12000) Then

x = 0
x0 = 0
Q = 568
Grids
End If
End Sub
Private Sub Timer5_Timer()
Dat = MSComm1.Input
If Dat "" Then
If (Data - Dat) < 20 Then
Text2 = Dat / 2
Temp = Dat
Data = Dat
If Temp / 2 > 100 Then
alert = "C:\ Windows \ media \" + "notify.wav"
sndPlaySound alert, snd_Async Or snd_loop
End If
End If
End If
End Sub
Private Sub Trace_Click()
Timer4.Enabled = True
Trace.Enabled = False

Universitas Sumatera Utara

Command7.Enabled = False
Read.Enabled = False
Line2(5).BorderColor = &HFF0000
Line2(4).BorderColor = &HFF0000
Line2(2).BorderColor = &HFF&
MSComm1.PortOpen = True
x = 0
Timer5.Enabled = True
Grids
Open "C:\Data\" + Text5 + ".DAT" For Output As #1
End Sub
Private Sub Form_Load()
With MSComm1
If .PortOpen = True Then .PortOpen = False
.CommPort = 4
.Settings = "19200,n,8,1"
.DTREnable = True
.RTSEnable = True
.RThreshold = 1
.SThreshold = 0
End With
R = 568
x = 0
x0 = 0
y10 = 6952
Data = 70
End Sub
Private Sub Timer1_Timer()
Text1 = Time
End Sub
Private Sub Grids()
Picture1.Cls
Q = 568
For GRID = 1 To 17
Picture1.Line (0, Q)-(15000, Q), QBColor(3)
Q = Q + R
Next GRID
Q = 568
For GRID = 1 To 35

Universitas Sumatera Utara

Picture1.Line (Q, 0)-(Q, 10000), QBColor(3)
Q = Q + R
Next GRID
Picture1.Line (0, 7952)-(15000, 7952), QBColor(9)
End Sub
Private Sub Timer3_Timer()
Grids
Timer3.Enabled = False
End Sub

Universitas Sumatera Utara

Lampiran 3
Gambar Komponen
1. Sensor Termokopel tipe K

2. Modul RS485

4. Adaptor

5. Rangkaian

3. Kabel Penghubung
6. PC

Universitas Sumatera Utara

Lampiran 4
Gambar Alat Secara Keseluruhan

Universitas Sumatera Utara

Lampiran 5
Rangkaian Lengkap Sistem

+5V

10µF/25V

220 V
PLN

AN 7805

100 ohm
220µF/25V

D1

+5V

10K

10K

-

Termokopel

+

+ 5V

Jaringan RS485

10K

Xtal 4Mhz

PB0 (XCK)

PA0 (ADC0)

40

2

PB1 (T1)

PA1 (ADC1)

39

3

PB2 (INT2

PA2 (ADC2)

38

4

PB3 (OC0)

PA3 (ADC3)

37

5

PB4 (SS)

PA4 (ADC4)

36

6

PB5 (MOSI)

PA5 (ADC5)

35

7

PB6 (MISO)

PA6 (ADC6)

34

8

PB7 (SCK)

PA7 (ADC7)

33

9

RESET

ATMEGA 8535

-

Modul RS485

GND

100K

100K

+ 5V

Modul RS485

Universitas Sumatera Utara

PC

out

4k7

4k7

Monitor

LM324

+

1

AREF

32

GND

31

AVCC

30

PC7(TOSC2)

29

PC6(TOSC1)

28

10

VCC

11

GND

12

XTAL2

13

XTAL1

14

PD0 (RXD)

PC5

27

15

PD1 (TXD)

PC4

26

16

PD2 (INT0)

PC3

25

17

PD3 (INT1)

PC2

24

18

PD4 (OC1B)

PC1(SDA)

23

19

PD5 (OC1A)

PC0(SCL)

22

20

PD6 (ICP1)

PD7(OC2)

21

+ 5V

GND