Archive for the ‘Uncategorized’ Category

USB Scroll Wheel

Wednesday, August 5th, 2009

I have been having a play with a rotary encoder this week and decided to turn it into a USB scroll wheel. I was using a very nice encoder but any standard potentiometer without the stop or a cheaper encoder would also work.

The whole experience turned out be much easier than I originally thought. To get a standalone USB device up and running took very little effort at all.

HARDWARE
I took one of my ATtiny45 USB-Key PCBs and hacked on a voltage divider (two 330k resistors) and some wires to my encoder (+5v, GND, Signal). The purpose of the voltage divider is to keep the sensor output (or ADC input) below the 2.56 vRef being used on the chip and also below the 3.6V being used as Vcc on the PCB.

No pictures or videos yet as it is just a ball of wires.

FIRMWARE
The firmware is based on the Easy logger project from Objective Development. I changed the USB HID report descriptor to reflect a mouse rather than a keyboard. I then added a bit of code to analyse the ADC reading and calculate the rotational velocity of the wheel.
The device is only active once you push the button. This is to stop everything going crazy when I plug in a half finished device during development. The device can be switched off again by another press of the button for the same reason.
I got pretty bored reading all the USB HID documentation so rather than figuring it all out properly, I just snooped in on my normal mouse, read the HID report descriptor and adapted the relevant parts used for it’s scroll wheel. The software I used to snoop was “USB Prober” which is in my Utilities folder (Mac OS X 10.5). This might be a standard issue tool or I may have installed it as part of the developer tools. A screen-shot of grabbing this information is shown here. I don’t know where or how to find out this info on windows but I’d look at Jan Axelson’s site here as a good place to start.
PROBLEMS / STATUS
Even though I’ve altered USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH in the code it doesn’t seemed to have effected the report descriptor on the computer. More than likely I’ve missed something somewhere but that is what you get for a quick hack.

The source code to main.c is at http://brokentoaster.com/usb-dial/main.c.html . I also made a couple of minor changes to the usbconfig.h file which is at http://brokentoaster.com/usb-dial/usbconfig.h.html.

It doesn’t work that well but it does work. Most importantly it proves to me that I can now take any sensor I like and turn it into a computer interface device of some description… perhaps even do something usefull … one day … maybe. If I ever get some presentable hardware together I’ll update with a picture or two.

Quickcoms 2 : Pocket Term

Saturday, July 11th, 2009

I started this project in 2006 while I was living in Japan with an idea to enter it in the 2006 AVR competition. Some things went astray with the hardware design so I dumped it in order to do five other more viable entries. The concept for the project was to take my Quickcoms Renasas design from 2005 and develop it further from the prototype. I mostly wanted to add keyboard support so it could act as stand alone terminal in addition to just decoding serial data. I also wanted it to be the size of a deck of cards and support a LiION battery. I wanted to enlarge the LCD to get closer to 80×40 chars on screen. Include support for a couple of LCDs on the PCBs to allow for a black and white low power version.

What went wrong ( other than trying to put the moon on a stick) ?

  • I made an assumption about the keyboard from the AVR application note that I would not have to send any data to the keyboard. Most AT keyboards will work without you sending any data back towards them so long as you don’t wish to change the status LEDs. I bought a neat little keyboard to go with project from one of the many electronics dens around Akihabara. I wanted something small and light to throw in a toolkit without taking up all the room. Unfortunately this keyboard used an obscure chipset which follows an old protocol which purposely sends a malformed packet and waits for you to send an error response. With no scope or Logic analyser at the time this was a pretty big nail in this projects coffin. Although it only required a couple of small changes to the PCB and some voltage dropping resistors to configure the ATMega16 to transmit I managed to procrastinate this for two years.
  • I managed to blow up the back-lighting on the LCD display. Took me a while to get around to ordering a replacement.
  • I didn’t provide a decent positive and negative supply rail for the op amps. I tried to rely on the comms transceiver chip to provide this. Unfortunately it was supplying 1 quad opamp and several multiplexes it and seemed to fall over completely. In my prototype I simply used a MAX232ACP with onboard capacitors to provide my circuits with the rails. I had assumed the new transceiver chip would be able to do the same.

