Doubling the pusle count


Closed Thread
Results 1 to 40 of 44

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Maybe you didn't know it alrady but, i've been a car accessoiries installer (alarm, car starter, radio, gps, etc etc ) for over 12 years and i still do some custom car modification here and there.

    Why i asked, is because most cruise control brand have their own application list and hints. Even on some VSS generated cable, some cars may have another source for an optional Cruise control or else. And you was right... i never see any opel/vauxhall here... only few picture here and there over the web.

    Anyways, without knowing the exact frequency range, Darrel's example have to work within it's range... no doubt on it!

    To interface.. a simple NPN or PNP or simple OP-AMP would do the job pretty well. I don't think 12V amplitude is really needed... maybe 5Volts could work... with a simple resistor in serie.

    Hey.. you didn't SIMed it this time ?
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    Steve, no I didn't know you had the automotive electrical experience.

    I'm off to download some spice application and SIM this... or should I just contact a local PCB house and get them to send me a prototype... afterall if its wrong I'll bin that one and order another

    Any chance of a quick schematic on the input.. I was planning on using a small 100mA 5v reg for the PICs supply, and assume that the transistor would be between +5 and gnd (C and E) with the base connected to the sensor ?

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


    Did you find this post helpful? Yes | No

    Default

    What i suspect to work... is something as simple as...
    <img SRC="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1433&stc=1&d=117279195 7">

    for the input, a simple resistor in serie will work without problem (1-10k), OR a simple voltage divider.
    Attached Images Attached Images  
    Last edited by mister_e; - 2nd March 2007 at 00:48.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    The pulses appear to be 0-12-0 "square" wave, but not 50/50 duty cycle.
    I was hoping it would be the easy way (50%).
    Oh well, back to the drawing board. I'm re-writing it now.

    Should have something later today (that's probably tomorrow for your time period).
    <br>
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Darrel... i don't think it will be revealant to be 50% or not... it's all about pulse/miles after all.

    In the good ol' time we installed 2 magnetic sensor on the drive shaft as a VSS generator. using that... no way you could have a 50% duty cycle as the magnets where about 1 inch wide.

    I should take a car ride here and record the VSS signal to see how clean it is... in case some want to know.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    AAAAAAAAAAAHAHAHAHAHAHHA i knew that one of my OLD cruise control installation manual would be handy one day or another... here's a quote of the revealant part...
    <table><tr><td></td><td>
    Quote Originally Posted by Good ol' dusty manual
    Using a multimeter to measure the frequency
    of the VSS pulse. Usually, the PPM
    (pulses per mile) of the VSS signal is
    known. At 40 km/hr (25 mph) the following
    frequencies should be:
    2000 PPM : 14 hz
    4000 PPM : 28 hz
    5000 PPM : 35 hz
    8000 PPM : 56 hz
    </td><td></td></tr></table>
    Last edited by mister_e; - 2nd March 2007 at 02:04.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    It was easier than I thought, just more of the same stuff.

    <table><tr><td>
    IdleState CON 0
    </td><td>
    IdleState CON 1
    </td></tr></table>
    Code:
    '****************************************************************
    '*  Name    : FREQx2.bas                                        *
    '*  Author  : Darrel Taylor                                     *
    '*  Date    : 3/1/2007                                          *
    '*  Version : 2.0                                               *
    '*  Notes   : Doubles the frequency of input pulses,            *
    '*          : and maintains the same DutyCycle as the Input.    *
    '*          : Range = .1hz to 500 hz  (0-40% DutyCyle)          *
    '*          : Target = PIC12F629/675                            *
    '****************************************************************
    @  __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 0                            ; State of input when sensor
                                                ;    is not on a "Slot"
    NotIdle    CON IdleState ^ 1
    LastState  VAR BIT                          ; Last state the Input changed to
    LoopCount  VAR byte                         ; Counts the loops of each pulse
    LoopCount1 VAR byte
    LoopCount2 VAR byte
    
    PulseWidth  VAR byte  BANK0                 ; Counts the loops of output pulse
    PulseWidth1 VAR byte  BANK0
    PulseWidth2 VAR byte  BANK0
    
    LastPulseWidth  VAR byte                    ; saved width of last pulse
    LastPulseWidth1 VAR byte                    ;    so it can duplicate it
    LastPulseWidth2 VAR byte
    
    CycleWidth  VAR byte  BANK0                 ; Counts the loops of output cycle
    CycleWidth1 VAR byte  BANK0
    CycleWidth2 VAR byte  BANK0
    
    OutPulseCount VAR BIT
    
    
    CMCON = 7
    'ANSEL = 0    ; for 12F675
    
    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
            
            if LastState = NotIdle then         ; Start of Input Pulse
                CycleWidth  = LoopCount
                CycleWidth1 = LoopCount1
                CycleWidth2 = LoopCount2
                ASM
                    bcf   STATUS,C              ; CycleWidth = LoopCount / 2
                    rrf   _CycleWidth2, F       ; Output Cycle is half of Input
                    rrf   _CycleWidth1, F
                    rrf   _CycleWidth, F
                ENDASM
                LoopCount  = 0                  ; reset LoopCount
                LoopCount1 = 0
                LoopCount2 = 0
            else                                ; End of Input Pulse
                PulseWidth  = LoopCount
                PulseWidth1 = LoopCount1
                PulseWidth2 = LoopCount2
                ASM
                    bcf   STATUS,C              ; PulseWidth = PulseWidth / 2
                    rrf   _PulseWidth2, F       ; Output Pulse is half of Input
                    rrf   _PulseWidth1, F
                    rrf   _PulseWidth, F
                ENDASM
                LastPulseWidth = PulseWidth
                LastPulseWidth1 = PulseWidth1
                LastPulseWidth2 = PulseWidth2
                SpeedX2Pin = NotIdle            ; start First Output Pulse
                OutPulseCount = 0
            endif
        else
            if SpeedX2Pin = NotIdle then
                if PulseWidth = 0 then          ; countdown output time (24bit)
                    if PulseWidth1 = 0 then
                        if PulseWidth2 = 0 then
                            SpeedX2Pin = IdleState ; end of pulse, 
                        else                       ; wait for next transition
                            PulseWidth2 = PulseWidth2 - 1
                            PulseWidth1 = 255
                            PulseWidth  = 255
                        endif
                    else
                        PulseWidth1 = PulseWidth1 - 1
                        PulseWidth  = 255
                    endif
                else
                    PulseWidth = PulseWidth - 1
                endif
            else
              @ NOP                             ; Keep the loop symmetrical
              @ NOP
              @ NOP
              @ NOP
              @ NOP
            endif
            
            if OutPulseCount = 0 then
                if CycleWidth = 0 then          ; countdown to Midpoint of cycle
                    if CycleWidth1 = 0 then
                        if CycleWidth2 = 0 then
                            SpeedX2Pin = NotIdle ; Start second pulse
                            OutPulseCount = 1
                            PulseWidth  = LastPulseWidth
                            PulseWidth1 = LastPulseWidth1
                            PulseWidth2 = LastPulseWidth2
                        else
                            CycleWidth2 = CycleWidth2 - 1
                            CycleWidth1 = 255
                            CycleWidth  = 255
                        endif
                    else
                        CycleWidth1 = CycleWidth1 - 1
                        CycleWidth  = 255
                    endif
                else
                    CycleWidth = CycleWidth - 1
                endif
            else
              @ NOP                             ; Keep the loop symmetrical
              @ NOP
              @ NOP
              @ NOP
            endif
        endif
    goto Main
    end
    HTH,
    DT

Similar Threads

  1. COUNT is not counting again
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 33
    Last Post: - 19th June 2009, 05:52
  2. Can't get COUNT to count
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 24th March 2009, 00:14
  3. Count pulses between VARIABLE TIME
    By RodSTAR in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th October 2007, 13:44
  4. Multiplex Display with count comand
    By mdaweb in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th October 2005, 05:09
  5. Count command
    By hawk72501 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 6th September 2005, 20: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