Barcode (QR) reader – part 1

Here's another one of my little weekend projects (in this case, more than one weekend). It is a barcode (and QR) reader that plugs into the PC's USB port and is seen by the system as an HID device, specifically a keyboard. Thanks to this feature, it can be connected to any computer / tablet and can be used from any application (spreadsheet, for example). I tested on WinXP, Win7, Win10 (Windows) and Ubuntu, Debian (Linux) and also on an Android tablet equipped with an OTG cable and the result has always been the same: it works and does not need drivers. Just to understand what it is, let's take a look at the circuit mounted on prototype boards. This is the top view:

and this one from the bottom (flat cable wires, separated, are best for these jobs)

If someone is already leaving this project because they think it is a bit complicated to build a prototype like this, I invite them to be patient... I have found on-line circuits that are compatible with this application and the next step will be to adapt the firmware to these cheap ones widely used modules, avoiding if possible the use of the soldering iron. Here is also the current schematic:

For the more readable version in pdf, load the EF209sch.pdf from the “files” section.

The circuit is based on the ATmega88 microcontroller. It could also be made with other models of the same family, but having only this one in my small mobile laboratory, the choice was forced. To develop the firmware I used a VM with WinXP (which I normally use for the many projects with 8-bit microcontrollers) and on this I installed WinAvr, which is a package containing the C compiler and several other useful tools. WinAvr doesn't have its own IDE, as you can control anything from the command line and use notepad++ (included in the package) for editing source files, but I'm accustomed to using an IDE so I downloaded and installed AvrStudio , the official tool of Atmel (now Microchip). My favourite version for WinXP is the 4.19 which is the last before implementations that unfortunately require you to upgrade (and make slower) the OS in order to work.

At this point, with the software tools available, I went to see an old site, which I have known for years, where there is a library capable of creating a USB device at low speed, using only an interrupt on the micro and a little firmware. This library has changed its name many times and has been continually improved and refined and is used in many devices related to Atmel AVRs, including the famous USBASP programmers. The link to the main page is this: https://www.obdev.at/products/vusb/index.html

I use DuckDuckGo for my internet searches; if you enter the keywords: avr virtual usb, you will be directed there. You will also find several sample projects, supplied with source code and in many cases also with schematics and PCB drawing. A nice site, very well documented.

I went through the list of various projects and eventually downloaded two. By mixing them and making some changes, I finally got what I wanted. Here are the links to the respective pages:

a) 1-Key_keyboard by Flip van der Berg http://blog.flipwork.nl/?x=entry:entry081009-142605

b) Terminal Keyboard by Neil Stockbridge http: // hobby-electrons. sourceforge.net/projects/terminal-keyboard/

Since the controllers used in both projects were different from mine, I changed the names of some registers (serial port) and then successfully compiled. The AvrStudio IDE also has a part on the right where a list of the internal registers and the individual bits within these registers is available, so it is quite easy to rename those that unfortunately change their name from one model to another, even if a lot similar. In addition to mixing the two programs mentioned and modifying the registers, I also made a small addition: the Terminal Keyboard program (also another by the same author) has a simple entry method, i.e. you send the byte...

Read more »