Each track is only 1 minute long, so use “Repeat” on your CD player to obtain a (nearly) continuous tone.

Don’t play this CD through your speakers, unless the volume is at minimum.

The audio tracks are recorded at 50% dynamic range, to avoid any clipping in the CD player itself (of course it should not do that, but my portable CD player used for testing is not perfect, maybe yours isn’t either).

Monday, September 07, 2015

The reason for the sharp dips in performance, are that the FAT filing system has to go off and allocate a new cluster every N writes. For example 512 byte sectors, 32Kbyte clusters, means a new cluster is needed every 64 writes.

Another factor on the XMOS board is whether the code is running in 'debug' or 'release' mode. This can make around 2x difference.

I also found that the code published on https://github.com/xcore/sc_sdcard seems to not pay attention to setup and hold times, and appears to be leaving the clock line in a logic "1" state when in fact data gets clocked on a logic 0 -> 1 transition.

All this led me to branch the repo and produce my own version, here: https://github.com/tuck1s/sc_sdcard

The changes are too numerous to list here (see the github changelog) but with pre-allocation of a file with contiguous sectors, and a Sandisk Extreme Pro SDcard, there's enough performance to write around 3Mbytes/s to the card.

My experiments with the even smaller "PetitFAT" filing system were halted because it only reads/writes a sector at a time and that would not give enough performance.

Measuring 'where the time goes', I can see that the time taken to clock in a sector's worth is usually only a few hundred microseconds, whereas the card can then take several milliseconds to respond that it's done. This is highly variable and also highly dependent on the grade of the SD card.

Monday, August 31, 2015

Being able to read/write information from an SD card is probably the easiest way to get large amounts of non-volatile storage into an embedded project.
I'm using XMOS StartKit,, with the code from here

The card reader is a part from Wurth Elektronik, Farnell / CPC part number CN18143 available here.

The data and clock lines have 120 ohm series resistors, as this can help to absorb transmission-line reflections on the connecting wires (even though they are fairly short).

In addition, pins 2 and 7 have 10K ohm pull up resistors.

Pins on an SD card are numbered from 9 (the chamfered end), then 1 to 8. This is because very early cards, like the one shown above, have no pin 9.

SD cards run from 3.3v, so this can be provided directly from the StartKit board.

The XMOS code supports both 1-bit (SPI mode) and 4-bit data access mode. Initially the code is set to use 1-bit SPI mode.

As well as GND and 3.3V, SPI mode only requires pins:

1 CS
2 MOSI
5 SCLK
7 MISO

These are connected up and monitored on the scope.

The signal quality looks OK.

The very old 16Mbyte card that I started with, would not read/write (it gave reason code=3).

Monday, August 24, 2015

I recently got one of these great little digital scopes. It has a few serial bus decoding packages (on a try-before-buy basis). You get 36 hours to play with them. Unfortunately they don't include I2S bus decoding. I2S is a bus standard commonly used for transferring digital audio around, for example between ADCs and DACs.

No matter! You can capture and export full-resolution traces of signals via a USB memory stick. This seems to work best if the stick is FAT formatted rather than FAT32. The file format is .CSV which is great for importing into Excel and viewing. You can then use Excel's charting function to provide a decode of your signals with much greater time-resolution than you can see on the scope's display itself (which is still pretty good). For example

You can also parse the .CSV file and decode signals quite easily using scripting languages such as PHP, giving outputs in binary, hex or whatever you like - e.g.

Every N samples (actually every 384 samples), there are two sample with LSB set to 0x09 rather than 0x01.
Counting the channels as seen on the front-panel from 1 to 16, these are marking channels 1 and 2 in the first data stream.
Channels 8 & 9 are I expect marked in the same way, although I don't have a second WM8804 running on that channel yet.

Thursday, July 09, 2015

Ages ago, I built a John Linsley-Hood design of phono preamp, first published in ETI magazine in 1992. This was considerably better than the phono stage in the integrated amp I was using at the time (a Creek CAS4040).

For a couple of decades I ran this from my bench power supply, so it was definitely time for its own PSU. Rather than etching my own circuit board, nowadays kits are available via eBay that save a lot of that messy work. I wanted something based on the LM317 / LM337 regulators, as they are known to have superior noise performance and regulation compared to the standard 7812 / 7912 family.

I started with this kit. Unpacking, you have a bag of bits and a very nice looking double-sided, through-hole-plated, silk-screen-printed PCB - way better than you can make yourself. And the total price of the kit is less than you'd pay from a regular supplier for the parts. The large electrolytic caps are Sanyo branded, and look genuine to me.

Here's a view of the PCB sides:

The negative regulator is branded "On" which is On Semiconductor, formerly Motorola.

I filed down the burrs on the heatsink holes, removed the anodization/paint with a small file, and applied some PC heatsink paste. Probably overkill, considering that the preamp will draw less than 100mA, but better than overheating.

here's the regulators mounted on the heatsinks, ready to insert in the board.

The circuit diagram supplied with the kit didn't quite match the PCB & kit of parts. Here's a marked-up version of the diagram:

The bypass capacitors around the full-wave rectifier diodes were interesting - I hadn't seen those before. I found this site and this article which explains what they're for.

Even with the caps in place, some ringing is evident when looking at the transformer secondary taps. While I'm somewhat skeptical that this would ever be audible, let's see if we can do better, based on that second article.

Firstly, let's add 330R dummy load resistors, so we can test the circuit behaviour without endangering the regulators.

The ringing is definitely there on the transformer secondary output:

Here's a closeup of the rising and falling edge ringing:

Now let's add 180R in series with each of the 100n snubber caps. It's a little bit awkward to fit this into the existing PCB, but it's possible.

Here's the improved damping result.

Here's the improved R-C snubbers in place.

Looking at the 12v outputs, they're pretty clean, with noise below 1mV on each rail.

Ready to connect to the preamp. I used a trailing 7-pin DIN socket for the power (using pins 6 & 7 for -/+12v so they can't be mistakenly connected to audio inputs).

I found that, when the preamp is connected to other devices such as USB sound-cards, hum levels were reduced when the power supply 0v output was not connected to mains earth. Perhaps the PC was already earthing via the sound-card and it was just introducing a ground loop.

Friday, July 03, 2015

The following circuit is a very simple water leak detector, which I made 25+ years ago (!!) following my fiancée having a washing machine go wrong and leak all over her apartment.

The circuit is not ideal - there are better designs out there. It was built with 'what I had in my scrapbox at the time'. It's purely analog, relying on the gain of the Darlington pair to provide reasonable on/off behaviour. This can actually be an advantage, as the sound will get louder as the leak becomes more serious and conducts more water.

The transistors used are not critical. I used BC108Cs.

Battery current drain is essentially zero (too low to measure on my meter) when there's no conduction.

The physical construction had a few hacks which surprised me when I took it apart again.

- The self-tapping screws are used both to hold in the buzzer, and act as the electrodes. Kind-of-neat, but soldering on to them was a nasty little shortcut I'm not proud of!

- The battery is just held in with double-sided tape. Good enough for something that's rarely changed.

- The circuit board is just loose in the box. Actually I had held it in place with blu-tak before, which was horrible. But the blu-tak seems to absorb moisture and prevents the circuit working properly.

- The plastic box would cut down the sound level too much. So it has holes cut in the box lid to let the sound out. These holes are then "sealed" using a blu-tak 'grommet' and thin plastic. Reasonable compromise between letting the sound out and not letting water in!

Here's a pic of the insides.

Nowadays, cheap commercial solutions are easily available such as this.