Skip to content
ACC Automation: PLC & Industrial Control Learning

ACC Automation: PLC & Industrial Control Learning

Practical Tips and Techniques

  • Programming
    • PLC Beginner’s Guide to PLC Programming
    • PLC Basics – Programmable Logic Controller
    • PLC Programming +
    • HMI (Human Machine Interface)
    • Misc Tips
  • Series
    • Machine Simulator (EasyPLC) Software Suite
    • Node-RED IoT Enabling Software
    • C-More CM5 HMI Series
      • C-More CM5 FAQ
    • LS Electric XGB PLC Series
      • LS XGB Series XEM PLC FAQ
    • Click PLC Series Industrial Automation
      • Click PLC – FAQ
    • BRX (Do-More) PLC
      • Do-More PLC – FAQ
    • Productivity 1000 Series PLC – P1000
      • Productivity PLC – FAQ
    • Productivity 2000 Series PLC – P2000
      • Productivity PLC – FAQ
    • Arduino Opta PLC
      • Opta PLC FAQ
    • Omron PLC – CP1H Series (CP1 Omron PLC Family)
    • Horner XL4 Series
    • C-More HMI Series Panel
      • C-More EA9 – FAQ
    • C-More Micro HMI – Human Machine Interface
    • MOSAIC – MOdular SAfety Integrated Controller
    • CTT Multi-functional Digital Counter Timer and Tachometer
    • Productivity Open Arduino Compatible Industrial Controller
    • PLC Fiddle – Online PLC Editor and Simulator
    • Arduino Uno Starter Kit
  • Purchase / Find Parts
    • XY-MD02 Temp Humidity Sensor – Modbus RTU
    • Automation Tools and Tips (Preferred Devices)
    • Communication Products
    • Click PLC – Purchasing Components
    • Omron CP1H
    • Omron CP1E
    • Omron C20K C28K C40K C60K
  • Misc Tips
    • Video Library
    • Misc Tips
    • What’s New
    • Management/Leadership
    • About
  • Contact
    • Contact
    • About
    • Privacy Policy
  • Search Threads

Build Secure HMI Access Control: AdvancedHMI Login Tutorial

December 29, 2025February 21, 2016 by garrys

We will be creating an HMI (human machine interface) login screen for the cylinder program that we developed previously.
BUILDING A PLC PROGRAM THAT YOU CAN BE PROUD OF – PART 6
Our program had a Run, Jog and Teach mode for the cylinders. Our user will login with a user name and password. Based upon the user level that is set we will control what modes each user will be able to operate. We will also write this user level mode into the PLC.


Sequence of Operation – AdvancedHMI Login Database Screen

The following is the sequence of operation:
Watch on YouTube: Creating an HMI Login Screen on AdvancedHMI Sequence of Operation

Note: All of the programs used are provided free of charge and are an excellent way to learn PLC / HMI programming.

AdvancedHMI Software

AdvancedHMI is a free HMI software package that communicates to a number of different PLC manufacturers. This package uses visual studio and vb.net to program, however, you do not need to be an expert on visual basic to implement this software. We will be using an access database (Access 2010) to store our user information. When the operator logs into the system, they will enter a user name and password. The program will compare this to the information in the database and set the appropriate modes on the HMI.

Access Database 020-minThe first thing that we need to do is to create a database to store user information. We will create a table called ‘tbl_user’. The fields in the database will be as follows:
First_Name – Text Field – 50 characters
Last_Name – Text Field – 50 characters
User_Level – Number – Integer
User_Name – Text Field – 50 characters
Password – Text Field – 50 characters

Access Database 010-minThe user level will be as follows:
0 – Stop and reset the machine only (Not logged in)
1 – Run, stop and reset the machine only
2 – Run, stop, reset and jog the machine
3 – Run, stop, reset, jog and teach the machine

Do-More PLC Modbus Addresses – AdvancedHMI Login Database Screen

Here is a list of addresses that we will be using for our login screen between the HMI and PLC.

Device Data Addresses Type Do-More PLC Description
Run/ Jog Selector 00008 Input MC8  MC8 on is jog mode
Jog / Teach Selector 00070 Input MC70  MC70 on is teach mode
User Level 40005 Output MHR5  Current user level

We will add a Login / Logout button on the main page of our control. This will allow the operator to sign in or out of the machine. To ensure that the operator knows that he is logged into the system we will display a message in a label also on the main screen. Here is what our main page now looks like:
User Interface Sign In vb.net

VB.net – AdvancedHMI Login Database Screen

The next thing we need to do is to design the form for our login information. This will contain two text boxes for the password and user name. We will also need two buttons; Login and Cancel. Our new form will be called Page2. Here is what it will look like:
User Interface Sign In vb.net

