How can I make a comparator circuit only produce an output when the input has stopped? (drops to near 0 volts)

Thread Starter

matelot

Joined Apr 15, 2013
43
Hi,
I hope someone can help me.
I have a comparator circuit I designed that allows me to monitor an input that drops to(or close to) 0V.
I use this at present.
A jpg of the diagram is below. There are two separate circuits on the same board.
What I would like to do is produce an output when the comparator switches off. A pulse of around a second would be perfect.
When the input drops below the comparator threshold there would be no output but when it rises again, taking into account the possibility of a momentary rise being ignored but covered by the capacitor, the output drops to (or close to) 0V for up to a second.
Is this possible with additions to the present circuit or could something similar give me the solution I am looking for?
Any help would be appreciated,
The input is not a very clean signal hence the use of a comparator.
Thanks,
Bob.
 

Attachments

LowQCab

Joined Nov 6, 2012
1,307
""the Input is not very clean""
Well what is it ??
What is its Impedance ?
Why does it vary ?
What is its Frequency range ?
Is it a Binary Signal ?, (either Off or On), or is it an AC Voltage ?
What are the Voltage Levels that are considered to be "High, and "Low" ?
How long of a Time-Period must it remain "near-zero" before you want a "one second Output" ?
What specific Voltage is considered to be "near-zero" ?
What specific Voltage is considered to be "High" or "On" ?
Do you want a Positive, or a Negative, Output-Pulse ?
How much Current will the Output-Pulse have to Source or Sink ?
Will You still need an LED Indicator that flashes in response to the "Noisy" Input ?
Do You want an additional LED that Indicates the new "One-Second-Pulse" ?,
Or just one LED indicating the new "One-Second-Pulse" ?

If you would just state the overall problem that you are trying to solve
it would make understanding what You are trying to do much easier.

What will the "One-Second-Pulse" Indicate ?
Why is the Input so noisy ?,
Or, are you simply trying to make the LED show an
average Input-State over a defined Time-Period ?
.
.
.
 

Thread Starter

matelot

Joined Apr 15, 2013
43
The input is derived from connecting it to one track of a garden railway. The other track is earthed.

It is not 'very clean' because the signal is earth and is picked up by one wheel which through the axle reaches a short section of the other rail that is insulated from the rest of the rail and is connected to the input.

If I don't get an output until the input has disconnected again I can use that to close a relay after the last wheel has left the short section and change the signal light to green to let another train pass, at present the moment the train hits the 'short section' the light changes allowing the train behind to move. This occasionally results in two trains in one section if the second train is moved fast enough.

The signal then resets a latched relay by earthing the point between a resistor and the relay coil or sets the relay by being connected between the other end of the coil and one of its contacts.

The circuit voltage is 24v DC but as the resistor and the coil are similar resistances (about 680 ohms) the potential divider leaves me with 12v below the resistor and 0v below the coil.
The present system has LED's that light whilst the train is on the 'short track' and work quite well.
 

LowQCab

Joined Nov 6, 2012
1,307
I can't really understand your descriptions, that's what Schematics are for.

Apparently, the Ground connection that you are sensing between the Tracks and the Wheel is kinda sketchy.
Here's how to fix that ...........

And why are you using a "Latching-Relay" ?
Train Lights Control FLAT .png
 

Thread Starter

matelot

Joined Apr 15, 2013
43
Hi LowQCab,
I am using latching relays because the circuit has been in existence for many years, is quite large, has worked fine most of that time, most of the people on the maintenance team don't understand much about electronics and I am trying to make improvements without losing them in electronic systems they won't touch.

If I can add small units to make a better job of the running of the system I feel that will help.

I have recently removed a large number of proximity sensors as they are not reliable enough for us and replaced them by insulating a small section of one rail, connecting a wire and earthing the other rail.

Connecting the insulating section to the present circuit as described earlier allows the present circuit to function quite well.

Sometimes if one driver is fast enough, when he sees a signal go to green (the train ahead has triggered the system and set the signal behind him to green) the driver moves off, if his train has cleared the short section before the train in front has cleared his then the train in front sets the rear signal back to green when the rear train is in the section.

If I can stop the train in front from resetting the signal behind to green until he has left the section this won't happen.

A circuit that produces a 0v output when the train in front 'leaves' the insulated section is what I am looking for.

The circuit I attached in an earlier thread works fine apart from the fact that it sends a 0V signal (held for a second or so by the capacitor so that if the wheel it touching a dirty part of the track the output stays on) the moment the front train touches the insulated section. I want it to send the same 0V signal for a second when the train leaves the insulated section.

