Flip Flop

Discussion in 'General Electronics Chat' started by Tobias, Sep 24, 2011.

  1. Tobias

    Thread Starter Active Member

    May 19, 2008
    158
    0
    Hello All

    I need to measure the 'timing' of two electric motors in relation to each other. By this I mean, each motor has a 36 tooth wheel. Using a hall effect, I want to know the relationship between rising edges from the 36 tooth wheel.

    So I thought I would use a flip flop. I would then measure the time the flip flop output was high versus low and I would know the timing.

    Take a look at the attached schematic. My problem is when Signal2 is still high and Signal 1 rising edge comes along, the Flip Flop doesn't trigger.

    I am still learning the flip flops. Do I have this wired correctly? Is there a leading edge triggered flip flop so it won't care if Signal2 is still high when Signal1 goes high?

    Attached is the spec sheet for the Flip FLop I am using too.
    Thanks in advance.
     
  2. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    The first mistake is that Vdd is shorted with Vss. This is not right and might blow your power supply.

    The second mistake is that Data 1 has to be connected to Vdd and not Vss.
     
  3. Tobias

    Thread Starter Active Member

    May 19, 2008
    158
    0
    Here you go, I had two traces overlapping so it looked like they were connected and Data is connected too VDD
     
  4. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    The diagram is the same.

    Where is Data 1 connected to?
     
  5. Tobias

    Thread Starter Active Member

    May 19, 2008
    158
    0
    This should do it.

    Data is connected to a 18F4431 PIC chip. Port C.1/CCP2
     
  6. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    Yes, better!

    Where are the signals coming from?

    Any circuit?
     
  7. Tobias

    Thread Starter Active Member

    May 19, 2008
    158
    0
    Signal1 and Signal2 are from two seperate hall effect sensors. The hall effects are sensing a geared wheel.

    When Signal2 is low when Signal1 goes high, all is happy.

    It works fine right now until Signal2 is high (tooth still present in front of sensor) when Signal1 goes from low to high. Which is the right thing for this flip flop to do. It is immediately turning off Data in that scenario. I need a way to trigger a flip flop on the clock and reset pins with just the leading edges from my hall effect sensors so this can't happen.
     
  8. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Have a look at the attached. I'm assuming that you have more than one 4013 handy.

    The key to the whole thing is that the 4013 clock inputs are positive-edge triggered; they'll ignore everything but the leading edge. As soon as U1a or U1b gets set by clocking the Q\ input through the D input, U2a gets preset or cleared, which immediately clears or sets the flip flop that caused the action.

    There is a case for a "glitch"; if both Hall sensors have an output simultaneously as at time 133ms, only one of them will get through. Notice the missing pulse for q-u1a.
     
    Last edited: Sep 24, 2011
  9. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    Expalain again what exactly you want to do please.
     
  10. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    What Tobias is talking about is illustrated by the attached simulation of his circuit.

    If the Hall2 sensor output has the Clear input high when the clock occurs, he's not getting an output.

    In the circuit I came up with, there is still a possibility of a 'tiny' glitch - but in reality, if both Hall sensors trigger simultaneously, you really don't want an output anyway.
     
  11. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    I understand what the problem of his circuit is but I asked what he needs as to be able to help him.

    If he just wants to measure the time delay between the two pulses, he can use a XOR gate.
     
  12. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Not so sure that a simple XOR gate will correct the problem.

    Have a look at the attached. I'm even using pulses with matching ON durations. If the ON durations aren't exactly matched, things go downhill really quickly.
     
    Last edited: Sep 24, 2011
  13. Tobias

    Thread Starter Active Member

    May 19, 2008
    158
    0
    Thank you!!
     
  14. Tobias

    Thread Starter Active Member

    May 19, 2008
    158
    0
    I could use two pins on the PIC to do this but I don't want to tie up two CCP pins. Using the Flip/Flop(s) I am hoping I can just measure one signal, compare the time high to time low and know the degree offset of the two gears on the motors.

    I will give the three Flip/Flop approach a go in the morning. Thanks again.
     
  15. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
  16. Tobias

    Thread Starter Active Member

    May 19, 2008
    158
    0
    I'm using an 18F4431 for the nice PWM functionality, to control four motors, keeping the pairs timed. I will have to look into that part number and maybe integrate it into my board. Thanks again.
     
  17. Tobias

    Thread Starter Active Member

    May 19, 2008
    158
    0
    I finally got to try it out and it works great, thank you!!!
     
  18. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Glad that worked for you. :)
     
Loading...