Problems whith pulsin


Closed Thread
Results 1 to 4 of 4
  1. #1
    melectro's Avatar
    melectro Guest

    Default Problems whith pulsin

    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.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    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
    Code:
    ' 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
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    melectro's Avatar
    melectro Guest


    Did you find this post helpful? Yes | No

    Default problems whith pulsin

    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

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    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?
    Code:
    ' 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...
    Last edited by mister_e; - 14th September 2005 at 02:28.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Replies: 17
    Last Post: - 12th April 2014, 02:17
  2. Better understanding PULSIN
    By Wirecut in forum mel PIC BASIC
    Replies: 12
    Last Post: - 29th June 2008, 10:17
  3. Funny PULSIN values: what is going on???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 30th April 2008, 08:02
  4. Pulsin 16F819 problem
    By rekcahlaer in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 11th April 2007, 13:52
  5. PULSIN and RCTIME
    By Dwayne in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 4th November 2004, 14:45

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts