Programming the PICSo, I have designed digital projects before, made LCDs display all manner of information, interfaced different chips, programmed PIC micro controllers. All the skills I needed to meet my objectives were already there...
Hmmm, the trouble with setting objectives for me is that there seem to be so many more secondary ones that even I didn't realise I had. The frequency display had to be able to select the stepping speed, the volume control had to display it's current setting, the signal strength meter had to be dampened to make it display just the way I wanted it and all this had to be done without being "jerky". (The term "jerky" is a technical one, used frequently in the G4UFS shack to describe the fluidity or rather non-fluidity of a display's responsiveness to a control button or knob)
Needless to say, the programming of the PIC took considerably longer than expected...
Noise!!!
The trouble with digital electronics is the considerable noise that can be generated on the power supply to the rest of the circuit. When a project is fully digital and not running at very high speed, you can get away with minimal filtering, a couple of millivolts isn't going to make much difference when you're switching between 0 and 5 Volts. However it's a very different story when interfacing with analog circuitry, especially audio circuitry.
The first power up with the DDS VFO was impressive. It worked!! Trust me, there was no one more surprised than I when it did! I heard stations from Europe calling CQ - a little muffled until I adjusted the BFO but nevertheless it was obvious that I was listening to Ham Radio signals. Feeling pretty smug with myself, I proceeded to refine the audio and become a little obsessed with how I might make it less noisy. The LM386 is not noted for its HiFi qualities, perhaps a different audio amplifier might do the trick?
Not a problem, just swap out the audio stage for another audio amplifier of better quality. I could do this due to the modular design I had incorporated. - another smug moment :)
I decided to use the TDA2003, a device I had used before in a great sounding internet radio build and one of which was sitting in my spares box. At the same time, I had worked out how to rectify the audio signal from the LM386 into something I could pass to the ADC of the PIC and display signal strength. A redesign of the audio board later and Presto! Another noisy audio circuit :(
Actually, the sound of the audio was a little better. The LM386 has quite a harsh sound with little bass frequencies. The TDA2003 was doing the best it could but I could detect a high pitch buzzing in the background and realised I was listening to the sound of my code running on the PIC, rapidly turning on and off all of those transistors as it attempted to meet all those secondary objectives :(
Having identified that noise was present on the power rail, I added capacitance to to the power feed and noted a significant reduction - great but not perfect. There is a limit to the number of 1000uF capacitors you can reasonably place on a board before you realise the law of diminishing returns.
Noise of this type is hard to trace through the circuit even with an oscilloscope. The best method I have found so far is to take a 100nF capacitor and start placing it at strategic points along the power line. If you have never experienced power line noise before, you might be forgiven for thinking that a capacitor placed at one end of a wire is the same as placing it at the other. It isn't. The power line will pickup and radiate noise at different points along its length depending on what it's connected to. I found that placing a 100nF capacitor in the feed to the BFO significantly reduced the noise and then traced the remaining squeaks to the pull-up resistors supplying the rotary encoders. Both points being fed with a solid regulated and smoothed DC voltage. Probing these two points, it was difficult to see the spikes of noise with the scope but dropping in a small capacitor and listening to the audio it was obvious and at the end of the day, it doesn't matter what the scope says, it's your ear that does the listening.