Intermediate
30 min

Capture, track, and manage information with ease using LV3296 and ATmega1284

Streamline inventory management with precision

Barcode Click with EasyAVR v7

Published Oct 02, 2023

Click board™

Barcode Click

Dev.Board

EasyAVR v7

Compiler

NECTO Studio

MCU

ATmega1284

The purpose of this scanner is to enhance retail efficiency by quickly and accurately capturing product information

A

A

Hardware Overview

How does it work?

Barcode Click is based on the LV3296 from Rakinda. This is the advanced barcode scanner/reader module which features the patented UIMG®, a computerized image recognition system technology that supports all mainstream 1D and standard 2D barcode types (for example - PDF417, QR Code M1/M2/Micro and Data Matrix) as well as GS1-DataBar™(RSS) (Limited/Stacked/Expanded versions). It can read barcodes on virtually any medium, including paper, plastic, mobile phones, LCD displays, etc. Thanks to the used area-imaging and UIMG® technologies, the device is able to scan barcodes rotated to any angle, with great speed and precision. The LV3296 scanner module uses a flat cable to connect to the click board™, via the ZIF FPC connector on the back side of the PCB. This flat cable carries all the signals used in communication between the LV3296 module and the host MCU, such as the RX, TX, buzzer, USB, interrupt, reset, and scanning trigger lines. The communication with Barcode click is done by utilizing two types of connection it offers - UART (TTL232) and USB. When the click board™ is placed into the mikroBUS™ socket, it will be able to exchange data with the UART module of the

MCU, via the standard mikroBUS™ RX and TX pins. When the USB cable is connected to the micro USB port on the click board itself, it can be identified either as the virtual USB port, a HID keyboard device or an HID POS device. HID devices do not require any special PC drivers, while the virtual USB device does. Many options and parameters of the Barcode click are configurable. Barcode click configuration is very easy and intuitive - it is enough to read special configuration messages, encoded into barcodes that can be found in the LV3296 user's guide. It is not even necessary to print them on paper - it is enough to show them on screen and scan them from there. Enter Setup message should be scanned first, followed by the desired configuration message. After successful configuration indicated by a short beep sound, the Exit Setup message should be scanned. The device features a very extensive set of encoded configuration commands, which include storing and recal of user default values, along with the factory defaults. When the Barcode device is first powered up, it will sound a greeting message, which indicates the successful initialization. The device is now ready to scan. Pressing the onboard TRIG button or pulling the

PWM pin of the  mikroBUS™ slot to a LOW logic level for at least 10ms, will trigger the barcode scan. It will turn on two LEDs and project a circle shaped aiming pattern on the surface it is aimed at, scanning it for a valid barcode. Both LEDs and the aiming pattern can be turned off in the configuration. A short beep sound and a blink of the Good Read indication onboard LED (GR) will indicate a successful barcode decoding and after releasing the TRIG line (configurable), the device will send the decoded information to the selected interface. Barcode click can report errors, with a distinctive error message sound - e.g. when the device is configured to use onboard micro USB, but it is not connected to the host USB device, it will sound an error if scanning is attempted. The RST button is used to reset the device. Pressing the RST button or pulling the RST line, routed to the mikroBUS™ RST pin to a LOW logic level for 100us to 500us will cause a device reset, followed by the greeting message sound. It should be noted that the device should not be reset too frequently; at least 2 seconds delay should exist between the reset cycles.

Barcode Click hardware overview image

Features overview

Development board

EasyAVR v7 is the seventh generation of AVR development boards specially designed for the needs of rapid development of embedded applications. It supports a wide range of 16-bit AVR microcontrollers from Microchip and has a broad set of unique functions, such as a powerful onboard mikroProg programmer and In-Circuit debugger over USB. The development board is well organized and designed so that the end-user has all the necessary elements in one place, such as switches, buttons, indicators, connectors, and others. With four different connectors for each port, EasyAVR v7 allows you to connect accessory boards, sensors, and custom electronics more

efficiently than ever. Each part of the EasyAVR v7 development board contains the components necessary for the most efficient operation of the same board. An integrated mikroProg, a fast USB 2.0 programmer with mikroICD hardware In-Circuit Debugger, offers many valuable programming/debugging options and seamless integration with the Mikroe software environment. Besides it also includes a clean and regulated power supply block for the development board. It can use a wide range of external power sources, including an external 12V power supply, 7-12V AC or 9-15V DC via DC connector/screw terminals, and a power source via the USB Type-B (USB-B)

connector. Communication options such as USB-UART and RS-232 are also included, alongside the well-established mikroBUS™ standard, three display options (7-segment, graphical, and character-based LCD), and several different DIP sockets which cover a wide range of 16-bit AVR MCUs. EasyAVR v7 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

EasyAVR v7 horizontal image

Microcontroller Overview

MCU Card / MCU

ATmega1284

Architecture

AVR

MCU Memory (KB)

128

Silicon Vendor

Microchip

Pin count

40

RAM (Bytes)

