Monday, December 6, 2010

Xilinx Coolrunner II & Xubuntu

After a few days wait the Xilinx Coolrunner II kit arrived in the post.

The Coolrunner is a CPLD which contains Macrocells, which are a step up from the basic gate array of a PLD and the XC2C256 on this board has 256 macrocells configured via an interconnect matrix.

Xilinx provide a programming suite, ISE, which is available for Windows and Linux. However they don't directly support Ubuntu. 

Here is a brief howto to get the ISE running on  Xubuntu.

The main hurdle with the ISE is that it requires a USB driver,  windrvr6, in order to use the Platform cable (DLC9G). However it is possible to configure Xubuntu to use libusb and to get the programming tool, iMPACT, to use this instead.

1.Install prerequisites..

apt-get fxload
apt-get libusb

2. Configure the udev rules

These load the correct hex file when the device is attached.

jamesb@Jalapeno:~$ cat /etc/udev/rules.d/xusbdfwu.rules
# version 0003
SYSFS{idVendor}=="03fd", SYSFS{idProduct}=="0008", MODE="666"
BUS=="usb", ACTION=="add", SYSFS{idVendor}=="03fd", SYSFS{idProduct}=="0007", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusbdfwu.hex -D $tempnode"
BUS=="usb", ACTION=="add", SYSFS{idVendor}=="03fd", SYSFS{idProduct}=="0009", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_xup.hex -D $tempnode"
BUS=="usb", ACTION=="add", SYSFS{idVendor}=="03fd", SYSFS{idProduct}=="000d", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_emb.hex -D $tempnode"
BUS=="usb", ACTION=="add", SYSFS{idVendor}=="03fd", SYSFS{idProduct}=="000f", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_xlp.hex -D $tempnode"
BUS=="usb", ACTION=="add", SYSFS{idVendor}=="03fd", SYSFS{idProduct}=="0013", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_xp2.hex -D $tempnode"
BUS=="usb", ACTION=="add", SYSFS{idVendor}=="03fd", SYSFS{idProduct}=="0015", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_xse.hex -D $tempnode"

3. Install the hex files.

These can be found in the ${XILINX}/ISE/bin/lin directory.

