0
\$\begingroup\$

Background

For a while now I've been trying to come up with a simple module to handle modulated light detection for part of a laser trip sensor. Initial attempts I wanted to use a dual op-amp as an RC Oscillator and a comparator but could never get the circuit to work. Now while reading up on logic gates and flip flops I thought I could use those to accomplish the same this. Initially I thought it would use two JK flip flops and several logic gates but ended up finding something far more simple.

Question

Can I use nothing more than a D flip-flop to detect if the pulse I'm receiving is that same as the one emitted? Here is the circuit simulated in CircuitJS. A little bit of hand waving is required do to simplification and shortcomings in the sim but assume that clk is the PWM being fed into a MOSFET powering the laser diode and the switch represents a phototransitor either receiving the laser light while closed or the beam being broken when opened. The inverter is to trigger an interrupt on break.

Falstad circuit simulation

\$\endgroup\$
  • \$\begingroup\$ You just want to capture high going pulse when Photo-transistor stroked by light?, can you please tell me simple behaviour what you want? \$\endgroup\$ – Prakash Darji Mar 29 '16 at 8:14
  • \$\begingroup\$ No, I want to capture if they are in phase together. When just detecting if it's high vs. low other light causes interference. \$\endgroup\$ – Morgan ARR Allen Mar 29 '16 at 8:18
  • \$\begingroup\$ means posedge of PWM clock and ON SWITCH perform at same time, you want to capture that condition. right? \$\endgroup\$ – Prakash Darji Mar 29 '16 at 8:25
  • 1
    \$\begingroup\$ "I've been trying to come up with a simple module to handle PWM detector for part of a laser trip detector." Your introduction is unclear. What do you mean by "PWM detector" and "laser trip detector"? "... detect if the pulse I'm receiving is that same as the one emitted". Why wouldn't it be? What is the context of your question? i.e. What are you making? \$\endgroup\$ – Transistor Mar 29 '16 at 12:29
  • 1
    \$\begingroup\$ Two problems. Firstly the input appears to be floating when the "transistor" is off, which may cause you to get weird results. Secondly and more critically, you are highly likely to violate the setup/hold times of the register which can make the output go metastable (be in both states at once, or oscillate between the two). \$\endgroup\$ – Tom Carpenter Mar 31 '16 at 7:13
1
\$\begingroup\$

If I understand the question, take the "clk" to one input of an XOR and the phototransistor - suitably biased - to the other XOR input. When "in sync" the output will be zero most of the time, except for delay between the "clk" and the sensor. A low-pass, perhaps an RC, followed by a schmitt trigger will tell if the signals are "in-sync" most of the time or not. If the delay is a large fraction of the "clk" period, then other circuitry would be required.

\$\endgroup\$
0
\$\begingroup\$

The phototransistor and laser will have some delay (perhaps few us for the phototransistor; laser delay depends on the driver). The DFF needs some setup time (D steady before CLK), so your circuit as drawn won't work.

If you drive D from the phototransistor (not 'through' the CLK signal as you have), and add a delay to CLK (R & C might be fine; then need to square up the edges with a couple of inverters), it will work.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.