Account
Please wait, authorizing ...

Don't have an account? Register here today.

×

Washing machine web 2.0. HMI interface in Vb.net

Written by David Posted on 3 July, 2011 at 11:10

Well, I leave the video of the application in vb.net working.

Web washing machine 2.0

I have modified the class in charge of communicating with the plc. In this case we will call the variables by their name. This is the class:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
Imports TwinCAT. Ads
PublicClass ClassAds
    PrivateAs TcAdsClient
    DimAs AdsState
    Enum AdsState
        Disconnected
        ErrorConnectconnectedOk
        
    EndEnum

"PLC ADS"
    PublicFunction Connect()AsString
        Try
            =New TcAdsClient
            adsClient. Connect("192.168.255.2.1.1"801)
            adsClient. Timeout=5000

            If adsClient. Readstate. AdsState. ToString="Run"Then
                = AdsState. ConectadoOk
            else
                = AdsState. ErrorConect
            EndIf
            Return adsClient. Readstate. AdsState. ToString
        Catcherras exception
            = AdsState. ErrorConect
            Return"Error"
        EndTry

    EndFunction

    PublicFunction ValorIntPorName(ByValAsString)

        DimAs AdsStream
        DimAs AdsBinaryReader

        Try
            'Recover Var
            Number DimAsInteger
            = adsClient. CreateVariableHandle(Name)

            =New AdsStream(2)
            adsClient. Read(Var, dataStream)
            =New AdsBinaryReader(dataStream)
            Return Read. ReadInt16
        catcherras exception

            = adsState. ErrorConect
            Return0
        EndTry
    EndFunction
    PublicFunction txtName(ByValAsString)

        DimAs AdsStream
        DimAs AdsBinaryReader
        DimAsString
        DimAsInteger

        Try
            'Recover Var
            Number DimAsInteger
            = adsClient. CreateVariableHandle(Name)

            =New AdsStream(31)
            = adsClient. Read(Var, dataStream)


            =New AdsBinaryReader(dataStream)
            'txt = Read.ReadString
            =NewString(Read. ReadChars(length))
            'txt = txt. Substring(0, txt. IndexOf("\0"))
            Return txt
        catcherras exception

            = AdsState. ErrorConect
            Return0
        EndTry

    EndFunction
    PublicSub WriteBoolPorName(ByValAsStringByValAsBoolean)

        DimAs AdsStream
        DimAs AdsBinaryWriter

         Try'Recuperar
            Numero Var
            DimAsInteger
            = adsClient. CreateVariableHandle(Name)
            =New AdsStream(1)
            =New AdsBinaryWriter(dataStream)
            Write. Write(Value)

            adsClient. Write(var, dataStream)
        Catcherras exception
            = AdsState. ErrorConect
        EndTry
    EndSub

    PublicSub Disconnect()
        If= Adsstate. ConectadoOkThen adsClient. Dispose()
        = AdsState. Disconnected
    EndSub
    PublicFunction StateAds()AsString
        If= AdsState. ConectadoOkthen
            return1
        else
            return0
        endif
    endfunction
#End region
endclass                   

To be able to read the variables by name, what we do is retrieve the Value that identifies this variable. We do this with the following function:
Var = adsClient.CreateVariableHandle(Name)
Name is the name of the variable. For global variables we will call them by . VariableName and for the rest ProgramName.VariableName.

- Publicidad -

I have created an enumeration to define the states of communication. And a new function to retrieve text from the plc. Specifically I am interested in the variable MAIN.txtWarning, this variable informs us of the current state of the sequence.

This is the code of the main form:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
PublicClass Form1
    DimAsNew ClassAds


    
