TheRadioBoard

Forum for the homemade radio builder. Newbies and Experts and everyone else are welcome here!
It is currently Mon Oct 20, 2014 4:23 am

All times are UTC




Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: Wed Oct 17, 2012 2:08 pm 
Offline

Joined: Sun Feb 28, 2010 2:12 pm
Posts: 1600
I'm interested in building a frequency counter circuit that allows me to remember a particular frequency and to indicate how much the oscillator has drifted from that frequency, for a sort of manual huff-and-puff approach. I imagine operation would be something like: tune oscillator to desired frequency and press the "memory" key. After that, the counter remembers the current frequency and changes to display +0 Hz. If the oscillator drifts up 100 Hz, the display would show +100 Hz, to allow the operator to manually pull it back down to +0 Hz.

I've seen some PIC frequency counter circuits and program code that maybe could be modified, but I have no experience with PIC programming or circuits, so I don't know what to look for in such circuits. Does anyone have a suggestion for an applicable and easy circuit (PIC-based or otherwise) that could be made to work as described above?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 17, 2012 8:37 pm 
Offline

Joined: Tue Mar 06, 2012 5:40 pm
Posts: 108
As someone who grew programming in asm on the glorious Motorola 68K, I find PIC asm plain terrible to learn and use.
I believe the frequency counter below is one of the few written in C and still capable of measuring frequencies up to some megahertz.
http://www.enide.net/webcms/index.php?p ... freq-meter
That code should be easy to modify in order to get the functions you need.

All other PIC based freq counters I could find so far are either slow (hundreds of KHz max) or asm coded and hard to modify.
A different approach to ease programming on the uC side would imply some fast external counter or programmable logic chip that leaves the critical work out of the uC. So far I could not find anything that does the job of a chain of 74xxx counters in a single chip i2c addressable counter, and sadly know nothing about programmable logic.

Hope the link helps.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 18, 2012 12:13 am 
Offline

Joined: Sat Mar 14, 2009 11:22 pm
Posts: 16
Location: Fort Worth, TX
Hi qrp gaijin

I have had good luck with the inexpensive frequency counter boards from ebay seller sunillakhani. These boards do not have a memory function but would let you manually compare original and drifted frequencies. There are two versions. The simpler one does NOT provide 100Hz resolution above 10MHz.

I use one of these boards as a general purpose frequency counter and with a homebrew shortwave regen receiver. I use another with an old Hammarlund receiver. DXing is a lot more fun with an accurate readout. My ancient BC-221 frequency meter is feeling neglected.

The FLL (frequency lock loop) version provides voltage output for a varactor huff and puff circuit (parts not included). It has a promised +/-7.5Hz lock but I have not tried this function yet. I have found that a simple FET source-follower buffer circuit between an oscillator and the counter is needed in some applications, particularly to prevent noise injection into the receiver.

These boards are available as kits or wired for a few dollars more. Shipping from India to the USA is a bit slow--over two weeks. I have no connection with nor have I communicated with this seller, so research carefully if you should decide to buy.

Good luck with your frequency memory project and tell us more about it. I enjoy reading your posts and I am following your large-element loop project.

Steve


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 28, 2012 11:27 pm 
Offline

Joined: Sun Jul 15, 2007 2:28 pm
Posts: 569
Location: Akershus, Norway
6gv5 wrote:
All other PIC based freq counters I could find so far are either slow (hundreds of KHz max) or asm coded and hard to modify.

I'm probably misunderstand something, but I can't figure out what you really wrote there, because even a simple pic counter reaches several tenths of megahertz before it wimps out. it will count as fast as the internal logic allows it to. Is it real time counting you mean?

Image


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 29, 2012 1:23 am 
Offline

Joined: Sun Apr 08, 2007 8:02 am
Posts: 1461
Location: Saskatoon
As someone who grew up programming a DEC PDP-8e, I'm right at home programming PICs. :P

The architecture is remarkably similar, and I suspect that the designers at Microchip had more than just a rudimentary knowledge of the PDP-8.

I agree that assembly language isn't everyone's cup of tea, but you can rely on a library of existing code that is readily available. For example Microchip Application Note 592 gives a circuit and complete program code for an autoranging 50 MHz frequency counter:

