I'm using an optical sensor to detect a gizmo on a part elevator. Depending on the mode of operation (e.g. loading or unloading) the PLC will either be looking for the sensor to turn off or on to decide when to stop the elevator. The gizmo is a little floppy so it can cause the optical sensor to oscillate between states at the edge of detection. So clearly a de-bounce circuit is required. One that de-bounces both transitions.
The attached image is what I'm using and it works but I'm always interested in finding more elegant/efficient ways to do things. Have I made this more complicated than necessary or is this about the best that can be done?
Edit: By the way, the 2 second setting for the timer is just to make it easier to watch the behavior. The actual timer is 100ms