Monday, 1 August 2016

How to Extract the DataGridView data into CSV

- 0 komentar
Here is the sample code to extract data from DataGridView to CSV file.

1. make a simple VB project.
2. add a DataGridView control and a Command button to the Form.

3. write this code to Extract button event click :

4. write some data to the DataGridView, here is the sample:

5. Here is the output CSV file :







[Continue reading...]

Saturday, 23 July 2016

OPC to SQL

- 0 komentar
OPC2SQL is a simple tool/application for polling data from OPC Server to SQL Database periodically.

The block diagram:

OPC Server         : WinCC, RSLinx, etc.
SQL Database : MySQL, MS SQL Server, etc


Follow the steps below:

1. Open the application.

2. Open Configuration tab, input all data, then Save

3. Make sure with OPC Server and OPC Items.
 

 4. Make sure with Database, Table and Columns.

5. Click Activate on Runtime tab. See the result. 



Please download the demo version HERE.
Contact hadiscada@gmail.com for full version, requests more features, some modifications, and source code.

Thank you.. :)
[Continue reading...]

Tuesday, 7 June 2016

SerialComm : Serial Communication (Chat)

- 0 komentar
This simple VB.net project is for testing connection/communication between 2 serial port.


We will use VSPE (Virtual Serial Port Emulator) to create 2 virtual COM ports.


The steps for testing:
1. copy the EXE, so we have 2 application file
2. open both application
3. open VSPE, make Pair for COM3 dan COM4
4. set Port on one application to COM3 and the other to COM4
5. click button Connect on both application
6. write some text on Text to Send box
7. click button Send.



Please download the project here.

Thank you..
[Continue reading...]

Monday, 6 June 2016

Modbus RTU Client

- 0 komentar
ModRTUClient is a VB.net application to Read and Write data register (Coil Output, Digital Input, Analog Input, Holding Register) from Modbus RTU (Master) device.

The different with Modbus RTU VB6 is, this project created using Visual Studio 2010 Express, and there is options to select I/O type register.



Please download the project from here.
* revised version (rev.1.2), please rename file extension to .zip

How to use:
1. Select the Port
2. Select Baudrate
3. Input Slave ID, Start Address register, and Register Quantity
4. Select type of I/O (Coil Output, Digital Input, Analog Input, Holding Register)
5. Select Data Type
6. click Connect button
7. click Read button
8. to Write, input Register to write, input the Value, then click Write button
9. Disconnect button for Disconnect from Modbus Master
10. Exit button for quit from application


Thank you..


note for the revised version (r1) :
- data type only Decimal
+ add combo box for select Parity
> edit script for sub Connect


[Continue reading...]

Sunday, 5 June 2016

AutoBatch : Auto Run Batch File

- 0 komentar

Hi..

I create a simple sample (demo) VB.net project (application) named AutoBatch. 
This application is for Auto Run BAT file, when the file is added to specified directory (folder).


Please download the project from here.

Learning points from this project was :
+ how to watch the content of diretory
+ how to run the BAT file 
+ how to delete file
+ how to save the Setting of application
+ how to load the Setting of application
+ how to use Timer to evaluate the change of folder
+ how to use Timer for Demo session
+ how to make a sample simple BAT file. 



picture when there is no BAT file.

picture when new BAT file added.

picture when Run BAT file.


Thank you..
[Continue reading...]

Friday, 27 May 2016

My Simple OPC Web

- 0 komentar
Hello..

Today, I want to share: MySimpleOPCWeb project.
this is the web version of MySimpleOPCClient (please read the article here).

I use Visual Studio Community 2015 (its free). I am not sure, is it OK with other version of Visual Studio or not.

Here is the design form:


We will use IIS Express as local web host, so make sure IIS Express is already installed on your PC.
This is the setting of Web, please open the project properties.


I use Matrikon OPC Server simulation as OPC Server, you can read the operation steps in the article of MySimpleOPCClient.


You can download the source code of MySimpleOPCWeb project here.