My problem is that I can't see how to send a just a pulse that would meet my requirements.
 

LowQCab

Joined Nov 6, 2012
1,307
Well ........ You didn't answer my question ......... and apparently, No,
I did not understand what You wanted.

It's terribly difficult to decipher all the Pro-Nouns in your explanation, but I'll give it another try.

It would appear that You are not concerned, necessarily, with Road-Crossing-Lights.
but it would appear that You are describing 2-Trains, and Track-Switching, or Merging Tracks,
and the Signals that are set up to inform the Engineers as to whether or not the Merge area is safe.

I also think that part of the problem is that I'm trying to come up with a
bullet-proof, simple, all Electronic-Circuit, that will eliminate your present "Latching-Relays",
and you're trying to come up with a better Switch to operate your Latching-Relays.

Properly designed Electronic-Circuits never wear-out, or need maintenance.

If you are dead-set on keeping your Latching-Relays, I can do it either way,
and will probably do it BOTH ways, so that You can call the option.
However, I will need to see a schematic of how they are wired,
and how they were intended to operate.
Your verbal descriptions are not making sense yet.

I've designed Control-Boxes that were packed with nothing but Relay-Logic,
and dabbled in ancient Elevator-Relay-Logic-Systems,
so I have no problem understanding Relay-Logic,
it's just WAY outdated, and I can only recommend it in a few very specialized applications.
--------------------------------------------------------------------------------------------------------

I would imagine that the Picture that I provided,
and associated functionality that it illustrated,
is equally applicable to Signals on the Tracks that are intended to inform any Engineers on
a particular Track, that the area ahead is clear, or not-clear.

Possibly You did not understand the logic that I was using
Here's what I now think that You want ........

Track-1 and Track-2, merge together and become a single Track-3.

Some distance before the merge,
Both Track-1 and Track-2 each have Signals that indicate to the Engineer on that Track that
the "merging-Tracks-area" up-ahead is clear, or not-clear.

Depending upon "who-gets-there-first",
the Track with the later arriving Train will get a Red-Light, indicating not clear ahead,
and, that later arriving Train must stop and wait for a Green Signal.

When the First arriving Train is clear of the "merging-Tracks-area",
the Red Signal for the waiting Train will change to Green,
indicating clear ahead, and that the Engineer may now proceed.

If this is what You want, this is super-easy to do, (without Relays),
even for any multiple number of Tracks.
But I still have no clue about how your existing Relays are set up,
so I can't make any suggestions regarding them without guessing.
.
.
.
 

eetech00

Joined Jun 8, 2013
2,644
Hi LowQCab,
I am using latching relays because the circuit has been in existence for many years, is quite large, has worked fine most of that time, most of the people on the maintenance team don't understand much about electronics and I am trying to make improvements without losing them in electronic systems they won't touch.
If I can add small units to make a better job of the running of the system I feel that will help.
I have recently removed a large number of proximity sensors as they are not reliable enough for us and replaced them by insulating a small section of one rail, connecting a wire and earthing the other rail. Connecting the insulating section to the present circuit as described earlier allows the present circuit to function quite well.
Sometimes if one driver is fast enough, when he sees a signal go to green (the train ahead has triggered the system and set the signal behind him to green) the driver moves off, if his train has cleared the short section before the train in front has cleared his then the train in front sets the rear signal back to green when the rear train is in the section.
If I can stop the train in front from resetting the signal behind to green until he has left the section this won't happen.
A circuit that produces a 0v output when the train in front 'leaves' the insulated section is what I am looking for.
The circuit I attached in an earlier thread works fine apart from the fact that it sends a 0V signal (held for a second or so by the capacitor so that if the wheel it touching a dirty part of the track the output stays on) the moment the front train touches the insulated section. I want it to send the same 0V signal for a second when the train leaves the insulated section.
My problem is that I can't see how to send a just a pulse that would meet my requirements.
We need to understand the "Latching" function your describing.

Are you using "Latching" type relays that set/reset by changing the DC polarity of the voltage to its coil?

-Or-

Are you using standard "Neutral" (non-polar) type relays and using its own contact to cause it to latch (in railroad terminology we call this a "stick circuit")?
 

eetech00

Joined Jun 8, 2013
2,644
The input is derived from connecting it to one track of a garden railway. The other track is earthed.
I think you mean one "rail" is input from? and the other "rail" is earthed (ground).