16384

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
Reset
PA6
RST
NC
NC
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Scanning Trigger
PD4
PWM
NC
NC
INT
UART TX
PD1
TX
UART RX
PD0
RX
NC
NC
SCL
NC
NC
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Schematic

Barcode Click Schematic schematic

Step by step

Project assembly

EasyAVR v7 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the EasyAVR v7 as your development board.

EasyAVR v7 front image hardware assembly
Buck 22 Click front image hardware assembly
MCU DIP 40 hardware assembly
EasyAVR v7 MB 1 - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
NECTO Compiler Selection Step Image hardware assembly
NECTO Output Selection Step Image hardware assembly
Necto image step 6 hardware assembly
Necto DIP image step 7 hardware assembly
EasyPIC PRO v7a Display Selection Necto Step hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Necto PreFlash Image hardware assembly

Track your results in real time

Application Output

After pressing the "FLASH" button on the left-side panel, it is necessary to open the UART terminal to display the achieved results. By clicking on the Tools icon in the right-hand panel, multiple different functions are displayed, among which is the UART Terminal. Click on the offered "UART Terminal" icon.

UART Application Output Step 1

Once the UART terminal is opened, the window takes on a new form. At the top of the tab are two buttons, one for adjusting the parameters of the UART terminal and the other for connecting the UART terminal. The tab's lower part is reserved for displaying the achieved results. Before connecting, the terminal has a Disconnected status, indicating that the terminal is not yet active. Before connecting, it is necessary to check the set parameters of the UART terminal. Click on the "OPTIONS" button.

UART Application Output Step 2

In the newly opened UART Terminal Options field, we check if the terminal settings are correct, such as the set port and the Baud rate of UART communication. If the data is not displayed properly, it is possible that the Baud rate value is not set correctly and needs to be adjusted to 115200. If all the parameters are set correctly, click on "CONFIGURE".

UART Application Output Step 3

The next step is to click on the "CONNECT" button, after which the terminal status changes from Disconnected to Connected in green, and the data is displayed in the Received data field.

UART Application Output Step 4

Software Support

Library Description

This library contains API for Barcode Click driver.

Key functions:

  • barcode_enable_scaning - Set PWM pin state

  • barcode_generic_read - Generic read function.

Open Source

Code example

This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.

/*!
 * \file 
 * \brief Barcode Click example
 * 
 * # Description
 * This example reads and processes data from Barcode clicks.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initializes driver.
 * 
 * ## Application Task  
 * Reads the received data.
 * 
 * ## Additional Function
 * - barcode_process( ) - The general process of collecting presponce 
 *                                   that sends a module.
 * 
 * \author Nemanja Medakovic
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "barcode.h"
#include "string.h"

#define PROCESS_COUNTER 2000
#define PROCESS_RX_BUFFER_SIZE 300

// ------------------------------------------------------------------ VARIABLES

static barcode_t barcode;
static log_t logger;

// ------------------------------------------------------- ADDITIONAL FUNCTIONS

static void barcode_process ( void )
{
    uint16_t rsp_size;
    uint16_t rsp_cnt = 0;

    char uart_rx_buffer[ PROCESS_RX_BUFFER_SIZE ] = { 0 };
    uint16_t check_buf_cnt;
    uint16_t process_cnt = PROCESS_COUNTER;

    while( process_cnt > 0 )
    {
        rsp_size = barcode_generic_read( &barcode, &uart_rx_buffer, PROCESS_RX_BUFFER_SIZE );

        if ( rsp_size > 0 )
        {  
            // Validation of the received data
            for ( check_buf_cnt = 0; check_buf_cnt < rsp_size; check_buf_cnt++ )
            {
                if ( uart_rx_buffer[ check_buf_cnt ] == 0 ) 
                {
                    uart_rx_buffer[ check_buf_cnt ] = 13;
                }
            }

            log_printf( &logger, "%s", uart_rx_buffer );

            // Clear RX buffer
            memset( uart_rx_buffer, 0, PROCESS_RX_BUFFER_SIZE );
        } 
        else 
        {
            process_cnt--;

            // Process delay 
            Delay_ms( 1 );
        }
    }
}

// ------------------------------------------------------ APPLICATION FUNCTIONS

void application_init ( void )
{
    log_cfg_t log_cfg;
    barcode_cfg_t cfg;

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, "--->  BarCode Click Init  <---" );

    //  Click initialization.

    barcode_cfg_setup( &cfg );
    BARCODE_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    barcode_init( &barcode, &cfg );

    Delay_ms( 500 );
}

void application_task ( void )
{
    barcode_enable_scaning( &barcode, BARCODE_LOGIC_ON );
    barcode_process( );
    barcode_enable_scaning( &barcode, BARCODE_LOGIC_OFF );
    Delay_ms( 2000 );
}

void main ( void )
{
    application_init( );

    for ( ; ; )
    {
        application_task( );
    }
}

// ------------------------------------------------------------------------ END

Additional Support

Resources