Oke. Thats it. If you found some problem using this project, or you have a suggestion, please let me know..
Thank you very much.

[Continue reading...]

Thursday, 26 May 2016

Modbus RTU Simulation

- 0 komentar
Welcome..

Today, we will simulate and emulate, Modbus RTU Server (Master).
Imagine, we have a Modbus RTU device (PLC, Remote I/O, etc) connected to our PC through Serial (COM) Port.
then, let we change the device (hardware) with an application (software), we will simulate it. And also, let we change the COM port connection with virtual serial port.
Oke?
Oke. we will use Mod_RSsim for the first one (Modbus RTU Simulator), and we will use VSPE (Virtual Serial Port Emulator) for the second one (Serial Port Emulator).

You can download Mod_RSsim from here.
You can download VSPE from here.

Oke. lets go..!

Now, we will configure the virtual connection of serial port :
- open VSPE application

- goto menu Device > Create

 

- select Pair, then click Next

 

- select unused (undefined) Port, example COM3 and COM4, then Finish

 

- the Emulator has started

 

- dont close the application, minimize is Ok.


Now, we will open Mod_RSsim application as Modbus RTU Master simulator :
- open Mod_RSsim

- select Port to MODBUS RS-232


- click on port icon to open the port setting


- select the type of I/O


- to write Digital Input or Coil Output, just double-click on the register


- to write Holding Register or Analog Input, double-click on register then write the value on the box



Oke. The next step is testing with Modbus RTU Client. We can use the simplest sample application from this blog: Modbus RTU Sample VB6. 
Actually I develop new (advanced) sample project for Modbus RTU client, maybe I will post here someday.


Thats all.. Thanks for visiting..
See you next time.. :)
[Continue reading...]

Wednesday, 30 March 2016

My Simple OPC Client

- 14 komentar
As request from our friends, here we create a simple VB application/project to communicate with OPC Server.

Previously, we create My OPC Client project, the latest is version 5, with some advanced feature. But some friends need more simple application, so we create this project. The purpose of the application is to connect to OPC Server, Read data and Write data. So here is MySimpleOPCClient..




For testing, we use Matrikon OPC Explorer, you can download from here.
Please download MySimpleOPCClient project source code from here.


The steps:
1. Run Matrikon OPC Explorer
2. Create group, and add some items to monitor, ie "Bucket Brigade.Int1"
4. Run MySimpleOPCClient
5. Write "Matrikon.OPC.Simulation.1" on OPC Server Name textbox
6. Click Connect button
7. On OPC Item textbox, write "Bucket Brigade.Int1"
8. Click on Add Item button
9. The value of item is automatically loaded to the Read Value textbox
10. Try to write new value on Write Value textbox, then click on Write button




Note: 
Before opening the project, please make sure you have OPCDAAuto.dll installed/registered on your system. Please follow these steps to register the DLL:
> download DLL from here
> copy file to /System32 folder
> open CMD (command prompt)
> write this command: "regsvr32 OPCDAAuto.dll"

We create this project with MS Visual Studio Express 2010, and we targeted to .NET Framework 4. If you get some problem, please let us know.

See you next time.. Thank you...
[Continue reading...]

Thursday, 17 March 2016

VB - PLC via SimaticNet

- 0 komentar
Yang akan kita lakukan adalah membuat komunikasi antara VB dan PLC Siemens melalui SimaticNet. Kali ini kita tidak akan memakai PLC sungguhan tapi memakai aplikasi PLC-SIM.
Tujuan kita pada percobaan kali ini hanya sekedar untuk membaca nilai dari MB 0 dari PLC dan menampilkannya ke form VB.

Yang perlu dipersiapkan adalah:
a. Aplikasi S7 PLC-SIM. aplikasi bawaan dari instalasi Simatic Manager.
b. Aplikasi NetToPLCSim. aplikasi tambahan, bisa download dari sini.
c. Aplikasi Visual Studio 2010 Express, atau versi lain.
d. DLL Libnodave, library tambahan untuk komunikasi via SimaticNet, unduh disini.