When the HMI first powers up and no user has logged in we will ensure that the Jog and Teach functions are reset by writing values directly to the PLC. We will also set the user level to 0.
Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles Me.Load
ModbusTCPCom1.Write(“00008”, 0) ‘Reset Run / Jog Selector PLC
ModbusTCPCom1.Write(“00070”, 0) ‘Reset Jog / Teach Selector PLC
ModbusTCPCom1.Write(“40005”, 0) ‘Set user level to 0
End Sub

Now let’s look at the logic for the button on the main page. If a person is logged into the machine then this button will log them out. This will also change the user level to 0 and write this to the PLC. In our case, MHR5 (400005) will contain the user level code. If no one is logged in then this button will call up our login form (Page2) so information can be entered.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
     If Button1.Text = “Login” Then
Page2.txtUsername.Text = “”
Page2.txtPassword.Text = “”
Page2.Show()
Else
SelectorSwitch1.Value = False
SelectorSwitch2.Value = False
          MomentaryButton1.Enabled = False ‘Start
          SelectorSwitch1.Enabled = False ‘Run / Jog Selector
          SelectorSwitch2.Enabled = False ‘Jog / Teach Selector
          Button1.Text = “Login”
          Label6.Text = “Please Login To Operate the Machine”
          ModbusTCPCom1.Write(“40005”, 0) ‘Reset user level in PLC
     End If
End Sub

