Connect with us

D-Type Flip-Flop (74HC74)

Discussion in 'General Electronics Discussion' started by AmandaM, May 15, 2015.

  1. AmandaM

    AmandaM

    21
    3
    May 15, 2015
    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
     
  2. mofy

    mofy

    46
    14
    Dec 19, 2014
    How is the reset pin held HIGH? Through a resistor?
     
  3. hevans1944

    hevans1944 Hop - AC8NS

    4,231
    1,995
    Jun 21, 2012
    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.
     
    Harald Kapp likes this.
  4. Arouse1973

    Arouse1973 Adam

    5,164
    1,078
    Dec 18, 2013
    Yes I agree with that. I wonder what the reason is for doing it the way he has, he says cleaner?
    Adam
     
  5. BobK

    BobK

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

    Bob
     
    Arouse1973 likes this.
  6. Laplace

    Laplace

    1,252
    184
    Apr 4, 2010
    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.
     
    Arouse1973 likes this.
  7. AmandaM

    AmandaM

    21
    3
    May 15, 2015
    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
     
  8. AmandaM

    AmandaM

    21
    3
    May 15, 2015
    Yes, I am using two 10K resistors to keep both the set and reset pins high.
     
  9. AmandaM

    AmandaM

    21
    3
    May 15, 2015

    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.
     
  10. AmandaM

    AmandaM

    21
    3
    May 15, 2015
    I know that I must be in the minority being female and interested in electronics but he is actually a she...
     
  11. mofy

    mofy

    46
    14
    Dec 19, 2014
    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.
     
    AmandaM likes this.
  12. Arouse1973

    Arouse1973 Adam

    5,164
    1,078
    Dec 18, 2013
    LOL, sorry about that Amanda. Missed the name. Another reason why people should sign off with their name :)
    Thanks
    Adam
     
    AmandaM likes this.
  13. BobK

    BobK

    7,631
    1,657
    Jan 5, 2010
    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
     
  14. AmandaM

    AmandaM

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

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

    Amanda
     
    Arouse1973 likes this.
  15. Arouse1973

    Arouse1973 Adam

    5,164
    1,078
    Dec 18, 2013
    Bring it on! Look forward to it.
    Adam
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-