Oke, sekarang kita buat dulu program VB nya.
1. Buka VS 2010, buat projek VB baru.
2. Tambahkan References ke DLL Libnodave.


3. Pada form1, tambahkan sebuah tombol (namai btnRead) dan sebuah text box (namai txtVal)


4. Buka jendela code, dan tambahkan script berikut:

Public Class Form1
    Public Shared fds As libnodave.daveOSserialType
    Public Shared di As libnodave.daveInterface
    Public Shared dc As libnodave.daveConnection
    Public Shared res As Integer
    Public Shared plcValue As Byte
    Public Shared memoryRes As Integer
    Public Shared MemoryBuffer(10) As Byte

    Public Shared Sub ConnectPLC()
        fds.rfd = libnodave.openSocket(102, "192.168.1.10")
        fds.wfd = fds.rfd
        di = New libnodave.daveInterface(fds, "IF1", 2, libnodave.daveProtoISOTCP, libnodave.daveSpeed187k)
        di.setTimeout(20000)
        res = di.initAdapter
        dc = New libnodave.daveConnection(di, 2, 0, 0)
        res = dc.connectPLC
        memoryRes = dc.readBytes(libnodave.daveFlags, 0, 0, 1, MemoryBuffer)
        plcValue = MemoryBuffer(0)
        dc.disconnectPLC()
        di.disconnectAdapter()
        libnodave.closePort(fds.rfd)
    End Sub

    Private Sub btnRead_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRead.Click
        ConnectPLC()
        txtVal.Text = plcValue
    End Sub
End Class


5. Simpan projek.

6. Sekarang jalankan aplikasi PLC-SIM.


7. Selanjutnya kita jalankan aplikasi NetToPLCSim, harus dibuka sebagai Admin (klik kanan > Run as admin).


Jika Port 102 sudah berhasil dibuka maka akan muncul tulisan "Port 102 OK"
8. Tambahkan PLC dengan tekan tombol Add.
9. Isi IP Network dan IP PLC Sim, atau bisa dengan browse.


10. Setelah ditambahkan, tekan tombol Start Server.


11. Sekarang jalankan projek VB.
12. Tekan tombol Read, maka value dari MB 0 akan ditampilkan.



Oke, sekian dulu dari kami, terima kasih sudah berkunjung, sampai jumpa lagi.



[Continue reading...]

Saturday, 5 March 2016

Taskbar Show Hide

- 0 komentar
Pernahkah Anda mendapatkan Taskbar Windows menghilang?
Taskbar adalah bar yang defaultnya terdapat di bagian bawah layar, dimana semua aplikasi yang sedang berjalan akan ditampilkan icon-nya. Melalui Taskbar ini kita bisa menampilkan dan menyembunyikan aplikasi yang sedang berjalan.
Taskbar juga sebgai tempat Quick Launch dan Sys Tray. Biasanya aplikasi penting akan meletakan icon kecil sebagai shortcut menu di Sys Tray.
Apa yang membuat saya ingin membahas ini adalah pengalaman saya dengan WinCC. Kami menggunakan PCS 7 v8.1, entah apakah problem ini berlaku juga pada WinCC/PCS 7 versi lain.
Problemnya adalah, ketika WinCC Runtime dijalankan, beberapa saat yang kami tidak tahu pasti (bisa jam/harian/mingguan) setelah itu Taskbar Windows menghilang. Ketika kami menekan tombol Start Windows tidak muncul Taskbar tersebut.
Dengan Taskbar yang hilang, kami tidak bisa melakukan beberapa action terhadap WinCC, seperti Exit Graphic Runtime dan lain-lain.
Oleh sebab itu kami mencari cara untuk bisa menampilkan Taskbar yang hilang tersebut, dan inilah solusinya:

