Wiring S-R Flp-flop to arduino

Trying to hook up a 74LS279 to capture the state of Watchdog time.

S - Input will be the reset signal from the watchdog.

R - Input will be a pin on the Arduino coded to reset flip-flop.

Q - Will be the State of the Watchdog timer.

Trying to avoid damaging Arduino/R-S Flip-flop. Guidance in electrical hook-up requested.

Googled looking for examples using Arduino, S-R Flip-flop circuits; search suggestion welcome.

Techno500

SR Flip-flop.JPG|743x673

Hi, Power the 279 with +5V. Levels are compatible with Arduino at +5V

S and R are ACTIVE LOW: So one or the other (not both) should go Low to Set or Reset the flip-flop.

Q is TTL level High when FF is set.

You can code the right level for R But whatif the watchdog is not Active Low? Then you'd need an inverter. Or different logic.

Make sense?

Well that circuit is a gated RS flipflop with the gate connection left open.

What are you trying to do? And why are you trying to do it?

In an Arduino's processor you can not get at the watchdog reset line.

X-Y Problem?

Makes sense.

Thank you Terry. Question; Are resistors required or can the FF be connected directly to Arduino pins. Powering circuit with +5 Volts.

@ Grumpy_Mike

I am using an External Watchdog I log every restart of Web server. Problem is I want to log each restart caused by the External Watchdog. External watchdog works and does reset the Arduino Mega perfectly. Hoping to latch the FF and monitor the State of Q, once reset has occurred; by using a reading an Arduino pin. After reading Q; I want to reset the FF.

Thought I read the SR FF is edge triggered. What did you mean by open Gate?

Techno 500

Are resistors required

No.

What did you mean by open Gate?

That circuit has two gates in front of the flip flop. Two of the inputs ( one on each gate ) are connected together, you can't do just that, there needs to be an output somewhere on that node. This is not an edge triggered flop flop circuit. RS flip flops are not edge triggered. To get an edge triggering you need either a master / slave D-Type or a J/K flip flop.

@Grumpy_Mike

Thanks for setting me straight. The two gates that are tried togather; can you connect a clock signal at this junction? What could the clock input be? I have a pulse that occurs every minute going to the External watchdog.

BTW, I am using SwitchDoc's, "Watchdog Dual Timer:" http://www.switchdoc.com/dual-watchdog-timer/

Techno500

I'd go with 74HC595, lower power draw, easier to operate.

The two gates that are tried togather; can you connect a clock signal at this junction?

Yes that is what you should do.

However it is just used to sample the R & S signals, or stop them getting through until you want. I would not think you needed those front gates just to latch a signal. Note an RS flip flop input gates have two logic states, one is passive and the other is active or driving. You should only drive one of the inputs (R or S ) at any one time. If you drive both at the same time then the output is determinate, however if you remove the two signals at the same time the output of the flip flop is indeterminate, that is you can not determine what it will be. With those input gates you have more of a chance of getting that two driving states being removed at the same time and hence not getting a deterministic circuit. In short, only reset the flip flop when it is not actively being set.

@Grumpy_Mike

What would happen if the ClocK was tried High and S input went Low, R input is 1 -- would this make Q = 1?

S input is only momentary Low, while sending Reset from Watchdog timer; then it goes High (Low = ~ 240 Seconds.).

When I write a 0 to R input of the FF; Q according to my thinking should be 0

After logging Q in its 1 state, I need to write a 0 to the R input of the FF -- Q would go to 0.

Please correct me if this not correct.

|500x452

The 74LS279 is an obsolete part.

It is not really compatible with modern CMOS parts - like an Arduino!

Perhaps most to the point, why not just feed your watchdog directly to the Arduino and let the Arduino do the job of the latch? That is after all, what microcontrollers are for!

What would happen if the ClocK was tried High and S input went Low, R input is 1 -- would this make Q = 1?

If clock were tied high then the input gate would have no effect apart to invert the inputs. So S would not be driving the flip flop but R would and Q would be a zero.

Why are you putting those gates on the input, the 74LS279 is just the flip flop triggered on a low, which is what you are after. Ditch those gates.

The 74LS279 is an obsolete part.

True.

It is not really compatible with modern CMOS parts - like an Arduino!

