In this article, EXOR’s ex707M is used to connect to a general-purpose USB Barcode Reader to read QR Code and Bar Code and display a screen.It also enables to export the data read from the device to SD Card.Javascript, Live Tag, and other functions were also used in the project.
Come on, let’s enjoy FA!
Implementation
Protocols
Start JMobile and add Variables Protocols; in the Variable communication driver, the tag will point to the HMI internal memory.Note that Variable tags are not retained, so when the project is started, the starting value of the tag will be 0 (or “” for string tags).
Tags
Next, add some Variable Tags.
- barcode:String[100], Barcode read result
- Tag2:int, Counter of Barcode read success
- Tag3_AlarmTrig, Barcode Triggers an alarm after a successful read and stores the data.
Logging Configuration
The next step is Logging Configuration; you can Logging with Trends, but Trends is usually for sampling numeric values, and the maximum sample size is 8 bytes.So if you want to Logging strings, you can either use a script that writes the information to a file, or use an alarm and read the string (which will be stored in the alarm history log) with the Live Tag function in the alarm description.In this article, we will implement a combination of the alarm history log and the live tag function.
Click on the Events Buffer.
In the Project, Alarm Buffer1 is created on Default.
Click on the Storage Device item to set the media in which the data will be stored.
This time, the setting is to save the data to SD Card.
Alarm Configuration
Next, click on “Alarms” to set the alarm.
Click the + button to add an alarm.
Enable
Enter the CheckBox for Enable and activate the corresponding alarm.
Ack
Ack is not required as it only displays the code read from the Barcode Reader.
Trigger
Trigger is the alarm firing status.In this case, we want to trigger an alarm when the bit is turned ON, so we set BitmaskAlarm:0.
Tag
This one sets the Tag that fires the alarm.Set it to Tag3_AlarmTrig declared earlier.
Description
The description is a description of the alarm, but there is actually another practical function, which is the “Live Tag” function.In the description below, the barcode tag is surrounded by [ ], which means that the barcode tag value will be displayed in the description.
Example
Array Tags(The whole Array)
Refer to the entire array (all elements are displayed):
[TagName]
All array elements are displayed in a comma-separated list.
[TagName[-1]]
All array elements are displayed in a comma-separated list.
Array Tags(The Element inside an Array)
[TagName.Index]
[MyARRAY.5] displays the sixth element of MyARRAY.
[TagName[TagIndex]]
[MyARRAY[TagIndex]] displays the sixth element of MyARRAY when TagIndex is 5.
Screen-1
This is the Barcode Reader operation screen.
BarCode Input Field
This is a Field that displays the result of reading from the BarCode Reader.
Data Link
DataLink is set to the string Tag defined earlier.
Keypad
The barcode reader used in this article was set to operate in keyboard emulation mode, so all you need to do is connect it to the HMI and you are ready to go.
Then, a numeric field set as R/W is placed in the page, and if the field is pressed, the value can be entered using the touch screen keyboard, or a bar code reader can be used.
Also, since it is no-nonsense to have the Keypad appear every time the Barcode Reader is run, if it is set to Wheel, the Keypad will not appear.
Write Mode
Write Mode can be set to On change or On Enter.In other words, the Bar Code is read, and only when the result changes, it is written to the Bar code Tag.
Next, set up two actions in the OnDataUpdate Event field.
Action1:JSAction
Sets the JSAction behavior.In other words, the Javascript named numeric1_onDataUpdate runs every time a Data Update is performed.
Action2:StepTag
Next, add the SetpTag action.Each time this action is triggered, Tag2 will be +1.
Barcode Read Check Counter
This is the Counter of the number of Bar Code reads.
Connect to Tag2 with DataLink Field.
Trigger BarCode Read Button
Now add a button to trigger the reading operation of the BarCode Reader.
Events>OnMouseClick adds an action when the button is clicked.
Add BeginDataEntry Action and set Page1:numeric1 in >Widge.
Page1:numeric1 is the “Input Trigger” of the Barcode Field.Originally, the Operator clicks on numeric1>Keypad is displayed>Data input, but this is changed to click on the button>numeric1 is ready to accept data input>Bar Code Reader receives the data.
Screen Change Button
This is the button for Screen switching.
BarCode Read status
This is a LAMP and numeric display that confirms the Read status of the Barcode.
If Tag3_AlarmTrig is True, Bar Code reading is successful.
This is only a lamp display.
Scripts
The last one is Javascript for Screen-1, which automatically resets when Tag3_AlarmTrig is turned on for more than 2 seconds.
var myCounter=0; var myTimer=page.setInterval(“f_reflesh()”,1000); function f_reflesh(){ var almTrigger=project.getTag(“Tag3_AlarmTrig”); if (almTrigger){ var coderesult=project.getTag(“barcode”) myCounter=myCounter+1; if (myCounter >=2){ myCounter=0; project.setTag(“Tag3_AlarmTrig”,false) } } return false; } function numeric1_onDataUpdate(me, eventInfo) { project.setTag(“Tag3_AlarmTrig”,true) return false; } |
Screen-2
Next is the alarm history display screen.
Alarm history table
Let’s add the Alarm history table from Object.
Set the Event Buffer to “Alarm Buffer1” (i.e., the alarm table you just added).
Export Data to SD Card
The last step is to create a button to Export Alarm History Table data to SD Card.
Add an OnMouseClick>DumpEventArchive() action to Events.
Set the Directory, time settings, etc. you want to export in the Folder Path to match your application.
Result
You can check the operation from this video.