It is not 'very clean' because the signal is earth and is picked up by one wheel which through the axle reaches a short section of the other rail that is insulated from the rest of the rail and is connected to the input.
Sounds like a DC track circuit and the train wheels "shunt" the track.
When the train shunts the track, does the circuit close? or does it open? and how does it affect the circuit for either case?

If I don't get an output until the input has disconnected again I can use that to close a relay after the last wheel has left the short section and change the signal light to green to let another train pass, at present the moment the train hits the 'short section' the light changes allowing the train behind to move. This occasionally results in two trains in one section if the second train is moved fast enough.
Sounds like a short duration timer (1 second or less) or "debouncer" might resolve this.

The signal then resets a latched relay by earthing the point between a resistor and the relay coil or sets the relay by being connected between the other end of the coil and one of its contacts.
This sounds like a standard relay that is latched thru its own contact and a series resistor. If ground is applied to the junction of the resistor and the coil, the relay is "shunted" (or same potential on both sides of coil) to its de-energized state. Correct?

The circuit voltage is 24v DC but as the resistor and the coil are similar resistances (about 680 ohms) the potential divider leaves me with 12v below the resistor and 0v below the coil.
This is "rule of thumb" standard resistance value.

The present system has LED's that light whilst the train is on the 'short track' and work quite well.
It would be great if you could provide a simple diagram showing the comparator and its connections to the track circuits.
You probably don't need a comparator, but instead, a short duration timer.

This problem somewhat reminds me of problems we had (in my former life) with DC track circuits and "rusty rail" situations.
 

Thread Starter

matelot

Joined Apr 15, 2013
43
Hi,
I have produced a small section of one of the circuit diagrams, I could attach the whole thing but it is so big even printed on A3 it is hard to read.
It is the 'rail' that is connected, .
The common rail is connected to 0v, the short insulated sections are connected to the circuit as shown on the diagram.
There are no comparators shown on the diagram as in fact there are quite a few signals that are connected direct, same as the diagram.
The 'A's in the grey boxes are not there at present and the wire is connected from one side of the box to the other but they are where copies of the circuit I am asking for would be connected. They could include a comparator or not.
When we first turn everything on all the signals are red, we then press a button (the 'total set'), all the relays make and all the signals go green.
A train travels along the track from the left side resetting and setting each relay as it goes. If the relay to the left of the insulated rail was set after the train had passed over the insulated section then its signal would effectively stay red until the train had gone preventing the next train from entering that section.
Where there are comparators the one shown in my first entry would be connected similar to box 'A' using the in and out connections on the comparator circuit.
I hope this helps.
 

Attachments

Last edited:

eetech00

Joined Jun 8, 2013
2,644
Hi,
I have produced a small section of one of the circuit diagrams, I could attach the whole thing but it is so big even printed on A3 it is hard to read.
It is the 'rail' that is connected, .
The common rail is connected to 0v, the short insulated sections are connected to the circuit as shown on the diagram.
There are no comparators shown on the diagram as in fact there are quite a few signals that are connected direct, same as the diagram.
The 'A's in the grey boxes are not there at present and the wire is connected from one side of the box to the other but they are where copies of the circuit I am asking for would be connected. They could include a comparator or not.
When we first turn everything on all the signals are red, we then press a button (the 'total set'), all the relays make and all the signals go green.
A train travels along the track from the left side resetting and setting each relay as it goes. If the relay to the left of the insulated rail was set after the train had passed over the insulated section then its signal would effectively stay red until the train had gone preventing the next train from entering that section.
Where there are comparators the one shown in my first entry would be connected similar to box 'A' using the in and out connections on the comparator circuit.
I hope this helps.
So...is the original problem that the second train passes a green signal that is supposed to have been set red by the first train?
If so, I can see how that can easily happen since the track section ahead of each signal is not interlocked..

Is this track single direction running only (one way traffic)?
 

eetech00

Joined Jun 8, 2013
2,644
So...here is what I think your trying to design. See simulation below.

I've used 2v@20mA Leds and 24VDC relays. TK1-TK3 represent track shunts that short to ground when the train wheels occupy each section moving from left to right. The simulation shows each relay de-energizing in sequence as the train progresses from left to right. (its a fast train...only takes a few seconds for this simulation):)
The things you should apply to your circuit is:
1. Add a diode across each coil to surpress back EMF. The back EMF can cause the relay (as well as nearby relays) to inadvertently energize (chatter).
2. Add diodes (D4,D5,D6) from the "SET" line to each relay to prevent "back feeds" that can also inadvertently hold/re-energize a relay.
3. I'm unable to determine if the "hold" resistor values are correct without knowing the model of relay you are using.
But they should be small enough to provide enough voltage and allow the relay to energize above the must operate voltage.
4. I don't think comparators are needed.