http://ww1.microchip.com/downloads/en/A ... 00592d.pdf

I used a simplified version of this code when I built my Nixie digital dial. I included additional code to subtract the IF offset.
http://theradioboard.com/rb/viewtopic.php?t=734
http://theradioboard.com/rb/viewtopic.php?t=2264


Top
 Profile  
 
 Post subject: Eureaka!
PostPosted: Thu Nov 08, 2012 11:01 am 
Offline

Joined: Sun Feb 28, 2010 2:12 pm
Posts: 1600
Eureaka! I've got it! I have found the ideal frequency counter solution for my particular situation.

I have a TI DSP unit, the C5535 eZdsp development kit. It has a nice glow-in-the-dark LED display (able to show 2 lines of text, approximately 96x16 pixels I think) and is programmable in C. It has stereo in and stereo out.

Now, if only we could make a frequency counter that outputs some sort of audio signal, and if I could get the eZdsp to read that audio signal and convert it back to a digital display, I'd have a nice little stand-alone, glow-in-the-dark frequency counter that's programmable in C and can support all the features I need like IF offset or a memory function and drift indicator.

So, how to make a frequency counter that outputs decodable audio? My synapses were crackling as I considered crazy schemes like a binary frequency counter that fed its binary output into a parallel-to-serial chip, that then would be clocked by a signal from the eZdsp and would in turn generate a series of audio tones indicating the state of each bit, audio tones that would then need to be decoded in software... complicated, but not impossible.

Then I suddenly remembered seeing a recent PA2OHH page that described a soundcard-based frequency counter:

http://www.qsl.net/pa2ohh/11freqcnt1.htm

This uses a pre-scaler to divide the RF frequency to create an AF signal, which is then measured in software and multiplied by the previous division factor to reconstruct the original RF frequency. Brilliant!

The PA2OHH idea provides the last piece of the puzzle. If the idea works on a PC, it must work on the DSP unit as well. And, since the DSP has stereo microphone inputs, I can use one audio channel for the frequency counter, and one audio channel for signal processing of the receiver audio! Woo-hoo! A frequency counter and DSP in one small box.

Can't wait to start.


Top
 Profile  
 
PostPosted: Thu Sep 25, 2014 6:55 am 
Offline

Joined: Sun Feb 28, 2010 2:12 pm
Posts: 1600
I finally managed to gather the parts, time, and motivation to work on my soundcard-based frequency counter.

The idea (by PA2OHH) is simple: allow the to-be-measured RF signal to trigger a binary ripple counter chip (74HC4060AP) that acts as a frequency divider. According to the datasheet, bit 14 divides the input signal by 16384, so bit 12 will divide the input signal by 4096. Take the output from bit 12 as AF, feed it into a computer soundcard, and process the digital sound data to determine the audio frequency, from which the original RF can be calculated by multiplying by 4096.

I was planning to implement the DSP part on my TI eZdsp development board, which has a built-in LED display that can be used for displaying the frequency, but then decided to implement the DSP on my Android phone instead. This gives a smaller, self-powered, more portable, and more flexible solution -- though I'll eventually program the eZdsp unit also for use in my non-portable rigs.

Here's a photo of it all in action:

Attachment:
freqcounter.jpg
freqcounter.jpg [ 173.34 KiB | Viewed 375 times ]