Where is it at now?

Well after sorting out the keyboard issue and replacing the LCD I have a small screen that will echo characters from the PS2 keyboard and from PC via a USB serial port. What needs to happen next is sorting out a positive and negative voltage rail to support the multiplexers and opamps. Once that is done I can start porting the code from the original system over to the AVR.

After that is complete I can add the extra features such as logging to the screen, save and replay sessions, and saved macros.

And then What?

After that there is the case (already partially designed) and publishing documentation of the project for the website.

MP3 Rev F GERBER Files now available

Tuesday, June 30th, 2009

Just a quick note to say that The GERBER files are now available on server. I have also tidyed up the CVS for PCB files and moved the old Protel files. I’ve also update the release names for the hardware to match the PCB Revisions.

This should make it easier for those of you out their that just want to build the standard design without custom modifications.
The downloads can be found at https://sourceforge.net/projects/butterflymp3/files/

ATTiny45 USB Key

Monday, June 22nd, 2009


USB Key.
These are simply ATTiny45 based USB devices based on the V-USB circuits and drivers developed at Ob-Dev. I haven’t decided what to do with these yet but the many ideas include a prank keyboard dongles like the capslocker or a keyboard to continually hit F1 or Delete to ensure the bios comes up.

My original idea was to have it generate and remember random passwords so you don’t need to type in your 63 char password for the wireless router every time someone comes to visit , simply plug in the dongle and it will type it for you. There are other non keyboard ideas as well such as a simple data logger that converts voltage, temperature, (insert random digital sensor here) to a comport that responds to commands or simply pushes data at a specified rate.

I see Sparkfun have done a nice version of this PCB with some similar ideas. Theres is called AVR Stick

MP3 Shield for Arduino

Monday, June 22nd, 2009


MP3 Shield for Ardiuno. Still needs a couple of fixes to the PCB ( I forgot that the arduino was running at 5V not 3V). Might add some voltage dropping resistors as the cheap solution (£0.10) or add an 74HC245 to do it properly so it can run with 3V arduino boards without mods (£0.34). I think I will go for resistors as this makes assembly easier and to mod for 3v operation just means removing a couple. No firmware as of yet so my next job(after fixing the hardware ) will be porting the vs1001 libs from the butterflymp3 project over to arduino. Haven’t decided weather to use my own MMC and FAT routines or just grab the ones from adafruit’s wave shield . The board has a 3.5mm headphone socket, SD/MMC slot, VS1011 decoder and a 5 way joystick. Perfect for mucking about with MP3s and Arduino.

Whats on my bench at the moment….

Saturday, June 20th, 2009

Its been rather quiet (blogwise) for me lately, so I thought I’d update with what I’ve been working on lately. The following is a rough outline of the stuff I’ve been working on and probably why I feel like I never get anything done.

  • General purpose usb key for experimenting with USB drivers firmware and the rest.
  • MP3 shield for Arduino. Basically an Arduino version of the ButterflyMP3 project.
  • Daisy chained LED matrix controller. A flexible and extendable display made up of modules that can make any length display you want without changing the firmware.
  • Quickcoms 2: Pocket Term. A follow up to my Circuit Cellar article and competition project. Current quickcoms info is here.
  • ButterflyMP3 VS1053 hardware revision.This newer chip decodes :

    Ogg Vorbis; MPEG 1 & 2 audio layer III (CBR +VBR +ABR); layers I & II optional; MPEG4 / 2 AAC-LC(+PNS), HE-AAC v2 (Level 3) (SBR + PS); WMA 4.0/4.1/7/8/9 all profiles (5-384 kbps); WAV (PCM + IMA ADPCM); General MIDI 1 / SP-MIDI format 0 files

  • ButterflyMP3 firmware updates

    • Add a simple LED based display. One LED lights up to indicate the track playing. Currently limited to 21 LEDs.
    • A simple Matrix keypad for music store “listening post” style operation. multiplexed on LED lines. Currently limited to 21 buttons. One button will trigger a track to be played.
    • Scrolling LED Matrix support. This is for my LED matrix project above if I ever finish it.

  • Butterfly Logger firmware updates

    • support GPS logging
    • support wireless sensors

  • The Glitch. A small device that goes inline with low voltage DC wall wart and switches it off and then on again once a day. (I bought a cheap router that needs a hard reset every so often.)

