Teknik Elektro LinksBarrier-Gate & Turnstile Interface, Thermostat, Relay Driver, Microcontroler Board

SER-2REL – Modul Serial Relay Untuk Kontrol Barrier-Gate dan Turnstile-Tripod

SER-2REL adalah modul Serial Relay yang memiliki 2 buah relay sebagai output. Dengan modul ini kita bisa mengendalikan kondisi 2 buah relay (on/off) melalui program komputer dengan antarmuka port serial atau melalui port USB dengan perantaraan kabel konverter USB-to-RS232. Modul ini membutuhkan catudaya eksternal 5V DC. Untuk mensuplai modul SER-2REL bisa digunakan adaptor/charger HP atau wall-adaptor dengan kapasitas arus minimal 500mA atau diambilkan dari power supply komputer ataupun port USB komputer/laptop.

ser-2rel_1

Aplikasi Serial Relay SER-2REL

Modul ini sangat cocok untuk aplikasi seperti:

  • kontrol buka/tutup barrier-gate
  • kontrol buka/tutup turnstile-tripod (pintu putar loket)
  • bel sekolah atau bel pabrik terprogram
  • kontrol extra-fan / air-conditioner pada ruang server

Spesifikasi Modul SER-2REL

  • Tegangan kerja DC 5V (eksternal), min 500mA
  • Jumlah Output: 2 buah relay (Kontak NO=10A, Kontak NC=6A @250VAC)
  • Mikrokontroler: AT89C2051/ATtiny2313
  • Konektor port serial: DB9 Female
  • Indikator: 3 buah LED Module Active (flashing), Relay-1 ON, Relay-2 ON
  • Komunikasi: Serial RS232 dengan with Super Simple Protocol @2400 baudrate
  • Sistem operasi: Win98, Win2000, WinXP, Win7, WinVista, Linux
  • Command-Line Interface: ser2rc.exe
  • Dukungan contoh program: Delphi/Lazarus, Python, REBOL, VB6, VB.NET

Super Simple Protocol

SER-2REL menggunakan protokol komunikasi yang sangat mudah. Masing-masing relay dapat dikontrol dengan mengirimkan hanya satu buah karakter saja. Nah, berikut adalah karakter-karakter perintah yang dikenali oleh modul SER-2REL.

‘A’ RELAY-1 ON
‘Y’ RELAY-1 OFF
‘B’ RELAY-2 ON
‘Z’ RELAY-2 OFF
‘1’ RELAY-1 SHORT-PULSE
‘2’ RELAY-1 MID-PULSE
‘3’ RELAY-1 LONG-PULSE
‘4’ RELAY-2 SHORT-PULSE
‘5’ RELAY-2 MID-PULSE
‘6’ RELAY-2 LONG-PULSE

Contoh Program Kontrol SER-2REL

Untuk menunjukkan betapa mudahnya modul SER-2REL dikontrol melalui komputer, berikut saya tampilkan beberapa contoh program kontrol dalam beberapa versi bahasa pemrograman.

VB.NET

ser-2rel_vbnet

Public Class Form1

 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 For i As Integer = 0 To _
 My.Computer.Ports.SerialPortNames.Count - 1
 ComboBox1.Items.Add( _
 My.Computer.Ports.SerialPortNames(i))
 Next
 btnDisconnect.Enabled = False
 End Sub

 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
 SerialPort1.Write("A")
 End Sub

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 SerialPort1.Write("Y")
 End Sub

 Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
 If SerialPort1.IsOpen Then
 SerialPort1.Close()
 End If

 Try
 With SerialPort1
 .PortName = ComboBox1.Text
 .BaudRate = 2400
 .Parity = IO.Ports.Parity.None
 .DataBits = 8
 .StopBits = IO.Ports.StopBits.One
 End With
 SerialPort1.Open()

 TextBox1.Text = ComboBox1.Text & " opened."
 btnConnect.Enabled = False
 btnDisconnect.Enabled = True
 Catch ex As Exception
 MsgBox(ex.ToString)
 End Try
 End Sub

 Private Sub btnDisconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisconnect.Click
 Try
 SerialPort1.Close()
 TextBox1.Text = SerialPort1.PortName & " closed."
 btnConnect.Enabled = True
 btnDisconnect.Enabled = False
 Catch ex As Exception
 MsgBox(ex.ToString)
 End Try
 End Sub

 Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
 SerialPort1.Write("B")
 End Sub

 Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
 SerialPort1.Write("Z")
 End Sub

 Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
 SerialPort1.Write("C")
 End Sub

 Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
 SerialPort1.Write("0")
 End Sub

 Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click

 End Sub

 Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
 SerialPort1.Write("1")
 End Sub

 Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
 SerialPort1.Write("4")
 End Sub
