Visar inlägg med etikett AVR. Visa alla inlägg
Visar inlägg med etikett AVR. Visa alla inlägg

måndag 3 oktober 2011

Mamepanel with Linux

The Mamepanel is great when building an usb arcade controller. It's a customizable (at build time) joystick/keyboard/volume control in one AVR uC. One drawback is that my two joystick setup wasn't recognized as two 8 button joysticks but rather as one joystick with 18 buttons. This is a known problem with using AVRUSB with a Linux-machine.
The only solution i found to the problem was to recompile the Linux usbhid module and mark the Mamepanel as quirky.
This is how I did it on Debian Lenny:
as root:
Get the source
aptitude update
aptitude install linux-source
tar jxvf /usr/src/linux-source-2.6.26.tar.bz2 linux-source-2.6.26/drivers/hid
cd linux-source-2.6.26/drivers/hid
Add these lines where they fit in /usr/src/linux-source-2.6.26/drivers/hid/usbhid/hid-quirks.c. The USB_DEVICE_ID_WIKIDOT_MAMEPANEL32 device id should probably be changed to something else if an ATMEGA8 is used (can be checked with lsusb).
#define USB_VENDOR_ID_VOTI           0x16c0
#define USB_DEVICE_ID_VOTI_MAMEPANEL32       0x05df
{ USB_VENDOR_ID_VOTI, USB_DEVICE_ID_VOTI_MAMEPANEL32, HID_QUIRK_MULTI_INPUT },
Build and load the new module (It's probably a good idea to check that usbhid.ko exists before rmmodding the old one)
make -C /usr/src/linux-headers-$(uname -r) M=$(pwd) modules
cd usbhid/
rmmod usbhid && insmod usbhid.ko
hope for the best.

söndag 20 september 2009

DIY nop binary wristwatch

For some time i've wanted a binary wrist watch and a couple of days ago when I felt for doing a small project that could be realised fairly quickly i finally came to it.

Here's a list of some basic hardware "features" i strived for:
  • Fit inside a wrist watch
  • Use as few parts as possible
  • Surface mount components where possible
  • Only minute and hour representation is necessary
  • Driven by button cells for "long time" ie months without replacing
  • Leds to represent time
  • 24 hour format
  • As single sided pcb layout as possible since hand connecting vias is a drag

Now, why reinvent the wheel so I fired up my favourite search engine but I couldn't find anything to satisfy my needs. Most of the binary watches were based on the megax8 (which in my taste is way too big and has too many features for a project like this). Finally I chose a between a tiny24 and a tiny25 and the went with the tiny24, mainly because I would have to use all the pins of the tiny25 and therefore making programming of the device problematic. An advantage of using the tiny24 is that it's 16-bit counter's got power consumption characteristics in par with both the tiny25's and the megax8 8-bit counters. This results in that we don't have to wake the CPU as often and thus save power. The datasheets are very scarse on details regarding current consumption when a 32.768kHz crystal is used so this is just an assumption made by looking at frequency=0.1MHz in the Idle Supply Current vs. Low Frequency (0.1-1.0MHz) table. Current consumption values of the timers are found in table Additional Current Consumption (percentage) in Active and Idle mode.


The circuit 

The MCU is a Tiny24 (14 pin).
The leds are charlieplexed.
Q1 is a 32,768kHz crystal
The pushbutton is connected to INT0.

The software
To conserve power the microcontroller is put to sleep as soon as it doesn't do anything useful (TIMER1 has to be active so we use "idle mode").
The timekeeping part of the software is based on using TIMER1 to trigger an interrupt every minute which wakes the CPU and updates the time.
When the button is pressed an INT0 interrupt wakes the CPU and the time is displayed.
binwatch.c
binwatch.h
display2.S
Makefile

The PCB
It's a double sided pcb with microcontroller and leds on the top layer and battery and crystal on the bottom layer.
The battery holder is a low profile battery holder for cr2032 batteries.
The button is smd and placed on the right side of the following pictures.
The PCB is 3 cm in diameter.

 top
 

 bottom






The watch
The donor watch was an old broken lcd watch. I removed the button used to set time and replaced it with a small screw with conical head and it all fit quite nicely.
The leds looks much stronger "irl".




Thoughts
Time representation could be changed from 00:00-23:59 to 00:01-24:00, to avoid wondering about whether watch is broken or just displaying 00:00