PDA

View Full Version : Problems whith pulsin



melectro
- 12th September 2005, 20:26
Hi, I write a program in PBP and have this problem.
I need to detect an 7.5Khz frecuency +/- 10 % but the range is too much from 6.4Khz to 9khz.
the program:
'Pic 16f84 at xtal 4 Mhz. WDT off PTU off
FI VAR PORTA.3 'input freq
SO VAR PORTB.0 'OUPUT LED
W0 VAR WORD 'VARIABLE W0

INIT :PULSIN FI,0,W0 'DETECT TRANSITION 1 TO 0 AND SAVE IN W0
IF W0 = 7 THEN PULSE

GOTO INIT
PULSE HIGH SO
PAUSE 500
LOW SO
PAUSE 500
GOTO INIT
END

Please sorry my English and my poor level in PBP but I try to learn more a day.
Apreciate any help.
Melectro.

mister_e
- 12th September 2005, 20:43
you can probably use COUNT to do the job.

Detecting 7.5Khz with +/- 10% => from 6.82 KHZ to 8.25 Khz

so what about the following


' Pic 16f84 at xtal 4 Mhz. WDT off PTU off'
' Detecting 7.5Khz with +/- 10% => from 6.82 KHZ to 8.25 Khz
'
FI VAR PORTA.3 'input freq
SO VAR PORTB.0 'OUPUT LED
W0 VAR WORD 'VARIABLE W0

INIT:
count fi,100,w0 ' Count pulses for 100ms
IF (W0>682) AND (w0<825) then PULSE
GOTO INIT

PULSE:
HIGH SO
PAUSE 500
LOW SO
PAUSE 500
GOTO INIT
END

melectro
- 13th September 2005, 19:52
Thanks mister_e ,I change the instruction to count and work good,but now the problem is that the pulse that receive is very short soupouse <20 ms (exactly the minimus time that close one ****ch ) this shut an 4064 to the reset an via RF send me the signal to receiver in the ouput I have the wave perfec.I soupouse that the time to take the measurement are big (100ms) in comparation whit the small pulse that shoot pulse:

count F1,100,W0

I change the value 100 to 75 50 and 25 but the program not work an change too the values that W0 .
IF (W0<600) and (W0>850) then pulse

but no work

I think ,if I count in 100 ms and the pulse to shoot are 20 ms I need to ajust the time fine to make the measurement more precise,but...
Any help
Regards
Melectro

mister_e
- 14th September 2005, 00:16
there's probably many method. but did you tried with a sampling time of 10ms with a range of 68 to 82?

Where the pulses cme from? did you monitor it to see if they're clean with the right amplitude?

Before thinking of using internal counter or interupt, can you try the following and post your result?


' Pic 16f84 at xtal 4 Mhz. WDT off PTU off'
' Detecting 7.5Khz with +/- 10% => from 6.82 KHZ to 8.25 Khz
' measuring the frequency period =>147uSec to 121uSec
'
FI VAR PORTA.3 'input freq
SO VAR PORTB.0 'OUPUT LED
W0 VAR byte
TLow var byte
THigh var byte

INIT:
pulsin fi,0,Tlow
pulsin fi,1,Thigh
w0=tlow+thigh
IF (W0<15) AND (w0>12) then PULSE
GOTO INIT

PULSE:
HIGH SO
PAUSE 500
LOW SO
PAUSE 500
GOTO INIT
END

make sense to me ... after being more than 24 hours awake...