Sunday, July 6, 2014

ELF Tag Documentation

Purpose
The "Electronic Lost & Found" Tag or ELF Tag is the result of my desire to design and build a small electronic device that I could make and share with friends and colleagues.  Beginning with the small, inexpensive devices such as Adafruit's Trinket or DigiStump's DigiSpark, I started with the idea that I would give everyone a microcontroller.  Why a microcontroller?  Because they are cool and are good tools for technical people to learn about physical computing.

After several iterations, I hit upon a design that was useful and also simple enough for me to make a dozen or so copies of.

Usage
It is a small device with a built-in USB male plug that can emulate an HID keyboard device.  When it is plugged into a Windows computer's USB port, it will automatically type out information that was pre-programmed into the device.  The example I chose to use was an electronic lost and found tag that could type out information about the owner and how to return the lost items.

It can also be programmed to do other things, but for a gift, the lost and found tag functionality was fine.

Design
The device is based upon the Atmel Attiny85 microcontroller and uses a very simple circuit to help the microcontroller acts as a low-speed USB device.  This USB interface is used both for the programming of the device and in the lost and found program itself.

Only 6 components total.
The rest of the job of emulating a USB device is done by the Micronucleus firmware.  This wonderful piece of software takes care of programming the device as well as running the user's program.  The software also makes the device roughly compatible with the DigiSpark, which means we can use their version of the Arduino IDE to program the device.

Hardware
The device is built upon a double-sided PCB that was designed and laid out with the KiCAD electronics design software.




The PCB was pre-cut to make the front and back alignment easier to manage.  The only critical alignment are the vias that connect the on-board USB pads from one side, to the main set of traces on the other.  All the other pads on the top side of the copper are unconnected.

The toner-transfer method was used.

After the board is etched, the shape of the USB connector is cut and cleaned up with a Dremel and a normal cutoff wheel.  The holes are then drilled and the parts are then soldered in place.  All totaled, it takes about two-hours per board to build.

Software
The Attiny85 chip must first be loaded with the Micronucleus bootloader and the fuses set before it can be programmed with the DigiSpark software.  This was accomplished using a full Arduino device acting as an ISP programmer.  Using the ArduinoISP sketch and circuit, the Attiny85 is first loaded with the micronucleus firmware.  For example:

avrdude -C"C:\Program Files (x86)\Arduino\hardware/tools/avr/etc/avrdude.conf" -v -pattiny85 -cstk500v1 -P\\.\COM4 -b19200 -U flash:w:C:\temp\micronucleus-1.11.hex:i

Then the fuses are set...

avrdude -C"C:\Program Files (x86)\Arduino\hardware/tools/avr/etc/avrdude.conf" -v -pattiny85 -cstk500v1 -P\\.\COM4 -b19200 -U lfuse:w:0xf1:m -U hfuse:w:0xdf:m -U efuse:w:0xfe:m

Note that in the case of the ELF Tags, I do not disable the RESET pin.

Once the bootloader is loaded and the fuses are set, the chip is ready to be installed on the ELF Tag.  From that point, it can be programmed using the DigiSpark version of the Arduino IDE.

The final step in the software setup is the installation of the customized LostAndFound.ino sketch that is compiled and loaded by the Arduino software.

The most recent version of this sketch can be found here...


Once this sketch is loaded, the device is ready to go.

No comments:

Post a Comment