Password management is increasingly gaining foot in many automation programs in PLC. It works by default in HMI or SCADA, but you know that even PLC can be used to write the logic for managing password activities. This feature is also useful if you use an in-built HMI of the PLC, and the HMI variables can be directly linked with the PLC. In this post, we will see how to write a PLC program for password management using structured text language (STL).
Let us understand the case scenario first. There is a provision to enter username and password in the HMI. The user needs to enter the correct credentials. We will match the password with 1234 and the username with 1111. If the user presses the enter button and it matches, then the user will be logged in. If the user presses the enter button and it does not match, then the user will not be logged in.
There is a feature for locking the user after failed retry counts. If the user has consistently entered wrong credentials for 3 times, then the user will get locked for 10 seconds. In that time, no login activity will happen. After 10 seconds, the user can login again. After successful login, if the user presses the logout button or auto-logout bit (after no activity happens in HMI for 5 minutes) is sensed from the HMI, then the user will be logged out.
We will write the PLC logic now. For this, we have used Studio 5000 software of Rockwell automation and structured text language. Following are the soft inputs in PLC – password entry, user entry, enter button, auto logout and log out button; and the soft outputs in PLC – user locked and user logged. Let us see the logic below.
In the first part, we will check for successful login. If the password is equal to 1234 and the user is equal to 1111 and the user presses enter button and the user is neither locked nor logged in, then the user will be logged in.
Next, we will check for unsuccessful login. If the password is not equal to 1234 or the user is equal to 1111 and the user presses enter button and the user is neither locked nor logged in, then the user will not be logged in.
Next, we will use a counter for counting failed login attempts. We use an instruction called OSRI or one shot rising, which gives an output on input rising edge. If the password is not equal to 1234 or the user is equal to 1111 and the user presses enter button, then a pulse generated will count the counter. The set value for the counter will be 3. When the counter is done, a bit named user locked will be set. The counter will reset if the user is locked or logged in.
When the user is locked, we will use a timer of 10 seconds for unlocking it again. Once the timer is done, the bit will be reset.
If the user presses the logout button or auto logout bit is received from HMI, then the user will be logged out.
In this way, we saw how to write a PLC logic for password management using structured text.
Read Next:
- Conveyor Sorting with Color Detection
- Difference Between PLC and CNC Machine
- PLC Crane Movement Control Program
- PLC Programming Clothes Washing System
- PLC Example for Traffic Light FBD Program