Programma Completo Annotato
; ============================================ ; Interfaccia Relè per Microprocessore 8085 ; Attiva relè per 5 secondi, poi lo disattiva ; ============================================ ; --- Equati --- RELAY_PORT EQU 08H ; Indirizzo porta di uscita DELAY_COUNT EQU 05H ; Cicli da 5 secondi (esterno) ; --- Programma Principale --- ORG 1000H ; Indirizzo di avvio tipico START: MVI A, 00H ; Azzera accumulatore OUT RELAY_PORT ; Assicura relè spento inizialmente MVI A, 01H ; Schema relè acceso (bit 0 = 1) OUT RELAY_PORT ; Attiva relè ; --- Ritardo di 5 Secondi --- MVI B, DELAY_COUNT ; Ciclo esterno = 5 OUTER: CALL DELAY_1SEC ; Subroutine ritardo 1 secondo DCR B ; Decrementa contatore JNZ OUTER ; Ripeti finché B=0 MVI A, 00H ; Schema relè spento OUT RELAY_PORT ; Disattiva relè HLT ; Ferma CPU ; --- Subroutine Ritardo 1 Secondo (approx, clock 3 MHz) --- DELAY_1SEC: LXI H, 0F424H ; 62.500 decimale (3M/48 ≈ 1s) DELAY_LOOP: DCX H ; 6 T-states MOV A, H ; 4 T ORA L ; 4 T JNZ DELAY_LOOP ; 10/7 T RET ; 10 T END
Spiegazione
- RELAY_PORT (08H): Collega il driver del relè (transistor + diodo) al bit 0 di questa porta.
- OUT RELAY_PORT: Invia l'accumulatore alla porta — eccita la bobina del relè.
- Ritardo:
DELAY_1SEC usa la coppia di registri HL come contatore a 16 bit. A 3 MHz, 62.500 cicli ≈ 1 secondo. Il ciclo esterno esegue 5 iterazioni. - HLT: Ferma il processore; il relè rimane spento.
Note Hardware
- Usa ULN2803 o 2N2222 + 1N4007 attraverso la bobina.
- La porta 08H deve essere decodificata per scrittura.
- Regola la costante di ritardo in base alla tua frequenza di clock.