Translate

Membuat Alat Pengaman Dengan SMS Gateway Modem Wavecom dilengkapi GPS EM-411 dan Tilt Sensor GY-61

Membuat Alat Pengaman Dengan SMS Gateway Modem Wavecom dilengkapi GPS EM-411 dan Tilt Sensor GY-61 ( Sensor Kemiringan )


          Kali ini saya akan menjelaskan mengenai bagaimana cara membuat alat pengaman dengan menggunakan 3 device berbeda yaitu sensor kemiringan GY-61, GPS EM-411 dan sms gateway modem wavecom. Sebenarnya kegunaan alat ini yaitu untuk pengaman sepeda motor, jadi saat dicuri akan ada GPS yang melacak, dan juga jika sepeda motor dibawa maling pasti akan terdeteksi kemiringannya, kemudian sms gateway digunakan sebagai media pemberi kabar ke pemilik sepeda motor bahwa motornya dalam keadaan bahaya. Sms gateway yang digunakan yaitu modem wavecom fastrack serial port. jika si pemilik sepeda motor telah mendapatkan pesan bahaya maka untuk mematikannya tinggal sms balik dengan pesan #L. fungsi GPS disini yaitu jika motor dibawa maling pasti akan ada perubahan lokasi, dengan perubahan itulah maka akan memberitahu kepada pemilik via sms. Terlebih dahulu lokasi harus disimpan koordinatnya baru bisa dipakai.



a. Minimum System ATMega164 





b. LCD 16x2




c. Modem Wavecom Serial Port




d. Tilt Sensor GY-61




e. GPS EM-411





f. Program Bascom AVR

$regfile = "m164pdef.dat"
$crystal = 12000000

Config Lcdpin = Pin , Rs = Portc.0 , E = Portc.1 , Db4 = Portd.5
Config Lcdpin = Pin , Db5 = Portd.4 , Db6 = Portd.6 , Db7 = Portd.7
Config Lcd = 16 * 2

Config Adc = Single , Prescaler = Auto , Reference = Avcc

Config Com1 = 4800 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Config Com2 = 9600 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0

Open "com1:" For Binary As #1
Open "Com2:" For Binary As #2

Dim X As Word
Dim Y As Word
Dim Z As Word
Dim A As Integer
A = 0

Dim Pas1 As Word
Dim Pas2 As Word
Dim Pas3 As Word

Dim Data_masuk As String * 100
Dim Cmti_pos As Byte , Cmgr_pos As Byte , Index_pos As Byte , Cmd_pos As Byte
Dim Pjg_sms_index As Byte , Pjg_data As Byte
Dim Sms_index As String * 3
Dim Cmd As String * 4
Dim Cmdbin As Byte
Dim Simpanlatup As Single
Dim Simpanlatbot As Single
Dim Simpanlongup As Single
Dim Simpanlongbot As Single
Dim Ews As String * 10 , Nss As String * 8 , Sat As String * 2
Dim Nssx As String * 8
Dim Hh As String * 2 , Hh2 As Byte , Mm As String * 2 , Ss As String * 2
Dim Ns As String * 1 , Ew As String * 1 , Dw As String * 6
Dim Przecinek As Byte , P As Byte
Dim Run As Byte , Gpgga As Byte , Cntr As Byte , Tudr As Byte , Ok As Bit
Dim Longitude1 As Single
Dim Latitude1 As Single
Dim Longitude1x As Single
Dim Latitude1x As Single
Dim Latx As Word , Longy As Word

Dim Tanda As Integer
Dim Hp As String * 30

Run = 1 : Reset Ok

P = 1
Tanda = 0


Hp = "085726496643"                                         'no HP yang dituju / Target

Ddra.7 = 1

'cdi
Ddra.6 = 1


Cls
Cursor Off

Start Adc


Passwd:
Tanda = 0
On Urxc Uart_rx
Enable Urxc
Enable Interrupts


Porta.6 = 1
Porta.7 = 1

Atas:
Do

While Ok = 0 : Wend

Reset Ok

X = Getadc(0)
Y = Getadc(1)
Z = Getadc(2)


Upperline
Lcd Nss : Lcd " " : Lcd Ns

Lowerline
Lcd Ews : Lcd " " : Lcd Ew


Latitude1 = Val(nss)
Latitude1 = Latitude1 * 100
'Latx = Latitude1

Longitude1 = Val(ews)
Longitude1 = Longitude1 * 100
'Longy = Longitude1


If X > 365 Or X < 310 Then
Goto Kirim
Elseif Y > 365 Or Y < 310 Then
Goto Kirim
End If

Pas1 = Getadc(3)
Pas2 = Getadc(4)
Pas3 = Getadc(5)

'Upperline
'Lcd Pas1 ; " " ; Pas2 ; " " ; Pas3