Not true.

TTL is not directly compatible with the ATmega inputs - they require 3.0V or more for logic high, 74LS only guarantees 2.7V unless you use a pull-up resistor on the output - I doubt the built-in pull-ups are strong enough though, I'd suggest 10k external for LS, 1k external for plain TTL.

Anyway just get a 74HC version of the chip in the first place!

I wrote 74HC595 above, (too used to those #s), what I intended was 74HC74. 46 cents at digikey.com http://www.ti.com/lit/ds/symlink/sn74hc74.pdf

MarkT: TTL is not directly compatible with the ATmega inputs

That makes it sound to a beginner that it will not work, which as you, and I, know is not the case.

It will often work, but not guaranteed === doesn't work when it most matters!

SwitchDoc Lab's, Dual Watch Dog is directly connected to reset pin of the Arduino Mega. I am only trying the RS Flip-Flop to cature the event; so I can log the event to a file (Re-starts of the server from the Watchdog timer.) LOW only exists for ~200 millisecons --output from the Watchdog.

Here is my code; if that will help understand what I am trying to accomplish:

#define ArduinoQ A11 // pin for SR Flip-flop Q State
#define ArduinoReset  A12// pin to reset SR Flip-flop (R Flip-flop input

int value = 0; 



void setup()
{ 
 //Creates an entry in "Server.txt" for every start; when Serial Monitor is opened.
    
    SdFile serverFile;
    serverFile.open("Server.txt", O_RDWR | O_CREAT | O_APPEND);

 //JP3 of Dual Watchdog Timer is connected to the S input of the Flip-flop  ((JP3 = LOW) and (R input = HIGH))  Q= HIGH
 pinMode(ArduinoReset, OUTPUT);  // pin A11 to OUTPUT
 digitalWrite(ArduinoReset, HIGH);  // pin A11 -- R input of flip-flop; toggles Q to 0
 pinMode(ArduinoQ, INPUT);
 value = digitalRead(ArduinoQ);  //pin A12 -- Flip-flop = Q

 Serial.begin(115200);

 if (value = LOW )   //happens too fast!!!!
 {
 if (!serverFile.isOpen()) error("Watchdog Starting Server");
 serverFile.println("Watchdog Starting Server  " + dtStamp);
 Serial.println("Watchdog Starting Server  " + dtStamp);
 serverFile.close();

 digitalWrite(ArduinoReset, LOW);  //pin A11 -- R input of Flip-flop ((JP3 = HIGH) and (R = LOW)) Q = LOW
 }
 else if (value = HIGH)
 {
 if (!serverFile.isOpen()) error("Re-Starting Server");
 serverFile.println("Re-Starting Server:  " + dtStamp);
 Serial.println("Re-Starting Server  " + dtStamp);
 serverFile.close(); 
 } 
}


void loop()
{
}

I am trying to follow; a schematic would be helpful and beneficial to others finding this discussion.

Techno500

MarkT: It will often work, but not guaranteed === doesn't work when it most matters!

No Mark, look at the operating conditions for those figures, you are running them at the extreme when they don't match up. That is something that is not going to happen connecting one Arduino output to one TTL input.

@Techno500 What I don't understand is where that schematic you posted came from. As I said the extra gates are not needed just one quarter of that chip. Also don't make the pin connected to the R into an output until you want to reset the flip flop by giving it a zero on the R input.

@Grump_Mike

The drawing is mine; tried to copy it from a data sheet.

This is the chip I have on-hand:

  1. S input is connected to JP3 of the "Dual Watchdog Timer" When S Input goes LOW, R Input is HIGH, Q will be HIGH

  2. R input will be connected to Arduino Output

  3. Q will be read by Arduino Input

Do I need Pull-Up resistors on the FF Inputs?

Set-Reset Latch.JPG|480x577

The drawing is mine; tried to copy it from a data sheet.

This data sheet? It does not match what you have drawn. See attached data sheet.

When S Input goes LOW, R Input is HIGH, Q will be HIGH

Yes.

  1. R input will be connected to Arduino Output

  2. Q will be read by Arduino Input

OK

Do I need Pull-Up resistors on the FF Inputs?

No.

sn74ls279rev6.pdf (44.1 KB)