Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important information on the platform change.

Barcode Scanner.jpg

Barcode scanner with Node-RED/PLC via ctrlX CORE using USB port

RomyX
Member
Introduction

This How-To explains how to read a 2D barcode with a scanner. The scanner is connected to the ctrlX CORE via the USB-C port. The data can be read in with the PLC or Node-RED application.

Prerequisites
  • ctrlX CORE
  • 2D Barcode Scanner (this examples uses the Voyager XP 1470g) with USB to USB-C adapter
  • Pre-installed PLC or Node-RED app
Scanner Configuration

To begin, the ctrlX CORE must be connected to the computer and the scanner to the ctrlX CORE. The scanner is then programmed using a reference code.
The basic configuration described in this point is the same for the Node-RED as well as for the PLC App.

RomyX_0-1688469000599.jpeg

 

  1. Connect the ctrlX CORE to the computer via the engineering port and open ctrlX WORKS (Quick Start Guide ctrlX CORE).
  2. Connect the Voyager XP 1470g 2D scanner to the USB-C interface of the ctrlX CORE.
  3. To reset the scanner to the factory settings, scan the Activate Custom Defaults barcode below.

    RomyX_0-1687955563424.png

     

  4. Scan the following code to programme the scanner. Scanning this code also adds carriage return and line feed.

    Barcode Reference.jpg

    Note: Depending on the country, port or characters being scanned, a different reference code must be used. Different reference codes are listed in the Voyager User Guide.

Example Barcode

To test the examples below, a test barcode is created with the content "Hello World".

Hello World Bar Code.JPG

Different barcodes can be created with this online configurator.

A) Realisation with Node-RED

With Node-RED, the scanner configuration can be realised graphically in a browser by inserting nodes.

  1. Open the Node-RED App using the ctrlX Works interface.

    Open Node-RED Flow Editor.JPG

  2. In the Node-RED dashboard, the nodes that can be added are visible on the left-hand side.
    For the realisation of the project we need to add a "serial in" and a "debug" node. Then the nodes are connected to each other.

    Insert Nodes.JPG

  3. Then double-click on the "serial in" node and rename it to "Scanner".
    Then define the serial port.

    Edit serial in Node.JPG

  4.  Change the port as follows and accept it:
    RomyX_0-1688483932431.png

  5. Check if the "Scanner Node" is connected (when the green light is on). Then execute the Node-RED Flow by pressing the "Deploy" button. From now on, the scanner is online and you can scan.
    Deploy Node-RED.JPG

  6.  Now it is possible to read the barcode using the barcode scanner. To do this, we read in the example barcode "Hello World" from the chapter "Scanner Configuration". It can be seen that the interpretation of the barcode is now displayed in Node-RED:


    Output_Node-RED.JPG

B) Realisation with PLC
  1. Open the PLC App using the ctrlX Works interface.

    Open PLC App.JPG

  2. When the PLC programme has opened, create a new project. Make sure that the PLC app is connected to the ctrlX CORE.

    New PLC Project.JPG

  3. Download the PRG_Barcode_Scanner.xml file attached to this How-To.

  4. Import the file PRG_Barcode_Scanner.xml into the PLC App.

    Import xml File.JPG

  5. Drag the program "PRG_Barcode_Scanner (PRG)" from "Application" into the "Task Configuration" of the PLC App.

    Task Configuration.jpg

  6. Add the "SysCom" library. To do this, double-click on "Library Manager", then click on "Add Library" and use the search function to find and add the "SysCom" library.

    Add Syscom Library.JPG

  7. Repeat the process and add the library "CmpSettings".

    Add CmpSettings Library.JPG

  8. Generate the code of the programme. Check that there are no error messages. Otherwise, correct the error messages.

    Generate Code.JPG

  9. Press the "Login" button.

    LogIn PLC.JPG

  10. After logging in, check that the "iState" in the programme corresponds to "0". Then press the "Start" button.

    Run, iState equals 0.JPG

    Note: Playing "Case 0" opens/configures the port.

  11. Then save the project and restart the ctrlX CORE (to complete the configuration of the port)

  12. When the restart has been completed, open the PLC project via the ctrlX WORKS interface (make sure that the PLC project is connected to the ctrlX CORE).

  13. Log in to PLC App again (as in step 9)

  14. In the PRG_Barcode_Scanner programme, change the "iState" from 0 to 1. To do this, double-click on the red box next to "iState". Then a new window opens and replace the 0 with a 1. Then accept this with "OK".

    iState equals 1.JPG

  15. Press the key combination "Ctrl" + "F7" to write the values online.

    iState.JPG

  16.  Press the "Start" button to run the program.

  17. Now it is possible to read the barcode using the barcode scanner. To do this, we read in the example barcode "Hello World" from the chapter "Scanner Configuration".
    It can be seen that it displays the barcode in the PLC as decimal - ASCII:

Decimal ASCII.JPG

Hint: If the scanner is reconfigured, the ctrlX CORE must be restarted.

Notes
  • Depending on the supplier integration, the device port can differ between "/dev/ttyACM" and "/dev/ttyUSB0". This needs to be checked for each device.
  • To check at which port address the device is connected use the ctrlX OS web UI: Logbook -> Enable System Messages -> search for "tty"

 

Must Read
Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist