Skip to main content

DAC square wave generation at 1 kHz

Short answer

Use DAC0800 with two op-amps for 0 to -5V output; 8255 port A drives the DAC, control word 80H. A program sends 00H then FFH to port A with a delay loop (B=67H, 103 counts) giving 500 µs per level, producing a 1 kHz square wave.

Interface a suitable DAC using 8255 PPI to a 8085 microprocessor to generate a square wave oscillating between 0V and -5V having a frequency of 1 KHz. Show the interfacing circuit and the necessary program.

Choice of DAC and assumptions

An 8-bit DAC0800 is used, followed by two op-amp stages (a current-to-voltage converter and a unity-gain inverter). Code 00H then gives 0 V and code FFH gives about -5 V (-4.98 V). The 8085 runs at 3 MHz (T = 0.333 us). The 8255 is I/O mapped at 80H-83H, and port A drives the DAC.

Interfacing circuit

 8085 -- AD0-AD7, IOW', IOR', RESET, A0,A1, CS'(A7=1) -- 8255
 8255 PA0-PA7 --------> DAC0800 D7-D0 (digital input)
 DAC0800: Vref(+) = +5 V via 5 kohm, Vref(-) via 5 kohm to GND  (Iref = 1 mA)
          Iout (pin 4) --> op-amp 1 (741, +/-12 V) with Rf = 5 kohm
                           V1 = +5 V x N/256        (0 to +4.98 V)
          V1 --> op-amp 2, inverting stage (10 kohm / 10 kohm, gain -1)
                           Vout = -5 V x N/256      (0 to -4.98 V)
 N = 00H -> 0 V ;  N = FFH -> -4.98 V (about -5 V)

Control word: port A output, mode 0 (others unused): 1000 0000 = 80H.

Timing calculation

For 1 kHz the period is 1 ms, so each level lasts 0.5 ms = 500 us = 1500 T-states at 3 MHz. Per half-period: MVI A (7) + OUT (10) + CALL (18) + delay + JMP (10, once per cycle). Delay routine: MVI B,n (7) + n x [DCR B (4) + JNZ (10)] - 3 + RET (10) = 14n + 14. One half = 7 + 10 + 18 + 14n + 14 = 49 + 14n T-states. One cycle = 2 x (49 + 14n) + 10 = 108 + 28n. For 3000 T-states (1 ms): 28n = 2892, n = 103.3. Take n = 103 (67H), so the cycle is 2992 T = 997 us and the frequency is 1.003 kHz.

Program

        MVI A,80H
        OUT 83H          ; port A output
START:  MVI A,00H        ; 0 V
        OUT 80H
        CALL DELAY
        MVI A,FFH        ; -5 V (full scale)
        OUT 80H
        CALL DELAY
        JMP START
DELAY:  MVI B,67H        ; n = 103
LOOP:   DCR B
        JNZ LOOP
        RET

Output: a square wave alternating between 0 V and about -5 V (-4.98 V) with 1 kHz frequency and 50% duty cycle.

✓ Answer checked by Claude Sonnet 5.5

All Instrumentation II chapter 4 questions →