Archive for the ‘pcbs’ Category

KiCad OS X nightly development builds are back

Wednesday, February 9th, 2011

After about eight months of not running I have fixed my nightly builds of KiCad for OS X. I have finally found the time to switch my KiCad repository over to the Bazaar and launchpad system that the KiCad developers have been using for some time now.

After a few changes here and there and updating wxWidgets to 2.9.1 I have the nightly build system back up and running. The build script I am using is given at the end of this post in Listing 4.

The KiCad compiling instructions for OS X have been updated and now work a lot better. You should be able to find the latest version over at launchpad here.

In case anyone else runs into similar problems I have repeated some of the errors and my hacks/work-arounds solutions below.

The nightly builds themselves are here as usual.

Getting it to compile again.

After following the compilation instructions referred to above, I ran into the following error. After a bit of web crawling and reading development lists I found that I needed to use the XML library built into wxWidgets rather than the system one.

The error looked like this:

Linking CXX executable eeschema.app/Contents/MacOS/eeschema
Undefined symbols:
“_XML_GetErrorCode”, referenced from:
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
“_XML_ErrorString”, referenced from:
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
“_XML_SetUnknownEncodingHandler”, referenced from:
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
“_XML_SetCharacterDataHandler”, referenced from:
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
“_XML_SetUserData”, referenced from:
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
“_XML_ParserFree”, referenced from:
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
“_XML_SetCdataSectionHandler”, referenced from:
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
“_XML_SetCommentHandler”, referenced from:
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
“_XML_Parse”, referenced from:
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
“_XML_SetElementHandler”, referenced from:
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
“_XML_ParserCreate”, referenced from:
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
“_XML_GetCurrentLineNumber”, referenced from:
_StartCdataHnd in libwx_osx_cocoau-2.9.a(monolib_xml.o)
_CommentHnd in libwx_osx_cocoau-2.9.a(monolib_xml.o)
_TextHnd in libwx_osx_cocoau-2.9.a(monolib_xml.o)
_StartElementHnd in libwx_osx_cocoau-2.9.a(monolib_xml.o)
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
“_XML_SetDefaultHandler”, referenced from:
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[2]: *** [eeschema/eeschema.app/Contents/MacOS/eeschema] Error 1
make[1]: *** [eeschema/CMakeFiles/eeschema.dir/all] Error 2
make: *** [all] Error 2

Error 1: Missing XML library

This was fixed by adding the --with-expat=builtin option when configuring wxWidgets.

This then lead me to another error to do with wxWidgets headers using anonymous enums and anonymous types. Part of this second error is shown below.

/opt/wxwidgets-svn/include/wx-2.9/wx/combo.h: In member function ‘bool wxComboPopup::IsCreated() const’:
/opt/wxwidgets-svn/include/wx-2.9/wx/combo.h:774: error: ‘‘ is/uses anonymous type
/opt/wxwidgets-svn/include/wx-2.9/wx/combo.h:774: error: trying to instantiate ‘template struct boost::polygon::is_polygon_90_set_type’
/opt/wxwidgets-svn/include/wx-2.9/wx/combo.h:774: error: ‘‘ is/uses anonymous type
/opt/wxwidgets-svn/include/wx-2.9/wx/combo.h:774: error: trying to instantiate ‘template struct boost::polygon::is_polygon_45_or_90_set_type’
/opt/wxwidgets-svn/include/wx-2.9/wx/combo.h:774: error: ‘‘ is/uses anonymous type
/opt/wxwidgets-svn/include/wx-2.9/wx/combo.h:774: error: trying to instantiate ‘template struct boost::polygon::is_any_polygon_set_type’
make[2]: *** [gerbview/CMakeFiles/gerbview.dir/class_gerber_draw_item.cpp.o] Error 1
make[1]: *** [gerbview/CMakeFiles/gerbview.dir/all] Error 2
make: *** [all] Error 2

Error 2: Anonymous enums using anonymous types being marked as errors by the compiler

Rather than figure out which flag to set on the cmake/compiler/linker mess, I went for a brute-force approach that I found here after a small amount of searching. I have expanded from the script given to the ones below to account for the particular style used in the wxWidgets header files.