1625551224748.png
 

LowQCab

Joined Nov 6, 2012
1,307
OK, here ya go ...................
( I forgot to make sure you're talking about 24-Volts DC, and not 24-Volts AC )
.
.
.
relay circuit example..png
.
.
.
relay circuit example 2 ..png
.
.
.
relay circuit example 3 FLAT ..png
.
.
.
Fix for Relays Flat .png
.
.
.
Electronic Relay Replacemrnt FLAT .png.
.
.
 

Thread Starter

matelot

Joined Apr 15, 2013
43
Hi again,
Thanks for the prompt replies.
We use a 24DC supply, the whole system runs on 24v DC.
The relays are mostly 12v omron MY4's 4 pole 4 way.
I must confess I added the 'set' part of the circuit at the last moment to help to understand why the relay contacts are in the 'normal' position when the red light is on and energised when the green light is on.
The routine is to switch on in a safe state, i.e. all the lights red, then set the system when everything is on so all the lights go green. Hopefully if we get a partial problem everything will default to red and safe. I forgot to put diodes in the drawing, they are in place otherwise one engine would 'set' everything.
I don't have diodes across all the relay coils as they were not there in the first place (when I took control) and as there doesn't seem to be a problem I haven't altered it.
There are a total of over 40 relays in the whole circuit.
On the lt spice drawing I don't think the rail will 'set' the relays again?
Your small drawing with the mosfet in is more or less what I have at present if I use the comparator or the circuit I have attached which we have used in a few places where the relays are a long distance from the track.
I don't have a problem with 'intermittent green-light resets?' If the rail is dirty and the train is not at that moment earthing the rail, as long as a signal has been sent and the relays have energised or de-energised the system works.
Would the solid state version with the 555 timer solve my problem and change the light back to green after a train has left the insulated section?
If the red line from the bottom is the track then what are the red and green wires from?
Bear in mind a need it to initially start up on all reds.
Thanks,
Bob.
 

Attachments

eetech00

Joined Jun 8, 2013
2,644
I don't have a problem with 'intermittent green-light resets?' If the rail is dirty and the train is not at that moment earthing the rail, as long as a signal has been sent and the relays have energised or de-energised the system works.
This statement seem contradictory.
The rail is dirty......but the system works.?

So what exactly is the problem?
 

LowQCab

Joined Nov 6, 2012
1,307
1)
DC, good.

2)
The Relays are "4PDT" 4-Pole-Double-Throw.

3)
We've got to get the terms in agreement ........

The word "Set" by its self, means nothing, it's just confusing.

The Relay terms are, NC for Normally-Closed, or, NO for Normally-Open,
and since these Relays are now known to be setup as "Electrically-Self-Latching" Relays,
it now might be appropriate to refer to their states as "Latched" or "Unlatched",
and since these Relays are dedicated to controlling Indicator-Lights,
it would also work to refer to the Relays position by the by the Color of the Indicator,
such as Green-Position, or Red-Position.
It would be even more descriptive to refer to Green-Position as "Latched-Green-Position".
Then everybody knows exactly what is being referred to.
--------------------------------------------------------------------------------------------------------

You still have not stated the rules surrounding the operation of these Indicator-Lights,
and everything you've been getting so far is based on the particular
persons "Best-Guess" as to what the actual problem might be with your system.
--------------------------------------------------------------------------------------------------------

Based on the Schematic Diagram that You supplied, everything should work,
with one exception ................
If the Train is physically longer that the distance between the short "Sensing-Sections" of the Track,
you will have all kinds of weirdness happening.
There is absolutely no way to tell what the outcome of a situation like this might be.
-------------------------------------------------------------------------------------------------------------

Your mention of "Proximity-Sensors" sounded like a good idea,
although I wouldn't use an actual Proximity-Sensor,
I'd simply drill a hole in-between the Track-Ties just big enough to recess a Photo-Transistor,
they're much less fussy than any Proximity-Sensor,
and super easy to use,
and they don't care how long the Train is,
and there's absolutely zero Relays involved.
------------------------------------------------------------------------------------------------------------

"" The routine is to switch on in a safe state, i.e. all the lights red,
then set the system when everything is on so all the lights go green. ""

This sentence makes no sense at all.

Do the Trains Drive themselves ?

What could happen if You turned on the Power and all Lights were Green ?

