Sharing With Passion
Showing posts with label I T. Show all posts
Showing posts with label I T. Show all posts

June 29, 2020

Posted by Sabar Santoso in , | June 29, 2020 1 comment
Saat ini penggunaan bahasa pemrograman berbasis objek sedang menjadi trend yang tak terhindarkan. Vendor perangkat lunak menawarkan bahasa dengan karakter tersebut dengan sebuah kosa kata yang cantik, yakni Visual, sehingga kita kenal Delphi milik Borland, Visual C++, Visual Basic, atau Oracle, PowerBuilder, Visual dBase, Visual Foxpro, untuk aplikasi database.

Tak terkecuali dalam aplikasi sistem kontrol industri, perangkat yang ditawarkan para vendornya juga semakin mendukung penggunaan pemrograman visual. Seperti Visual Basic, misalnya, kalangan industri sistem kontrol memberikan peluang untuk pengembangan sistem mereka dengan bahasa ini, terutama di kalangan pengguna sistem berbasis Windows. Yokogawa, ABB, Wonderware, adalah nama yang bisa disebutkan untuk hal ini.

Dalam artikel ini, kita akan mengetengahkan bagaimana Visual Basic digunakan mengakses data yang terdapat dalam memori sebuah PLC. Bahasa yang kita gunakan ialah Visual Basic 6.0 dan PLC-nya dari keluarga Omron. Komunikasi dilakukan melalui port serial. Aplikasi ini dibangun sebagai implementasi konsep dasar pertukaran data antara PLC dengan PC, dan membuka jalan bagi eksplorasi permasalahan komunikasi data lebih jauh dalam sistem kontrol industri. Pengesetan nilai setpoint parameter proses merupakan contoh utama penerapan program ini.

Rancangan Aplikasi
Pada aplikasi ini, kita mengisikan sebuah data diskret ke PLC. Masukan yang kita berikan dari antarmuka Visual Basic ini akan ditunjukkan dalam bit indicator pada card I/O PLC . Apabila data adalah bit 1, maka indicator akan menyala. Apabila data nol indicator-nya tidak menyala.



Persiapan Setting Sistem

* Pengesetan Host Link Units
Host link Unit berfungsi untuk menjembatani PC dalam memonitor status pengoperasian dan lokasi data dari PLC. Dalam hal ini kita menggunakan OMRON CQM1-CIF02. Parameter komunikasinya sudah ter-setting standar yaitu :

1. Kecepatan Transmisi.
Baud-rate = 9.600 bps

2. Format data untuk sebuah karakter.
Nomor start bits = 1
Panjang data = 7 bits
Event (vertical) parity = 1 bits
Nomor stop bits = 2

Pengesetan PC/Komputer
PC diset melalui pemrograman / penulisan kode, yaitu dengan men-set properti kontrol komunikasi. Pengesetan parameter kecepatan transmisi dan format data pada properti harus benar-benar sama dengan pengesetan pada Host link Unit.

Pemaketan Data
Agar dapat membaca ataupun menulis, satu rangkaian data harus dikirim dengan bentuk paket terstruktur yang disebut frame. Masing-masing lokasi data atau memori data mempunyai bentuk frame yang berbeda. Dalam contoh disini kita menuliskan data pada lokasi data IR (Internal Relay). Frame penulisannya:



Pemrograman Visual Basic
Berdasarkan data resource dan rancangan sistem kita, maka kita bisa memulai pembuatan program yang kita butuhkan. Dalam aplikasi ini window yang kita buat sebagai antarmuka aplikasi merupakan window sederhana dengan jumlah objek minimum yang mencukupi. Objek ini kita butuhkan sebagai bagian dari perangkat komunikasi serial dalam perangkat lunak. Untuk ini kita buat ambil sebuah objek komunikasi dengan nama default Comm1, dan tiga buah text box dan label yang sesuai.

Algoritma program meliputi pengaktifan port, pembacaan isi port, pembuatan frame data yang memenuhi syarat bisa dibaca PLC, yakni dengan frame yang telah kita sebutkan di atas, pengiriman data, dan pembacaan respon dari PLC. Pengecekan isi buffer merupakan opsional (tambahan saja).
Kode Program
Pengaktifan Port
Private Sub Form_Load()
Comm1.CommPort = 2
Comm1.Settings = "9600,E,7,2"
Comm1.PortOpen = True
End Sub
Properti CommPort bertugas men-set nomor serial port yang digunakan oleh PC. Karena kita menggunakan port COM 2 dan nama kontrol komunikasinya adalah Comm1, maka kodenya Comm1.CommPort = 2.

Properti Settings bertugas men-set baud rate, parity, data bits dan stop bits COM2. Dalam hal ini baud-rate = 9.600 bps, nilai parity = even, panjang data 7 bits dan stop bit =2.

Properti PortOpen bertugas men-set keadaan COM 2, terbuka atau tertutup. Karena kelompok kode di atas dieksekusi pada saat awal program komunikasi di run, maka isinya Comm1.PortOpen = True.

