Fastest Board Ever

Posted by Adam on July 17th, 2011 under Technology • No Comments

I’ve just got to have a little boast about my latest PCB. I managed to draw up the schematic and lay out the PCB in just 3 hours start to finish. And anyone who knows me will tell you that I’m quite thorough when designing boards, double-checking measurements and footprints and so on.

Admittedly, I was doing a lot of recycling, about 75% of it was cut & pasted from other boards I have designed in the past but hey, if it gets the board out the door quicker…

In case you’re wondering what it does, it’s a custom RS422 to RS232 Bit Rate Converter I did for a client and of course, the board works perfectly with no design errors.


Comment on this article

How to FFT with NXP’s DSP library

Posted by Adam on July 3rd, 2011 under Technology • 6 Comments

What a mouthful of acronyms in that title! This is going to be a very nerdy post.

Today I have been having fun processing audio with the NXP1758 Arm Cortex-M3 microprocessor. It’s really quite easy with the DSP library from NXP. Above is a screen shot of it showing the spectrum of a single note from a synthesizer.

The DSP Library

To get the library, download AN10913 from NXP’s website. There is no source code for the FFT, you need to link the static library NXP_M3_DSPLibFft.a into your project. The documentation doesn’t say much about the FFT function which is why I’m writing this blog post. Here’s some things they don’t mention:

  1. The FFT functions use complex numbers for both the input and output data
  2. It won’t do an in-place FFT – you need two separate data buffers
  3. The number of output data points is always equal to the number of input data points

Processing the data

I’m doing a 1024 point FFT so I’ll need a 4096 byte input buffer and a 4096 byte output buffer for a total RAM usage of 8k. The buffers are twice as large as you’d think because they need to store complex numbers. Each complex number consists of two 16-bit signed values, the first one being the real component and the second one the imaginary component which can be safely set to zero for audio data.

Interpreting the result

The result data contains a bunch of complex numbers which represent the amplitude and phase of each “frequency bin” in the spectrum. A frequency bin is a slice out of the total spectrum; being a digital process, FFT cannot deliver a continuous spectrum.

The bandwidth of each frequency bin is the sampling frequency divided by the number of FFT points. So for example if you are sampling at 22050Hz and using 1024 FFT points, each bin will cover a 21.53Hz slice of the total spectrum. Each bin has a centre frequency of (N*SAMPLERATE)/FFTSIZE where N is the bin number. So in my example above, bin 1 will be centred at 21.53Hz, bin 2 will be centred at 43.06Hz and so on. Bin 0 is centred at 0Hz and represents the DC component of the signal.

The results are complex numbers so you can work out not only the amplitude of each bin but also the phase. I am not interested in the phase so my example code below only computes the amplitude.

The Code

#include "dsp/cr_dsplib.h"
#include <stdint.h>
#include <math.h>

uint16_t fft_in[2048];
uint16_t fft_out[2048];
int16_t spectrum[512];

// Returns an array of 512 values containing the amplitude of each frequency
// bin from DC up to the sampling frequency / 2.
int16_t *processaudio(uint16_t audiobuffer)
{
  int i;

  // First copy the audio data to the real component of the FFT input buffer.
  // Set the imaginary component to zero for all samples.
  memset(fft_in, 0, sizeof(fft_in));
  for(i = 0; i < 1024; i++)
    fft_in[i*2] = audiobuffer[i];

  // Now I can run the FFT.
  vF_dspl_fftR4b16N1024(fft_out, fft_in);

  // Convert the output data back into real numbers because I am not interested
  // in the phase component.
  // Also note that the second half of the FFT output mirrors the first half so it is
  // only necessary to process 512 data points.
  for(i = 0; i < 512; i++)
  {
    a = fft_out[i*2];
    b = fft_out[i*2+1];
    spectrum[i] = sqrt((a*a)+(b*b));
  }

  return spectrum;
}

6 Comments

Macro Photography with a Phone Camera

Posted by Adam on June 28th, 2011 under Uncategorized • No Comments

Here’s a real easy way to do close-up when you’ve only got a phone. All you need is a loupe which is a magnifying lens inside a tube, they are used a lot by jewellers, artists and well, people who work in micro-electronics like me. Just plonk it over the lens of your phone’s camera and away you go! Use lots of light to get a good sharp image.



