High to Low or Low to High Detection with Reset.

Thread Starter

JonKon

Joined Oct 31, 2017
3
Hello everyone.

I am a Mechanical engineer trying to figure out this electricity thing!

Anyways the characteristics of the circuit I am trying to design are as follows.

12v
I have a magnetic field switch as an input.
I have a momentary push button.
And I am trying to turn on a light.

The kicker is I want the light to turn on and stay on whenever the mag switch goes from low to high or high to low. Then I would like to have the push button turn the light off no matter what state the mag switch is in. I would like the light to stay off until the mag switch changes state again.

I have attached a copy of a relay diagram that should do what I am trying to do but I would like to simplify it with logic gates and have been racking my brain to hard on how to get it done.

For now this a a pet project but eventually I may get some PCBs made for this.

Any help would be appreciated.
 

Attachments

AnalogKid

Joined Aug 1, 2013
11,056
Digital-logic-wise, it goes like this:
Leading edge detector
Trailing edge detector
OR the two detector outputs
Use the combined signal to SET a flipflop
The ff output drives the light
Pushbutton switch drives the ff RESET input

All of this can be done in one logic gate package, like a quad NAND gate or a hex inverterI designed two versions of this circuit for another thread.

Assuming the light runs on the same 12 V as the logic, what is it? Type, current, etc.

What is the output from the magnetic field switch? Manufacturer and part number, datasheet, etc.

To clarify a possible logic bomb, lets assume the switch just went from low to high and turned on the light. If the field goes from high to low before the reset is pushed, does the light stay on or turn off?

ak
 

crutschow

Joined Mar 14, 2008
34,469
Here's the LTspice simulation of a circuit using an XOR gate to generate a pulse on both the leading and trailing edges of the input signal (this assumes a 0-12V signal from the magnetic sensor), and using another gate in the package to latch from the output pulse (there are four XOR gates in one package).
The latch output stays high until reset by the PB switch.

The latch output will likely need a driver transistor and possibly a relay, depending upon what lamp load you have.

upload_2017-11-1_16-36-31.png
 

Attachments

Last edited:

Thread Starter

JonKon

Joined Oct 31, 2017
3
Digital-logic-wise, it goes like this:
Leading edge detector
Trailing edge detector
OR the two detector outputs
Use the combined signal to SET a flipflop
The ff output drives the light
Pushbutton switch drives the ff RESET input

All of this can be done in one logic gate package, like a quad NAND gate or a hex inverterI designed two versions of this circuit for another thread.

Assuming the light runs on the same 12 V as the logic, what is it? Type, current, etc.

What is the output from the magnetic field switch? Manufacturer and part number, datasheet, etc.

To clarify a possible logic bomb, lets assume the switch just went from low to high and turned on the light. If the field goes from high to low before the reset is pushed, does the light stay on or turn off?

ak
The Mag switch will be something like this, 2 leads NO switch. I could go with a 3 lead NO and NC switch (just more cost/work). It will run off the same 12v as the light.

If i need to use a relay to turn on the light, so be it, but if not that would be best.

When the switch changes state the light should stay on until the reset button is pushed.
61X99aqKfAL._SL1001_.jpg

JK
 

AnalogKid

Joined Aug 1, 2013
11,056
Here's the LTspice simulation of a circuit using an XOR gate to generate a pulse on both the leading and trailing edges of the input signal (this assumes a 0-12V signal from the magnetic sensor), and using another gate in the package to latch from the output pulse (there are four XOR gates in one package).
Outstanding minimalist design. But ...

If you change D1 to a 10K resistor and R2 to a 0.1uF capacitor, two things:

1. You won't overstress the U2 output when resetting a high state to a low state.

2. The circuit will not set itself if you release the reset button during a (admittedly brief) U1 output pulse.

ak
 
Last edited:

crutschow

Joined Mar 14, 2008
34,469
If you change D1 to a 10K resistor and R2 to a 0.1uF capacitor, two things:

1. You won't overstress the U2 output when resetting a high state to a low state.
I don't think a microsecond of output short is likely to damage the gate.
They are designed to tolerate momentary output shorts.
2. The circuit will not set itself if you release the reset button during a (admittedly brief) U1 output pulse.
I don't see that as a problem.
And, with capacitor coupling, the simulation shows it being reset by the trailing edge of pulse.
 

Thread Starter

JonKon

Joined Oct 31, 2017
3
Here's the LTspice simulation of a circuit using an XOR gate to generate a pulse on both the leading and trailing edges of the input signal (this assumes a 0-12V signal from the magnetic sensor), and using another gate in the package to latch from the output pulse (there are four XOR gates in one package).
The latch output stays high until reset by the PB switch.

The latch output will likely need a driver transistor and possibly a relay, depending upon what lamp load you have.

View attachment 138452

Roughly 27 Watts for this bulb. Do you think it would still need a relay or could that just be wired to the + on the bulb?

I am a little confused on what is drawn for the mag switch? And why does the PB switch have 4 wires going to it?

Thanks, Beginner
 

philba

Joined Aug 17, 2017
959
If the lamp is 12V then you will either need a relay or a Mosfet.

That switch is how you do switches in ltspice. In a real circuit, it would just be a standard spst switch.

Note that you will have to set up your mag switch with either a pull up or pull down resistor.
 

crutschow

Joined Mar 14, 2008
34,469
Roughly 27 Watts for this bulb. Do you think it would still need a relay or could that just be wired to the + on the bulb?
It will need a transistor or relay.
I am a little confused on what is drawn for the mag switch?
That's just to represent the mag switch signal.
In reality you would connect the mag switch to ground with a 1kΩ resistor in series to +12V or,
connect the switch to +12V with a 1kΩ resistor in series to ground.
In either case the signal is taken from the junction of the switch and resistor.
And why does the PB switch have 4 wires going to it?
That represents the operation of the PB switch.
V2 and the wires to the left of the switch are just for the simulation.
The real switch has two (top and bottom) wires,
 
Last edited:

AnalogKid

Joined Aug 1, 2013
11,056
Any n-channel power MOSFET rated for at least 30 V and 10 A will work. The higher the current rating, the cooler the part will run. The spec to watch is Rdson, resistance from drain to source when on (fully enhanced, the lowest resistance condition). At 12 V the lamp current is 2.25 A, so Rdson x 2.25 = the device power dissipation in watts.

ak
 

crutschow

Joined Mar 14, 2008
34,469
At 12 V the lamp current is 2.25 A, so Rdson x 2.25 = the device power dissipation in watts.
I believe you meant Rdson x 2.25². ;)

To keep the dissipation ≤1W (so no heatsink required) the MOSFET Rdson resistance should be ≤0.2Ω.
 
Last edited:
Top