Plus some white LED based low power kitchen lighting, playing around with 3D scanning and of course the online shop which I have been doing absolutly nothing on for the past couple of months.

Kicad OSX nightlies fixed again.

Friday, May 29th, 2009

Got my kicad builds sorted again. finally got the make command right to work with the boost library. I’ve updated to the latest (1.39) and everything seems to be going well.

My nightly make script now looks like this….

#update from svn
cd /temp/kicad-sources
svn up
new_version=`svn info | grep Revision | cut -f 2 -d\ `
old_version=`cat /temp/install/version.txt`
if [ $new_version -gt $old_version ]
then

#build it
cd build/release
cmake ../../ -DwxWidgets_CONFIG_EXECUTABLE=”/usr/local/bin/wx-config” -DwxWidgets_ROOT_DIR=”/usr/local/include/wx-2.8″ -DCMAKE_INSTALL_PREFIX=/temp/install -DBoost_INCLUDE_DIR=/temp/kicad-sources -DCMAKE_OSX_ARCHITECTURES=”ppc -arch i386″ -DCMAKE_CXX_FLAGS=”-D__ASSERTMACROS__”

# make clean
if make > /temp/kicad_errors-${new_version}.txt 2>> /temp/kicad_errors-${new_version}.txt && make install
then
file=kicad_osx_v${new_version}
echo $new_version > /temp/install/version.txt
mv /temp/kicad_errors-${new_version}.txt /temp/install/build_log.txt

#bundle
cd /temp/
cp -rf install ${file}
tar -czf ${file}.tgz ${file}

#upload
curl -T ${file}.tgz ftp://username:password@ftp.brokentoaster.com/
rm -rf ${file}

# cd /temp/kicad-sources/build/release/
# /Developer/usr/bin/packagemaker –doc osx-package.pmdoc –title ‘Kicad’ -o ${file}.mpkg
# curl -T ${file}.mpkg ftp://username:password@ftp.brokentoaster.com/

else
curl -T /temp/kicad_errors-${new_version}.txt ftp://username:password@ftp.brokentoaster.com/
fi

# go to sleep
open /Users/nick/Applications/SleepNow
else
echo “Kicad is uptodate 🙂 “
fi

/dev/cu vs /dev/tty ( osx serial ports)

Friday, March 13th, 2009

A while ago someone told me to use /dev/cu.usbserial rather than /dev/tty.usbserial as the former did not require hardware handshaking. I was looking for this justification again as my memory had gone a little hazey on the exact reason for using cu over tty. I found the following at http://lists.berlios.de/pipermail/gpsd-dev/2005-April/001288.html. Thought it a good thing to know and thought I’d remember it here for next time.

“The idea is to supplement software in sharing a line between incoming and outgoing calls. The callin device (typically /dev/tty*) is used for incoming traffic. Any process trying to open it blocks within the open() call as long as DCD is not asserted by hardware (i.e. as long as the modem doesn’t have a carrier). During this, the callout device (typically /dev/cu* — cu stands for “calling unit”) can be freely used. Opening /dev/cu* doesn’t require DCD to be asserted and
succeeds immediately. Once succeeded, the blocked open() on the callin device will be suspended, and cannot even complete when DCD is raised, until the cu device is closed again.

That way, you can have a getty listening on /dev/tty*, and can still use /dev/cu* without restrictions.”

So this is what I use when programming with AVRDude as the butterfly doesn’t have any DCD/DTR lines to assert. Its just TX, RX, and GND. If you have problems on the mac using a tty serial port you should try its cu equivalent.

GEDA portfiles

Monday, March 9th, 2009

Now I’ve got kicad building again ( although rather bloated at 20Mb ) I thought I’d have a play with some other items on my todo list. I’ve manage to get most of the GEDA suite working on the mac and have created portfiles for mac ports to be able to install them. I haven’t got gwave to work yet due to some dependances and some of the installs needed to be forced to overwrite some other files but in general they seem to work. I hope to add kicad as a port file in the near future but I will see if I can get these programs to work first.