For power I use 2 AAA batteries giving 2.4 volts; according to the datasheet, the chip will work down to 2V. I tried running the chip off of 1.2 volts but the crystal oscillator wouldn't start (it's possible however that the counter is still working in this state). (edit: it seems I should use at least 4.5V supply voltage or else the counter's high frequency performance may suffer.) The crystal oscillator is for calibration purposes only and generates a 2 MHz test signal to drive counter's input pin. The piezoelectric earphone connects to the output bit 12 of the binary counter so I can aurally verify that AF is really being produced. Also, the AF output goes through the alligator clips to a hacked cable with a TRRS (tip-ring-ring-sleeve) connector that plugs into the headset jack of my Android phone. I created the cable with the TRRS connector by slicing up one of my Android microphone-enabled headsets. The wires are really fine inside the headset cable which led to some initial confusion as to which wires were responsible for the microphone (I initially failed to identify the wire connecting to the sleeve, mistaking it for a non-conducting insulator only). After finally figuring out the plug wiring, and with some trepidation, I connected the circuit to my phone, hoping not to destroy any sensitive phone circuitry with my breadboarded circuit.

And it works! The AF signal that I hear in the earphone is processed by my program on the phone to determine the audio frequency (by counting the zero crossings), which is then multiplied by 4096 to give the RF, which as you see is displayed as 2000 kHz on-screen (the Hz label is a typo in my program). To be really precise I need to calibrate the system by measuring the actual crystal oscillation frequency (with say my FT817) and adjust the 4096 multiplier to something like 4095.95 or 4096.03 to give the exact oscillation frequency of the crystal. But for a first lash-up, the results are good enough: the 2 MHz crystal properly shows up as 2 MHz.

The next step is to figure out exactly how to drive this counter with the feeble RF signal from my regen. I did some experiments long ago with a 3-stage broadband amplifier connecting to a small link winding, but looking back, I'm pretty sure the amplifier must have been parasitically oscillating due to my poor construction practices and the intermittent results.

If the attainable frequency measurement is accurate enough, it should be possible, using the phone's AF output to somehow generate a control voltage, to make a huff-and-puff stabilised regen or VFO.

Another advantage of using my smartphone for the DSP is the wide range of options I have for displaying the frequency. In addition to simply printing the frequency as plain digits, one can think of all sorts of retro-looking analog display schemes: linear dial, circular dial, nixie-tube display, etc.


Last edited by qrp-gaijin on Thu Sep 25, 2014 1:56 pm, edited 2 times in total.

Top
 Profile  
 
PostPosted: Thu Sep 25, 2014 7:12 am 
Offline
Site Admin
User avatar

Joined: Sat Jun 06, 2009 6:58 pm
Posts: 3269
Location: South Florida
qrp-gaijin wrote:
The next step is to figure out exactly how to drive this counter with the feeble RF signal from my regen.

This is where my head exploded. :shock: All that tech, to measure the operating frequency of an essentially century-old receiver! :? But -- nice work on the counter. Finally, a good use for a cell phone!

73,

Jim

_________________
Image
http://kr1s.kearman.com/
http://qrp.kearman.com/


Top
 Profile  
 
PostPosted: Thu Sep 25, 2014 7:35 am 
Offline

Joined: Sun Feb 28, 2010 2:12 pm
Posts: 1600
KR1S wrote:
qrp-gaijin wrote:
The next step is to figure out exactly how to drive this counter with the feeble RF signal from my regen.

This is where my head exploded. :shock: All that tech, to measure the operating frequency of an essentially century-old receiver! :?

I've recently started to try targeted DX hunting of SWBC stations, and have had some successes with my FT-817ND, which of course has a digital display that enables this kind of targeted listening. I realized that to have the same kind of enjoyment from my homebrew receivers, I would need an accurate frequency display. I spent too many hours thinking about analog solutions: a bandset + 2 bandspread capacitors; a dial string; a ten-turn pot and varactor; a limited tuning range with several plug-in coils; etc. I finally decided that the only general-purpose and accurate solution was indeed a frequency counter.

As for the numerical frequency display on the smartphone: one thing that immediately comes to mind is to use some Nixie tube images courtesy of Wikipedia:
ImageImageImageImage

I'd also like to try to emulate some of the beautiful dials on dial on old retro sets (from http://www.qsl.net/sm5dff/eng/index.html):
Image

Image


Top
 Profile  
 
PostPosted: Sat Sep 27, 2014 11:48 am 
Offline

Joined: Sun Feb 28, 2010 2:12 pm
Posts: 1600
This frequency divider circuit is turning out to be a surprisingly useful gadget.

First use: an audible field strength meter. I connected a common-emitter amp with collector feedback bias to the RF-in port of the 74HC4066 divider circuit. I connected a short clip lead to the base. Surprisingly, I found that simply bringing the unattached, high-impedance end of the clip lead near the hot end of my oscillating regens's tank coil gave enough RF to trigger the counter and yield an audible square wave tone (at a frequency 1/4096th of the oscillator frequency) at the crystal earphone connected to the divider circuit's AF out port. As I waved the clip lead around the circuit the RF intensity gets lower, which leads to less ability to trigger the counter, so the square wave starts to break up and become a raspy square wave, that further degrades into slow clicking and finally silence as the local field intensity around the clip lead reduces below the threshold needed to trigger the counter input. It's really fascinating to wave the clip lead around the tank and to see which physical portions of the circuit are hottest with RF.

As a specific example, even a tiny 1 cm length of wire that is dangling off of the top end of my regen's tank radiates a surprising amount of RF that can easily trigger the counter when the counter's makeshift antenna is brought nearby. Much longer wires in other parts of the regen circuit don't trigger the counter at all. Lesson learned: we need to be really careful about the wiring lengths at the hot end of the tank! Connecting a 30 cm whip antenna to the top of the regen's tank caused so much RF radiation that all parts of the chassis and even nearby appliances' electric cords were carrying enough RF such that the counter was triggered when the counter's antenna was brought nearby.

The second use is a broadband tester to see if an HF oscillator is oscillating or not. I don't have a scope, so typically when building an oscillator for the first time I have to quite tediously tune a spotter receiver to the frequency I think the oscillator should be oscillating at, then sweep either the oscillator or the receiver to look for the oscillator's signal. But with this frequency divider chip, preceded by the common-emitter preamp, I can simply connect the oscillator-under-test to the preamp input and aurally listen to see if I hear anything or not. Since the frequency is divided by 4096, this means that a 3 MHz signal generates a 732.4 Hz tone, and a 30 MHz signal generates a 7324 Hz tone, so the entire HF range 3-30 MHz is mapped to an easily audible AF range.

On the downside, it seems that to get a clean frequency reading from the DSP software, I need to connect the preamp circuit directly to the tank coil, which does inject a lot of noise into the tank. I tried using a low-impedance coil tap and an additional common-base stage (followed by the common-emitter preamp, that connected to the counter chip), but still got too much digital noise in the regen. More isolation is needed: I'll probably try some JFET buffer circuits next.


Top
 Profile  
 
PostPosted: Sat Sep 27, 2014 11:45 pm 
Offline

Joined: Sat Aug 18, 2007 8:52 pm
Posts: 2722
Location: Australia
Interesting post - thanks.

...............


Top
 Profile  
 
PostPosted: Tue Sep 30, 2014 6:26 am 
Offline

Joined: Sun Feb 28, 2010 2:12 pm
Posts: 1600
I suppose the use case I discovered, about using a clip lead + RF amp + frequency divider + AF output as an audible field strength meter, is similar to the idea behind the RF sniffer pen posted here: viewtopic.php?f=8&t=5780

Still, I like the audible clicking that the above circuit gives out. It feels like I'm using a Geiger–Müller counter as I wave the clip lead around and hear the clicking in the phones get faster or slower.


Top
 Profile  
 
PostPosted: Sat Oct 11, 2014 8:57 am 
Offline

Joined: Mon Jan 14, 2008 1:15 am
Posts: 52
Location: Australia
> As someone who grew up programming a DEC PDP-8e, I'm right at home programming PICs.

Totally agree Bob ! Although in my case I started out on the PDP11/05.

Have worked with many, many micro's, but still love PICs (in Assembler) for their elegance and speed.

You can rule the world with a PIC!


Top
 Profile  
 
PostPosted: Sun Oct 12, 2014 8:48 pm 
Offline

Joined: Tue Jan 04, 2011 1:52 am
Posts: 274
Location: Toronto
I have on my bench a 8-digit frequency counter that was a $99 kit some ... 15 years ago maybe. But for use with my receivers I made the 5-digit version of this PIC-based counter. I also added a two-transistor RF preamp to the input for increased sensitivity and so that it doesn't load the measured device.

I also program PICs, but it would take me too long to produce something as good as the above, so I was happy to download and use the firmware.

I'm comfortable in PIC assembler, but I'm happier and more productive in C, especially since I found the SourceBoost IDE and C compiler. You can do alot with their free versions. For only $20, their simulator plugins are great.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Americanized by Maël Soucaze.