If Pas1 < 100 And A = 0 Then
Waitms 200

Cls
Upperline
Lcd "Simpan koordinat"
Wait 2
Cls

Simpanlatup = Latitude1 + 10
Simpanlatbot = Latitude1 - 10

Simpanlongup = Longitude1 + 10
Simpanlongbot = Longitude1 - 10

Upperline
Lcd Simpanlatup
Lowerline
Lcd Simpanlatbot

Wait 2

Cls

Upperline
Lcd Simpanlongup
Lowerline
Lcd Simpanlongbot

Wait 2
Cls

Tanda = 1
A = 1
Goto Atas
End If


If Pas2 < 100 And A = 1 Then
Waitms 200
A = 2
End If

If Pas3 < 100 And A = 2 Then
Waitms 200
A = 3
End If

If Pas1 < 100 And A = 3 Then
Waitms 200

Cls
A = 0
Goto Main

End If



If Latitude1 > Simpanlatup And Tanda = 1 Then
Goto Kirimx
Elseif Latitude1 > 1 And Latitude1 < Simpanlatbot And Tanda = 1 Then
Goto Kirimx
End If

If Longitude1 > Simpanlongup And Tanda = 1 Then
Goto Kirimx
Elseif Longitude1 > 1 And Longitude1 < Simpanlongbot And Tanda = 1 Then
Goto Kirimx
End If


Waitms 200

Loop





Main:
Do

X = Getadc(0)
Y = Getadc(1)
Z = Getadc(2)

Upperline
Lcd "x = " ; X ; "  " ; "y = " ; Y
Lowerline
Lcd "z = " ; Z


Waitms 200

Loop




Kirim:
Print #2 , "AT+CMGS=" ; Hp
Wait 1
Print #2 , "Motor dalam keadaan bahaya!!!"
Print #2 , Chr(26)
Wait 1

Porta.6 = 0
Porta.7 = 0

Goto Terima

Return



Kirimx:

Longitude1x = Longitude1 / 100
Latitude1x = Latitude1 / 100

Print #2 , "AT+CMGS=" ; Hp
Wait 1
Print #2 , Latitude1x ; " " ; Longitude1x
Print #2 , Chr(26)
Wait 1

Porta.6 = 0
Porta.7 = 0

Goto Terima

Return




Terima:
Disable Urxc
Disable Interrupts

Cls
 Do


   Upperline
   Lcd "Siap terima"

   Input #2 , Data_masuk
   Pjg_data = Len(data_masuk)

   Cmti_pos = Instr(data_masuk , "CMTI")
   If Cmti_pos <> 0 Then
      Index_pos = Instr(data_masuk , ",")
      Incr Index_pos
      Pjg_sms_index = Pjg_data - Index_pos
      Incr Pjg_sms_index

      Sms_index = Mid(data_masuk , Index_pos , Pjg_sms_index)

      Print #2 , "AT+CMGR=" ; Sms_index ; Chr(13) ; Chr(10)

   End If



   Cmd_pos = Instr(data_masuk , "#")
   If Cmd_pos <> 0 Then
      Incr Cmd_pos
      Cmd = Mid(data_masuk , Cmd_pos , 1)

         If Cmd = "L" Then
         Porta.6 = 1
         Goto Passwd
         End If

      Print #2 , "AT+CMGD=" ; Sms_index ; Chr(13) ; Chr(10)

   End If
Loop





Uart_rx:

If Run <> 0 Then

Run = Udr Xor 36

If Run = 0 Then

Cntr = 0

Nss = ""

Ews = ""

Sat = ""

Ns = ""

Ew = ""

Dw = ""


Hh = ""

Mm = ""

Ss = ""

End If


Else

Select Case Cntr

Case 0 To 4

Tudr = Lookup(cntr , Gga)
'untuk memilih data pada baris "GPGGA"

Run = Udr Xor Tudr

Case 6 To 7
Hh = Hh + Chr(udr)
'UTC Time: "Hour"

Case 8 To 9
Mm = Mm + Chr(udr)
'UTC Time: "minutes"

Case 10 To 11

Ss = Ss + Chr(udr)
'UTC Time: "seconds"

Case 17 To 25

Nss = Nss + Chr(udr)


Case 27

Ns = Ns + Chr(udr)
'stuff latitude flag

Case 29 To 38

Ews = Ews + Chr(udr)
'longitude

Case 40

Ew = Ew + Chr(udr)
'stuff longitude flag

Case 44 To 45

Sat = Sat + Chr(udr)

Case 51 To 54

Dw = Dw + Chr(udr)

Case 55

Set Ok : Run = 1

Case Else

Tudr = Udr

End Select

Incr Cntr

End If

Return



'GPS statement, the head of ASCII code

