« Back to home

Using GreenPak Programmable Logic

In my last post I mentioned that the breakout boards I had designed for the the tiny GreenPak chips had arrived, turns out it was just in time as I discovered a need for them very quickly.

A friend of mine needed a simple solution that would allow him to detect button presses through the microphone input of a mobile phone - the quick and dirty solution of simply putting a button and a resistor between ground and the microphone input worked in most cases but for some inputs there wasn't enough noise to generate a measurable change in audio level.

I proposed using a small tone generator that would be triggered by the button, this would be more reliable and generate a consistant signal regardless of the input, as long as the button pulled the input to ground you would get exactly the same signal on the phone regardless of the electrical characteristics of the button.

Button Press Trace

There are a number of different ways you could do this - a discrete BJT based oscillator, a 555 timer or a small CPU like an ATtiny85 or a PIC. Then I remembered I had the GreenPak devices sitting on my desk and decided I could use them instead.

Development Tools

The GreenPak Designer software is very easy to work with and they provide a decent number of well described examples on their site.

GreenPak Designer

You will also need a development board, Silego provide a universal board that works with most of their range (GreenPak 2 through to GreenPak 5) for around $US 60. The kit comes with STQFN-12 and STQFN-20 adapters so you can work with both sizes of chip. The variation of board you order (GreenPak 3 Development Kit for example) determines what range of sample chips come with it, you can always add additional chips to your order though.

Development Board

The development board is very nicely laid out - the STQFN adapter sits in the middle, there is a pin header at one end to attach to the GPIO pins of the chip under test as well as a series of well spaced test points around the edge of the board. A nice touch is the two sets of 6 ground pins on each edge of the board, this avoids the common problem of trying to attach multiple wires to a single ground pin.

Development Board in Use

In reality your board will look more like this when in use. In this case I have a cheap logic analyser and a scope hooked up to measure the inputs and outputs so I can test the circuit. Not shown in this image is a small breadboard holding the additional discrete components needed to complete the circuit. The set up can get a bit messy but it's a lot easier to work with than other development boards I have used.

Circuit Design

Schematic

The design is very simple, a filter on the input, a falling edge detecter and a delay line to generate a second pulse 100ms after the first. There were some limitations imposed by the GreenPak though:

  • Rather than providing a set of standard logic gates the GreenPak gives you a set of Lookup Tables (LUTS) which is far more flexible. Each LUT can take the place of multiple gates which means designs can be very compact.
  • Each device has a finite number of LUTS with varying numbers of inputs - occasionally you have to use one with more inputs than required and tie one or more of them together or to ground.
  • The particular device I used only provided D type flip flops and I wanted something that behaved more like a Set/Reset - putting some LUTS in front of it to get that behaviour wasn't difficult but I had to add an additional gate to increase the propagation delay on the CLK input so the data line had a chance to stablise first. The propogation delay can be an issue, you will need to take care with your signal paths if you want to keep everything synched up.
  • Determining what the signal level was at various stages of the circuit was a bit problematic until I realised I could simply route the intermediate output directly to an IO pin and measure it there. This made things a lot easier.

The GreenPak devices are very low power, this particular design consumes 3uA while idle and 30uA while generating the tone. The majority of that idle current is due to a pullup resistor on the input and could probably be reduced even further.

With the low current draw and very wide input voltage range (1.8V to 5.0V) I simply drive the chip directly from a 3V CR2032 coin cell (with a small signal diode to provide some polarity protection). This should allow for nearly 75000 hours of operation, not too bad at all.

Assembly

One of my biggest concerns was being able to solder the devices by hand. When I designed the breakout board I deliberately gave it very long pads with enough room to get a soldering in without bumping or dislodging the chip. This turned out to be a good idea and made soldering them to the board very simple - the technique I used was:

  • Apply a small amount of flux to the pads and align the chip with the pads. This requires some patience and a good way to magnify your view (I used my phone camera with a high zoom).
  • Use a soldering iron to heat a single pad. The pads on a fabricated board have enough solder on them from the manufacturing process, you don't need to add any more.
  • The combination of the molten solder and flux will effectively pull the chip into place and fix it to the board so it won't be dislodged by vibration or air.
  • Finally I heat the remainder of the pads with a hot air gun and the job is done.

Soldering

This technique has proved very reliable and repeatable, if you are using home made boards you will have to either tin the pads (very lightly) before soldering or use solder paster - I haven't tried that yet.

Conclusion

It was relatively quick to develop and test the circuit (and no rewiring of a breadboard required to test changes). Once I had the final logic design for the GreenPak it was a simply matter to burn it to the chip and build up some prototypes on stripboard for field testing.

Prototype Board

The final board design for the finished product is tiny, basically the size of the coin cell holder. All up it was a weekends worth of work to design and prototype the circuit, a much faster turnaround than if I had to build it out of discrete components. After a few days of field testing I ordered the final boards for him and the first devices will be on the way to his customers as soon as they arrive.

Before redesigning your circuit there are some things you should take into account that may effect production. Silego do allow you to order pre-progammed chips (with your program of course) and will deliver them directly to your production house but there is a minimum order quantity of 3000 (a full reel) - if you are doing smaller production runs this is not really cost effective.

Programming the devices by hand is time consuming, loading the blank chip into the programming adapter is very fiddly and can take a few attempts to get it to sit right. For small runs (less than 50 or so) that you are building at home this might be suitable but if you want a 100 or more that time quickly eats into your production schedule. If your production run size is somewhere between that 100 and 3000 mark the GreenPak may not be the best solution.

I have cleaned up the breakout board design for the 12 pin version of the chip as well as put together a similar breakout for the 20 pin - once these boards turn up and I get a chance to test them I will make the designs publicly available (along with a few other SMT to DIP breakouts I have done). I'll announce that in a future post when everything is ready.