PrivateSub buConectar_Click(ByValAs System. ObjectbyValas system. EventArgs)Handles buConnect. Click
        Plc1.Connect()
        Timer1. Enabled=True
    EndSub

    PrivateSub buDesconectar_Click(ByValAs System. ObjectbyValas system. EventArgs)Handles buDesconnect. Click
        If Plc1.StateAds=1Then Plc1.Disconnect()

    EndSub

    PrivateSub Timer1_Tick(ByValAs System. ObjectbyValas system. EventArgs)Handles Timer1. Tick
        Timer1. Enabled=False

        If Plc1.StateAds 1Then
            MessageBox. Show("Error Ads")
            ExitSub
        EndIf

        laTemp. Text="Temperature= "& Plc1.IntValueByName(". Temperature")&"ºC"
        laNivelAgua. Text="Water  Level= "& Plc1.ValueIntByName(". Water Level")
        theState. Text= Plc1.txtByName("MAIN.txtWarning")

        pbM1. Visible= plc1.ValueIntByName(". M1")
        pbPump. Visible= pbM1. Visible
        pbM2. Visible= plc1.ValueIntByName(". M2")
        pbY1. Visible= plc1.ValueIntByName(". Y1")
        pbY2. Visible= plc1.ValueIntByName(". Y2")

        pbX1. Visible= plc1.ValueIntByName(". X1")
        ImgFondo(Plc1.ValueIntPorName(". CajonCerrado"))

        Timer1. Enabled=true
    endsub
    privatesub imgFondo(byValasinteger)
        ifthen
            pbFondo. ImageLocation=".. /.. /Resources/LavPreparada.png"
        Else
            pbFondo. ImageLocation=".. /.. /resources/TodoParado.png"
        EndIf
    EndSub

    PrivateSub buMarcha_Click(ByValAs System. ObjectbyValas system. EventArgs)Handles buMarcha. Click
        If Plc1.StateAds 1ThenExitSub
        Plc1.WriteBoolByName(". End

    Sub
    PrivateSub Sub buCerrarCajon_Click(ByValAs System. ObjectbyValas system. EventArgs)Handles buCloseBox. Click
        If Plc1.StateAds 1ThenExitSub
        Plc1.WriteBoolByName(". CajonClosed"True)
        Plc1.WriteBoolByName(". DoorClosed"True)
    EndSub
    PrivateSub buAbrirCajon_Click(ByValAs System. ObjectbyValas system. EventArgs)Handles buAbrirCajon. Click
        If Plc1.StateAds 1ThenExitSub
        Plc1.WriteBoolByName(". CajonClosed"False)
        Plc1.WriteBoolByName(". DoorClosed"False)
    EndSub
    PrivateSub Form1_Disposed(ByValAsObjectByValAs System. EventArgs)HandlesMe. Disposed
        If Plc1.StateAds=1Then Plc1.Disconnect()
    EndSub
EndClass             

This code doesn't have much history. It's about establishing the connection. Using a timer, read the status of the motors and valves, to show or not the pictureBox. The background image is changed using the ImgFondo function, depending on the state, showing one or another image. The rest of the code is the events of the Buttons to open/close or start the washing machine.
Here, I leave both the plc program and the application in vb.net. Remind you to change the AMS address in ClassAds. To continue with our project we will have to start the web server and create the functions (vb.net) to record in the database.

Bookmark on DeliciousDigg this postRecommend on Facebookshare via RedditShare with StumblersTweet about itSubscribe to the comments on this post

Authors: David

See original.

Free Subscription
SUBSCRIBE TO OUR NEWSLETTER
DO YOU NEED A SERVICE OR PRODUCT QUOTE?
LASTEST INTERVIEWS

Entrevista a Jaime Maldonado, Presidente de Air-Con Inc

En entrevista con ACR Latinoamérica, Jaime Maldonado, Presidente de Air-Con Inc, destacó los proyectos que tiene la compañía para este año 2024, sobre todo con la transición de los nuevos refrigerantes. Además, Air-Con estará como expositor en Refriaméricas Miami, y Jaime nos habló sobre sus expectativas con el evento y lo que darán a conocer para todos los visitantes.

Webinar: Armstrong y Energía de Distrito

Por: Rafael Behar, Gerente de Apoyo de Aplicación, Armstrong Fluid Technology Los sistemas de energía de distrito se caracterizan por una o más plantas centrales que producen agua caliente, vapor y/o agua fría, que luego fluye a través de una red de tuberías aisladas para proporcionar agua caliente, calefacción y/o aire acondicionado a los edificios cercanos. Los sistemas de energía de distrito sirven a una variedad de mercados de uso final, incluidos los centros de las ciudades (distritos comerciales centrales), campus universitarios, hospitales e instalaciones de atención médica, aeropuertos, bases militares y complejos industriales. Al combinar cargas para múltiples edificios, los sistemas de energía urbana crean economías de escala que ayudan a reducir los costos de energía y permiten el uso de tecnologías de alta eficiencia. En este seminario web vamos a introducir a Armstrong Fluid Tecnología y su dirección para la energía urbana con enfoques en plantas de calefacción. https://www.acrlatinoamerica.com/20...

Webinar: Mejores Practicas para la Optimización de Sistemas

Importancia de la correcta automatización de plantas de agua helada con el objetivo de pasar al siguiente nivel, que es la optimización de los sistemas para obtener una mayor eficiencia energética y ahorro del costo operativo y de mantenimiento. Por: Camilo Olvera Rodríguez, Gerente de Ventas - México, ARMSTRONG FLUID TECHNOLOGY https://www.acrlatinoamerica.com/20...

Webinar: Enfriando el futuro: Las nuevas tendencias en refrigerantes para supermercados y almacenes

https://www.acrlatinoamerica.com/20... Únete a nosotros en este emocionante Webinar sobre las últimas tendencias en refrigerantes para supermercados y almacenes. Descubre cómo mantener tus productos frescos de manera eficiente, mientras contribuyes a la sostenibilidad y cuidado del medio ambiente. En esta sesión, exploraremos las innovaciones más recientes en refrigerantes ambientalmente preferibles, incluyendo tecnologías avanzadas de enfriamiento. Aprenderás sobre las ventajas de adoptar estas nuevas soluciones, no solo en términos de eficiencia energética, sino también en la reducción de emisiones y el cumplimiento de regulaciones ambientales. Por: Guillermo Brandenstein, Sr Account Manager - Honeywell

Webinar: ¿Es adecuada la forma de vender en las empresas HVAC/R?

En esta presentación se tratarán puntos neurálgicos sobre cómo lograr vender sin necesidad de licitar, teniendo muy presente que el cliente no nos compre porque somos los más baratos sino porque somos su mejor opción. Por: Ing. Rolando Torrado, CEO - Rolando Torrado https://www.acrlatinoamerica.com/20...
Load more...
SITE SPONSORS










LASTEST NEWSLETTER
Ultimo Info-Boletin