Gga:

Data 71 , 80 , 71 , 71 , 65                                 'GPGGA

Vtg:

Data 71 , 80 , 86 , 84 , 71                                 'GPVTG

Rmc:

Data 71 , 80 , 82 , 77 , 67                                 'GPRMC






g. Program Tracking System GPS

'program ini akan mengirimkan koordinat tiap 20 detik sekali

$regfile = "m164pdef.dat"
$crystal = 12000000

Config Lcdpin = Pin , Rs = Portc.0 , E = Portc.1 , Db4 = Portd.5
Config Lcdpin = Pin , Db5 = Portd.4 , Db6 = Portd.6 , Db7 = Portd.7
Config Lcd = 16 * 2

Config Adc = Single , Prescaler = Auto , Reference = Avcc

Config Com1 = 4800 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Config Com2 = 9600 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0

Open "com1:" For Binary As #1
Open "Com2:" For Binary As #2

Dim X As Word
Dim Y As Word
Dim Z As Word
Dim A As Integer
A = 0

Dim Pas1 As Word
Dim Pas2 As Word
Dim Pas3 As Word

Dim Data_masuk As String * 100
Dim Cmti_pos As Byte , Cmgr_pos As Byte , Index_pos As Byte , Cmd_pos As Byte
Dim Pjg_sms_index As Byte , Pjg_data As Byte
Dim Sms_index As String * 3
Dim Cmd As String * 4
Dim Cmdbin As Byte
Dim Simpanlatup As Single
Dim Simpanlatbot As Single
Dim Simpanlongup As Single
Dim Simpanlongbot As Single
Dim Ews As String * 10 , Nss As String * 8 , Sat As String * 2
Dim Nssx As String * 8
Dim Hh As String * 2 , Hh2 As Byte , Mm As String * 2 , Ss As String * 2
Dim Ns As String * 1 , Ew As String * 1 , Dw As String * 6
Dim Przecinek As Byte , P As Byte
Dim Run As Byte , Gpgga As Byte , Cntr As Byte , Tudr As Byte , Ok As Bit
Dim Longitude1 As Single
Dim Latitude1 As Single
Dim Longitude1x As Single
Dim Latitude1x As Single
Dim Latx As Word , Longy As Word

Dim Tanda As Integer
Dim Mark As Integer
Dim Hp As String * 30

Dim Count As Integer
Dim Zona As Integer
Count = 0
Zona = 0

Run = 1 : Reset Ok

P = 1
Tanda = 0


Hp = "085726496643"                                         'no HP yang dituju / Target

Ddrb.5 = 1
Ddrb.6 = 1
Ddrb.7 = 1

'cdi
Ddra.6 = 1

Ddrd.4 = 1
Ddrd.5 = 1
Ddrd.6 = 1
Ddrd.7 = 1

Cls
Cursor Off

Start Adc

Mark = 0

Passwd:
Tanda = 0

Portb.5 = 1
Portb.6 = 1
Portb.7 = 1
Portd.5 = 1

Porta.6 = 1
Porta.7 = 1

Portd.6 = 1
Portd.7 = 1

Atas:

On Urxc Uart_rx
Enable Urxc
Enable Interrupts

Do

While Ok = 0 : Wend

Reset Ok

X = Getadc(0)
Y = Getadc(1)
Z = Getadc(2)

Upperline
Lcd Nss : Lcd " " : Lcd Ns

Lowerline
Lcd Ews : Lcd " " : Lcd Ew

Latitude1 = Val(nss)
Latitude1 = Latitude1 * 100
'Latx = Latitude1

Longitude1 = Val(ews)
Longitude1 = Longitude1 * 100
'Longy = Longitude1

If X > 365 Or X < 310 Then
Mark = 1
Elseif Y > 365 Or Y < 310 Then
Mark = 1
End If

Pas1 = Getadc(3)
Pas2 = Getadc(4)
Pas3 = Getadc(5)

'Upperline
'Lcd Pas1 ; " " ; Pas2 ; " " ; Pas3

If Pas1 < 100 And A = 0 Then
Waitms 200

Cls
Upperline
Lcd "Simpan koordinat"
Wait 2
Cls

Simpanlatup = Latitude1 + 10
Simpanlatbot = Latitude1 - 10

Simpanlongup = Longitude1 + 10
Simpanlongbot = Longitude1 - 10

Upperline
Lcd Simpanlatup
Lowerline
Lcd Simpanlatbot

Wait 2

Cls

Upperline
Lcd Simpanlongup
Lowerline
Lcd Simpanlongbot

Wait 2
Cls

Tanda = 1
A = 1
Goto Atas
End If


If Pas2 < 100 And A = 1 Then
Waitms 200
A = 2
End If

If Pas3 < 100 And A = 2 Then
Waitms 200
A = 3
End If

