Maker Pro
Maker Pro

SIMPLE pulse stretching circuit wanted

P

Peter

Jan 1, 1970
0
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
 
T

Tim Kettring

Jan 1, 1970
0
You could use a transistor and a 555 timer to streach the pulse , if your
circuit doesnt do it .
 
M

maxfoo

Jan 1, 1970
0
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.

Use an interrupt to detect the pulse...





Remove "HeadFromButt", before replying by email.
 
P

Peter

Jan 1, 1970
0
maxfoo said:
Use an interrupt to detect the pulse...

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.
 
T

Terry Pinnell

Jan 1, 1970
0
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

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.
 
C

CFoley1064

Jan 1, 1970
0
Subject: SIMPLE pulse stretching circuit wanted
From: [email protected] (Peter)
Date: 5/12/2004 3:53 PM Central Standard Time
Message-id: <[email protected]>

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

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
 
F

Fritz Oppliger

Jan 1, 1970
0
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.

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?
 
S

Soeren

Jan 1, 1970
0
Hi Peter,

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

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 ?)
 
P

Peter

Jan 1, 1970
0
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 ?)

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.
 
R

Robert C Monsen

Jan 1, 1970
0
Peter said:
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.

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
 
Top