Friday, November 14, 2008

Project: Function Generator and Frequency Counter


This project was based on an article published in Everyday Practical Electronics magazine for a very flexible high speed combination function generator/frequency counter.

I built it because I was having great difficulty tuning a breadboarded DTMF tone detector circuit with my oscilloscope. I was convinced the problem was the inability to lock the triggering circuit on the correct tone, so they solution was to trigger the scope with a stable continuous frequency. Funny - by the time I built the circuit, I had completely lost interest in the original DTMF detection circuit.

Research into function generators revealed them to be expensive, even used on Ebay, so I decided to build one based on the EPE Magazine article (PIC-Gen July 2000 issue)

I cheated and ordered the PCB from EPE Magazine rather than etching my own (did I mention I really hate etching PCBs?)

The final circuit is identical to that published in the magazine, so I will not detail that except to reference the excellent source article.

My changes relate to the case, layout of the connectors and front panel, and the LCD module I used.

The front panel is arranged differently only because I decided to buy a different case (cost), and that I wanted to add a BNC connector wired to the TTL output to use as an external scope trigger.

The LCD module is different because I simply used the one I had on hand from a previous bargain purchase from my junk box. This required some fairly simple modifications to the assembly code.

As constructed, the circuit provides a fairly stable output from less than 1hz to about 10 Mhz. I say fairly stable, because there is some wobble on the scope display, and the frequency count has a tendency to drift with no load.

It does stabilize a bit under load.

I suspect that most of my stability issues are related to noise from my haphazard unshielded wiring scheme. One of these days I need to make a concerted effort at shielding and routing wires to reduce the jitter.

The hard part for building this circuit was acquiring the parts. MAX038 is an awesome chip, but its pretty hard to find. I don't recall exactly where I found it, but I do remember it was priced in Australian dollars and shipped from Hong-Hong - pretty interesting for a part from a company based in Dallas.

Originally I powered the circuit with a pair of nine volt batteries on the assumption that doing so would reduce problems with 60hz noise from the power line causing instability.

In 2008, after I built my CNC PCB Milling Machine, I machined a custom PCB to create the required split positive and negative supply from a dual 12 VAC wall wart I had in my junk box. I cut the custom connector off the wall wart and soldered the wires directly to the power supply PCB rather than buy and wire up a power supply connector. The circuit is no less stable with the AC power supply than it was on batteries, and its a lot easier to deal with.


The main lesson I learned from this one is to create the front panel art BEFORE soldering all the connectors. I did not do that, and have been too lazy to take it all apart to do a proper front panel. I thought when I built it that I would remember what all the switches did, but a couple years away ruined that concept.

UPDATE 12/29/2010:

As requested in a comment from jman, I have posted the updated source code, listing and hex file to my CNC milling machine Google source repository.   It can be accessed to browse at:  https://code.google.com/p/cnc-milling-machine/source/browse/#svn%2Ftrunk%2Fpicgen

No comments: