Connect with us

SIMPLE pulse stretching circuit wanted

Discussion in 'Electronic Basics' started by Peter, May 12, 2004.

Scroll to continue with content
  1. Peter

    Peter Guest

    I am trying to detect a short (negative) pulse with a PIC (Picaxe).
    (Actually it is the input from a keyboard.) Problem is the program is
    also doing other things and tends to miss the pulse. So what I want to
    do is stretch the pulse and apply it to another input pin on the PIC.
    When it detects the longer pulse there it then goes and processes
    (multiple) subsequent keyboard inputs on the first pin.

    I don't want any complicated circuits, just something simple I can
    solder onto the back of an otherwise full board. Will the following
    work? Can I simplify it to just one resistor down below? Do I need the
    diode?

    The top part is existing. ie. the line ie pulled high with the 4k7R
    and gets pulled low by the keyboard.

    +5
    /
    \4k7
    Keyboard in /
    -------.------------'------------- PIC Input
    |
    |
    | +5 +5
    | / /
    | \ 1M \ 4k7
    | / /
    '---|<----'---||----'------- Second PIC Input
     
  2. Tim Kettring

    Tim Kettring Guest

    You could use a transistor and a 555 timer to streach the pulse , if your
    circuit doesnt do it .
     
  3. maxfoo

    maxfoo Guest

    Use an interrupt to detect the pulse...





    Remove "HeadFromButt", before replying by email.
     
  4. Peter

    Peter Guest

    I can't unfortunately. I have a realtime clock attached as well and it
    uses the interrupt for one second clock ticks to the PIC.
     
  5. Your spec is incomplete. What input pulse length? Clean or noisy? And
    what output pulse length?

    Your schematic is also incomplete. What is capacitor value?

    Meanwhile, making a few assumptions of my own, I couldn't see how that
    configuration could work properly.

    Like Tim, I'd suggest a simple 555 monostable. You could adapt the
    standard circuit at
    http://www.terrypin.dial.pipex.com/Images/555Mono.gif
    by choosing appropriate values for Ct and Rt. For example, to stretch
    a (presumably *very* brief) pulse to say 10 ms, use 100k and 100nF.
     
  6. CFoley1064

    CFoley1064 Guest

    Subject: SIMPLE pulse stretching circuit wanted
    Hi, Peter. Try this -- it might work for you (view in fixed font or M$
    Notepad):

    Pulse Stretcher
    VCC
    +
    |
    .-.
    | |1M
    | |
    '-'
    1N914 ___ | PIC Input
    o--|<--|___|--o-------o
    NGT Pulse 4.7K |
    ---.01uF
    ---
    |
    ===
    GND

    You might want to replace the 1N914 with a schottky, if you've got one
    available. This should stretch your pulse to several ms. or so. And you
    should be able to tack-solder the components to the underside of the board.

    Good luck
    Chris
     
  7. but doesn't the RTC set a flag that you could read saying that IT was
    causing the interrupt? Your service routine can check and handle both
    buttons and time?
     
  8. Soeren

    Soeren Guest

    Hi Peter,

    That won't work.

    +5
    /
    \4k7
    Keyboard in /
    -------.------------'------------- PIC Input
    |
    |
    | +5 +5
    | / |
    | \ 1M = Cap.
    | / |
    '---|<----'---------'------- Second PIC Input

    This might, but it depends on whether the keyboard can charge the
    capacitor enough, in the time it is low (if it is mechanical switches,
    it should work).


    As others has pointed out, the sensible way of doing it is with
    interrupts (Which PIC do you use, since you think it can only handle one
    interrupt source ?)
     
  9. Peter

    Peter Guest

    As others has pointed out, the sensible way of doing it is with
    I am using a Picaxe 18x. It can only interrupt on one pin. Well it can
    interrupt on multiple pins but they must be all on together. To
    interrupt on separate pins you therefore have to diode mix the two
    pins onto a third pin, interrupt on that pin and then test which of
    the other two pins actually triggered the input.

    I tried that but it only worked sometimes but more often than not it
    missed the keyboard inputs. The picaxe checks for interrupts between
    each statement executed so I can only assume that the keyboard pulses
    occurred during statement execution and hence were not detected.
     
  10. Use S on an SR flip-flop to catch it. When its caught, and the PIC has
    seen it, assert R to clear it with an output pin. Your only trouble
    then is if the PICAXE is too slow to clear it in time for the next
    pulse.

    Regards,
    Bob Monsen
     
  11. onestone

    onestone Guest

    You may also need to account for debounce.

    Al
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-