Maker Pro
Maker Pro

D-Type Flip-Flop (74HC74)

AmandaM

May 15, 2015
21
Joined
May 15, 2015
Messages
21
Hello Everyone

I am relatively new to electronics but am a seasoned programmer. I'm currently building a weather station based on the ATMega1284P Microcontroller. My rain gauge is of the tipping bucket style which works by way of a reed-switch. For various reasons I don't want to use an interrupt to detect when the reed-switch activates so I have decided to use a flip-flop. I just happen to have quite a few 74HC74 D-Type flip-flops available so it is convenient to use that IC.

When the rain gauge tips, it sends a pulse to the SET pin of the FF which of course causes Q1 to go HIGH. The Microcontroller then looks at Q1 and if HIGH adds to a counter and then resets the FF. All well and good! The problem with this FF is that it needs GND in order to SET and RESET. This is of course not a problem when setting however, it is a little awkward in code for me to send the reset pin to ground. I would much prefer (cleaner) to send a HIGH signal.

So my question is merely some advise:

I have decided to use a NPN transistor (2N3904) in a switch configuration to reverse the polarity required to reset the FF.
  • 74HC74 Reset Pin to the transistor's Collector
  • Transistor's Emitter to Ground
  • Transistor's Base to the Microcontroller via a 500R resistor
The result, when the transistor's base goes high the FF reset pin is connected straight to ground.

This configuration seems to work perfectly. My question? Is this an acceptable practice or are there hidden issues that I am not considering?

Many thanks
Amanda
 

mofy

Dec 19, 2014
46
Joined
Dec 19, 2014
Messages
46
How is the reset pin held HIGH? Through a resistor?
 

hevans1944

Hop - AC8NS
Jun 21, 2012
4,878
Joined
Jun 21, 2012
Messages
4,878
Sounds okay to me, but why bother? It is trivial for software to invert a logic level. And, as @mofy said, remember to pull the collector of the Reset transistor high with a 10 kΩ resistor. Change your code and save the trouble of adding a transistor and two resistors to the 74HC74 flip-flop.
 

Arouse1973

Adam
Dec 18, 2013
5,178
Joined
Dec 18, 2013
Messages
5,178
Sounds okay to me, but why bother? It is trivial for software to invert a logic level. And, as @mofy said, remember to pull the collector of the Reset transistor high with a 10 kΩ resistor. Change your code and save the trouble of adding a transistor and two resistors to the 74HC74 flip-flop.

Yes I agree with that. I wonder what the reason is for doing it the way he has, he says cleaner?
Adam
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
Too bad you are not using a PIC. Some of the newer ones have an SR latch built in.

Bob
 

Laplace

Apr 4, 2010
1,252
Joined
Apr 4, 2010
Messages
1,252
So you are using a dual D-FF as a single SR-FF, but the SR inputs are active low. You could use cross-coupled NOR gates to get a SR-FF with active high inputs. But any SR-FF will be in an unstable state when both SR inputs are activated. How will you insure that the reed switch input has become inactive before resetting the FF? One approach might be to feed the reed switch signal to the clock input with the D input high; however, debouncing the switch contacts might then become an issue. A delay of a fraction of a second before resetting the FF would solve that.
 

AmandaM

May 15, 2015
21
Joined
May 15, 2015
Messages
21
Thanks everyone. I agree, code can be written to reset the FF via ground but perhaps I should have made it more clear on my original post. I am trying to teach myself electronics so therefore I wanted to experiment with changing logic levels with only electronic components and not software.

I also should have mentioned that I am indeed using pull-up resistors for the set and reset FF pins. I merely wanted to know if there were any issues that I had not considered with this approach. I appreciate all comments.

Many Thanks
Nicola
 

AmandaM

May 15, 2015
21
Joined
May 15, 2015
Messages
21
So you are using a dual D-FF as a single SR-FF, but the SR inputs are active low. You could use cross-coupled NOR gates to get a SR-FF with active high inputs. But any SR-FF will be in an unstable state when both SR inputs are activated. How will you insure that the reed switch input has become inactive before resetting the FF? One approach might be to feed the reed switch signal to the clock input with the D input high; however, debouncing the switch contacts might then become an issue. A delay of a fraction of a second before resetting the FF would solve that.


The pulse from the reed switch occurs so quickly that the Microcontroller could possibly miss the signal, hence why using a FF to "store" the activation. When the rain gauge tips the reed-switch sends a very short pulse so I know it has finished when the Microcontroller resets the FF. It is unlikely that the processor will reset to the FF at exactly the same time as the rain gauge tips again. As previously mentioned, I know that I could use a interrupt to catch the signal but I want to save the interrupt for other sensors.
 

AmandaM

May 15, 2015
21
Joined
May 15, 2015
Messages
21
Yes I agree with that. I wonder what the reason is for doing it the way he has, he says cleaner?
Adam

I know that I must be in the minority being female and interested in electronics but he is actually a she...
 

mofy

Dec 19, 2014
46
Joined
Dec 19, 2014
Messages
46
You seem to have all the bases covered. Just one thing with CMOS, don't leave any inputs floating even in unused parts of a package, tie them either HIGH or LOW. They have a way of oscillating and causing strange resuslts.
 

Arouse1973

Adam
Dec 18, 2013
5,178
Joined
Dec 18, 2013
Messages
5,178
I know that I must be in the minority being female and interested in electronics but he is actually a she...
LOL, sorry about that Amanda. Missed the name. Another reason why people should sign off with their name :)
Thanks
Adam
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
The pulse from the reed switch occurs so quickly that the Microcontroller could possibly miss the signal, hence why using a FF to "store" the activation. When the rain gauge tips the reed-switch sends a very short pulse so I know it has finished when the Microcontroller resets the FF. It is unlikely that the processor will reset to the FF at exactly the same time as the rain gauge tips again. As previously mentioned, I know that I could use a interrupt to catch the signal but I want to save the interrupt for other sensors.
However, the opposite could occur. You might reset the FF while the reed switch is still closed, and it will be set again immediately.

Bob
 

AmandaM

May 15, 2015
21
Joined
May 15, 2015
Messages
21
Thanks everyone, I appreciate the comments.

Be warned - I may ask more newbie questions...

Amanda
 
Top