Pictron,
I am sorry I can not give you all the code. But I can help you to write your code. I can give you only the tricks. Because there is a little bit commercial side in this job.
Anyhow, let start to work now. You have to learn firstly how to use the TMR1 in 16F628 chip.
look these codes;
bcf STATUS,RP0 'change bank
bcf STATUS,RP1
clrf TMR1L ' clear TMR1 low
clrf TMR1H ' CLEAR tmr1 High
movlw 7
movwf T1CON 'give 7 to T1CON Register
same code in PBP;
TMR1=0
T1CON=7
when you give number 7 to T1CON register the TMR1 start to count the frequency connected to PortB.6 pin which is the fixed input pin for external signal sources. Meanwhile you have to wait 1000 ms for first sampling mode. In a simple way
you can try the following
GetFrq:
TMR1=0
T1CON=7
Pause 985 'we do not wait 1000 ms because there are also some delay on the program steps)
Freq=TMR1
Count=freq/1000:Total=(freq//1000)
Lcdout $FE,$80,"0-65 KHz : MOD=0"
Lcdout $FE,$C0,"Fre:",#count,".",dec3 Total," Hz "
'now you have the frequency in your hand.
depending of the frequency which you measure you have to change the sampling period as 100 ms, 10 ms, 1 ms.
As I told you before it was not so easy to control the right delay time as 1000 ms - 100 ms - 10 ms - 1 ms. For this reason these command should be given in asm language. It is the sample for the delay of 1 ms;
movlw 0xf2
movwf _SureL
movlw 0x02
movwf _SureH
Delay_3
decfsz _SureL, f
goto $+2
decfsz _SureH, f
goto Delay_3
goto $+1
I hope you have undertood somethings.
ERO




Bookmarks