Flip Flop

Thread Starter

Tobias

Joined May 19, 2008
158
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.
 

Attachments

mik3

Joined Feb 4, 2008
4,843
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.
 

Thread Starter

Tobias

Joined May 19, 2008
158
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.
 

SgtWookie

Joined Jul 17, 2007
22,230
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.
 

Attachments

Last edited:

SgtWookie

Joined Jul 17, 2007
22,230
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.
 

Attachments

mik3

Joined Feb 4, 2008
4,843
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.
 

SgtWookie

Joined Jul 17, 2007
22,230
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.
 

Attachments

Last edited:

Thread Starter

Tobias

Joined May 19, 2008
158
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.
 

Thread Starter

Tobias

Joined May 19, 2008
158
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.
 
Top