The program make short (0.125s) test of the input signal to determine the prescaler value. Next is the actual counting with the proper prescaler value and then the result is send to the display.
This is fast breadboard proof-of-concept project, and I don't intend to make a finished product, for now at least. Of course there must be some sort of preamplifier/protection in front of the frequency counter in order to be usable.
In the pictures below is shown the breadboard and five different quartz crystals generating different frequencies. The differences between the value on the display and the value on the oscilloscope are negligible. I tested the schematic also with frequencies above 90 MHz and even above 100Mhz and the results was accurate, but of course most significant digit was lost in case of 100+ MHz.
Link for downloading the code and .hex files: LINK
The code is compiled with MikroC Pro. RA5/MCLR must be configured as I/O or if not there must be 10k resistor connected between RA5 and +5V. When programming the microcontroler with PICkit 3 the option "Tools/Use VPP First Program Entry" should be selected and the schematic should be disconnected from the power supply.
Very interesting project. Unfortunately, problem with hex. by a file - a processor after programming stops to be identified. Does the respected author can to help? 73! Vitaly
ReplyDeleteWhat program and what programmer do you use?
DeleteI used the program PICkit 2 v2.61 and "native" device. After failure, I have tried to use homemade JDM with program "PonyProg2000", factory "Triton". The Process occurs so: comptroller successfully "is flooded", afterwards, in an effort consider appears the message "device is not identified or faulty". I used undoubtedly worker 628 3 items - result same. Dear Hristo, but what program and device use you?.Thank you. Respectfully yours, Vitaliy
ReplyDeleteI use the same program and my programmer is DIY clone of PICkit2. You can try this:
DeleteFirst, in the program set "VDD PICkit2" to 5V.
Second, in "Tools" check the option use "VPP First Program Entry".
These steps should help the program to recognize the chip.
Hristo, thank you for consultation. I shall without fall try your advice, but first want to try the processor from the other parties - beside me doubts about marking product from chinese "friends". I have done quite a few designs, but such - first once. Respectfully yours, Vitaliy
ReplyDeleteХристо, большое спасибо за помощь. Действительно,с включением "VPP First Program Entry" все "зашилось" нормально. Хочу добавить входной формирователь на полевых транзисторах. У меня уже собран ГСС на AD9850, с индикацией на модуле MAX7219. Частотомер на том же модуле, как мне кажется, хорошо будет смотреться на передней панели универсального прибора. Еще раз спасибо за программу и помощь. С уважением, Виталий.
ReplyDeleteplease upload firmware
ReplyDeleteHi,Dear Histro
ReplyDeleteI was Loaded Your Hex file in my pic but it process failure and the pickit2 programmer do not recognize my pic after that.
Is my PIC dead?
Sorry to hear that. I don't believe it's dead.
DeleteTry this: In the Pickit2 click on the "Tools" menu and check the option "Use VPP first program entry". After this it should recognize the chip.
this HEX does not work .. When recording on pic 16f628 hangs everything.
ReplyDeleteI tried to compile the source code also did not work.
could anyone make this work?
correcting .. 16F628A
DeleteHello Christo and friends!I also faced a similar problem,but did not give up,and decided this way:I filled the hex file with the wxpic program and a homemade JDM programmer on the Com port of the computer.Tried this chip to fill a different program for the hours put into a finished product,it works! How the chip in this product will behave-I do not know,yet I have not soldered.For me, the main thing is that the chip works, the rest is done -I do not see any obstacles.But in the program there's something,some kind of muck which cuts the initialization,when administered manually, then everything is in order and the program automatically determine the chip.PonyProg not zalivaee PIC, although both programs are being put on Win10.Good luck to everyone!73!
ReplyDeleteSomehow it turned out badly,I did not introduce myself.Andrew, UB3PCO
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteчто нужно изменить чтобы использовать другой кварцевый резонатор, например на 16 мГц
DeleteYou can connect crystal resonator 16 MHz to RA6 and RA7, and the microcontroller will run faster, but if you want to use that frequency for the time base, then you should remove the 32768 Hz crystal and rewrite the code so Timer 1 to use the internal clock (Fosc/4). I am not sure what benefit will that change give you, but it can be done.
Delete
ReplyDeleteQuartz at high frequencies have temperature compensation, so the frequency meter will more accurately measure the frequency.
Кварцевый резонатор не имеет температурной компенсации. Кварцевие генераторы имеют такую, но они очень большие и потребляют больше тока.
DeleteCrystal resonator doesn't have temperature compensation - crystal oscillator might have (usually abbreviated TCXO) but these are bulkier and consume more power. These are indeed more accurate and if you want to build something serious you could use one of these, but the code will need some changes.
I understand that there is a division coefficient to get 1 hertz. What and where do I need to change?
DeleteI don't have time to rewrite the program. Feel free to do it if you want :)
DeleteI understood you . Thank .
ReplyDeleteHi! #define _XTAL_FREQ 4000000, but in your project 32768...
ReplyDeleteNo, the microcontroller runs at 4 MHz, only Timer1 runs at 32768 Hz.
DeleteХристо, you have a picture on a drawing of a crystal 32768 Hz, in an asm - 4 MHz.
DeleteAs I said, the microcontroller runs with its own internal oscillator at 4 MHz. ONLY TIMER1 RUNS AT 32768 Hz.
DeleteThank you, I understand.
ReplyDeleteHello! Does the firmware contain security bits?
ReplyDeleteI don't know what are these security bits.
Delete