New PCBs in from BatchPCB


My order of PCBs from BatchPCB arrived the week before Christmas so plenty of soldering and things to keep me busy over the holiday. I’ve also been distracted of late with building a reprap, although I’ve not got much further than amassing a number of PCBs, components and motors, watch this space for details as the build progresses.

My Batch PCB contained a new version of the Arduino MP3 board with provision for running from the 5V Duemilanove Arduino and a number of MLMC boards so I can string them together for testing. Unfortunately the ArduinoMP3 PCB had a couple of design errors, which is typical when your working on a design off and on over a course of months. The design will probably be released soon, but the libraries and demo code are also proving slightly more difficult.

Some changes to Hardware.
The basic design of the board is the same, VS1011 and SD card shared on the SPI bus with a 5 way Joystick on some digital lines.

I forgot about the TX/RX lines being shared with digital 0 and 1 on the arduino so I’ve had to re-route signals using those pins to the previously unused analog/general IO pins.

A couple of changes related to running the circuits on a 5V / 3V3 system. My Butterfly MP3 system that I based this on was powered from a single supply rail of 2.8V. The FTDI USB chip on the arduino was originally used to provide a 3V3 supply to the shield. I thought the 50 mA stated in the data sheet would be enough as my butterfly mp3 system only used about 50mA including processor and display. Unfortunately the is a large current draw when an SD Card is inserted causing the FTDI chip to reset and breaking connection with the PC. Although not a big problem I decided to add an LP2981 LDO regulator to supply a 100mA for the card and MP3 player circuits. If you don’t want to use this then you can not fit the parts and easily bypass with a jumper wire.

C++ing the libraries
I was hoping to use the existing libraries for the Arduino and SD cards to access the MMC/SD Cards and provide demo code to show using the shield. For an as yet unknown reason the existing libraries from Adafruit wave shield do not work. In order to test my hardware I have converted my MMC and FAT libraries from the ButterflyMP3 project to C++ for use with the Arduino system. I few teething problems and issues as I remember how C++ works and I now have a working SD Card system. Output from my current software is shown below

I’d like to use the already available libraries as they offer FAT32 and extended features over my bare bones implementation – so not quite ready to publish any finished code just yet.

Next step is adding the support for the VS1011. Again not quite as smooth as I’d hopped but moving along with the help of the old intronix logic port. Currently the VS1011 is not setting up correctly. Occasionally it plays OK but mostly nothing or a very slow version of a song, indicating to me the clock registers are not being set correctly.

I think another weekend or so of work and I’ll be there but if you’d like a copy of the current PCBs or Arduino files then just drop me an email or leave a comment.

Current Demo Software Terminal Output

