Electronic – Help with On/Off Flip Flop Switch

flipflopmicrochipmicrocontrollerrelayswitches

I'm still fairly new to electronics and have been teaching myself as a hobby. Currently I'm working on a project that detects a red laser beam, and once detected will turn AC lights OFF if they're already on, or ON if they're off.

I've got everything working except 2 things:
* open relay if it is closed, close relay if it is open
* not require constant laser source

At the moment it will only turn on while the laser is pointed at the detector.

How would I go about activated or deactivation the relay once the laser is detected for say 200ms? In other words how do I set it up to not require a constant laser source.

Secondly, what would be a good way to detect if the relay is already on or not? I mean I can check and see if the light sensor is active or not, but I'm trying to do this all without an Arduino or other micro controller. So how would I detect if the relay or light sensor is active or not from inside the same circuit, and then perform the opposite action to turn the lights on or off.

Am I going about this the right way or am I missing something?

Any help on this is greatly appreciated.

Thanks

Best Answer

A T-flip-flop memorizes a 1bit state until the next clock edge, and inverts that bit at every clock edge. You can easily build one by putting an HIGH level at both the J and K inputs of a standard JK-flip-flop like the old-fashioned 4027 or the 74HC73.

On the other hand, I don't see why you would want to check whether the relay is excited or not, since it is your detector circuit that controls it, so your circuit "knows" whether it is energizing the relay coil (unless you need to detect failures).

If you use a comparator connected to a circuit which detects the LASER beam, the output of the comparator can be connected to the T-flip-flop input, generating a clock edge every time the beam is detected. For any detection the T-FF will toggle its output, which can be connected, using a suitable interface (a simple transistor used as a switch will do), to the relay. Note that the T-FF will keep its output in the same state (ON/OFF) until the next detection.

EDIT (To incorporate a suggestion from Peter Bennett)

To have a circuit which is reliable and doesn't behave erratically, you should disable the clock of the T-FF for a small time interval after a detection, this to avoid a possible burst of ON/OFF events in the case the beam is waved over the sensor. This can be achieved with a so-called monostable multivibrator (one-shot) between the output of the comparator and the T-FF clock input. The comparator output triggers the one-shot which produces a pulse of given duration and becomes insensible to other transitions until that duration has elapsed. Therefore the T-FF can receive a new clock pulse only after the one-shot delay has ended. You may consider using a 74HC123 for the job.