Perhitungan FCS dan Pengiriman data.

FCS (Frame Check Sequence) adalah hasil konversi 8-bit data ke 2 digit karakter ASCII. Ke 8-bit data merupakan hasil dari exclusive OR secara berurut (sequence) karakter pertama hingga karakter terakhir pada sebuah frame. Perhitungan FCS ini kita letakkan dalam event kotak perintah (command box).

Private Sub Command1_Click()
Dat$ = Text1.Text
L = Len(Dat$)
A = 0
For I = 1 Sd L
Opo$ = Mid$(Dat$, I, 1)
A = Asc(Opo$) Xor A
Next I
FCS$ = Hex$(A)
If Len(FCS$) = 1 Then
FCS$ = "0" + FCS$
End If
DatTX$ = Dat$ + FCS$ + "*" + Chr$(13)
Comm1.Output = DatTX$
End Sub

Paket data akan yang dikirim diletakan dalam variabel DatTX$.

Pengambilan Respons PLC dari Buffer

Setiap kejadian pembacaan data ataupun penulisan harus melibatkan 2 perintah, yaitu kirim data dan terima respon. Perintah terima respon bertujuan agar buffer tetap bersih/kosong pada saat awal dan akhir kejadian, sehingga data yang terbaca tidak tercampur oleh sisa data (respon) dari kejadian sebelumnya.
Private Sub Command2_Click()
Text2.Text = Comm1.Input
End Sub
Hasil pembacaan diletakkan pada Text2.

Pengecekan isi buffer
Private Sub Command3_Click()
Text3.Text = Comm1.InBufferCount
End Sub
Properti InBuffercount bertugas untuk mengetahui jumlah karakter di dalam buffer. Jadi dalam hal ini Text3 berguna untuk memonitor jumlah karakter dalam buffer.



Eksekusi Program
Sebelum program dijalankan, kita pastikan dulu bahwa semua peralatan telah dihubungkan secara benar, dan masing-masing telah di-set sesuai dengan ketentuan di atas. CPU dan I/O Card kita tempatkan pada panelnya dan koneksi kabel Host Link pada port serial dihubungkan dengan benar. Setelah dipastikan siap, barulah program kita jalankan. Dalam hal ini kita bisa melakukannya melalui lingkungan dalam Visual Basic, maupun program kompilasi .EXE.



Antarmuka aplikasi akan tampak seperti window pada gambar 2. Pada antarmuka ini, data yang kita kirim harus sudah diketik oleh pengguna dalam bentuk frame tanpa "*" dan "|" (karena keduanya sudah kita tuliskan dalam kode program). Setelah diketikkan isi datanya, baru kita tekan tombol Transmit.

Tampak bahwa isiannya ialah @00WR0110FFFF, yang berarti:
Channel : 110 atau 0110 dalam 4 digit desimal
Data: FFFF dalam heksa
Setelah kita tekan Transmit kita tekan Response, untuk mendapatkan data respon dari PLC (yang merupakan pengecekan apakah data yang kita kirim telah diterima PLC). Dengan method Input PLC akan memberi respon dengan frame @00WR0045*|, yang berarti data telah diterima PLC.

Dengan menekan tombol Buffer, isi buffer diketahui kosong, karena telah didahului proses pengambilan isinya melalui penekanan tombol Response.

Dengan proses di atas kita telah berhasil membuat sebuah antarmuka komunikasi dasar antara komputer dengan mesin PLC kita. Dengan kemudahan pemrograman visual, aplikasi ini tentu amat potensial dikembangkan agar semakin baik dan memudahkan pengguna. Fasilitas penulisan data dalam desimal (misalnya setpoin suhu pada boiler), atau pengesetan alamat secara otomatis dari database yang memuat alokasi memori PLC merupakan contoh pengembangan dalam hal ini.

February 05, 2018

Posted by Sabar Santoso in , , , , , | February 05, 2018 No comments
The C++ programming language was introduced by Bjarne Stroustrup of the AT&T laboratories in 1985 as an extension of C, with additional features borrowed from the esoteric language Simula. Since then, C++ has grown rapidly in response to the practical need for a programming language that is able to efficiently handle composite and diverse data types. The language implementation is pivoted on the ingenious concept of object oriented programming (OOP). Today, C++ dominates the commercial market and is favored among system programmers and application developers.


Object oriented programming

To illustrate the advantages of an object oriented programming language compared to a structured language such as Matlab, Fortran 77, or C, we assume that an international sports competition has been entered by runners from many countries around the globe. The record of each runner consists of several fields including name, country of origin, city of birth, date of birth, and best performance time.

In a structured language, each one of these fields is normally registered in a separate data vector. In an OOP language, each runner becomes an object defined as a member of the class of runners, and each member is described by the collection of these fields. This formalism allows us to record, recall, and manipulate in any desired way the personal data of each runner using simple symbolic operators. Sub-classes consisting, for example, of runners of a particular nationality can be readily defined to facilitate more detailed manipulations.