jamesb@Jalapeno:~$ ls -al /usr/share/*.hex
lrwxrwxrwx 1 root root 48 2010-12-05 21:32 /usr/share/xusbdfwu.hex -> /opt/Xilinx/12.3/ISE_DS/ISE/bin/lin/xusbdfwu.hex
lrwxrwxrwx 1 root root 48 2010-12-05 21:32 /usr/share/xusb_emb.hex -> /opt/Xilinx/12.3/ISE_DS/ISE/bin/lin/xusb_emb.hex
lrwxrwxrwx 1 root root 48 2010-12-05 21:32 /usr/share/xusb_xlp.hex -> /opt/Xilinx/12.3/ISE_DS/ISE/bin/lin/xusb_xlp.hex
lrwxrwxrwx 1 root root 48 2010-12-05 21:32 /usr/share/xusb_xp2.hex -> /opt/Xilinx/12.3/ISE_DS/ISE/bin/lin/xusb_xp2.hex
lrwxrwxrwx 1 root root 48 2010-12-05 21:32 /usr/share/xusb_xpr.hex -> /opt/Xilinx/12.3/ISE_DS/ISE/bin/lin/xusb_xpr.hex
lrwxrwxrwx 1 root root 48 2010-12-05 21:32 /usr/share/xusb_xse.hex -> /opt/Xilinx/12.3/ISE_DS/ISE/bin/lin/xusb_xse.hex
lrwxrwxrwx 1 root root 48 2010-12-05 21:32 /usr/share/xusb_xup.hex -> /opt/Xilinx/12.3/ISE_DS/ISE/bin/lin/xusb_xup.hex

You can use ln -s to create the symlinks..

4. Setup some scripts to start up ISE and IMPACT

 jamesb@Jalapeno:~/bin$ cat ise

source /opt/Xilinx/12.3/ISE_DS/
XIL_IMPACT_USE_LIBUSB=1 /opt/Xilinx/12.3/ISE_DS/ISE/bin/lin/ise &


source /opt/Xilinx/12.3/ISE_DS/
XIL_IMPACT_USE_LIBUSB=1 /opt/Xilinx/12.3/ISE_DS/ISE/bin/lin/impact &

So, assuming that worked, plug in the platform cable and you should get an orange light.. you're good to go!

I suppose I'd better go off and write some code now.. byee..

My environment :-

Xubuntu  10.10
Linux Jalapeno 2.6.35-23-generic #41-Ubuntu SMP Wed Nov 24 10:18:49 UTC 2010 i686 GNU/Linux
Xilinx_ISE_DS_Lin_12.3_M.70d.1.0 in /opt/Xilinx/12.3/ISE_DS/
Platform Cable DLC9G

Linky :-

YMMV etc.

Wednesday, December 1, 2010

Audio board for the Camera A2D project

Started working on the audio board prototype for the Camera A2D project. 
It's based around a pair of NE5532 op amps. The input stage converts the balanced line input from the microphone, and the second stage acts as a preamp with level control to supply the correct levels to the nNovia.
Should be on to some audio tests shortly so time to dig the signal generator and scope out.

Tuesday, November 30, 2010

Discrete Fourier Transform in Ruby

...Just for a laugh...

I'm reading this amazing book at the moment, and thought it would be fun to code some stuff in Ruby.

The code...


require 'complex'

class DFT
        def initialize( size )
                @freq = size, Complex(0,0) )

        # set data
        def data( data )
                @data = data

        # get frequency table
        def freq

        # reset the frequency table
        def reset
      ! do |d|
                        Complex( 0,0 )

        # transform data and return the frequency table
        def transform
                raise "No input data" unless @data
                (0..@freq.size-1).each do |k|
                        @data.each_with_index do |d,i|
                                @freq[k] = Complex(
                                        @freq[k].real + d * Math.cos( 2 * Math::PI * k * i / @data.size ),
                                        @freq[k].imag - d * Math.sin( 2 * Math::PI * k * i / @data.size )
                return @freq

And a test...


require 'dft.rb'
require 'test/unit'

class TestDFT < Test::Unit::TestCase
        def setup
                # Compose a data set containing two frequencies, f1 & f2
                # Assume the data set contains 1 second worth of samples so
                # f1 & f2 are in Hz and should be less than half the number of samples (Nyquist)
                @data =
                f1 =10
                f2 =25
                amplitude = 1
      ! do |d|
                        Math.sin( 2 * Math::PI * f1 * i / @data.size ) + Math.sin( 2 * Math::PI * f2 * i / @data.size )

        def test_dft_throws_exception_with_no_input
                dft = 32 )
                assert_raise RuntimeError do
                        freq = dft.transform

        def test_dft_has_correct_output_size
                dft = 32 )
       @data )
                freq = dft.transform
                assert_equal( 32, freq.size )
                assert_equal( 32, dft.freq.size )

        def test_dft_has_correct_output
                dft = 32 )
       @data )

                assert > 1
                assert > 1

        def test_display
                dft = 32 )
       @data )
                puts "\nFrequencies found:\n"
                dft.freq.each_with_index do |f,i|
                        if (f.abs > 1)
                                printf( "%d %.30f   %.30f  %.30f\n", i, f.real, f.imag, f.abs )

Wednesday, November 17, 2010

Unit testing in TCL

The unit...


proc fib {n} {
        if {$n==1}  {return $n}
        if {$n==2}  {return [expr {$n-1}]}
        if {$n==3}  {return [expr {$n-1}]}
        return [expr { [fib [expr {$n - 1}]] + [fib [expr {$n - 2}]] } ]

The test...


package require tcltest 2.0
namespace import ::tcltest::*
source ../src/fib.tcl

# 1 1 2 3 5 8 13 21 34

test fib-1 { Test first is 1 } {
        fib 1
} 1

test fib-2 { Test second is 1 } {
        fib 2
} 1

test fib-3 { Test third is 2 } {
        fib 3
} 2

test fib-4 { Test fourth is 3 } {
        fib 4
} 3

test fib-5 { Test fifth is 5 } {
        fib 5
} 5

test fib-6 { Test ninth is 34 } {
        fib 9
} 34

test fib-7 { Test fortieth is 102334155 } {
        fib 40
} 102334155 

I put in the last couple of tests for good luck and for #ian :-)

Oh I must have been bored....


Tuesday, November 16, 2010

The Six Characteristics of Shorinji Kempo

Todays T-Shirt choice reminded me of the Six Characteristics of Shorinji Kempo.

  • Ken Zen Ichinyo – Body and the mind are one.
  • Riki Ai Funi – Strength and power should never be separated from compassion.
  • Shushu Koju – Defence comes before attack. 
  • Fusastu Katsujin – Defend and protect without killing. 
  • Goju Ittai – Use hard and soft techniques together, in balance.
  • Kumite Shutai – Pair work is fundamental.  


Live Half for yourself, Half for Others.

That is all.

Friday, November 12, 2010

Homebrew tapeless camera

This is an ongoing project I'm working on which started as a circuit that I decided was necessary to be able to neatly interface the nNovia QC120 A2D2 recorder to a Sony DXC-325P camera with CA-325P studio back.
This interface deals with translating VTR start/stop signals from the camera into GPI signals to pause and resume the recorder when it is in record mode.

In addition to the device control, there will also be XLR Balanced line input to be converted to unbalanced line level.
There is also the possibility of getting it to communicate with the nNovia RS-422 port and using this protocol to control the device.
I'm still working on the final design. I have built the PIC 16f872 based circuit that controlls the nNovia via the GPI control lines and this seems to work very well.
The next step with the PIC interface is to try controlling the RS232 port on the nNovia to start and stop the deck and get its status.
I will be prototyping the Preamp shortly. I have a plan to use the A2D interfaces on the PIC to drive an LED PPM or VU meter on the front panel of the case.

Here's the schematic of the current prototype.

Thursday, November 11, 2010

Is TDD Karate or Kung-fu?

Today we had a discussion in the office about the current TDD (Test Driven Development) course we are following and it has to be said there is more than a little confusion over it. One of the main sources of this confusion seems to be 'why' we are doing it.  And I can see where the confusion creeps in. Quite a few of the members of the team have years of programming experience and may already or have been practicing TDD in some guise or another so those people already know the benefits and have adapted the process to their way of working. To me this is fine. Perhaps they would be better served with working on some other very useful principles such as the SOLID principles. [Robert C. Martin] Some of the other members know of TDD and are perhaps reluctant to use it because of past experiences or whatever.  These people need to know what the goal is, what will they be good at at the end of this?

At this point someone started explaining that it was like learning Karate. In some martial arts including Karate it is common for the students to practice set moves or Kata by copying the seniors in the group but in the beginning it appears (Karate experts please correct me) that they are not necessarily told why they perform the moves they do, just to do them. Remember, polish-on, polish-off from Karate kid?

Well, I don't subscribe to this opinion. I have practiced martial arts and the one I happened to choose, Shorinji Kempo, (Shorinji being the Japanese form of Shaolin) teaches it's students useful techniques and the reasons for using them. And it teaches all aspects of the art continuously and with balance gradually increasing in complexity. At no point does anyone not know why they are doing something.  The art also encourages strategic thinking and how to choose the best technique to use for a given situation (even if the best strategy is not to get involved at all).

I think that this would be a better way to progress and learn the techniques, especially for the enquiring minds. Learning by rote has no interest for me.

So do you want to be a Karate black belt beating bricks with your bare hands (why do they do that?) or a contemplative Shaolin monk analysing the situation and choosing the best strategy to approach it.


[Robert C. Martin, SOLID Principles, ]

ps. I know I mixed up Kung-fu, Shorinji Kempo etc.. but you get the point.. maybe.

pps. In fact I wonder if I mean 'Martial Art' vs 'Martial Way' aka Budo? (Was reminded of Aikido   by @Boston_IT)

Friday, October 8, 2010

Broadcast Technology

Today I was lucky enough to visit our Central Technology Area at of our office in Manchester. CTA take care of a good deal of what is broadcast from Manchester to the region and they have a staggering amount of technology old and new which they look after.

I didn't have a great deal of time to nose about but here are a couple of gems I spotted.

A reel-to-reel deck and a machine that I'm guessing has something to do with time signals or the Pips - not really sure.

This is a bit of nostalgia for me, it's an NTL 2212 IRD which was one of the first generation MPEG receiver/decoders. I used to work on these back in 1995.  I suspect this one has now been retired to be replaced by one of the Tandberg units. (Tandberg took over the NTL Advanced Products Division)

If you thought the IRD was large by todays standards (most are 1u now) the NTL Series 2000 encoders were 12u!  But very pleasant to work on. (No BGA chips and few SMD's)

I also spotted a Tektronix vm700a lurking in the racks. I remember those things cost as much as my first house.

We also found some old microwave links in the basement. Apparently these were used at Holme Moss in the Peak District.

These things date back to the 70's. We haven't dared turn them on - yet!


Thursday, September 30, 2010

Of Droids and Muin

For a while I have had it in the back of my mind to pick up on a couple of old projects that are kicking around the workshop. One of them was a project based on the Droids MUIN board with XBee modules. The original project which was going to be around rocket telemetry is now not likely to happen, but I decided to have a go at getting the PIC development environment set up for the Muin board. The MUIN (PN.990.005) is based on a 28 pin PIC 18F2520 with 10-Bit A/D, 32k Flash, two 8-Bit ports and a 6-Bit port.

Oh, and to keep things interesting I want to use Mac OSX and an ICD2 over USB.

So, on to the first challenge, finding a development environment. Sadly Microchip don't as yet appear to provide an environment for operating systems other than W*ndows. A quick search on google came up with a likely contender in piklab. Piklab is free and GPL and appears to have many of the features of MPLab, and it supports ICD2 among others.  Installation was greatly eased by using Macports.

sudo port install piklab

And piklab needs a toolchain. I chose GNU PIC Utils (gputils).

sudo port install gputils

This should get you a running piklab installation. You'll need to select the gputils toolchain.

Next up, getting the ICD2 working. This really depends on the version of the ICD2 firmware. Mine was woefully out of date but you might find yours is fine.

Updating the ICD2 firmware.  There's a couple of options here.

  1. Use a W*ndows machine, install MPLab and update from there.
  2. Install and Run MPLab under Wine, then use piklab to update.

I chose 2 as I have no W*ndows machines in the house.  Off to Macports again.

sudo port install wine

Then download and run the MPLab installer:

wine setup.exe

To install the new firmware just point the piklab firmware directory (Programmer->Settings->Programmer Selection->Specific) to:

/path_to_mplab/MPLAB IDE/ICD2

Then connect (Programmer->Connect) and piklab will update your firmware.
It should now be possible to create a new project and a stub .asm file which should compile and program.

In the next enthralling instalment I'm going to see if I can get some servo code running.
Meanwhile here are some links to some very useful software.

Wednesday, May 5, 2010

The Beagle has Landed

...The Beagleboard, that is.

Beagleboard is a fanless USB powered single board computer powered by an OMAP 3530 ARM Cortex A8.

It's got USB, Serial, SD/MMC, Stereo audio IO and DVI-D (via a HDMI connector) out. There are projects getting Android and Linux running on it as well as other OS's

I'm planning on running RiscOS Open on it.

Fun times...

Thursday, April 29, 2010

Wakefield Acorn & RiscOS Computer Show

It was the Acorn and RiscOS show in Wakefield. I've not been before
but I have heard about it and now we're not living too far away it's
become more realistic to get to.

For a platform whose original creating company died 12 years ago,
there is still a devoted if small following. Not only are people
still interested in using the machines and OS, but people have taken
over development of the OS and there are now two streams of RiscOS
development, one through Castle Technologies who bought the rights to
the OS and hardware designs and also produced new RiscOS computers in
the form of the Iyonix, and who are tasked with
releasing RiscOS as an open source project.
Interestingly the
RiscosOpen project has produced ports of RiscOs which run on netbooks
and also platforms such as Beagleboard.

There were also people exhibiting older 8 bit computers such as the
BBC B and Master. There are people out there now producing new storage
solutions using compact flash and SD for these vintage machines,
breathing new life into them. One exhibitor, Joel, demonstrated the Domesday
project which is the first time I've seen this system.

I know the computers are old and the platform is niche, but I still
have a soft spot for Acorn, having grown up with BBC Micros (which I
still own) and having spent several years repairing Acorn computers.

Wakefield Show
Facebook Photos

Thursday, March 11, 2010

Wayback Machine - Putting it all together

Started work putting the front panel together, and also fitting the Arduinos in the case.

It turns out the waveshield is capable of driving the speaker, and it works very well indeed. The sound quality is not bad either. I used the 'sox' unix program to convert MP3 data into raw 22khz 8 bit wav data. Here is the incantation I used :-

sox the_archers.mp3 -b8 the_archers.mp3.wav channels 1 rate 22k
I still need to get a decent printed card for the legend behind the top panel, but it's starting to look good.

On a side note, someone at work had an old Radio Times, which suited the radio superbly..

Friday, February 5, 2010

Wayback Machine - Stripping the Hacker radio

Thought I'd post a bit of an update on the progress of the Wayback Machine.

The Wifi connection is working using the Wifly module (see previous post) and connects nicely to the router. I've had a few problems with RFI where the signal from the built in antenna seems to interfere with the other electronics causing the Wifly to keep resetting until you stop it by touching (and attenuating) the antenna with your finger. I hope to solve this at some point.

I made a start stripping down the old Hacker radio. I thought I might be able to resuse the amplifier board, but to be honest I don't think I'm going to have room for all the electronics and two PP9 batteries too. So I'm hoping the Waveshield amp is capable of driving the speaker, perhaps with a small amp.

Next step is to get the Arduinos wired up together and to the Wifly via a MAX3232. (The Wifly is 3.3V logic, so needs a level converter and the MAX is a very proper way of doing that.)

I've also got to get the hacksaw out at some point and make a new Perspex front panel.

Still lots to do...

Wednesday, January 27, 2010

WiFly WIFI Module

WiFly Ver 2.15, 10-15-2009
MAC Addr=00:06:66:00:23:c2
Auto-Assoc Custard chan=1 mode=MIXED SCAN OK
Joining Custard now..
DHCP: Start
DHCP in 186ms, lease=86400s
Listen on 2000

11 17 3 WiFly_GSX-2.09
28 1 10 config
29 1 10 custard
30 1 10 cis
31 18 3 WiFly_GSX-2.15

207 Free, Boot=31, Backup=31