Phase watching and phase degree
selcuk
Posts: 7
Hi everyone,
I want to follow input frequency and I want to put same frequency to output,But I cant catch same frequnency.
My code list below.
please help me...
CON
······· _clkmode = xtal1 + pll16x
······· _XinFREQ = 6_400_000
OBJ
······· txt : "VGA_Text"
VAR
······· long ctr, frq
······· long stack[noparse][[/noparse]80]
······· long stack2[noparse][[/noparse]80]
······· long freq,cog,freqmain
PUB Go | Time, freqnew, freqold,freqtmp
··· txt.start(16)
··· cognew(counterf, @stack)
··· repeat
····· if freqmain <> 0·······
······· pwmb_start
······· freqold := freqmain
······· Time := cnt
······· repeat
········· txt.out($00)················· 'clear the screen
········· txt.dec(freq)················ 'display the value (in Hz)
········· waitcnt(Time+=8_000_000)
········· freqnew := freqmain
·········· if freqnew <> freqold
··········· freqold := freqmain
··········· pwmb_start·······························
PUB pwmb_start | success······· '' pwm B CHANNEL start
· pwm_stop
· success := ( cog := cognew(pwm_b_channel,@stack2) + 1 )
PUB pwm_stop··················· '' pwm B CHANNEL stop
· if cog
··· cogstop(cog~ -1)
PUB counterf | cntadd, cnt_, temp, old···· '' TX frequency meter
· cntadd := 102_400_000
· cnt_· := 0
· temp· := 0
· old·· := 0·
· ctra := ctra_
· frqa := 1···························
· cnt_ := cnt
· repeat
··· waitcnt(cnt_+=cntadd)
··· freq := phsa
··· temp := freq
··· freq := freq - old
··· old· := temp
··· freqmain := freq
PUB pwm_b_channel | cnt_, period········ '' pwm B CHANNEL RUTiNE
· dira[noparse][[/noparse]7]~~
·
· period :=· 102_400_000 / freqmain
· ctra := ctra_pwm
· frqa := 1
· waitpeq(%0,%1,0)············· ' wait for tx signal =0
· waitpeq(%1,%1,0)············· ' wait for tx signal =1
·
· cnt_ := cnt
· cnt_ := cnt_ + period
·
· repeat
··· waitcnt(cnt_+=period)·
··· phsa := - (period / 2)
·····
DAT
ctra_·· long· %01010 << 26 + 0
ctra_pwm····· long····· %00100 << 26 + 7
I want to follow input frequency and I want to put same frequency to output,But I cant catch same frequnency.
My code list below.
please help me...
CON
······· _clkmode = xtal1 + pll16x
······· _XinFREQ = 6_400_000
OBJ
······· txt : "VGA_Text"
VAR
······· long ctr, frq
······· long stack[noparse][[/noparse]80]
······· long stack2[noparse][[/noparse]80]
······· long freq,cog,freqmain
PUB Go | Time, freqnew, freqold,freqtmp
··· txt.start(16)
··· cognew(counterf, @stack)
··· repeat
····· if freqmain <> 0·······
······· pwmb_start
······· freqold := freqmain
······· Time := cnt
······· repeat
········· txt.out($00)················· 'clear the screen
········· txt.dec(freq)················ 'display the value (in Hz)
········· waitcnt(Time+=8_000_000)
········· freqnew := freqmain
·········· if freqnew <> freqold
··········· freqold := freqmain
··········· pwmb_start·······························
PUB pwmb_start | success······· '' pwm B CHANNEL start
· pwm_stop
· success := ( cog := cognew(pwm_b_channel,@stack2) + 1 )
PUB pwm_stop··················· '' pwm B CHANNEL stop
· if cog
··· cogstop(cog~ -1)
PUB counterf | cntadd, cnt_, temp, old···· '' TX frequency meter
· cntadd := 102_400_000
· cnt_· := 0
· temp· := 0
· old·· := 0·
· ctra := ctra_
· frqa := 1···························
· cnt_ := cnt
· repeat
··· waitcnt(cnt_+=cntadd)
··· freq := phsa
··· temp := freq
··· freq := freq - old
··· old· := temp
··· freqmain := freq
PUB pwm_b_channel | cnt_, period········ '' pwm B CHANNEL RUTiNE
· dira[noparse][[/noparse]7]~~
·
· period :=· 102_400_000 / freqmain
· ctra := ctra_pwm
· frqa := 1
· waitpeq(%0,%1,0)············· ' wait for tx signal =0
· waitpeq(%1,%1,0)············· ' wait for tx signal =1
·
· cnt_ := cnt
· cnt_ := cnt_ + period
·
· repeat
··· waitcnt(cnt_+=period)·
··· phsa := - (period / 2)
·····
DAT
ctra_·· long· %01010 << 26 + 0
ctra_pwm····· long····· %00100 << 26 + 7
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Please help me...
Thanks for all reply
Post Edited (selcuk) : 5/29/2008 9:49:39 AM GMT
You can edit your post to do this.