Doubling the pusle count


Closed Thread
Results 1 to 40 of 44

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hi Malc-c,
    Tell your friend to take the car to a speedometer shop. They will install a gear increaser to calibrate the speedometer, or they will change the drive gear or driven gear. This is probably the cheapest fastest route.
    JS
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  2. #2
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Guys thanks again for your contributions

    I'll pass on the URL to this topic and let him have a read.

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi Malcolm,

    Here's one for your friend.
    It doubles input pulses from somewhere around .1 hz to 750hz. (output = .2 to 1500hz)
    Should be good enough for a speedometer.

    I did it on a 12F629 and it's internal oscillator. But, you should be able to run it on just about any 14bit core. (94 words)
    If the sensor's dutycycle isn't around 50% (40-60% max), I may need to make a couple changes.

    Here's what it looks like on the scope. Top is the input, bottom is the output.



    Code:
    '****************************************************************
    '*  Name    : FREQx2.bas                                        *
    '*  Author  : Darrel Taylor                                     *
    '*  Date    : 2/27/2007                                         *
    '*  Version : 1.0                                               *
    '*  Notes   : Doubles the frequency of input pulses             *
    '*          : Range = .1hz to 750 hz (40-60% DutyCycle)         *
    '*          : Target = PIC12F629                                *
    '****************************************************************
    @  __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF
    DEFINE  NO_CLRWDT 1
    
    Clear
    
    SpeedPin   VAR GPIO.2                       ; Input from speed sensor
    SpeedX2Pin VAR GPIO.4                       ; Output to Speedometer
    IdleState  CON 1                            ; State of input when sensor
                                                ;    is not on a "Slot"
    LastState  VAR BIT                          ; Last state the Input changed to
    LoopCount  VAR byte                         ; Counts the loops of each pulse
    LoopCount1 VAR byte
    LoopCount2 VAR byte
    
    X2Count    VAR byte                         ; Counts the loops of output pulse
    X2Count1   VAR byte
    X2Count2   VAR byte
    
    CMCON = 7
    SpeedX2Pin = IdleState
    OUTPUT SpeedX2Pin
    
    Main:
        LoopCount = LoopCount + 1                  ; 24-bit counter
        If LoopCount = 0 Then
            LoopCount1 = LoopCount1 + 1         
            if LoopCount1 = 0 then
                LoopCount2 = LoopCount2 + 1
            endif
        endif
        IF SpeedPin <> LastState then              ; If Input State Changed?
            
            LastState = SpeedPin
            X2Count = LoopCount
            X2Count1 = LoopCount1
            X2Count2 = LoopCount2
            ASM
                bcf   STATUS,C                     ; X2Count = LoopCount / 2
                rrf   _X2Count2, F                 ; Output Pulse is half of Input
                rrf   _X2Count1, F
                rrf   _X2Count, F
            ENDASM
            LoopCount = 0                          ; reset LoopCount
            LoopCount1 = 0
            LoopCount2 = 0
            SpeedX2Pin = !IdleState                ; start Output Pulse
        else
            if SpeedX2Pin != IdleState then
                if X2Count = 0 then                ; countdown output time (24bit)
                    if X2Count1 = 0 then
                        if X2Count2 = 0 then
                            SpeedX2Pin = IdleState ; end of pulse, 
                        else                       ; wait for next transition
                            X2Count2 = X2Count2 - 1
                            X2Count1 = 255
                            X2Count  = 255
                        endif
                    else
                        X2Count1 = X2Count1 - 1
                        X2Count    = 255
                    endif
                else
                    X2Count = X2Count - 1
                endif
            else
              @ NOP                                ; Keep the loop symmetrical
              @ NOP
              @ NOP
              @ NOP
            endif
        endif
    goto Main
    end
    HTH,
    DT

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink and without PIC ???

    I remember we did that with a 4069 hex inverter ... some centuries ago.

    The trick is to trigger a simple monostable through a basic diode AND Gate on the rising edge ... and also the falling edge.

    How ???

    an inverted falling edge is a leading edge ... no more.

    That's not a "true" freq. doubler ... but it doubles the Pulse count !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Sure,

    But can a monostable multivibrator measure the previous pulse width and modify it's time period accordingly?

    Added: In a single 8-pin package?
    <br>
    Last edited by Darrel Taylor; - 1st March 2007 at 09:51. Reason: 8-pin
    DT

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink Take it easy ...

    Hi, Darrel

    Your job is nice ...and I do appreciate !!!

    Just understand it is over the requirements ...

    But excellent example for further general development !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Is it me? Or is everyone going nut's around me.

    I got a teddy bear to throw here....
    <br>
    DT

Similar Threads

  1. COUNT is not counting again
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 33
    Last Post: - 19th June 2009, 04:52
  2. Can't get COUNT to count
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 23rd March 2009, 23:14
  3. Count pulses between VARIABLE TIME
    By RodSTAR in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th October 2007, 12:44
  4. Multiplex Display with count comand
    By mdaweb in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th October 2005, 04:09
  5. Count command
    By hawk72501 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 6th September 2005, 19:04

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