End Class

PYTHON

ser-2rel_python

import serial, time

def main():
 ser2rel = serial.Serial("COM1", 2400)
 if not ser2rel.isOpen():
 ser2rel.open()

 print "RELAY-1 ON"
 ser2rel.write('A') #RELAY-1 ON
 time.sleep(1)

 print "RELAY-1 OFF"
 ser2rel.write('Y') #RELAY-1 OFF
 time.sleep(1)

 print "RELAY-2 ON"
 ser2rel.write('B') #RELAY-2 ON
 time.sleep(1)

 print "RELAY-2 OFF"
 ser2rel.write('Z') #RELAY-2 OFF
 time.sleep(1)

 print "RELAY-1 dan RELAY-2 ON"
 ser2rel.write('C') #ALL ON
 time.sleep(1)

 print "RELAY-1 dan RELAY-2 OFF"
 ser2rel.write('0') #ALL OFF
 time.sleep(1)

 if ser2rel.isOpen():
 ser2rel.close()

if __name__ == '__main__':
 main()

REBOL

ser-2rel_rebol

REBOL [
 File: %ser2rel.r
 Deskripsi: "Contoh program kontrol modul SER-2REL"
 GUI: %rebgui.r
 Website: http://teknikelektrolinks.com
]


do %rebgui.r

system/ports/serial: [
 COM1 COM2 COM3 COM4 COM5 COM6 COM7 COM8 COM9
]

serialports: system/ports/serial
serial-port: none

connected: 0
serbuf: make string! 500
sp: []
foreach p serialports [
 append sp to-string p
]


