logic circuit to output 5V 2 second pulse upon receiving leading or trailing edge of pos pulse

Thread Starter

DonRRSU

Joined Apr 28, 2019
4
I am trying to design a logic circuit that will output a 5v, 2 second pulse when it receives the leading or trailing edge of a 5V varying (5 to 60 sec) pulse. This is an application for the activation/deactivation of the R/R crossing lights and crossing bells sound card of a model train layout.
I had a lot of training in logic circuits decades ago but I seem to have misplaced a lot of that knowledge from lack of use over the last 20 years.
I'm familiar with transistors, gates and all the hardware that goes into circuits but can't put them together to get the correct end result.
Thanks,
DonRRSU
 

WBahn

Joined Mar 31, 2012
29,979
Just to be clear, you want a 2 second pulse on BOTH the leading and the trailing edges of your longer pulse?
 

AnalogKid

Joined Aug 1, 2013
10,990
If the input pulse width is guaranteed always to be longer than the output pulse, that makes the circuit a bit less complex. Do the two output pulses have to be exactly the same, or can they vary by 5% ish (two separate timers, one for the positive edge and one for the negative edge)? Here is something from 2017 that is close to the idea. R3-C3 and U1D are there to debounce the switch, and the two output periods are different, but the idea is the same.

DualPulser-5-c.gif

What is your preference - all transistors, all logic gates, ??? 3/4 of a CD4093 looks like a good place to start. Adding the 4th section gets you both positive and negative output pulses.

For a more consistent output pulse you want a circuit with only one pulse former that is triggered by either edge. doing this with NAND gates requires 5 of them, or two ICs. You can cut the package count down to one IC if you add a couple of small signal diodes to the circuit to form an OR gate.

Also, what does the output signal have to drive, as in peak output current?

ak
 
Last edited:

crutschow

Joined Mar 14, 2008
34,285
Below is the LTspice simulation of a circuit using four Schmitt-trigger NAND gates (one IC package) configured as an XOR gate to generate a leading and trailing edge pulse.

R1C1 determines the pulse-width for both pulses.
R2C2 generates a debounce delay to avoid multiple pulses from switch bounce.

M1 is a MOSFET buffer to drive the lights and bells. It can be just about any logic-level N-MOSFET (maximum Vgs threshold ≤2V).
The 2N7000 can carry up to an absolute maximum of 200mA.

upload_2019-4-28_23-21-21.png
 
Last edited:

danadak

Joined Mar 10, 2018
4,057
If you are getting back into hobby here is a discussion using visual
blocks to program Arduino, in this case an ATTINY85 chip. You can
generate all kinds of pulse sequences pretty easy. As well as trigger
the pulse train off complex triggers, like button pressed AND voltage
> xx volts for example. And in a train more qualifiers, logical and/or
analog. Plus the timing is fairly accurate over T and V, 2% is what
folks are reporting.

All you need is the ATTINY, a bypass cap for its power pins, and a button
(in your case).

upload_2019-4-29_9-41-13.jpeg

https://forum.allaboutcircuits.com/threads/flexible-pulse-sequence-generator.156863/#post-1359631

A arduino UNO can be configured to program the ATTINY series of parts.


Regards, Dana.
 

Bernard

Joined Aug 7, 2008
5,784
Using a common 555 as a 2 sec. one shot, bias input, pin 2, to 1/2 of 6V Vcc with 2 10k Rs & capacitive couple input pulse, - or+ via .1 uF to pin 2. With a + pulse OS will fire on trailing edge & on - pulse will fire on leading edge.
 

AnalogKid

Joined Aug 1, 2013
10,990
Using a common 555 as a 2 sec. one shot, bias input, pin 2, to 1/2 of 6V Vcc with 2 10k Rs & capacitive couple input pulse, - or+ via .1 uF to pin 2. With a + pulse OS will fire on trailing edge & on - pulse will fire on leading edge.
But what he wants is an OS that will fire on *both* the leading and trailing edges of the same input pulse.

ak
 

eetech00

Joined Jun 8, 2013
3,859
Just taking a guess...but the TS probably has a circuit that mimics the “island” of a RR grade crossing system. The circuit “deenergizes” when an Engine (or train) enters the “island” and energized when the last car leaves the island. The 2 second pulse is generated when the island de-energizes and energizes. The 5-60 seconds duration would be based on the length of the train so reflects the time the island is occupied.

Just a guess..

eT
 

djsfantasi

Joined Apr 11, 2010
9,156
Model RR crossing gates usually use two sensors. One some distance before the crossing, to turn on flashing lights and lower the gates (with a slow speed motor or two). This sensor must detect the leading edge. The second is some distance beyond the gate, to raise the gates and stop the lights. This sensor must detect the trailing edge. Then there is the bell sound.

MRR manufacturers sell a complete controller to automate these actions. The controller has to be able to perform the actions if the train is traveling in either direction.

Apparently, the TS is trying to duplicate these controllers with only one sensor. It’s not an easy task and won’t model prototype crossings.
 

Thread Starter

DonRRSU

Joined Apr 28, 2019
4
Thanks for all the reply post. Sorry I didn't provide more details in my initial post.
The crossing lights system and the crossing bell sound card system have different input trigger requirements.
The lights system requite a positive going pulse to start and a negative going pulse to stop (basically applying 5V and removing 5V). That is being supplied by an infrared sensor system I fabricated that energizes/deenergizes a small 5VDC relay with double pull/double throw contacts. One NO contact is used to trigger the lights when a train is present and the lights are turned of 1 second after the train clears the IR sensor. The 1 sec turn off delay is for realism effects. The IR sensor is up stream from the road crossing so that the alert occurs before the train engine enter the crossing.
The bell sound card requires anything from a momentary short to circuit ground to a infinite short to circuit ground to start the audio action. Then the audio action is stopped by another momentary short to circuit ground. There has to be fraction of a second between the start and stop short to ground pulse for the sound card to react to it. To keep it simple I originally tried to use the gap of the 5VDC relay held closed and normally closed second set of contacts to get a pulse separation but the contacts shifted too fast.
The post from Analogkid and crutschow both look very promising. Thanks very much from me and my 4 grandkids that wanted more realism in Grandpa's train layout:)
 

Thread Starter

DonRRSU

Joined Apr 28, 2019
4
Below is the LTspice simulation of a circuit using four Schmitt-trigger NAND gates (one IC package) configured as an XOR gate to generate a leading and trailing edge pulse.

R1C1 determines the pulse-width for both pulses.
R2C2 generates a debounce delay to avoid multiple pulses from switch bounce.

M1 is a MOSFET buffer to drive the lights and bells. It can be just about any logic-level N-MOSFET (maximum Vgs threshold ≤2V).
The 2N7000 can carry up to an absolute maximum of 200mA.

View attachment 176247
 

Thread Starter

DonRRSU

Joined Apr 28, 2019
4
Thanks crutschow,
I put this circuit together on a breadboarding module I have and it worked perfect!! Thanks for your help.
DonRRSU
 
Top