Now it's more clear. I try to search simple and working frequency meter code on PB forum, but no success.
Have someone already done and willing to share the frequency meter source code in picbasic? I'll be grateful for that.
Thanks,
Louis
Now it's more clear. I try to search simple and working frequency meter code on PB forum, but no success.
Have someone already done and willing to share the frequency meter source code in picbasic? I'll be grateful for that.
Thanks,
Louis
Hi Louis
You did not say which pic you are using. You can read frequency by feeding the signal to the external timer input on your pic. It works by setting the TMR1 register to 0 , start the timer, let it count for a fixed period of time, stop the timer, read the value in TMR1 to variable Freq and display. The Pause routine is not super accurate for gating the timer so you need to tweak the value. A better way would be to use a second timer with an interrupt. This should get you started
Code:Freq var word 'Read Freq T1CON = %00000110 'No prescale/Osc off/Sync off/External source/TMR1 off TMR1L = 0 ' Clear Timer1 TMR1H = 0 ' Clear Timer1 T1CON.0 = 1 ' Start 16-bit timer Pause 100 'Capture of Input Frequency 0.1sec Pause 1000 =1sec T1CON.0 = 0 ' Stop 16-bit Timer Freq.lowbyte = TMR1L 'Read Tmr1 count to low byte Freq.highbyte = TMR1h 'Read Tmr1 count to high byte
Last edited by mark_s; - 11th July 2017 at 18:26.
It looks like on the pic16f690 pin2, RA5 T1CKI. I have one of those modules but never got around to interfacing it with a pic.
Post your progress
One of the best examples of measuring frequency with impressive accuracy is here:
http://www.picbasic.co.uk/forum/showthread.php?t=1137
On post #21.
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
Bookmarks