Categories

Frequency counter with PIC16F628A

Posted on Tuesday, September 23rd, 2014 in DIY, PIC by DP

FreqC

xristost blogged about the frequency counter module he made:

First of all I wanted a PIC microcontroller to do the whole job without any additional ICs. Also I wanted to use the the familiar 16F628A, but because one of the portA pins (RA5) can be used only as input I was short of outputs to do the job. Driving 6 digit 7-segment multiplexed display requires 7 + 6 = 13 outputs. The 16F628A has 16 IO pins, two of which are used for the crystal oscillator, one is for the signal input and other one can be used only for input, that leaves us with only 12 useful IO pins. The solution was to drive one of the common cathodes with a transistor, which opens when all other digits are switched off.

This entry was posted on Tuesday, September 23rd, 2014 at 11:00 am and is filed under DIY, PIC. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.

9 Responses to “Frequency counter with PIC16F628A”

  1. KH says:

    Proper 6 digits of precision would need an OCXO etc. 6 digits is rarely useful in hobby work. Given crystal precision and temp stability, a 4 digit LED module and a floating decimal point for kHz units would fit the PIC part nicely. Ewww, he uses tantalums…

    • Jan says:

      I just wonder why he went all that trouble with the transistor and what not instead of using a different PIC. There are plenty of PICs around $2 that could do the job.

      I don’t agree that 6 digit resolution is not useful – if he is doing anything with HAM radio, there at 20MHz 6 digits gives you resolution of 100s of Hz. There are communication modes that actually require that sort of frequency stability (or better!) and seeing whether your signal drifts in frequency is important. What is rarely needed is absolute accuracy, though. With usual 10ppm crystal he could achieve 200Hz stability.

      • KH says:

        There are a lot of books stuck in the PIC16F877A and early PIC18 period and maybe either he is either using old stock or he doesn’t know about the new stuff. For example I still have 4 PIC16F84A that I can’t figure what to use for myself.

        Actually I’ve never seen any ham radio blog postings here on DP. No obvious category tag either. So I do think folks around here would rarely need 6 d-p, especially for an audio-to-ultrasonic range thingy.

    • Josh says:

      What’s the issue with tantalums? Unless you accidentally reverse-polarise them I don’t see why you wouldn’t use them over bulkier electrolytics in this case.

      • KH says:

        Coltan, my friend, coltan.

      • KH says:

        Important to be Green for products to avoid getting used by Greenpeace as an example to others, heh heh. I avoid them in my hobby stuff as a matter of principle.
        Take for instance SSDs. Initially, when they started the write-cache-to-flash on power outage trend, you can see some manufacturers using banks of tantalums. Oh, bad idea, Greenpeace will get you for that. So that quickly changed to banks of MLCCs. Now that the analog IC people have made some nice supercap controllers, I’m seeing boards using supercaps now. Problem solved.
        Many articles talk about tantalum in consumer products, but fact is, tantalum caps in mass market consumer products have become a really rare thing.

  2. Chris Chung says:

    Another way to save PINs would be to use one common cathode and one common anode LED modules. This way you can drive 6 digits w/ 3 pins in a sort of charlieplexing setup.
    Better yet use 4 digit modules and enable the decimal to give some range display w/ higher resolution.
    8 segments + 4 digits (actually 8 via charlieplexing) = 12 IO pins.

  3. alan says:

    What’s so heretical about adding a 3 to 8 decoder? One chip, and there’s more resolution than you can shake a stick at.
    6-digit displays are great for HEX dumps too: 4 digit address, 2 digit value. 8-digit displays are better when you have 16-bit wide memory.

    • KH says:

      Project author wanted a single chip solution; fair enough, so we were offering opinions based on that constraint. He can probably fit a 74HC(T)164 in the back, or if he raised the display by 1 turned pin socket height, he can even put a DIP part right under the display. Better than that bunch of diodes, I think.
      I tried hex dumps for tracing some USB code once; even on a 16×2 HD44780 it wasn’t ideal. 16×8 chars on a handphone LCD screen was much better.

Leave a Reply

Notify me of followup comments via e-mail. You can also subscribe without commenting.

Recent Comments

  • Joe Desbonnet: Ya, I can recommend the low melting point solder. I used brand 'ChipQuik' and it's amazingly easy to use.
  • Jerome: I need a new BusPirate for the Fablab ;) Many thanks!
  • Max: Seems like an unexpectedly violent way to remove the chip indeed. A hot air station should of course do the job just fine, but in...
  • jose: Part removal described here is pure butchery, the cheapest hot air station will do a fast and clean job removing the QFP, heat air to...
  • Cody: Yes please