In doing this I noticed a few messages regarding others trying to get port files up for gEDA on the mac so I assume they will make it into the main ports tree at some time in the near future.

To use my files you can browse them at http://www.brokentoaster.com/macports/ or download them all at http://www.brokentoaster.com/macports/ports.zip.

First you will need to extract the files into a local directory such as /users/me/ports. Then you will need to add /users/me/ports to the /opt/local/etc/macports/sources.conf file. The last action is to run the command portindex from your newly created ports directory to ensure the index is up to date.

If these are of any use to you then enjoy. Good luck.

Kicad OSX nightlies fixed

Wednesday, February 25th, 2009

I finally decided to investigate why kicad had stopped building back in Decemember. I had initially thought it was to do with large changes to the source being done at that time or with my trying to get a newer build of wxMac to work with it properly.
I turns out I updated the Boost library and that was what was causing my builds to fail.

Somewhere on the mac a “check” macro gets defined. Apparently this is if “DEBUG” is defined somewhere but I could not figure out where or why this was going on (see this post. I decided to simply modify the boost files concerned to work aroaund this problem. By renaming the “check” function and its called I was able to get kicad compiling again. Sadly it does not fix the serious flaws in wxmacs graphics implimentation ie. the fact that it does not do XOR draws properly.Anyway here are the diffs I made

fixing kicad again for th mac
/temp/kicad-sources/boost/ptr_container/detail/static_move_ptr.hpp:
line 155: check renamed to check_

4 changes in /temp/kicad-sources/boost/detail/is_incrementable.hppcheck “check(” replaced with “check_(“

boost/ptr_container/detail/static_move_ptr.hpp

% diff /temp/boost_1_37_0/boost/ptr_container/detail/static_move_ptr.hpp
/temp/kicad-sources/boost/ptr_container/detail/static_move_ptr.hpp


154c155
< void check(const static_move_ptr& ptr)
---
> void check_(const static_move_ptr& ptr)

boost/detail/is_incrementable.hpp

% diff /temp/boost_1_37_0/boost/detail/is_incrementable.hpp
/temp/kicad-sources/boost/detail/is_incrementable.hpp


68c68
< char (& check(tag) )[2];
---
> char (& check_(tag) )[2];
71c71
< char check(T const&);
---
> char check_(T const&);
81c81
< , value = sizeof(is_incrementable_::check(BOOST_comma(++x,0))) == 1
---
> , value = sizeof(is_incrementable_::check_(BOOST_comma(++x,0))) == 1
92c92
< , value = sizeof(is_incrementable_::check(BOOST_comma(x++,0))) == 1
---
> , value = sizeof(is_incrementable_::check_(BOOST_comma(x++,0))) == 1

The error I was getting was the following

In file included from /temp/kicad-sources/boost_1_38_0/boost/ptr_container/detail/reversible_ptr_container.hpp:22In file included from /temp/kicad-sources/boost_1_38_0/boost/ptr_container/detail/reversible_ptr_container.hpp:22,
from /temp/kicad-sources/boost_1_38_0/boost/ptr_container/ptr_sequence_adapter.hpp:20,
from /temp/kicad-sources/boost_1_38_0/boost/ptr_container/ptr_vector.hpp:20,
from /temp/kicad-sources/kicad/include/board_item_struct.h:9,
from /temp/kicad-sources/kicad/include/pcbstruct.h:10,
from /temp/kicad-sources/kicad/3d-viewer/3d_viewer.h:29,
from /temp/kicad-sources/kicad/3d-viewer/3d_aux.cpp:23:
/temp/kicad-sources/boost_1_38_0/boost/ptr_container/detail/static_move_ptr.hpp:154:50: error: macro "check" passed 2 arguments, but takes just 1

I have now updated my automagic build script to upload the error log if It doesn’t compile.

All of my builds are still found at http://www.brokentoaster.com/kicad/ and should be universal apps. If anyone has had any success with wxCocoa or other builds I’d be happy to add them to my build list.