Page2 is our login form. Here is the programming logic for the Login Button.
Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
If txtPassword.Text = “” Or txtUsername.Text = “” Then
MessageBox.Show(“Please complete the required fields…”, “Authentication Error”, MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
‘ Connect to DB
Dim conn As New System.Data.OleDb.OleDbConnection()
conn.ConnectionString = “Provider=Microsoft.ACE.OLEDB.12.0;Data Source= F:\Users\Shortt\Downloads\Creating a HMI Login Screen in AdvancedHMI\HMI\AdvancedHMIBetaV399a\AccDatabase.accdb”
Try
Dim sql As String = “SELECT * FROM tbl_user WHERE User_Name='” & txtUsername.Text & “‘ AND Password = ‘” & txtPassword.Text & “‘”
Dim sqlCom As New System.Data.OleDb.OleDbCommand(sql)
‘Open Database Connection
sqlCom.Connection = conn
conn.Open()
Dim sqlRead As System.Data.OleDb.OleDbDataReader = sqlCom.ExecuteReader()
If sqlRead.Read() Then
Dim FirstName As String
Dim LastName As String
Dim UserLevel As Integer
FirstName = sqlRead(“First_Name”)
LastName = sqlRead(“Last_Name”)
UserLevel = sqlRead(“User_Level”)
MainForm.ModbusTCPCom1.Write(“40005”, UserLevel)
MainForm.Button1.Text = “Logout”
MainForm.Label6.Text = FirstName & ” “ & LastName & ” Level = “ & UserLevel
MainForm.MomentaryButton1.Enabled = True ‘Start
If UserLevel = 3 Then
MainForm.SelectorSwitch1.Enabled = True ‘Run / Jog Selector
MainForm.SelectorSwitch2.Enabled = True ‘Jog / Teach Selector
ElseIf UserLevel = 2 Then
MainForm.SelectorSwitch1.Enabled = True ‘Run / Jog Selector
MainForm.SelectorSwitch2.Enabled = False ‘Jog / Teach Selector
Else
MainForm.SelectorSwitch1.Enabled = False ‘Run / Jog Selector
MainForm.SelectorSwitch2.Enabled = False ‘Jog / Teach Selector
End If
MainForm.Show()
Me.Hide()
Else
‘ If user enter wrong username and password combination show error
MessageBox.Show(“Username and Password do not match..”, “Authentication Failure”, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
‘Clear all fields
txtPassword.Text = “”
txtUsername.Text = “”
‘Focus on Username field
txtUsername.Focus()
End If
conn.Close()
          Catch ex As Exception
MessageBox.Show(“Failed to connect to Database.. System Error Message: “ & ex.Message, “Database Connection Error”, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End Sub

A further explanation of the code above can be found at the following address.
How to create login form in VB.NET


Connecting to our database – AdvancedHMI Login Database

The ConnectionString will vary from machine to machine. To automatically determine the connection string to our database we can do the following:
1 – Click DataBindings in the Properties window. Click F4 if you cannot see the properties window or add it on View – Properties Window.
AdvancedHMI 030 ConnectionString-min
2 – Under DataBindings, click on Text – Add Project Data Source. This will call up the Data Source Configuration Wizard.
AdvancedHMI 031 ConnectionString-min
3- Choose Database as your Data Source Type and click Next.
AdvancedHMI 032 ConnectionString-min
4- Choose Dataset as your Database Model and click Next.
AdvancedHMI 033 ConnectionString-min
5 – Click on New Connection
AdvancedHMI 034 ConnectionString-min
6 – Click on Microsoft Access Database File as your Data Source and click Continue
AdvancedHMI 035 ConnectionString-min
7- The Add Connection window appears. Beside the ‘Database file name:’ click Browse. Locate the database file that we created above.
8 – Click the Test Connection. You should get the test connection succeeded message.
AdvancedHMI 036 ConnectionString-min
9 – Click OK to close the Add Connection wizard. Expand the “Connection string that you will save in the application”. Copy the connection string given and paste it on conn.ConnectionString.
Note: Copy – Ctrl + C / Paste – Ctrl + V
AdvancedHMI 037 ConnectionString-min

Here is the programming logic for the Cancel Button.
Private Sub ReturnToMainButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
MainForm.Show()
Me.Hide()
End Sub

In this program, we are just writing a user level in PLC memory address MHR05. The control of the PLC can be limited if hardwired selector switches and pushbuttons were in the system. Implementing a login screen is very straightforward and can be part of your overall automation solution.

Download the access database and the Bin directory for the AdvancedHMI login screen.

The cylinder PLC program from Building a PLC Program That You Can Be Proud Of – Part 6 can be downloaded with the following link.
Download the PLC program and the Bin directory for the advanced HMI Screen.

Watch on YouTube: Creating an HMI Login Screen on AdvancedHMI – Explaining the Code

If you have any questions or need further information please contact me.
Thank you,
Garry



If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLC’s are not difficult to learn and understand. We will walk through the numbering systems used in PLCs. This includes Bits, Decimal, Hexadecimal, ASCII and Floating Point.

To get this free article, subscribe to my free email newsletter.


Use the information to inform other people how numbering systems work. Sign up now.

The ‘Robust Data Logging for Free’ eBook is also available as a free download. The link is included when you subscribe to ACC Automation.


Categories AdvancedHMI, Communication, Do-More, Do-More Designer, HMI, Modbus TCP, PLC, PLC Learning Tags acc automation, advanced hmi, advanced hmi examples, advanced hmi manual, advanced hmi modbus, advanced hmi tutorial, AdvancedHMI, advancedhmi download, advancedhmi manual, Creating a HMI Login Screen on AdvancedHMI, HMI, hmi plc programming tutorial, hmi programming tutorials, hmi training, log in, login, login screen, plc programming examples, plc programming ladder logic, plc programming tutorial, plc training, scada, scada systems basics, scada tutorial for beginners
The Hidden Language of PLCs: How Bits Control Everything
USB to Serial Communication Device Driver Configuration Tutorial

Donate


Help maintain this website.

Subscribe to ACC Automation:

Recent Posts

  • Unlock FREE PLC Productivity Programming Software with Ease Now!
  • P1-M622-16DR Mini PLC: Is This Your Factory’s New Best Friend?
  • ACC 2025 500+ Free PLC Ladder Logic HMI Decade Knowledge Base
  • Industrial Ethernet Switch – 8 Gigabit Ports For EXTREME Temp?
  • Why Your PLC Dies Without the Right Power Supply!
  • What if DIGITAL TWINS Could Transform Your Factory?
  • Can I Use CLAUDE AI to Program a PLC Successfully?
  • What is PLC Logic in Scan Cycles REALLY Doing?
pictory

YouTube Channel Subscribe:

Ezoic - Intelligent Technology for Website Publishers

Archives

Categories

  • Unlock FREE PLC Productivity Programming Software with Ease Now!
  • P1-M622-16DR Mini PLC: Is This Your Factory’s New Best Friend?
  • ACC 2025 500+ Free PLC Ladder Logic HMI Decade Knowledge Base
  • Industrial Ethernet Switch – 8 Gigabit Ports For EXTREME Temp?
  • Why Your PLC Dies Without the Right Power Supply!
  • What if DIGITAL TWINS Could Transform Your Factory?
  • Can I Use CLAUDE AI to Program a PLC Successfully?
  • What is PLC Logic in Scan Cycles REALLY Doing?
  • Most Asked PLC Ladder Logic Question and Why
  • CLICK PLC Controls Rail Conveyor Palletizer in 5 Easy Steps?

Donate


Help maintain this website.

Newsletter

HostPapa Web Hosting

HostPapa Web Hosting

Ezoic Blog - How I Made A Fast WordPress Site With Ads Using Ezoic Leap
  • Unlock FREE PLC Productivity Programming Software with Ease Now!
  • P1-M622-16DR Mini PLC: Is This Your Factory’s New Best Friend?
  • ACC 2025 500+ Free PLC Ladder Logic HMI Decade Knowledge Base
  • Industrial Ethernet Switch – 8 Gigabit Ports For EXTREME Temp?
  • Why Your PLC Dies Without the Right Power Supply!
© 2026 ACC Automation: PLC & Industrial Control Learning • Built with GeneratePress