An OOP language allows us to introduce a data type of our choice viewed as an object in a defined class, and then use the class as a building block for  further development. This flexibility essentially allows us to build a language without building a compiler. In this sense, an OOP language is an ultimate language.

C++ is a generalization of C, but accomplishes much more than C, to the extent that it should be regarded, studied, and taught as a separate language. It is neither necessary nor recommended to study C as a prerequisite of C++, though knowledge of C can be helpful.

September 08, 2012

Posted by Sabar Santoso in , , , , | September 08, 2012 No comments

As you may have realized, the PHP language revolves around the central theme of practicality. PHP is about providing the programmer with the necessary tools to get the job done in a quick and efficient fashion. Five important characteristics make PHP’s practical nature possible:
• Familiarity
• Simplicity
• Efficiency
• Security
• Flexibility
One final characteristic makes PHP particularly interesting: it’s free!

Familiarity
Programmers from many backgrounds will find themselves already accustomed to the PHP language. Many of the language’s constructs are borrowed from C and Perl, and in many cases PHP code is almost indistinguishable from that found in the typical C or Pascal program. This minimizes the learning curve considerably.

Simplicity
A PHP script can consist of 10,000 lines or one line: whatever you need to get the job done. There is no need to include libraries, special compilation directives, or anything of the sort. The PHP engine simply begins executing the code after the first escape sequence (). If the code is syntactically correct, it will be executed exactly as it is displayed.

Efficiency
Efficiency is an extremely important consideration for working in a multiuser environment such as the WWW. PHP 4.0 introduced resource allocation mechanisms and more pronounced support for object-oriented programming, in addition to session management features. Reference counting has also been introduced in the latest version, eliminating unnecessary memory allocation.

Security
PHP provides developers and administrators with a flexible and efficient set of security safeguards. These safeguards can be divided into two frames of reference: system level and application level.

- System-Level Security Safeguards :
PHP furnishes a number of security mechanisms that administrators can manipulate, providing for the maximum amount of freedom and security when PHP is properly configured. PHP can be run in what is known as safe mode, which can limit users’ attempts to exploit the PHP implementation in many important ways.
Limits can also be placed on maximum execution time and memory usage, which if not controlled can have adverse affects on server performance. Much as with a cgi-bin folder, administrators can also place restrictions on the locations in which users can view and execute PHP scripts and use PHP scripts to view guarded server information, such as the passwd file.

- Application-Level Security Safeguards :
Several trusted data encryption options are supported in PHP’s predefined function set. PHP is also compatible with many third-party applications, allowing for easy-integration with secure ecommerce technologies. Another advantage is that the PHP source code is not viewable through the browser because the script is completely parsed before it is sent back to the requesting user. This benefit of PHP’s server-side architecture prevents the loss of creative scripts to users at least knowledgeable enough to execute a ‘View Source’. Security is such an important issue that this book contains an entire chapter on the subject.

Flexibility
Because PHP is an embedded language, it is extremely flexible towards meeting the needs of the developer. Although PHP is generally touted as being used in conjunction solely with HTML, it can also be integrated alongside languages like JavaScript, WML, XML, and many others. Additionally, as with most other mainstream languages, isely planned PHP applications can be easily expanded as needed.
Browser dependency is not an issue because PHP scripts are compiled entirely on the server side before being sent to the user. In fact, PHP scripts can be sent to just about any kind of device containing a browser, including cell phones, personal digital assistant (PDA) devices, pagers, laptops, not to mention the traditional PC. People who want to develop shell-based applications can also execute PHP from the command line.

Since PHP contains no server-specific code, users are not limited to a specific and perhaps unfamiliar Web server. Apache, Microsoft IIs, Netscape Enterprise Server, Stronghold, and Zeus are all fair game for PHP’s server integration. Because of the various platforms that these servers operate on, PHP is largely platform independent, available for such platforms as UNIX, Solaris, FreeBSD, and Windows 95/98/NT.
Finally, PHP offers access to external components, such as Enterprise Java Beans and Win32 COM objects. These newly added features put PHP in the big league, truly enabling developers to scale PHP projects upward and outward as need be. An Introduction to PHP 7

Free
The open source development strategy has gained considerable notoriety in the software industry. The prospect of releasing source code to the masses has resulted in undeniably positive outcomes for many projects, perhaps most notably Linux, although the success of the Apache project has certainly been a major contributor in proving the validity of the open source ideal. The same holds true for the developmental history of PHP, as users worldwide have been a huge factor in the advancement of the PHP project.

PHP’s embracing of this open source strategy result in great performance gains for users, and the code is available free of charge. Additionally, an extremely receptive user community numbering in the thousands acts as “customer support,” providing answers to even the most arcane questions in popular online discussion groups.

Search

Bookmark Us

Delicious Digg Facebook Favorites More Stumbleupon Twitter