TEST
0
MMC_RESET returned 0
MMC_SEND_STATUS returned 0
MMC_SEND_CID returned 0
0: FE 02 54 4D 53 44 30 31 47 28 9A CF 7B 33 00 7A ..TMSD01G(...3.z
1: 83 08 8E FF FF FF FF FF FF FF FF FF FF FF FF FF ................
MMC_SEND_CSD returned 0
0: FE 00 2D 00 32 5B 59 83 D6 7E FB FF 80 16 40 00 ..-.2[Y.......@.
1: FB 5E C9 FF FF FF FF FF FF FF FF FF FF FF FF FF .^..............
MMC_Capacity returned 1037952
MMC_Name returned 0 SD01G(
MMC_Read returned 0
MMC First Sector:
0: FA 33 C0 8E D0 BC 00 7C 8B F4 50 07 50 1F FB FC .3........P.P...
1: BF 00 06 B9 00 01 F2 A5 EA 1D 06 00 00 BE BE 07 ................
2: B3 04 80 3C 80 74 0E 80 3C 00 75 1C 83 C6 10 FE ...<.t..<.u.....
3: CB 75 EF CD 18 8B 14 8B 4C 02 8B EE 83 C6 10 FE .u......L.......
4: CB 74 1A 80 3C 00 74 F4 BE 8B 06 AC 3C 00 74 0B .t..<.t.....<.t.
5: 56 BB 07 00 B4 0E CD 10 5E EB F0 EB FE BF 05 00 V.......^.......
6: BB 00 7C B8 01 02 57 CD 13 5F 73 0C 33 C0 CD 13 ......W.._s.3...
7: 4F 75 ED BE A3 06 EB D3 BE C2 06 BF FE 7D 81 3D Ou.............=
8: 55 AA 75 C7 8B F5 EA 00 7C 00 00 49 6E 76 61 6C U.u........Inval
9: 69 64 20 70 61 72 74 69 74 69 6F 6E 20 74 61 62 id partition tab
A: 6C 65 00 45 72 72 6F 72 20 6C 6F 61 64 69 6E 67 le.Error loading
B: 20 6F 70 65 72 61 74 69 6E 67 20 73 79 73 74 65  operating syste
C: 6D 00 4D 69 73 73 69 6E 67 20 6F 70 65 72 61 74 m.Missing operat
D: 69 6E 67 20 73 79 73 74 65 6D 00 00 00 00 00 00 ing system......
E: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
F: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
11: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
12: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
13: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
14: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
15: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
16: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
17: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
18: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
19: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
1A: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
1B: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 ................
1C: 37 00 06 03 C3 E6 F3 00 00 00 0D B3 1E 00 00 00 7...............
1D: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
1E: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
1F: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA ..............U.
0
SECTORS PER CLUSTOR 20
BYTES PERSECTOR 0200
FAT Init returned:0
SECTORS PER CLUSTOR 20
BYTES PERSECTOR 0200
FAT boot Sector info
FAT begins at sector 244
Clusters begin at sector 768
Sectors per cluster = 32
Root dir starts at sector 736
THESTR~1.MP3 00045 037A00 2E0F
THESTR~2.MP3 00124 03400 2E1A
THESTR~3.MP3 001F5 025C00 2E24
THESTR~4.MP3 0028C 030400 2E2E
TWINSE~1.MP3 0034D 051B249 2E39
THEWHI~1.MP3 00494 03867AF 2E45
THESTR~5.MP3 0057B 02FE00 2E51
THESTR~6.MP3 0063B 032B00 2E5C
THESTR~7.MP3 0079 034D00 2E68
BEASTI~1.MP3 007DD 02EC9A4 2E74
BEASTI~2.MP3 00899 02E93C3 2E80
BEASTI~3.MP3 00954 01F172F 2E8B
THESTR~8.MP3 009D1 03A300 2E95
THESTR~9.MP3 00ABA 02DC00 2E9F
THEST~10.MP3 00B71 02F00 2EA9
THEST~11.MP3 00C2D 026900 2EB4
05-ILE~1.MP3 00CC8 02E8C16 2EBD
BEASTI~4.MP3 00D83 03EF2C9 2EC8
Files: 18
1A
DONE

STL to IGS (IGES) Conversion

I’ve been trying to get my models from Sketchup into a decent file format for use with different analysis engines and for producing drawings for machining.

After a week of playing about with different options I have managed to get from Sketchup files to IGES files.
I used BRL-CAD to convert from .stl to its native format and then exported as an .igs from there.
Below is a copy of the script i used to convert a whole directory of files.


#!/bin/bash
# Convert an STL file to IGES format using BRL CAD

for file in *.stl
do
# Add the -b option or binary format stl files (aoi,solid edge etc)
# stl-g -b ${file} ${file}.g

# Use ascii format for exports from sketchup
stl-g ${file} ${file}.g
done

for file in *.g
do
mkdir ${file}.d
g-iges -m -o ${file}.d ${file} all
cp ${file}.d/*.igs ${file}.igs
rm -rf ${file}.d
done

I did run into an issue or two along the way. When initially export as iges with the command g-iges -o file.igs file.g all the file produced caused every program I tried to load it with to crash with the exception of BRL-CAD which loaded it just fine. I found that when I used the -m option and export all regions to a directory of iges files the files worked. The STL files produced by the STL output plug-in for sketchup produces STL files in the ASCII format some programs may produce files in binary format, in which case you will need to add the -b option to the stl-g command. I had to use this when converting the STL files from the reprap project to iges files.

Why IGES files? Because I couldnt get STEP files. While STL files are widely supported they are mesh files that describe surfaces only. Most professional mechanical CAD packages use constructive solid geometry (CSG) techniques and don’t like mesh files so much. That’s not to say I couldn’t load STL files into these packages but the loaded part was less useful when imported from STL as compared to IGES. An IGES file allows me to measure and convert to a solid object or more easily produce drawings for a machinist to work with.

Complete 3D Model of Butterfly MP3



I hope to use this data to do some stress analysis of the case design using CAE Linux and look at geting the case built using SLA or SLS techniques.

The Sketchup model is at http://www.brokentoaster.com/butterflymp3/photos/ButterflyMP3_and_Cases.skp

3D Model AVR Butterfly

I’ve been playing with Google SketchUp for a while as a free tool for doing electronics enclosure design (ie. MP3 Player cases). It seems quite capable although not really targeted at designs in the mm range. I think I will use a larger scale like 10:1 or 100:1 next time to see if that makes things easier.

Here is my first attempt at an AVR Butterfly model for use in case designs on the data logger and MP3 player. You can download in skp and stl format. To export SketchUp files as STL I have used the plugin from http://www.guitar-list.com/download-software/convert-sketchup-skp-files-dxf-or-stl

Stereo Lithography (STL)
SketchUp (SKP)
Image (PNG)

Battery Capacity Logger MkII

A minor update to my battery logger script to tidy up the format of the log file and to make a slightly nicer (maintainable) script file.

#!/bin/sh
# batterylogger.sh : Log the battery capacity to a file
#
filename=/var/log/batterycapacity.log
date=`date`
capacity=`system_profiler SPPowerDataType |grep "charge capacity"`
count=`system_profiler SPPowerDataType |grep "Cycle count"`
echo ${date} ${capacity} ${count} >> ${filename}

This gives a log file output like the following

Sat 14 Nov 2009 13:45:06 GMT Full charge capacity (mAh): 4740 Cycle count: 163

To create the log file in a sensible place like /var/log/ I did the following:

sudo touch /var/log/batterycapacity.log
sudo chmod 666 /var/log/batterycapacity.log

I’ve also switched to using periodic instead of cron as I can’t seem to get cron to work reliably. To make it work with periodic I simply place my batterylogger.sh script in the directory /etc/periodic/daily/

NOTE: I’ve had a couple of issues lately with pasting from the web into a script file and finding i get the following error:
No such file or directory´╗┐#!/bin/sh

I’ve found that this problem is due to binary characters in my text file. I think they are UTF-8 encoded characters that have slipped in from cutting and pasting. To solve this problem I use the command vim -b script. This will load up the file in binary mode so I can see what funny characters have found their way into my file. After deleting the offending character or characters the script functions as expected.

Battery Capacity Logger

I just replaced the battery in the 2005 ibook G4 today, great to return to the days of 4 hours of use. I decided I’d like to monitor the life of the battery and so wrote a quick cron job script to log the battery capacity every day. I also have installed this on my main laptop which still gives me 3 hours after 18 months of use.

Write the script.
#!/bin/sh
# batterylogger.sh : Log battery capacity to a file
#
date >> ~/batteryCapacityLog.log
system_profiler SPPowerDataType | grep “charge capacity” >> ~/batteryCapacityLog.log

Make it executable and put somewhere sensible.
chmod 755 batterylogger.sh
cp batterylogger.sh /usr/local/bin/
Make sure it is activated daily by adding the following line in crontab using crontab -e which will make it run at 5:10am every day. This time is chosen to not clash with other actions executing should my laptop be awake at 5am and also to ensure it run each morning when I wake the laptop up.

10 5 * * * /usr/local/bin/batterylogger.sh

The format looks like the following:
Wed Nov 11 20:03:26 GMT 2009
Full charge capacity (mAh): 4859
I may improve the format in the future and add some nice “gnuplot” plots but this gives me the info I want right now. For the record, the outgoing battery was showing a capacity of around 350mAh. This translates to roughly 10-15 mins of use. OS X 10.5.8

The MLMC website is up.

I’ve just put a new website up for the MLMC project. No new information over what has been mentioned in the previous blog post, but it is a start. With the initial page up I hope it will encourage me to publish information sooner rather than later. Of course I still need to find time to do some actual work on the project. Next week perhaps…. You can find the site at http://brokentoaster.com/mlmc/

Modular LED Matrix Controller (MLMC)


What is it?
The MLMC is a smart daisy chain-able LED matrix module.
I call it smart because a display of these can be extended without changing either the firmware on the module controller or the firmware on the display controller. Each individual module will take care of refreshing its display. When new data is sent old data is passed along the chain to the next module. This makes building an arbitrary length scrolling display very simple to implement.

The LED matrix is on a separate PCB so it is simple to adapt to other LED matrices without chaining the controller PCB/firmware. This means that if you were producing a number of different sized displays you could use the same controller PCB. For example for one made from a 16 by 16 LED matrices or a large one made from custom PCBs using 16 by 16 individual 10mm LEDs.
Why?
I liked all of the many LED matrix projects seen on the web and in Circuit Cellar magazine. To enlarge or adapt these displays would mean a redesign of firmware and hardware.

I had a small number of dense 16 by 16 matrices sitting about from my times bargain hunting in Akihabara. These are unused by any of the projects I have seen on the web and in magazines. These matrices have a strange footprint, the pin layout is a cross formation rather than two parallel rows of pins which is more commonly seen). This means work is needed to adapt existing projects to work.

If I built a system purely around the LED matrices I have then very few people could use the resulting design. I would also not be able to reuse the design once my limited supply of these matrices was consumed. By separating out the control hardware from the display hardware I am able to make a much more flexible and enduring design.

I’ve always been a fan of the 2 Line LCD displays which are common in many projects. These have a standard well known interface so it is trivial to add one to a project. I want to bring that ease of implementation to scrolling LED matrix displays as I have many projects that could all benefit from a large display.
What has been done so far?
A prototype 2 Layer PCB has been manufactured by Batch PCB.
Some basic screen display firmware has been written.
A system tested with 1 Bit per pixel, 16 bit columns of the display are clocked in and displayed while last word in buffer is clocked out.
Preliminary PWM brightness control has been tested but not on a pixel per pixel basis.
What needs to be done?

Hardware
  • Move resistors ( LED module pcb)
  • Add decoupling caps (control module pcb)
  • Add local voltage regs (control module pcb)
  • Build more modules for testing of chaining
  • Build different LED Modules
Firmware
  • Extend from on/off pixels to brightness value
  • ISR response needs improving
Software Library/Examples
  • Arduino software is only a basic testing routine.

What will be done?
To call this project finished these are the things I hope to have done.
  • Release all firmware under a Creative commons License.
  • Release all pcb files under a Creative commons License.
  • Release protocols /data sheets under a Creative commons License.
  • Release an Arduino library to talk to a string of these under a Creative commons License.
How Long will it take?
It will probably never be completed. So I hope to publish unfinished work when it is suitably unfinished whenever I remember.

USB Scroll Wheel

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

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.