Here’s a frozen pea! well, why not?

And of course, the real reason I want to do this – closeups of circuit boards.


Comment on this article

Small Fix to KaChingPal

Posted by Adam on June 15th, 2011 under KaChingPal • No Comments

If you’ve had some issues with KaChingPal not notifying you of transactions, I have fixed the problem. This issue only affected some users and not others, seemingly at random.

Well anyway it is fixed now so you can enjoy your KaChing! again.


Comment on this article

Circuit Sketch Proof of Concept is Launched

Posted by Adam on May 5th, 2011 under Circuit Sketch • 2 Comments

The first prototype of Circuit Sketch is done. There are many features missing and most probably a few bugs but it’s basically working. Let’s call it a proof-of-concept rather than a finished product.

So what is Circuit Sketch I hear you ask? Circuit Sketch is an online tool for quickly drawing electronic schematic diagrams. You can then share the circuits online by posting them to online forums or your favourite social media.

I’ve had some fun making this, it’s been a good project to learn some more advanced Javascript, DHTML and jQuery.

Why not try it out at circuitsketch.com. Send me an email (or tweet or whatever) and let me know what you think of it. I’d really love some feedback at this stage.


2 Comments

First Board from OurPCB

Posted by Adam on April 28th, 2011 under Technology • No Comments

A few people in my circle of acquaintances have been recommending OurPCB for prototype printed circuit boards so I thought I’d give them a try with my latest board. This board is a work-for-hire job so I’m sorry I can’t tell you what it’s for but I can tell you it’s a 4-layer board.

With 4 layer boards, you can’t see everything from visual inspection. The proof will be whether the board works after I populate it. But apart from the solder mask registration being slightly out, the board looks pretty nice. They even threw in gold coating for free!

OurPCB are a little slower than other board fabs I have used – it was almost three weeks before I got my boards – but they are cheaper. They seem pretty good.


Comment on this article

Circuit Sketch

Posted by Adam on April 25th, 2011 under Circuit Sketch • No Comments

While browsing through electronics forums or answering electronics-related questions in my email, I always think there must be a better way to quickly create circuit diagrams and attach them to posts. On the forums I have seen many methods such as a screen-shot from a CAD package:

or maybe draw it in Photoshop:

or the good old pencil-and-scanner approach:

ASCII art:

or even a photo of a text book!

 

So to make life easy for discussing electronics via email or forums, I think it is time for a new product. Circuit Sketch is an online tool with which you can quickly draw a circuit diagram and copy it into a post or just share it via a simple URL. The product is online so there is no need to install any software (good if you are using someone else’s computer).

It’s only at prototype stage at the moment so it is not fully functional but I’d love to hear what you all think about it. I should be putting it live on circuitsketch.com sometime in the next few days. Stay tuned.


Comment on this article

Boxes boxes boxes

Posted by Adam on April 12th, 2011 under Uncategorized • No Comments

I’m developing a couple of new electronic products and once again I am infuriated by the lack of suitable enclosures. Don’t the enclosure making people understand what I want?!

Take a look at these fairly typical boxes from Hammond Manufacturing:

A lot of the boxes produced by Hammond and such companies tend to have small front panels and a long body. But the reality of modern electronics is the circuitry is very small. It is the connectors, display and controls which take up the most room, so what you really want is a short body and a large panel. When I use these boxes, I end up wasting a lot of space as you can see in this photo of one of my prototypes, more than half the space in the box is unused because I need a front panel large enough for all the connectors.

I have spent days searching through the websites of every box manufacturer I can find but they are all more or less the same. I am currently investigating the economics of getting some custom plastic boxes made. I’ll post more here as I make progress.


Comment on this article

2011 Resumé

Posted by Adam on February 28th, 2011 under Business • No Comments

My updated resumé is now online at http://siliconsparrow.com/Adam_Pierce_Resume_2011.pdf

So if you need some gadgets or software created, why not give me a call.


Comment on this article

Sparrow Cake

Posted by Adam on January 22nd, 2011 under Uncategorized • No Comments

My Mum made me a birthday cake with my logo on it. Thanks Mum!

Happy birthday to me!


Comment on this article