
Introduction
In this article we will focus on the practical use of the BoxID/Clocker reader. The article is intended for those who are already familiar with integrating the reader with a Mitsubishi PLC, if you haven’t already done so, please refer to the first part of the article.
The PLC project from this article in GX Works3 is available for download on our github:
https://github.com/Inveo-spzoo/BoxID-Clocker—Mitsubishi-GxWorks3—Sample-Poroject-
List of variables
After configuring both devices, it is time to create the first application using the full power of the reader’s capabilities. Remember that the number of blocks depends on the model of the reader.
However, before we move on to programming, we need to familiarize ourselves with the individual data blocks and their functionalities. One of the basic blocks for operating BoxID/Clocker readers is the “control” block – it allows you to control outputs, read inputs, generate beeps and view login data. Variables with the prefix “Q” are the PLC’s output data, and variables with the prefix “I” its input data.

Description of the functions of individual variables:
Q_resetNewIdFlag – this flag is used to confirm the reflection of a new user card, setting the state high is required for the reset of the I_newIdFlag to occur
I_newIdFlag – this flag assumes a high state when a new card is reflected, the flag will be reset by setting the high state to Q_resetNewIdFlag
I_in1 – input state 1
I_in2 – state of input 2
I_out1 – state of output 1
I_out2 – state of output 2
I_liveBit – bit indicating correct configuration of both devices
I_uidLen – length of userID
I_uid – userID data array
I_userId – variable indicating whether the user is registered in the database if the card ID is recognized then the user id will be displayed otherwise the value 64535 will be displayed.
I_group – the user’s group
I_name1 – the first member of the user’s name
I_name2 – the second member of the user’s name
Q_out1_ctrl – relay output 1 (coil control)
Q_out2_ctrl – relay output 2 (coil control)
Q_soundAccept- sound signal “accept”
Q_soundReject – sound signal “reject”
The following handshake must be performed to enable data writing from the PLC to the reader. This is a confirmation of the introduction of a new user.

Another basic block is the “User_editor”, which is used for both reading users and writing them to the reader’s memory. Each user has its own group and ID.

There are two ways to add users. We can add them from the reader’s built-in web server or from the PLC level by performing appropriate operations on the data block.
Note: the variables of the “user_editor” block are used for both reading and writing, there is no division into input and output parameters here.
Description of the functions of individual variables:
readUserid – the number of the user whose data we want to read
writeUserId – the number of the user whose data we want to write
addNewUser – we must set the value to 1 each time before adding a new user, this will set the index in the nearest free space – the value will automatically be set to 0 by the reader so you do not need to delete it
currentUserId – the id index of the user we want to write or read
uid – the id number of the user card
name1 – the first part of the user name
name2 – the second part of the user name
group – group/access level of the user
active – bit, which allows deactivating the access of a given user without removing him from the memory
The next important block is “lcd”. The block allows full control over the built-in display, we have 4 lines of 20 characters each. Which allows us to create a simple menu and display the result of login.

Description of the functions of each variable:
useLcd – setting the state high allows you to take control of the display, a low state will display the IP address of the reader
showTime – setting the state high will display the current date and time in the first line
clearLcd – clears the display
backlight – display backlight ON/OFF
line1 – first line
line2 – second line
line3 – third line
line4 – fourth line
The last block is the keypad, we use it only in readers with a keyboard.

character – a character pressed on the keyboard
After getting acquainted with the data blocks and their contents, it’s time to create the first practical application. This will be a simple user management system. In fact, the BoxID reader has a built-in system for managing users – our task will be to operate it with a few simple instructions.
Access control
As I mentioned at the beginning, the reader requires the so-called handshake, or reset of the newID flag, for proper operation:

We can start by manually guiding two users to the system, then we will proceed to create a simple program that will trigger the reader’s built-in relay output for 3s in case of correct authorization.


As you can see, I added two users. When the card is brought close to the reader and “Get last read UID” is pressed, the last read code will be entered into the Card UID field.
Below is the implementation of a simple access control program in ST language:

Program action:
If the ID is invalid, the user is not logged in. In case of positive verification, the system activates the relay output for 3 seconds.
After the preset time, the output is automatically reset and the system returns to waiting for the next user.
Correct login:

Incorrect login:

If the login is correct, the I_userId value takes the value of the user index, otherwise it takes the value of 65535.
User management
Before we move on to user management we will create a block of auxiliary variables User_help_var:

We already know how to verify users, the next step is to master reading existing users from the reader’s built-in database.
Currently, our user base looks like this:

In this case, let’s try to read the user with index 1:

The above code allows both reading and writing users. It has been prepared so that, using writing values to auxiliary variables with postfixes “Button” and “Set”, it is possible to manage the database, for example, from the HMI. To read a user with index 1, set the variable “currentUserId” to 1 and set the auxiliary variable “readUserIDButton” to 1. As you can see in the preview above, the data of a user with index 1 appeared.
We have already mastered reading a user, the next and final step is to master writing new users from the PLC. As in the case of manually adding a user, you need to enter the first and last name and bring the new card close to the reader.

After running this data, you just need to bring the card you want to assign to this user closer to the reader, then set the high state of the “writeUserIDButton” variable.

The user will be entered on the nearest free index in memory. This is how we successfully entered Adam Nowak into the user base.
LCD display
By default, the display should show the IP address

Below we see the contents of the “lcd” block:

Setting the variable “useLcd” to the state “true” allows you to take full control of the display.

The variable “showTime” allows you to display the current time on the first line, and “backlight” to illuminate the display.
Efekt:

Now let’s try to combine the access control program we wrote earlier with the display operation. In addition to driving the relay output for 3 seconds, we will greet our user and display his name on the screen:


At the very end, it can enrich our system with a sound signal in case of successful authorization by adding support for the state of the “Q_soundAccept” variable.

Keyboard
The last programmable element of the reader, depending on the version, can also be the keypad, and this is where it comes in. In the case of readers with a keyboard, in addition to the blocks: “Control”, ‘User_editor’ and ‘Lcd’ we still have the ‘Keypad’ block, but for convenient operation of the keyboard we will need the ‘Keypad’ function block.
In the project, add a new function block in ST language and call it “Keypad”


The variable block should be imported from the Local Label -> “Keypad.csv” file, and the source code of the function block should be copied from the Local Label -> “Keypad_script” text file.
After doing the above, you can call the function block in the main file by assigning variables to the appropriate places: “clearLcd”, ‘line1’ and ‘character’.
The “character” variable comes from the “Keypad” block, the “number” variable is the output string from the keyboard, in this case we assigned the first line of the Lcd display as the place to display the content typed from the keyboard.

After calling the function and assigning a string to the first line of the display, we can enter any string of digits:

Completion
Thank you for taking the time to read our manual on integrating BoxID/Clocker readers with Mitsubishi PLCs! We hope that the information in the manual will make it easier for you to implement this solution in your projects. If you have any questions, do not hesitate to contact our support team.
Good luck with the integration!