Hello! As the title suggests, I'm programming a 74-series chip tester to help clean out a drawer of them.
While working on the testing suite for a d-type flip flop (SN74LS74), I have had problems checking the "clear" function on the flip flops.
The first bit of code I've pasted below is meant to check both the PRESET and CLR functions. The other pin is always held high. Admittedly the function is named poorly, as the bool "isPreset" lets me test whether both PRESET and CLR are working. When CLR is low, Q should be forced low and notQ should be forced high. When PRESET is low, Q should forced high and notQ should be forced low. Manipulating "isPreset" lets me differentiate between the two.
*/
bool presetCheck(bool isPreset, unsigned input, unsigned q, unsigned notq)
{
//write pin low
digitalWrite(input, LOW);
//check q
bool result1 = (digitalRead(q) == isPreset);
//check notq
bool result2 = (digitalRead(notq) == !isPreset);
bool result = result1 && result2;
result = result && 1;
digitalWrite(input, HIGH);
return result;
}
Then, when I call the function below, I check both the preset and clear function by changing the input boolean. The first call works (successfully checks preset). However, regardless of whether the input boolean to the second call is true or false, it always returns false to both result1 AND result2. This seems strange to me for two reasons.
- Why would the preset case work perfectly fine and clear not work
- How is it that switching the input boolean yields the same output for the same gate?
I've changed the order of the code, replaced variables with explicit numbers, etc., and still get the same problem. Is there a clear mistake that I am making?
if (!result) {
return false;
} else{
result = result && presetCheck(true, notpre, q, notq);
Serial.print("check pre: ");
printer(result);
result = result && presetCheck(false, notclr, q, notq);
Serial.print("check clr: ");
printer(result);
return result;
}
}

