/* * This project is a virtual implementation of the TTL coax continuity tester: * https://www.lloydm.net/Demos/logic-1.html * https://www.lloydm.net/Demos/Supplement-Coax_continuity_tester.pdf * Lloyd Milligan (WA4EFS) June 2025 * * © CC attribution - https://creativecommons.org/licenses/by/3.0/us/ */ // Test buttons and coax #define A 2 // Test center #define B 3 // Test shield #define X 4 // Coax center #define Y 5 // Coax shield // Outputs #define L1 10 #define L2 11 #define L3 12 // Time intervals const unsigned long DEBOUNCE = 10; const unsigned long DEBUG_PRINT_WAIT = 5000; // Declare logic variables globally for analysis print boolean C, D, E, F, J, M, N, P, Q; // Input values (1 or 0) int A_value, B_value, X_value, Y_value; // Outputs 5 volts (1) or ground (0) // L1 is 0=ON while L2 and L3 are 1=ON int L1_state, L2_state, L3_state; // Debug unsigned long last_debug_print = 0; void setup() { Serial.begin(9600); // Inputs and outputs pinMode(A, INPUT); pinMode(B, INPUT); pinMode(X, INPUT); pinMode(Y, INPUT); pinMode(L1, OUTPUT); pinMode(L2, OUTPUT); pinMode(L3, OUTPUT); // Serial.print("Setup complete!\n\n"); } void loop() { exerciseLogic(); //debugPrint(); // Uncomment to print logic values } // TTL - Reference circuit uses 7400, 7408, and 7486 boolean ic7408(boolean input_1, boolean input_2) { // 2-input AND return input_1 && input_2; } boolean ic7400(boolean input_1, boolean input_2) { // 2-input NAND return not ic7408(input_1, input_2); } boolean ic7432(boolean input_1, boolean input_2) { // 2-input OR - Not used in TTL circuit return input_1 || input_2; } boolean ic7402(boolean input_1, boolean input_2) { // 2-input NOR - Ditto return not ic7432(input_1, input_2); } boolean ic7486(boolean input_1, boolean input_2) { // 2-input XOR return ic7408(ic7400(input_1, input_2), ic7432(input_1, input_2)); } // Functions isLow() and isHigh() are not used // Test button values are read in exerciseLogic() function boolean isLOW(int button) { // Normally HIGH button pressed = LOW // No minimum button press duration if (digitalRead(button) == HIGH) return false; while (digitalRead(button) == LOW) delay(DEBOUNCE); return true; } boolean isHigh(int button) { // Normally LOW button pressed = HIGH // No minimum button press duration if (digitalRead(button) == LOW) return false; while (digitalRead(button) == HIGH) delay(DEBOUNCE); return true; } void exerciseLogic() { A_value = digitalRead(A); // TTL logic simulation B_value = digitalRead(B); X_value = digitalRead(X); Y_value = digitalRead(Y); // C = ic7400(A_value, X_value); D = ic7400(B_value, Y_value); E = ic7400(X_value, Y_value); // F = ic7408(C, D); Q = ic7486(A_value, B_value); // J = ic7400(E, F); P = ic7400(J, true); // NAND as inverter M = ic7400(P, Q); // N = ic7408(E, Q); // L1_state = ic7408(M, N); L2_state = M; L3_state = E; digitalWrite(L1, L1_state); // Invert output if ON = LOW (false) digitalWrite(L2, L2_state); digitalWrite(L3, L3_state); // } void displayOutput() { // Reserved // In place of LED's // Alternatively output text to an accessory display } void detailPrint() { Serial.print("A = "); Serial.println(A_value); // Internal logic circuit values (analysis) Serial.print("B = "); Serial.println(B_value); // Internal logic circuit values (analysis) Serial.print("C = nand(A, X) = "); Serial.println(C); Serial.print("D = nand(B, Y) = "); Serial.println(D); Serial.print("E = nand(X, Y) = "); Serial.println(E); Serial.print("F = and(C, D) = "); Serial.println(F); Serial.print("J = nand(E, F) = "); Serial.println(J); Serial.print("P = not(J) = "); Serial.println(P); Serial.print("Q = xor(A, B) = "); Serial.println(Q); Serial.print("M = nand(P, Q) = "); Serial.println(M); Serial.print("N = and(E, Q) = "); Serial.println(N); Serial.print("X = "); Serial.println(X_value); // Internal logic circuit values (analysis) Serial.print("Y = "); Serial.println(Y_value); // Internal logic circuit values (analysis) // Serial.print("L1= and(M, N) = "); Serial.print(L1_state); Serial.println(" (Good 1=ON)"); Serial.print("L2= not(M) = "); // LEDs L2 and L3 are sink = on (common +) Serial.print(L2_state); Serial.println(" (Open 0=ON)"); Serial.print("L3= not(E) = "); Serial.print(L3_state); Serial.println(" (Short 0=ON)"); } void debugPrint() { if (millis() > (last_debug_print + DEBUG_PRINT_WAIT)) { last_debug_print = millis(); detailPrint(); Serial.println("----------------------------------------------"); } }