I know If I google this I'll probably get a load of circuits and such in the results I can take a look at. But what I'm begging for really is for direct feedback on what I "think" I understand already. So I've taken a problem and used the small amount of stuff I believe I understand and come up with a potential solution without looking up any solutions to begin with. If anyone is willing to take the time to look at my circuit and point out any errors I've made It would really help. I am mildly autistic and my learning process is not really what you would call normal, I feel very uncomfortable with practical work until I'm sure I understand the theory.
So the problem is how to create a device that has two momentary buttons one for off and one for on. The actual device's function is not important, it could be a torch or something like that, not anything power hungry.
This is the circuit I've come up with.
U2 is an op-amp buffer and U1 a comparator. I've not assigned any models to these components yet or connected their power pins, I am just trying to see if I've got the basic concept correct.
This is my thinking, feel free to correct me if I've misunderstood anything:
When OFF is pressed, this pulls SIG high. Which causes U1's output to go low, this in turn pulls REF below 6V so when the button is released and SIG retuns to 6V, it is still higher than REF so U1's output stays low. When ON is pressed, this pulls SIG low so U1's output goes high. REF is now pulled above 6V so when the button is released and SIG returns to 6V it is still below REF so U1's output remains high.
When U1's output is high, Q1 turns on, this pulls M1's gate to ground (-12V to source), turning it on and supplying power to the device. When U1's output is low, this turns Q1 off, thus allowing R9 to pull M1's gate to 12V (0V to source) and turning it off cutting power to the device. C1 I'm hoping will momentarily ground the output of U1 on power up to force an OFF condition.
I don't want to disappoint you. But you are in the 'General electronics' section of an Arduino forum.
If you want a solution which does, whatbyou want to achieve, using arduinos, then you are right here.
Looking for a pure electronics solution, ok there are definitely a lot of experts here, but I suggest you jump to a 'pure' electronics forum.
I misunderstood the scope of the forum section. My apologies to all.
Since I have the opportunity, let me change the functionality, as that would be just as valid a learning experience as any.
So to do this with an arduino, or probably just a MC with the arduino bootloader. I'd probably put the ON button on port D2 and the off button on any other port, say D3 for the sake of argument. Then put the MC into low power sleep mode, which would be woken up by an interrupt event on D2. The circuit above would be used as-is except the op-amp and comarator part would be removed and the output of an IO pin, say D7 would be placed where the comparator's output currently is.
On power up, D7 would be set to OUTPUT and LOW and then the MC put to sleep with the wake up event set. Upon wake up, D7 is set to HIGH turning on M1, then just loop looking for an event on D3, when this happens, set D7 LOW again and go back to sleep.
I reckon you should first try simulating the circuit with Microcap or NI MultiSim.
At first glance, when both switches are not pressed (initial conditions)....if the + input of the first op amp is at 6 V. The first op amp is a voltage follower, so the output of that op amp will be 6V. SIG is 6V.
REF goes to 1.9V. C remains discharged at 0V. Output of U1 op-amp is 0V.
Pressing the OFF button makes SIG go up to about 12V. And op-amp U1 output stays at 0V.
Pressing the ON button momentarily, will momentarily make SIG go to about 0.5 V. Op-amp u1 output goes to 12V. Charges C to 12V. REF moves to about 10V. But the ON button is eventually released..... so SIG goes back to 6V, and C probably starts discharging back to 0V. REF gets back to 1.9V again.... and U1 output goes back to 0V. This was just first glance. Probably a poor first glance heheh.
Yeah.... once the required behaviour of the system has been fully defined, it should be possible to use systematic logic design methods (gates and flip flops) to do what you need.