---
title: "ADC with 8085 using 8255: fan and heater control"
subject: "Instrumentation II"
chapter: 4
key: "semester_5/instrumentation_ii:adc-8255-fan-heater"
source: https://www.bctengineer.com/q/semester_5/instrumentation_ii/adc-8255-fan-heater
site: BCT Engineering
---

# ADC with 8085 using 8255: fan and heater control

Instrumentation II · Chapter 4: Interfacing A/D And D/A Converters

- Asked in: 2068 Chaitra, 8 marks
- Video: [Temperature control using microprocessor](https://www.youtube.com/watch?v=Nxe8D3UHaTg) — Engineering Basics
- Answer checked by Claude Sonnet 5.5 on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_5/instrumentation_ii/adc-8255-fan-heater
- Whole chapter: https://www.bctengineer.com/md/semester_5/instrumentation_ii/chapter-4

## Question

You have to interface ADC with 8085 using 8255A ports. Interface a fan and a heater using opto couplers to derive the I/O devices. If the temperature is less than 10°C, turn on the heater and if the temperature is higher than 35°C, turn on the fan. Use port A of 8255 for transferring digital data output of ADC to the CPU and part C for control signals. Assume that an analog input is present at second input of the multiplexer and a clock input of suitable frequency is available for ADC. Also write an appropriate flow chart and algorithm to facilitate your design. Draw the diagram of your design.

## Short answer

8255 at 80H–83H, control word 91H: port A input (ADC data), port B output (PB0 heater, PB1 fan via optocouplers), PC4 START/ALE, PC5 OE, PC6 ADD A=1, PC0 EOC. ADC channel IN1 (001). Heater on for code <1AH (10°C), fan on for code >5AH (35°C).

## Answer

#### Assumptions
8085 I/O mapped; 8255 at **80H (A), 81H (B), 82H (C), 83H (control)**. ADC0808 (8 channels, 8 bit), analog temperature signal at **channel IN1** (ADD C B A = 001). Sensor LM35 (10 mV/deg C) with amplifier gain 5 so that 0-100 deg C = 0-5 V; 1 count = 0.39 deg C. Heater and fan are driven through opto-couplers (MOC3021 + triac or transistor + relay) from port B.

#### Threshold codes
10 deg C -> 10/100 x 255 = 25.5, take **1AH (26)**.
35 deg C -> 35/100 x 255 = 89.25, take **5AH (90)**.

#### Control word and port use
- Port A: input (ADC data). Port B: output (PB0 = heater, PB1 = fan, via opto-couplers). Port C upper output: PC4 = START/ALE, PC5 = OE, PC6 = ADD A (high). Port C lower input: PC0 = EOC.
- Control word: 1 00 1 0 0 0 1 = 1001 0001 = **91H**.

#### Diagram
```text
 LM35 -> amp -> IN1 --+
                      | ADC0808 -- D0-D7 --> PA0-PA7
 CLK (640 kHz) -------+  START,ALE <-- PC4
                         OE <------- PC5
                         ADD A <---- PC6 (=1), ADD B, C = GND
                         EOC ------> PC0
 8085 <-> 8255 (AD0-7, IOR', IOW', A0, A1, CS')
 PB0 -> [Opto-coupler] -> Heater driver -> Heater
 PB1 -> [Opto-coupler] -> Fan driver -> Fan
```

#### Algorithm
1. Initialise the 8255 (91H); turn heater and fan off.
2. Select channel 1, give START/ALE pulse.
3. Wait for EOC = 1.
4. Enable OE, read port A (temperature code), disable OE.
5. If code < 1AH: heater ON, fan OFF.
6. Else if code > 5AH: fan ON, heater OFF.
7. Else both OFF.
8. Repeat from step 2.

```text
 START -> Init -> Start conversion -> EOC? -no-> wait
   -> Read data -> T < 10 ? -yes-> Heater ON
                        -no-> T > 35 ? -yes-> Fan ON
                                       -no-> both OFF
   -> back to Start conversion
```

#### Program
```text
        MVI A,91H
        OUT 83H
        MVI A,00H
        OUT 81H          ; heater, fan off
LOOP:   MVI A,40H        ; ADD A=1, START=0
        OUT 82H
        MVI A,50H        ; START/ALE = 1
        OUT 82H
        MVI A,40H        ; START = 0 : conversion begins
        OUT 82H
WAIT:   IN 82H
        ANI 01H          ; EOC (PC0)
        JZ WAIT
        MVI A,60H        ; OE = 1
        OUT 82H
        IN 80H           ; read temperature
        MOV B,A
        MVI A,40H        ; OE = 0
        OUT 82H
        MOV A,B
        CPI 1AH
        JC HEAT          ; below 10 C
        CPI 5BH
        JNC FAN          ; above 35 C
        MVI A,00H        ; between: both off
        OUT 81H
        JMP LOOP
HEAT:   MVI A,01H
        OUT 81H
        JMP LOOP
FAN:    MVI A,02H
        OUT 81H
        JMP LOOP
```

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. With 0-100 deg C mapped to 0-255 counts, what code corresponds to 10 deg C?
   A. 5AH
   B. 0AH
   C. 1AH
   D. FFH
   Answer: C. 10/100 x 255 = 25.5, taken as 26 = 1AH. (Key point: Threshold code)

2. Port A input, port B output, upper C output, lower C input (EOC on PC0), mode 0 gives which word?
   A. 91H
   B. 99H
   C. 81H
   D. 93H
   Answer: A. 1001 0001: A in, C upper out, B out, C lower in, giving 91H. (Key point: Control word)

3. What does the program do after reading the temperature code?
   A. Fan on if code below 1AH
   B. Heater on if code below 1AH, fan on if above 5AH, otherwise both off
   C. Both on if above 5AH
   D. Heater on if above 5AH
   Answer: B. Below 10 deg C turns the heater on, above 35 deg C the fan, and in between both are off. (Key point: Decision logic)

4. Why are opto-couplers used between port B and the heater and fan?
   A. To amplify the digital data
   B. To increase clock speed
   C. To convert analog to digital
   D. To isolate the low-voltage 8085 side from the high-power loads
   Answer: D. Opto-couplers give electrical isolation so the loads cannot damage the logic and noise is not fed back. (Key point: Opto-coupler)

## Related in Instrumentation II

- [8-channel ADC interface with 8255 and 8085](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Aadc8-8255-problem) — Instrumentation II, chapter 4
- [ADC at 80H with 8255A: display on port B LEDs](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Aadc-8255-80h-leds) — Instrumentation II, chapter 2
- [8255 at A0A0H: interface and control words](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Appi-a0a0h-control-words) — Instrumentation II, chapter 2
- [8255A at B0H: add port A and B, show on port C](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Appi-b0h-addition) — Instrumentation II, chapter 2
- [Keyboard and printer with 8255A at 4044H](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Akbd-printer-ppi-4044h) — Instrumentation II, chapter 2
- [Interfacing ADC0808 with 8085 using 8255A](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Aadc0808-8255-interface) — Instrumentation II, chapter 4

## Related in other subjects

- [3-phase IM principle; speed less than sync](https://www.bctengineer.com/question.md?key=semester_4%2Felectrical_machine%3Athree-phase-im-principle-slip) — Electrical Machine, chapter 5
- [Detection gain of DSB-AM is less than 1](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Adetection-gain-dsbam-less-than-1) — Communication Systems, chapter 9
- [When terminal voltage is less or more than emf](https://www.bctengineer.com/question.md?key=semester_5%2Felectric_machines_ii%3Aterminal-voltage-less-or-more) — Electric Machines II, chapter 1
- [8085 ALP: transfer data with more than 3 ones](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8085-ones-greater-than-3) — Microprocessor, chapter 2