If Pas1 < 100 And A = 3 Then
Waitms 200

Cls
A = 0
Goto Main

End If

If Latitude1 > Simpanlatup And Tanda = 1 Then
Mark = 1
Elseif Latitude1 > 1 And Latitude1 < Simpanlatbot And Tanda = 1 Then
Mark = 1
End If

If Longitude1 > Simpanlongup And Tanda = 1 Then
Mark = 1
Elseif Longitude1 > 1 And Longitude1 < Simpanlongbot And Tanda = 1 Then
Mark = 1
End If

Waitms 200

Incr Count

If Count > 100 Then
Count = 0
End If

If Mark = 1 And Zona = 1 And Count = 100 Then

Longitude1x = 0
Latitude1x = 0

Longitude1x = Longitude1 / 100
Latitude1x = Latitude1 / 100

Print #2 , "AT+CMGS=" ; Hp
Wait 1
Print #2 , "Motor dalam keadaan bahaya!!!"
Print #2 , Longitude1x ; " " ; Latitude1x
Print #2 , Chr(26)
Wait 1

End If

If Mark = 1 And Zona = 0 Then
Zona = 1

Longitude1x = 0
Latitude1x = 0

Longitude1x = Longitude1 / 100
Latitude1x = Latitude1 / 100

Print #2 , "AT+CMGS=" ; Hp
Wait 1
Print #2 , "Motor dalam keadaan bahaya!!!"
Print #2 , Longitude1x ; " " ; Latitude1x
Print #2 , Chr(26)
Wait 1

Porta.6 = 0
Porta.7 = 0

End If

Loop

Main:
Do

X = Getadc(0)
Y = Getadc(1)
Z = Getadc(2)

Upperline
Lcd "x = " ; X ; "  " ; "y = " ; Y
Lowerline
Lcd "z = " ; Z

Waitms 200

Loop

Terima:
'Disable Urxc

Cls
 Do

   Upperline
   Lcd "Siap terima"

   Input #2 , Data_masuk
   Pjg_data = Len(data_masuk)

   Cmti_pos = Instr(data_masuk , "CMTI")
   If Cmti_pos <> 0 Then
      Index_pos = Instr(data_masuk , ",")
      Incr Index_pos
      Pjg_sms_index = Pjg_data - Index_pos
      Incr Pjg_sms_index

      Sms_index = Mid(data_masuk , Index_pos , Pjg_sms_index)

      Print #2 , "AT+CMGR=" ; Sms_index ; Chr(13) ; Chr(10)

   End If

   Cmd_pos = Instr(data_masuk , "#")
   If Cmd_pos <> 0 Then
      Incr Cmd_pos
      Cmd = Mid(data_masuk , Cmd_pos , 1)

         If Cmd = "L" Then
         Porta.6 = 1
         Goto Passwd
         End If

      Print #2 , "AT+CMGD=" ; Sms_index ; Chr(13) ; Chr(10)

   End If
Loop

Uart_rx:

If Run <> 0 Then

Run = Udr Xor 36

If Run = 0 Then

Cntr = 0

Nss = ""

Ews = ""

Sat = ""

Ns = ""

Ew = ""

Dw = ""


Hh = ""

Mm = ""

Ss = ""

End If


Else

Select Case Cntr

Case 0 To 4

Tudr = Lookup(cntr , Gga)
'untuk memilih data pada baris "GPGGA"

Run = Udr Xor Tudr

Case 6 To 7
Hh = Hh + Chr(udr)
'UTC Time: "Hour"

Case 8 To 9
Mm = Mm + Chr(udr)
'UTC Time: "minutes"

Case 10 To 11

Ss = Ss + Chr(udr)
'UTC Time: "seconds"

Case 17 To 25

Nss = Nss + Chr(udr)


Case 27

Ns = Ns + Chr(udr)
'stuff latitude flag

Case 29 To 38

Ews = Ews + Chr(udr)
'longitude

Case 40

Ew = Ew + Chr(udr)
'stuff longitude flag

Case 44 To 45

Sat = Sat + Chr(udr)

Case 51 To 54

Dw = Dw + Chr(udr)

Case 55

Set Ok : Run = 1

Case Else

Tudr = Udr

End Select

Incr Cntr

End If

Return



'GPS statement, the head of ASCII code

Gga:

Data 71 , 80 , 71 , 71 , 65                                 'GPGGA

Vtg:

Data 71 , 80 , 86 , 84 , 71                                 'GPVTG

Rmc:

Data 71 , 80 , 82 , 77 , 67                                 'GPRMC






i. Downloader Software ( Extreme Burner )





j. Cara Sambung Modem Wavecom Ke MCU + RS232







k. VIDEO HASILNYA











No comments:

Post a Comment