The Solid-State-Controller I provided has what I thought was a great bonus,
it powers-up Green !!!, and doesn't need a "Master-Reset-Switch".

What does "when everything is on" mean ?

""........ if we get a partial problem everything will default to red and safe. ""
There is no such thing as a "partial-problem", either the system works perfectly,
or it was a compromised design or execution.

Are there actual Human-Lives at risk with this System ???,
You keep saying the word "safe" like somebody might die or be injured.

This is an extravagant Model-Train setup...... Right ???

If You would just clearly state the over-all problem You are trying to solve,
we might get somewhere, (eventually).
--------------------------------------------------------------------------------------------------------

"LT-Spice", who are You talking to ?
---------------------------------------------------------------------------------------------

"" Would the solid state version with the 555 timer solve my problem and
change the light back to green after a train has left the insulated section? ""

I, evidently, don't know what problem You are trying to solve.
With the exceptions of powering-up in the Green-state, and
not requiring a "Master-Reset-Button",
it works exactly like the Relay set-up You provided.
When a new Track-Sensing-Section creates a Ground-Pulse,
the Red-Light Latches "On", and the previous Red-Light is switched to Green.
But my design can't get "Out-of Sync" when
a long Train contacts 2-Track-Sensing-Sections at the same time, which, of course,
could be a huge problem with the original Relay setup.

"" If the red line from the bottom is the track then what are the red and green wires from? ""
If this isn't completely obvious, I don't think I'm going to be able to help You.
---------------------------------------------------------------------------------------------------------

"" Bear in mind a need it to initially start up on all reds. ""
Why ?????
------------------------------------------------------------------------------------------------------------
What is the Delay for ???
good delay.JPG.
.
.
 

Thread Starter

matelot

Joined Apr 15, 2013
43
If this isn't completely obvious, I don't think I'm going to be able to help You.
I think you may be correct.
I am asking if anyone is willing to come up with a small circuit that is driven by 24v DC.
It has one input, the input could be held at 24v by a resistor.
When the input is pulled to 0V nothing happens
When the 0v is removed, bearing in mind it might disappear for very short periods due to a poor input but this will not be more than a second and this is to be ignored, when the input of 0V disappears a pulse of preferably 0V is to appear on the output for about a second.
If the output is a 1 second pulse of 24V this is fine and can be altered by another circuit.
Would someone mind producing a circuit that is capable of doing this please.
Thank you.
 
Last edited:

eetech00

Joined Jun 8, 2013
2,644
I think you may be correct.
I am asking if anyone is willing to come up with a small circuit that is driven by 24v DC.
It has one input, the input could be held at 24v by a resistor.
When the input is pulled to 0V nothing happens
When the 0v is removed, bearing in mind it might disappear for very short periods due to a poor input but this will not be more than a second and this is to be ignored, when the input of 0V disappears a pulse of preferably 0V is to appear on the output for about a second.
If the output is a 1 second pulse of 24V this is fine and can be altered by another circuit.
Would someone mind producing a circuit that is capable of doing this please.
Thank you.
Ok...so here is where things become confusing.

"When the 0v is removed, bearing in mind it might disappear for very short periods due to a poor input but this will not be more than a second and this is to be ignored, when the input of 0V disappears a pulse of preferably 0V is to appear on the output for about a second."

What do you mean disappear?
If the input is held at 24v with a resistor, why would the input "disappear"?

The input to this new "one shot" timer circuit has to be kept at known levels. In this case either 24v or 0v. There would be a threshold value that would trigger the timer to begin "timing". So if the input "disappears", then that implies that the input was at 0v and returned to 24v.
A normal "non-triggered" state would have the input at 24v and the timer output inactive. An input transition from 24v to 0v would trigger the timer and the output would go active for 1 second. A transition from 0v to 24v during timeout would be ignored and the timer will continue to run until timeout completes. When the timeout completes the output goes inactive again.

Is this what you mean? If so, then a 555 monostable (one shot) is desired.

You could wire the timer is such a way that when a signal goes Red, it cannot go green again until a short (1 second) timeout completes.
 
Last edited:

sparky 1

Joined Nov 3, 2018
607
An ideal Vref 2.500 Volts and the sensor you have reads near zero for example 0.01V.
by summing the two values you will get 2.510 by comparing 2.500 and 2.510 you could initiate a set and reset of a 1 second pulse. It is also possible to get a difference of 2.490 once you fix the voltage the op amps are just analog to that constant reference voltage.
 
Last edited:
Top