display "Program Kontrol SER-2REL" [
 group-box "Serial Port" data [
 text "COM:"
 tport: drop-list "COM1" data sp
 return
 koneksi: led 30 "Serial Port" data none
 return
 button 40x6 "Buka Port" [
 if connected = 1 [alert "Port serial sudah terbuka." break]
 comport: tport/text
 nport: tport/picked
 switch/default nport [
 1 [ if error? try [serial-port: open/binary/direct/no-wait serial://port1/2400/8/none/1] [alert "Gagal membuka port serial COM1." break]]
 2 [ if error? try [serial-port: open/binary/direct/no-wait serial://port2/2400/8/none/1] [alert "Gagal membuka port serial COM2." break]]
 3 [ if error? try [serial-port: open/binary/direct/no-wait serial://port3/2400/8/none/1] [alert "Gagal membuka port serial COM3." break]]
 4 [ if error? try [serial-port: open/binary/direct/no-wait serial://port4/2400/8/none/1] [alert "Gagal membuka port serial COM4." break]]
 5 [ if error? try [serial-port: open/binary/direct/no-wait serial://port5/2400/8/none/1] [alert "Gagal membuka port serial COM5." break]]
 6 [ if error? try [serial-port: open/binary/direct/no-wait serial://port6/2400/8/none/1] [alert "Gagal membuka port serial COM6." break]]
 7 [ if error? try [serial-port: open/binary/direct/no-wait serial://port7/2400/8/none/1] [alert "Gagal membuka port serial COM7." break]]
 8 [ if error? try [serial-port: open/binary/direct/no-wait serial://port8/2400/8/none/1] [alert "Gagal membuka port serial COM8." break]]
 9 [ if error? try [serial-port: open/binary/direct/no-wait serial://port9/2400/8/none/1] [alert "Gagal membuka port serial COM9." break]]
 ] [ alert "Pilih dulu salah satu port serial pada tabel." break]
 
 serial-port/rts-cts: false
 update serial-port

 set-text koneksi rejoin [comport " OPEN"]
 set-data koneksi true
 connected: 1
 ]
 return
 button 40x6 "Tutup Port" [
 if connected = 1 [
 close serial-port
 set-text koneksi rejoin [comport " CLOSE"]
 set-data koneksi none
 connected: 0
 ]
 ]
 ]
 return
 group-box "Kontrol Relay" data [
 relay1: led "RELAY1 = OFF" data none return
 button 19x6 "R1 ON" [ insert serial-port "AAA" set-data relay1 false set-text relay1 "RELAY = ON"]
 button 19x6 "R1 OFF" [ insert serial-port "YYY" set-data relay1 none set-text relay1 "RELAY = OFF"]
 return
 relay2: led "RELAY2 = OFF" data none return
 button 19x6 "R2 ON" [ insert serial-port "BBB" set-data relay2 false set-text relay2 "RELAY = ON"]
 button 19x6 "R2 OFF" [ insert serial-port "ZZZ" set-data relay2 none set-text relay2 "RELAY = OFF"]
 return
 ]

 at 51x0 group-box "Relay Flicker" data [
 text "RELAY-1"
 return
 button 28x6 "ON 0.3s" [ insert serial-port "111" set-data relay1 false wait .3 set-data relay1 none]
 return
 button 28x6 "ON 1s" [ insert serial-port "222" set-data relay1 false wait 1 set-data relay1 none]
 return
 button 28x6 "ON 2.0s" [ insert serial-port "333" set-data relay1 false wait 2 set-data relay1 none]
 return
 
 at 0x39 text "RELAY-2"
 return
 button 28x6 "ON 0.3s" [ insert serial-port "444" set-data relay2 false wait .3 set-data relay2 none]
 return
 button 28x6 "ON 1s" [ insert serial-port "555" set-data relay2 false wait 1 set-data relay2 none]
 return
 button 28x6 "ON 2.0s" [ insert serial-port "666" set-data relay2 false wait 2 set-data relay2 none]
 ]
 
 at 90x0 group-box "Foto Modul SER-2REL" data [
 image %ser-2rel.jpg
 ]
 return
 at 140x62 image %rebol.gif
 return
 at 90x64 label "Programmer:"
 at 92x68 text "Chandra MDE"
 at 90x74 label "Website:"
 at 92x78 link "http://teknikelektrolinks.com"
]

do-events

PowerBASIC

ser2rc_pb

#COMPILER PBCC 5
#COMPILE EXE
#DIM ALL


FUNCTION PBMAIN () AS LONG
 LOCAL nComm AS LONG
 LOCAL COMPORT AS STRING
 
 COMPORT$ = COMMAND$(1)
 ERRCLEAR
 nComm = FREEFILE
 COMM OPEN COMPORT$ AS #nComm
 IF ERR THEN
 STDERR "Can't open comm port " & COMPORT$
 EXIT FUNCTION
 END IF

 STDOUT "SER2RC - teknikelektrolinks.com"
 STDOUT



 COMM SET #nComm, BAUD = 2400 ' 2400 baud
 COMM SET #nComm, BYTE = 8 ' 8 bits
 COMM SET #nComm, PARITY = 0 ' No parity
 COMM SET #nComm, STOP = 0 ' 1 stop bit

 COMM SEND #nComm, COMMAND$(2)

 ' Close the comm port.
 COMM CLOSE #nComm

END FUNCTION

Bagaimana, mudah bukan?

Dan tak hanya VB.NET, PYTHON, REBOL dan PowerBASIC saja, kami menyediakan contoh program dalam versi bahasa pemrograman yang lain seperti DELPHI/LAZARUS, VB6 dan lain-lain.

Nah, jika Anda membutuhkan modul SER-2REL untuk mengontrol barrier-gate atau turnstile-tripod, silakan langsung menuju TKP melalui link berikut ini.

ordernow

Dan jika Anda membutuhkan modul sejenis dengan interface port USB, Anda bisa mengunjungi situs USBINOV berikut ini.

usbinov

Selamat berkarya.

Add a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>