Signal Conditioning and Data Acquisition System

117603
Back to Signal Conditioning and Data Acquisition System

Module 3: Embedded Microcontrollers – PIC18F / Others

  1. Q1(e). Which of the following is NOT part of a typical microcontroller? (i) CPU (ii) RAM (iii) I/O Ports (iv) Hard Disk2025?m

    Module 3: Embedded Microcontrollers – PIC18F / Others

    Which of the following is NOT part of a typical microcontroller?
    (i) CPU
    (ii) RAM
    (iii) I/O Ports
    (iv) Hard Disk

    View this question on its own page →
    Worked Solution

    Answer

    Correct option: (iv) Hard Disk

    Explanation

    A typical microcontroller integrates essential computing and control resources on a single chip, such as:

    • CPU: Executes program instructions.
    • RAM: Temporarily stores variables and runtime data.
    • I/O ports: Interface with sensors, actuators and external devices.
    • Timers/counters: Generate timing functions and count events.
    • Peripherals: May include ADC, communication interfaces, PWM and other modules.

    A hard disk is a separate mass-storage device and is not normally an integrated component of a microcontroller.

    Therefore, the correct answer is (iv).

  2. Q1(f). A timer in a microcontroller counts: (i) External pulses only (ii) Internal clock pulses (iii) Code instructions (iv) Data bytes2025?m

    Module 3: Embedded Microcontrollers – PIC18F / Others

    A timer in a microcontroller counts:
    (i) External pulses only
    (ii) Internal clock pulses
    (iii) Code instructions
    (iv) Data bytes

    View this question on its own page →
    Worked Solution

    Answer

    Correct option: (ii) Internal clock pulses

    Explanation

    A timer in a microcontroller is generally driven by the internal system clock or a clock derived from it. It increments its count at regular intervals and is used for generating delays, measuring time intervals, scheduling tasks and producing periodic events.

    A counter can instead be configured to count external events or pulses.

    Example

    If a timer receives a 1 MHz clock, one clock period is:

    T=11MHz=1μsT = \frac{1}{1\,MHz} = 1\,\mu s

    The timer can therefore measure time by counting these clock periods.

    Therefore, the correct answer is (ii).

  3. Q1(g). RISC microcontrollers are characterized by: (i) Many complex instructions (ii) Simple and fast instructions (iii) No registers (iv) Only analog operations2025?m

    Module 3: Embedded Microcontrollers – PIC18F / Others

    RISC microcontrollers are characterized by:
    (i) Many complex instructions
    (ii) Simple and fast instructions
    (iii) No registers
    (iv) Only analog operations

    View this question on its own page →
    Worked Solution

    Answer

    Correct option: (ii) Simple and fast instructions

    Explanation

    RISC (Reduced Instruction Set Computer) microcontrollers use a relatively small and simple instruction set. Instructions are designed to execute efficiently, often in a small number of clock cycles.

    Main characteristics of RISC

    • Small and simple instruction set.
    • Fast instruction execution.
    • Large or efficient register usage.
    • Simple instruction formats.
    • Efficient pipelining in many architectures.
    • Suitable for embedded real-time applications.

    This approach makes the processor easier to implement and can provide high performance for a given clock frequency.

    Therefore, the correct answer is (ii).

  4. Q4(b). Explain the architecture of a microcontroller with neat block diagram. Describe the basics of assembly language and C-language programming used for microcontrollers.20257m

    Module 3: Embedded Microcontrollers – PIC18F / Others

    Explain the architecture of a microcontroller with neat block diagram. Describe the basics of assembly language and C-language programming used for microcontrollers.

    View this question on its own page →
    Worked Solution

    Solution: Microcontroller Architecture, Assembly and C Programming

    Microcontroller Architecture

    A microcontroller is a compact integrated circuit containing a processor, memory, I/O and peripherals for embedded control applications.

                  ┌─────────────────────┐
                  │        CPU          │
                  │ ALU + Control Unit  │
                  │ Registers           │
                  └──────────┬──────────┘
                             │ System Bus
            ┌────────────────┼────────────────┐
            ↓                ↓                ↓
       Program Memory    Data Memory       I/O Ports
       Flash/ROM         RAM/EEPROM        GPIO
            │                │                │
            └────────────────┼────────────────┘
                             ↓
                  Timers / Counters
                  ADC / PWM / DAC
                  SPI / I²C / UART
    

    Major blocks

    • CPU: Executes instructions.
    • ALU: Performs arithmetic and logical operations.
    • Registers: High-speed temporary storage.
    • Program memory: Stores firmware.
    • RAM: Stores temporary variables and stack data.
    • EEPROM/Flash: Stores non-volatile data or program code.
    • GPIO: Interfaces with external sensors and actuators.
    • Timers/Counters: Generate delays and measure/count events.
    • ADC/DAC/PWM: Interface between digital electronics and analog systems.
    • Communication peripherals: SPI, I²C, UART/USART and others.

    Assembly Language Programming

    Assembly language uses processor-specific mnemonics representing machine instructions.

    Example:

    MOVLW 05H
    MOVWF COUNT
    INCF  COUNT, F
    

    The exact instructions depend on the microcontroller architecture.

    Advantages

    • Precise hardware control.
    • Efficient execution.
    • Small and predictable code.

    Limitations

    • Difficult to write and maintain for large applications.
    • Processor-specific.

    C Language Programming

    C provides structured, readable programming while still allowing direct hardware control through registers, pointers and bit operations.

    Example:

    #include <stdint.h>
    
    int main(void)
    {
        uint8_t count = 0;
        while (1)
        {
            count++;
        }
    }
    

    In practical firmware, initialization functions configure clocks, GPIO, ADC, timers and communication peripherals before the main loop executes.

    Assembly vs C

    Feature Assembly C
    Readability Low High
    Hardware control Very direct Direct through registers/APIs
    Portability Low Higher
    Development time Longer Shorter
    Optimization Can be highly optimized Compiler-dependent

    Conclusion

    A microcontroller combines processing, memory and peripherals in one device. Assembly provides low-level control, while C provides a practical balance of performance, readability and portability for embedded DAQ applications.

  5. Q5(a). Describe the working of ADC and DAC in a microcontroller system with examples.20257m

    Module 3: Embedded Microcontrollers – PIC18F / Others

    Describe the working of ADC and DAC in a microcontroller system with examples.

    View this question on its own page →
    Worked Solution

    Solution: ADC and DAC in a Microcontroller System

    ADC: Analog-to-Digital Converter

    An ADC converts an analog voltage into a digital code that a microcontroller can process.

    Working

    Analog Sensor → Signal Conditioning → ADC → Digital Code → CPU
    
    1. The analog signal is applied to the ADC input.
    2. The ADC samples the signal.
    3. The input range is divided into discrete levels.
    4. The nearest digital code is generated.
    5. The microcontroller reads the code and converts it into engineering units.

    For an ideal nn-bit ADC with input range VFSV_{FS}:

    LSB=VFS2nLSB = \frac{V_{FS}}{2^n}

    Approximately, the ADC code is:

    CodeVinVFS(2n1)Code \approx \frac{V_{in}}{V_{FS}}(2^n-1)

    Example

    For a 10-bit ADC with 0–5 V input:

    LSB51024=4.883 mVLSB \approx \frac{5}{1024}=4.883\text{ mV}

    DAC: Digital-to-Analog Converter

    A DAC converts a digital number generated by the microcontroller into an analog voltage or current.

    CPU → Digital Code → DAC → Analog Voltage → Actuator
    

    For an ideal nn-bit voltage DAC with reference VrefV_{ref}:

    VoutCode2n1VrefV_{out}\approx\frac{Code}{2^n-1}V_{ref}

    The exact transfer equation depends on the DAC architecture and datasheet conventions.

    Applications

    • ADC: temperature, pressure, light and biomedical sensors.
    • DAC: waveform generation, motor control references, audio and analog actuator control.

    ADC vs DAC

    Feature ADC DAC
    Conversion Analog → Digital Digital → Analog
    Input Voltage/current Digital code
    Output Digital code Analog voltage/current
    Use Measurement Control/output generation

    Conclusion

    ADC enables the microcontroller to measure the physical world, while DAC enables it to generate controlled analog outputs.