In the desire to search for an interesting project involving programmable logic, this one seemed attractive – it is a two-stage design and it is low cost and has fast results (less than an hour to build this current stage 1 if that is all you’re interested in), easy to demonstrate with just a pair of headphones or a lamp, and depending on how far you want to take the extended circuit (covered in another post since that circuit is not directly relevant to programmable logic), it covers many diverse domains such as digital logic, programmable logic, digital and analog signal processing (including digital filtering), op-amp math, filters and frequency analysis.
What is needed?
At a minimum, a CPLD (complex programmable logic device) board and an oscillator are needed. Total cost is less than about £20 or $30USD and you can reuse the CPLD board for other projects if a socket is used. A few other parts are commonly available and you may already have them.
To program the CPLD, a BeagleBone Black (BBB) is needed (there have been lots of discussions in the forum on using a BBB as a general-purpose test instrument, and I often use it to generate high speed pulses among other tasks. Here, the BBB is used as a Xilinx programmer). A Raspberry Pi if you have one could also work as a programmer but I did not try it.
What does it do?
It generates reasonable quality noise. An oscilloscope trace here shows the output and frequency spectrum described later. This is highly useful for test purposes and some example uses are shown. When you don’t need noise the CPLD can be reprogrammed. So, the circuit is useful as a development board for programmable logic learning too.
How can the CPLD be programmed for custom tasks?
There are a few ‘hardware description languages’ (HDLs) that can be used for this. A later post will detail step-by-step how to go about this. For now, the compiled file is attached that can be instantly downloaded onto the CPLD and prove that the board works.
The circuit shown here can be simplified further if desired. It is possible to remove the regulator U2 and the surrounding capacitors, and it may be possible to power the circuit from two AA batteries (this is slightly outside the threshold for the oscillator but it worked for me). The FB1 inductor is desirable but optional, if you don’t have it just replace with a wire.
After construction, the board is programmed with a BBB as shown here. If you want to connect headphones to the output as a test, insert a resistor of about 1k in series.
Here are photos of the constructed circuit. The holes on the right are where the BBB temporarily connects for programming.
Here is the underside showing the oscillator. Square-pad board is preferable to stripboard for this project and sometimes for many other surface mount projects too. The oscillator is surface mount (unfortunately it’s not easy to find a through-hole 3.3V oscillator) but the pads on it are about as large as the prototyping board, so it is easy to solder as shown in the photo below.
Once it has been assembled and programmed (it should take just 3 or 4 seconds with the BBB) you should see a pseudo-random sequence egressing from the Digilent CPLD board. You can see it on an oscilloscope, or clearly hear it with headphone in series with a 1k resistor as mentioned. The oscilloscope view earlier shows the signal and the frequency spectrum (stretching out to infinity).
Here is an alternative use for the noise:
The oscillator has been replaced with a 7555 timer (not 555, since it needs to operate at a lower voltage) for a slow clock of about 100Hz. The output is connected to any driver (e.g. an N-channel MOSFET) and then to a lamp in this example. Here a slow clock was used to simulate a flickering candle type effect perhaps for Halloween. CPLDs are cheap but microcontrollers like PICs are cheaper, so a flickering candle effect is more cost-effective with a microcontroller of course. In this video, I just used the BBB to generate the clock since it was handy, instead of wiring up a 7555 (quicker writing some code than wiring up the chip :-)
That’s it. Not sure how long the lamp will last :-) I ran it from 9V instead of 12V to look after it a bit. Perhaps it could be pre-heated with some current in the off state.
You could now perhaps try the extended circuit in the next post (which uses the same programmed CPLD with no modifications but just extends the circuit further), or start planning a new project using the board. A step-by-step walk-through of the code will be the subject of another post.