for i in `grep -l ‘enum {‘ *.h | sed -e ‘s/\.h//g’` ; \
do \
perl -pi -e \
“s/enum {/’enum en_$i’ . int(rand(100)) .’ {‘/eg” $i.h; \
done

Listing 1: Small script to replace all occurances of “enum {” with “enum en_filenameXX {“

Listing 1 is the original script given which enumerates the anonymous enums with a name consisting of the filename (without the extension) and a random number from 0-99.

This next command I adapted from the first to account for the fact that the style of the wxWidgets header files meant that a lot of the enums were declared with the keyword enum alone on a line with the rest of the declaration on the following line. This finds those declarations and assigns them a name similar to the first script but with a number from 100-199 to ensure we don’t repeat names already given. It is shown below in Listing 2.

for i in `grep -l ‘^enum en_.*$’ *.h | sed -e ‘s/\.h//g’` ;\
do \
perl -pi -e \
“s/^enum$/’enum en_$i’ . int(rand(100)+100) .”/eg” $i.h;\
done

Listing 2: Small script to replace all occurrences of “enum” with “enum en_filename1XX ” where “enum” occurs by itself on a line and assuming the rest of the declaration continues on the following line.

The problem with the previous two scripts is that they use a random number to assign the unique identifier. Being random there is the possibility that this number can come up twice.
This last command (Listing 3) helps us check for duplicate names generated by the previous scripts. We then need to go in and fix the duplicates by hand.

grep ‘enum en’ *.h | sort | uniq -c | sort -n

Listing 3: Command to check for duplicate names created by previous two scripts.

A single script could be written to give unique identifiers to all the anonymous enums and ensure that the identifiers are unique. But as this was a quick enough process and solved my problems I haven’t bothered to refine it further. Perhaps next time I update wxWidgets I’ll give it another thought. I thought this was a useful enough hack to share.

Automating the builds

Listing 4 below shows my daily build script which automatically updates the code to the latest development snapshot via Bazaar. Next it will check if the version has changed and if so build and package the latest version. If this all goes well we compress the new version into an archive and upload it to the website. If the compilation does not complete according to plan then the error log and some other useful information is uploaded to the website instead. Note that all usernames and passwords have been changed to placeholders in this version. This is run every day (or night depending on your time zone) by a cron job.

#!/bin/sh
#
. /Users/nick/.bashrc

#Make a nightly build of KiCad

#update from launchpad using bazaar
cd /Temp/kicad.bzr/kicad/
bzr update

new_version=`bzr revno`
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=”/opt/wxwidgets-svn/include/wx-2.9/” -DCMAKE_INSTALL_PREFIX=”/temp/install” -DCMAKE_OSX_ARCHITECTURES=”ppc -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk/ -mmacosx-version-min=10.5″ -DCMAKE_CXX_FLAGS=”-D__ASSERTMACROS__” -DCMAKE_OSX_SYSROOT=”/Developer/SDKs/MacOSX10.5.sdk”

# 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://user: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://user:password@ftp.brokentoaster.com/

else

#insert some useful debug info
echo “*** GCC Version Info ***”>> /temp/kicad_errors-${new_version}.txt
gcc -v >> /temp/kicad_errors-${new_version}.txt

echo “*** wxWdgets Version Info ***”>> /temp/kicad_errors-${new_version}.txt
wx-config –list >> /temp/kicad_errors-${new_version}.txt
head /Volumes/Store/wxWidgets-2.9.1/osxbuild/config.log >> /temp/kicad_errors-${new_version}.txt

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

# go to sleep
if [ ! -e /Users/nick/Applications/insomnia.flag.true ]
then
open /Users/nick/Applications/SleepNow.app
fi
else
echo “KiCad is up to date : ) ”
fi

Listing 4: BASH script to update, build and upload KiCad. This is run daily via a cron job

So if you want to test the latest developer build of KiCad on OS X then look no further than here.

Arduino MP3 Shield Rev B (correct files this time)

Monday, June 14th, 2010

I have to apologise to everyone who downloaded the Revision B Arduino MP3 Shield PCBs when I posted them here and here.

I accidently uploaded and emailed everyone the wrong files, not only were they not revision B they weren’t even revision A. This was totally my fault as I grabbed the files from the wrong directory when uploading. I was sure I had checked they were correct but obviously I hadn’t.

I’ve included some pictures of what the layout is supposed to look like for Rev B so you can check the gerbers and EAGLE files are correct before getting any made. ( Look for the large ‘B’ on the top copper layer.)




Figure 1 : Arduino MP3 Shield Rev B PCB - Top view




Figure 2 : Arduino MP3 Shield Rev B PCB - Bottom view

I have since fixed the links and are now hosting the correct files. Here are the links again:

EAGLE files are here

GERBER files are here

Arduino Library files are here

PDF of the schematic is here

Once again sorry to everyone who got the wrong files.

Creative Commons License
Arduino MP3 Shield by Nick Lott is licensed under a Creative Commons Attribution-Share Alike 2.0 UK: England & Wales License.
Based on a work at www.brokentoaster.com.

MAX6675 Thermocouple breakout board (TC-6675)

Monday, May 31st, 2010

In order to improve and verify the performance of my Reprap Mendel extruder I decided to build a system based on a K-Type thermocouple. I ordered some samples of a MAX6675 from Maxim Integrated Products. I decided to use this chip over the Analog Devices AD595 out of curiosity as it was new to me and due to the 12-bit digital output. Although plenty of breakout boards already exist for this product I decided to design my own based around this PCB-mount thermocouple connector. I like the idea of being able to simply unplug a thermocouple and quickly plug another one in so the use of a standard miniature socket sounds like a pretty good idea to me. It makes switching between probes a breeze and allows me to use cheap thermocouple probes from Maplin

I haven’t tested this board yet so I’ll have to update the post later after I’ve had a chance to play with some ferric chloride.

Having stood back from the design for about 3 seconds it occurs to me that I should probably combine this with my ATTINY45 USB Key project to make a standalone Thermocouple to USB converter, but who has the time 🙂 .

All files are Creative Commons Attribution-Share Alike 2.0
TC-6675, Schematic (PDF)
Eagle Library (MAX6675ISA+ and RS#3817564)
TC-6675 Schematic (EAGLE)
TC-6675 PCB layout (EAGLE)

Arduino MP3 Rev B v0.0

Monday, February 15th, 2010

Last week I managed to have some luck with my Arduino MP3 shield. The big hold up was caused by not having enough power from the FT232RL chip to supply the decoder and the memory card at the same time (50mA max d-oh). I also had a software issue, I had not altered the code to deal with the 16Mhz clock speed of the arduino from the 8Mhz I was using on the ButterflyMP3 project. The SPI clock was running at 8Mhz where it needed to be slower than 6MHz (to comply with the VS1011E datasheet). Once I had that sorted everything just popped into place and started working reliably.

I apologise in advance for the poor integration of the library examples. I have simply and quite roughly ported the minimal parts of my buterflymp3 project over to the arduino and this hardware. The examples will test reading FAT16 file system on the MMC/SD card, test the VS1011E decoder chip, and play the first mp3 file found on the memory card. I hope to get these tidied up later but have not had any time to do so lately.

The PCB has not actually been tested yet so I’d hold off building a million of these until after a successful test. There is unlikely to be much wrong with it though as I have simply added a voltage regulator and re routed a couple of signals to fix my earlier mistakes. ( I’d forgotten that I/O lines 0 and 1 are used by the uart on the arduino)

I have embedded the BOM below. ( The bom is here if you don’t see it below)

Here are all the files so far. These are all released under a Creative Commons 2.5 license .

EAGLE files are here

GERBER files are here

Arduino Library files are here

PDF of the schematic is here

To use the library simply put the “mp3” folder from the zip file inside the “libraries” folder in your arduino folder (create one if it doesn’t exist). Restart Arduino 018 or later and you should have “mp3” entries in the menus under examples and import libraries.

The BOM references a 2.8V LDO voltage regulator but the schematic shows a 3.3V. Either will work fine but the 2.8 will give you slightly lower power usage.

If you are interested in PCBs or kits, drop me a line at buy_pcbs@brokentoaster.com
As always any comments, suggestions or ideas are welcome.