Aplikasi TaskbarShowHide
Aplikasi ini dibuat dengan bahasa VB. Sumbernya kami dapat dari forum di internet. Dengan aplikasi ini kita bisa Show Taskbar dan Hide Taskbar, sederhana.
Berikut langkah-langkah untuk membuatnya:

1. Buka Visual Basic.
2. Pada Form1, tambahkan dua tombol, btnShow dan btnHide seperti berikut:


3. Buka jendela code untuk Form1, dan ketik code berikut:

Public Class Form1

    Private Sub btnShow_Click(sender As Object, e As EventArgs) Handles btnShow.Click
        ShowTaskBar()
    End Sub

    Private Sub btnHide_Click(sender As Object, e As EventArgs) Handles btnHide.Click
        HideTaskBar()
    End Sub
End Class



4. Tambahkan module baru dengan nama Module1.
5. Ketik code berikut:

Option Explicit On

Module Module1

    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
        (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer

    Private Declare Function SetWindowPos Lib "user32" _
        (ByVal hwnd As Integer, ByVal hWndInsertAfter As Integer, ByVal x As Integer, _
         ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, _
         ByVal wFlags As Integer) As Integer

    Private Const SWP_HIDEWINDOW = &H80
    Private Const SWP_SHOWWINDOW = &H40

    Public Function HideTaskBar() As Boolean
        Dim lRet As Integer
        lRet = FindWindow("Shell_traywnd", "")
        If lRet > 0 Then
            lRet = SetWindowPos(lRet, 0, 0, 0, 0, 0, SWP_HIDEWINDOW)
            HideTaskBar = lRet > 0
        End If
        Return True
    End Function

    Public Function ShowTaskBar() As Boolean
        Dim lRet As Integer
        lRet = FindWindow("Shell_traywnd", "")
        If lRet > 0 Then
            lRet = SetWindowPos(lRet, 0, 0, 0, 0, 0, SWP_SHOWWINDOW)
            ShowTaskBar = lRet > 0
        End If
        Return True
    End Function
End Module


Run dan cobalah untuk Show/Hide Taskbar.
Selamat mencoba..

[Continue reading...]

Thursday, 11 February 2016

Error While Publishing WinCC WebNavigator

- 1 komentar
Hello friends !

This time I want to share a problem while using WinCC WebNavigator with CEMAT v8.1.
So, maybe this article is suitable for people with experience of WinCC and Web Navigator, because I will not describe some basic steps.


Problem
I have a problem when I do WinCC Web View Publisher Wizard. At the end of the process (Web Publishing Wizard) I get some error, some Picture cannot be published because there are "undefined identifier". Like this:

------- @PG_C_ANNUN8_STANDARD.pdl
Status: Fail
Line: 213    Error:   error  (003f) : undefined identifier 'C_ReadProjStdAS'
Line: 213    Error:   error  (0066) : 'C_ReadProjStdAS' is not a function
Line: 213    Error:   error  (0045) : illegal assignment


------- @C_SetTrendCurves_APL.pdl
Status: Fail
Line: 68    Error:   error  (003f) : undefined identifier 'C_StrngToUpper'
Line: 68    Error:   error  (0066) : 'C_StrngToUpper' is not a function
Line: 68    Error:   error  (0007) : different levels of indirection


Analyze
> There are 2 function (fct) which cause Error: 'C_ReadProjStdAS' and 'C_StrngToUpper'
> I check to the folder: D:\CEMAT_CS\ WINCC\library\CematBin, the FCT files is already exist there.
> I open the pdl, then search for some script within faceplate. I found script on some object, which call the function 'C_ReadProjStdAS'. When I compile the script, Error happens.

Solution
The first step is: googling... haha.
from many discussions on Siemens forum, I get this Solution.
The Solution is: Regenerate Header
Open Global script C editor, then click on menu Options > Regenerate Header
After finish, try to compile the script on the faceplate. It must be no error right now. Then you can do Web Publich again.


Good luck!




[Continue reading...]
 
Copyright © . HadiSCADA - Posts · Comments
Theme Template by BTDesigner · Powered by Blogger