Back to the 2026 paper

Module 3: Embedded Microcontrollers – PIC18F / Others

20267m

Describe ADC and DAC interfacing with a microcontroller. Compare SPI and I2C communication.

Worked SolutionAI Assisted

ADC and DAC Interfacing with a Microcontroller

ADC interfacing

MermaidDiagram
Rendering diagram…
  • On-chip ADC (PIC18F): 10-bit, multiplexed analog pins. Steps: set pin as analog, select channel, set Vref and acquisition time, start conversion (GO/DONE), wait for completion, read ADRESH:ADRESL.
  • External ADC: (e.g. MCP3208 over SPI) used when higher resolution or more channels are needed.
  • Digital value: D=(Vin/Vref)×(2n−1)D = (V_{in}/V_{ref}) \times (2^n - 1).

DAC interfacing

MermaidDiagram
Rendering diagram…
  • Parallel DAC (DAC0808) connected to a port, or serial DAC (MCP4921 on SPI, MCP4725 on I2C).
  • Microcontroller writes the code; output Vout=Vref⋅D/2nV_{out} = V_{ref}\cdot D/2^n; an op-amp buffers it.
  • Uses: waveform generation, motor speed, calibration.

SPI vs I2C

Point SPI I2C
Lines 4 (MOSI, MISO, SCK, CS) 2 (SDA, SCL)
Speed Faster (10 MHz or more) 100 kHz, 400 kHz, 3.4 MHz
Addressing Chip select per slave 7-bit address in protocol
Duplex Full duplex Half duplex
Devices Few (more CS lines) Many on one bus
Complexity Simple hardware Protocol overhead, ACK
Use ADC, SD card, display EEPROM, RTC, sensors

Exam tip

Explain the ADC steps on PIC18F and finish with the SPI vs I2C table.

Similar questions

Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.