Skip to main content
  1. Resources/
  2. Study Materials/
  3. Electronics & Communication Engineering/
  4. ECE Semester 5/

Embedded System & Microcontroller Application (4351102) - Winter 2024 Solution

19 mins· ·
Study-Material Solutions Embedded-System 4351102 2024 Winter
Milav Dabgar
Author
Milav Dabgar
Experienced lecturer in the electrical and electronic manufacturing industry. Skilled in Embedded Systems, Image Processing, Data Science, MATLAB, Python, STM32. Strong education professional with a Master’s degree in Communication Systems Engineering from L.D. College of Engineering - Ahmedabad.
Table of Contents

Question 1(a) [3 marks]
#

State the features of ATmega32.

Answer:

FeatureDescription
Architecture8-bit RISC processor
Memory32KB Flash, 2KB SRAM, 1KB EEPROM
I/O Ports32 programmable I/O pins
Timers3 timers (Timer0, Timer1, Timer2)
ADC10-bit, 8-channel ADC
CommunicationUSART, SPI, I2C (TWI)
  • High Performance: 16 MIPS at 16MHz
  • Low Power: Multiple sleep modes
  • Operating Voltage: 2.7V to 5.5V

Mnemonic: “ARM-TIC” (Architecture-RISC, Memory-32KB, Timers-3, I/O-32pins, Communication-3types)


Question 1(b) [4 marks]
#

Explain criteria for choosing microcontroller.

Answer:

CriteriaConsideration
PerformanceSpeed, instruction set, architecture
MemoryRAM, ROM, EEPROM requirements
I/O RequirementsNumber of pins, special functions
Power ConsumptionBattery life, sleep modes
CostUnit price, development cost
Development ToolsCompiler, debugger availability
  • Application Requirements: Real-time constraints, processing needs
  • Package Size: Space limitations in final product
  • Peripheral Support: ADC, timers, communication interfaces

Mnemonic: “PM-IPCD” (Performance, Memory, I/O, Power, Cost, Development)


Question 1(c) [7 marks]
#

Define the Embedded System. List the Application of Small, Medium, Large Embedded System.

Answer:

Definition: Embedded system is a computer system with dedicated function within a larger mechanical or electrical system, designed to perform specific tasks with real-time constraints.

Applications Table:

System TypeMemory SizeApplications
Small Scale<64KBCalculator, Digital watch, Toys
Medium Scale64KB-1MBMobile phones, Routers, Printers
Large Scale>1MBAutomobiles, Aircraft systems, Satellites
graph TD
    A[Embedded System] --> B[Small Scale]
    A --> C[Medium Scale]  
    A --> D[Large Scale]
    B --> E[Calculator
Digital Watch
Remote Control] C --> F[Mobile Phone
Router
Printer] D --> G[Car ECU
Aircraft Control
Medical Equipment]

Characteristics:

  • Real-time Operation: Predictable response times
  • Resource Constraints: Limited memory and processing power
  • Dedicated Functionality: Single-purpose design

Mnemonic: “SML-CMP” (Small-Calculator/Medium-Mobile/Large-Lifesupport)


Question 1(c) OR [7 marks]
#

Draw and explain general block diagram of embedded system.

Answer:

graph TB
    A[Input Interface] --> B[Processor/Controller]
    B --> C[Output Interface]
    B --> D[Memory
RAM/ROM/EEPROM] B --> E[Communication
Interface] F[Sensors] --> A C --> G[Actuators/Display] E --> H[External Systems] I[Power Supply] --> B

Block Functions:

BlockFunction
ProcessorCentral processing unit (CPU/MCU)
Input InterfaceSensor data acquisition, user input
Output InterfaceActuator control, display output
MemoryProgram storage, data storage
CommunicationExternal system connectivity
  • Input Processing: ADC, digital input conditioning
  • Output Control: PWM, relay drivers, LED displays
  • Power Management: Voltage regulation, power optimization

Mnemonic: “PIOMCP” (Processor, Input, Output, Memory, Communication, Power)


Question 2(a) [3 marks]
#

Write a Full form of EEPROM and explain EEPROM registers.

Answer:

Full Form: Electrically Erasable Programmable Read-Only Memory

EEPROM Registers:

RegisterFunction
EEAREEPROM Address Register
EEDREEPROM Data Register
EECREEPROM Control Register
  • EEAR: Holds 10-bit address (0-1023) for EEPROM access
  • EEDR: Data register for read/write operations
  • EECR: Control bits - EERE (Read Enable), EEWE (Write Enable)

Mnemonic: “AAD-CRE” (Address-EEAR, Data-EEDR, Control-EECR)


Question 2(b) [4 marks]
#

Explain reset circuits for ATmega32

Answer:

Reset Sources Table:

Reset TypeTrigger Condition
Power-on ResetVCC rises above threshold
External ResetRESET pin pulled low
Brown-out ResetVCC falls below threshold
Watchdog ResetWatchdog timer overflow
graph LR
    A[Power-on] --> E[Reset Vector]
    B[External Pin] --> E
    C[Brown-out] --> E
    D[Watchdog] --> E
    E --> F[Program Counter = 0x0000]
  • Reset Duration: Minimum 2 clock cycles
  • Reset Vector: Program execution starts from address 0x0000
  • Hardware Connection: External reset requires pull-up resistor

Mnemonic: “PEBW” (Power-on, External, Brown-out, Watchdog)


Question 2(c) [7 marks]
#

Define Real Time Operating System and explain its characteristics.

Answer:

Definition: Real Time Operating System (RTOS) is an operating system designed to handle real-time applications with strict timing constraints and predictable response times.

Characteristics Table:

CharacteristicDescription
DeterministicPredictable execution times
PreemptiveHigher priority tasks interrupt lower ones
MultitaskingMultiple tasks execution
Fast ResponseMinimal interrupt latency
Priority-basedTask scheduling based on priority
Resource ManagementEfficient memory and CPU usage
graph TD
    A[RTOS] --> B[Hard Real-time]
    A --> C[Soft Real-time]
    B --> D[Strict Deadlines
Safety Critical] C --> E[Flexible Deadlines
Performance Critical]
  • Task Scheduling: Round-robin, priority-based algorithms
  • Inter-task Communication: Semaphores, message queues
  • Memory Management: Static allocation for predictability

Mnemonic: “DPM-FPR” (Deterministic, Preemptive, Multitasking, Fast, Priority, Resource)


Question 2(a) OR [3 marks]
#

Explain AVR family.

Answer:

AVR Family Classification:

AVR TypeFeatures
ATtiny8-32 pins, basic features
ATmega28-100 pins, full features
ATxmegaAdvanced features, DMA
  • Architecture: 8-bit RISC, Harvard architecture
  • Instruction Set: 130+ instructions, single cycle execution
  • Memory: Flash program memory, SRAM, EEPROM

Mnemonic: “TAX” (Tiny-basic, mega-full, Xmega-advanced)


Question 2(b) OR [4 marks]
#

Explain the use of fuse bits for selection of ATmega32 clock sources.

Answer:

Clock Source Selection:

Fuse BitsClock Source
CKSEL3:0Clock source selection
SUT1:0Start-up time selection

Clock Options Table:

CKSEL ValueClock SourceFrequency
0001External Crystal1-8 MHz
0010External Crystal8+ MHz
0100Internal RC8 MHz
0000External ClockUser defined
  • Crystal Selection: Requires external crystal and capacitors
  • RC Oscillator: Built-in, less accurate but convenient
  • Start-up Time: Allows crystal stabilization

Mnemonic: “CRIS” (Crystal, RC, Internal, Start-up)


Question 2(c) OR [7 marks]
#

Draw ATmega32 pin configuration and explain function of MISO, MOSI, SCK & AREF Pin.

Answer:

MMOISSSCIOKRXXPPPPPEVGTTBBBBBPPPSCNAA01234BBBECDLL567T211234567891111012343333333333220987654321098PPPPPPPPAGAPPAAAAAAAARNVCC01234567EDC76FC

Pin Functions Table:

PinFunctionDescription
MOSIMaster Out Slave InSPI data output from master
MISOMaster In Slave OutSPI data input to master
SCKSerial ClockSPI clock signal
AREFAnalog ReferenceADC reference voltage
  • SPI Communication: MOSI, MISO, SCK work together for serial data transfer
  • ADC Reference: AREF provides stable voltage reference for ADC conversion
  • Pin Multiplexing: These pins have alternate functions as GPIO

Mnemonic: “MMS-A” (MOSI-out, MISO-in, SCK-clock, AREF-reference)


Question 3(a) [3 marks]
#

Explain Role of DDR I/O Register

Answer:

DDR (Data Direction Register) Functions:

Bit ValuePin Configuration
0Input pin
1Output pin
  • Port Control: Each port has corresponding DDR (DDRA, DDRB, DDRC, DDRD)
  • Bit-wise Control: Individual pin direction control
  • Default State: All pins input (DDR = 0x00) after reset

Code Example:

DDRA = 0xFF;  // All Port A pins as output
DDRB = 0x0F;  // PB0-PB3 output, PB4-PB7 input

Mnemonic: “DDR-IO” (Data Direction Register controls Input/Output)


Question 3(b) [4 marks]
#

Write an AVR C program to get a byte of data from Port B, and then send it to Port C.

Answer:

#include <avr/io.h>

int main(void)
{
    unsigned char data;
    
    // Configure Port B as input
    DDRB = 0x00;
    
    // Configure Port C as output  
    DDRC = 0xFF;
    
    while(1)
    {
        // Read data from Port B
        data = PINB;
        
        // Send data to Port C
        PORTC = data;
    }
    
    return 0;
}

Program Explanation:

  • DDRB = 0x00: Sets all Port B pins as input
  • DDRC = 0xFF: Sets all Port C pins as output
  • PINB: Reads current state of Port B pins
  • PORTC: Writes data to Port C output pins

Mnemonic: “RSTO” (Read-PINB, Set-DDR, Transfer-data, Output-PORTC)


Question 3(c) [7 marks]
#

A door sensor is connected to the port B pin 1, and an LED is connected to port C pin7. Write an AVR C program to monitor the door sensor and, when it opens, turn on the LED.

Answer:

#include <avr/io.h>

int main(void)
{
    // Configure PB1 as input (door sensor)
    DDRB &= ~(1<<1);  // Clear bit 1
    
    // Configure PC7 as output (LED)
    DDRC |= (1<<7);   // Set bit 7
    
    // Enable pull-up for PB1
    PORTB |= (1<<1);
    
    while(1)
    {
        // Check door sensor status
        if(PINB & (1<<1))
        {
            // Door closed - turn off LED
            PORTC &= ~(1<<7);
        }
        else
        {
            // Door open - turn on LED  
            PORTC |= (1<<7);
        }
    }
    
    return 0;
}

Hardware Connection:

  • Door Sensor: Connected between PB1 and GND
  • LED: Connected to PC7 through current limiting resistor
  • Pull-up: Internal pull-up enabled for PB1

Program Logic:

  • Sensor Closed: PB1 = HIGH, LED OFF
  • Sensor Open: PB1 = LOW, LED ON

Mnemonic: “DCOL” (Door-sensor, Configure-pins, Open-check, LED-control)


Question 3(a) OR [3 marks]
#

Discuss Data Types in AVR C programming.

Answer:

AVR C Data Types Table:

Data TypeSizeRange
char8-bit-128 to 127
unsigned char8-bit0 to 255
int16-bit-32768 to 32767
unsigned int16-bit0 to 65535
long32-bit-2³¹ to 2³¹-1
float32-bitIEEE 754 format
  • Memory Efficiency: Use smallest appropriate data type
  • Unsigned Types: For positive values only, doubles range
  • Bit Fields: Can define specific bit-width variables

Mnemonic: “CIL-FUB” (Char-8bit, Int-16bit, Long-32bit, Float-32bit, Unsigned-positive, Bit-specific)


Question 3(b) OR [4 marks]
#

Explain Serial Communication Protocol.

Answer:

Serial Communication Parameters:

ParameterDescription
Baud RateData transmission speed (bits/second)
Data BitsNumber of data bits (5-9)
ParityError checking (None, Even, Odd)
Stop BitsEnd of frame marker (1 or 2)
sequenceDiagram
    participant TX as Transmitter
    participant RX as Receiver
    TX->>RX: Start Bit (0)
    TX->>RX: Data Bits (8)
    TX->>RX: Parity Bit (Optional)
    TX->>RX: Stop Bit(s) (1)
  • Asynchronous: No clock signal, uses start/stop bits
  • RS232 Standard: ±12V levels, converted to TTL levels
  • Common Baud Rates: 9600, 19200, 38400, 115200

Mnemonic: “BDPS” (Baud-rate, Data-bits, Parity-check, Stop-bits)


Question 3(c) OR [7 marks]
#

Write an AVR C program to read pins 1 and 0 of Port B and issue an ASCII character to Port D according to the following table:

Answer:

#include <avr/io.h>

int main(void)
{
    unsigned char input;
    
    // Configure PB1 and PB0 as input
    DDRB &= ~((1<<1)|(1<<0));
    
    // Configure Port D as output
    DDRD = 0xFF;
    
    // Enable pull-ups for PB1 and PB0
    PORTB |= (1<<1)|(1<<0);
    
    while(1)
    {
        // Read PB1 and PB0
        input = PINB & 0x03;  // Mask other bits
        
        switch(input)
        {
            case 0x00:  // Pin1=0, Pin0=0
                PORTD = '0';  // ASCII '0' = 0x30
                break;
                
            case 0x01:  // Pin1=0, Pin0=1
                PORTD = '1';  // ASCII '1' = 0x31
                break;
                
            case 0x02:  // Pin1=1, Pin0=0
                PORTD = '2';  // ASCII '2' = 0x32
                break;
                
            case 0x03:  // Pin1=1, Pin0=1
                PORTD = '3';  // ASCII '3' = 0x33
                break;
        }
    }
    
    return 0;
}

Truth Table Implementation:

Pin1Pin0Input ValueASCII Output
000x00‘0’ (0x30)
010x01‘1’ (0x31)
100x02‘2’ (0x32)
110x03‘3’ (0x33)

Mnemonic: “MATS” (Mask-inputs, ASCII-conversion, Truth-table, Switch-case)


Question 4(a) [3 marks]
#

Draw interfacing diagram of relay and relay driver ULN2803 with ATmega32

Answer:

APPPPPPPPTCCCCCCCCm01234567egCNGaOON3M1D21ocofofmURm123456789LReoNeln2la8ayf0yo1111111113crU876543210coLonaNnnl2nel8ec0ct3teeddttooL+o1a+G2dR1NVe2DlVay

Component Functions:

  • ULN2803: Darlington transistor array, current amplification
  • Protection Diodes: Built-in flyback diodes for inductive loads
  • Relay Coil: Requires 12V, controlled by ULN2803 output

Mnemonic: “UPC” (ULN-driver, Port-control, Current-amplify)


Question 4(b) [4 marks]
#

Write steps of programming the A/D converter using polling method

Answer:

ADC Programming Steps:

StepAction
1Configure ADMUX register (reference, channel)
2Configure ADCSRA register (enable, prescaler)
3Start conversion (set ADSC bit)
4Wait for conversion complete (poll ADIF flag)
5Read result from ADCL and ADCH

Code Implementation:

// Step 1: Configure ADMUX
ADMUX = (1<<REFS0);  // AVCC reference, channel 0

// Step 2: Enable ADC with prescaler
ADCSRA = (1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0);

// Step 3: Start conversion
ADCSRA |= (1<<ADSC);

// Step 4: Wait for completion
while(!(ADCSRA & (1<<ADIF)));

// Step 5: Read result
result = ADC;  // Combined ADCL and ADCH

Mnemonic: “CCSWR” (Configure-ADMUX, Configure-ADCSRA, Start-conversion, Wait-complete, Read-result)


Question 4(c) [7 marks]
#

Explain I2C-Two Wire Serial Interface (TWI) Protocol in detail.

Answer:

I2C Protocol Features:

FeatureDescription
Two WiresSDA (Data) and SCL (Clock)
Multi-masterMultiple masters can control bus
Addressing7-bit or 10-bit device addresses
BidirectionalData flows both directions
sequenceDiagram
    participant M as Master
    participant S as Slave
    M->>S: Start Condition
    M->>S: Slave Address + R/W
    S->>M: ACK
    M->>S: Data Byte
    S->>M: ACK
    M->>S: Stop Condition

I2C Frame Structure:

  • Start Condition: SDA goes low while SCL is high
  • Address Frame: 7-bit address + R/W bit
  • Data Frame: 8-bit data + ACK/NACK
  • Stop Condition: SDA goes high while SCL is high

TWI Registers in ATmega32:

RegisterFunction
TWCRControl and status
TWDRData register
TWARAddress register
TWSRStatus register
  • Clock Stretching: Slave can hold SCL low to slow down master
  • Arbitration: Prevents collisions in multi-master systems
  • Pull-up Resistors: Required on both SDA and SCL lines (4.7kΩ typical)

Mnemonic: “SAD-CSA” (Start-Address-Data, Control-Status-Address)


Question 4(a) OR [3 marks]
#

Explain any one PWM mode for controlling speed of DC motor by using 8-bit timer

Answer:

Fast PWM Mode (Mode 3):

ParameterValue
WGM bitsWGM01=1, WGM00=1
TOP value0xFF (255)
Resolution8-bit
Frequencyfclk/(256×prescaler)

PWM Configuration:

// Configure Timer0 for Fast PWM
TCCR0 = (1<<WGM01)|(1<<WGM00)|(1<<COM01)|(1<<CS01);

// Set duty cycle (0-255)
OCR0 = 128;  // 50% duty cycle
graph LR
    A[Timer0] --> B[PWM Signal]
    B --> C[Motor Driver]
    C --> D[DC Motor]
    E[OCR0 Value] --> A
  • Duty Cycle Control: OCR0 value determines motor speed
  • Non-inverting Mode: High pulse width = OCR0/255
  • Motor Control: Higher duty cycle = higher speed

Mnemonic: “FTO” (Fast-PWM, Timer0, OCR0-control)


Question 4(b) OR [4 marks]
#

Write steps for reading data from an SPI device

Answer:

SPI Read Steps:

StepAction
1Configure SPI control register (SPCR)
2Set SS pin low to select slave
3Write dummy data to SPDR
4Wait for transmission complete (SPIF flag)
5Read received data from SPDR
6Set SS pin high to deselect slave

Code Implementation:

// Step 1: Configure SPI as master
SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR0);

// Step 2: Select slave
PORTB &= ~(1<<SS);

// Step 3: Send dummy byte
SPDR = 0xFF;

// Step 4: Wait for complete
while(!(SPSR & (1<<SPIF)));

// Step 5: Read data
data = SPDR;

// Step 6: Deselect slave
PORTB |= (1<<SS);

SPI Timing:

  • Clock Polarity: CPOL bit determines idle state
  • Clock Phase: CPHA bit determines sampling edge
  • Data Order: MSB first (default) or LSB first

Mnemonic: “CSWWRD” (Configure, Select, Write-dummy, Wait, Read-data, Deselect)


Question 4(c) OR [7 marks]
#

Draw and explain interfacing diagram of LM35 with ATmega32.

Answer:

L+APGOVM5TANpC3Vm0DtC5eigoaTanne3adm2lp:GeNr0DaVOG.tCUN1fuCTDµorPFre(U(PLTPcnSiMiaoen3(npin5Pass1i3ceo)n)irtf2oi)rltbeertiwnegen

LM35 Specifications:

ParameterValue
Output10mV/°C
Range0°C to 100°C
Supply4V to 30V
Accuracy±0.5°C

ADC Code for Temperature Reading:

#include <avr/io.h>

unsigned int readTemperature(void)
{
    unsigned int adcValue, temperature;
    
    // Configure ADC
    ADMUX = (1<<REFS0);  // AVCC reference, PA0
    ADCSRA = (1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0);
    
    // Start conversion
    ADCSRA |= (1<<ADSC);
    
    // Wait for completion
    while(!(ADCSRA & (1<<ADIF)));
    
    // Read ADC value
    adcValue = ADC;
    
    // Convert to temperature
    // ADC = (Vin × 1024) / Vref
    // Vin = (10mV/°C) × Temp
    temperature = (adcValue * 500) / 1024;
    
    return temperature;
}

Temperature Calculation:

  • ADC Resolution: 10-bit (0-1023)
  • Reference Voltage: 5V
  • LM35 Output: 10mV/°C
  • Formula: Temp = (ADC × 5000mV) / (1024 × 10mV/°C)

Mnemonic: “VARC” (Voltage-output, ADC-conversion, Reference-5V, Calculation-formula)


Question 5(a) [3 marks]
#

Draw Timer 0 Working Block diagram.

Answer:

graph TD
    A[System Clock] --> B[Prescaler]
    B --> C[Timer/Counter 0]
    C --> D[Compare Unit]
    C --> E[Overflow Flag]
    D --> F[OCR0]
    D --> G[PWM Output]
    H[External Clock] --> B

    style C fill:#f9f,stroke:#333,stroke-width:4px

Timer0 Components:

ComponentFunction
PrescalerClock division (1,8,64,256,1024)
Counter8-bit up counter (0-255)
Compare UnitCompares counter with OCR0
OverflowSets flag when counter overflows
  • Clock Sources: Internal clock or external pin
  • Modes: Normal, CTC, Fast PWM, Phase Correct PWM
  • Interrupt: Timer overflow and compare match

Mnemonic: “PCCO” (Prescaler, Counter, Compare, Overflow)


Question 5(b) [4 marks]
#

Draw Interfacing of MAX7221 to ATmega32.

Answer:

APPPTBBBm574e(((gMSSaOCS3SK)2I))7SD-EISGGegA0m--eG7n,tcDoDPninscepocDCCVGlntILS+NaneNKDyed((c(((PPCttMPPPiioeoAiiinnndXnnnnP714eti21119,con2)32)9ts1)))iPoi2nn-ss3:,1+455G--VN18D7,,1200--1213

MAX7221 Features:

FeatureDescription
Display Driver8-digit 7-segment LED driver
SPI InterfaceSerial data input
Current ControlAdjustable segment current
Shutdown ModePower saving feature

Initialization Code:

void MAX7221_init(void)
{
    // Configure SPI pins
    DDRB |= (1<<PB5)|(1<<PB7)|(1<<PB4);  // MOSI, SCK, SS as output
    
    // Initialize SPI
    SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR0);
    
    // Wake up MAX7221
    MAX7221_write(0x0C, 0x01);  // Shutdown register
    
    // Set decode mode
    MAX7221_write(0x09, 0xFF);  // BCD decode for all digits
    
    // Set intensity
    MAX7221_write(0x0A, 0x08);  // Medium brightness
    
    // Set scan limit
    MAX7221_write(0x0B, 0x07);  // Display all 8 digits
}

Mnemonic: “SCD-ISS” (SPI-interface, Current-control, Decode-mode, Initialize-setup, Scan-limit)


Question 5(c) [7 marks]
#

Explain Weather Monitoring System.

Answer:

System Block Diagram:

graph TD
    A[Temperature Sensor
LM35] --> E[ATmega32
Microcontroller] B[Humidity Sensor
DHT11] --> E C[Pressure Sensor
BMP180] --> E D[Light Sensor
LDR] --> E E --> F[LCD Display
16x2] E --> G[Data Logger
EEPROM] E --> H[Wireless Module
ESP8266] H --> I[Cloud Server] J[Power Supply
Battery/Solar] --> E

System Components:

ComponentFunctionInterface
LM35Temperature measurementADC
DHT11Humidity & temperatureDigital I/O
BMP180Atmospheric pressureI2C
LCDLocal displayParallel
ESP8266WiFi connectivityUART
EEPROMData storageI2C

Features and Applications:

  • Real-time Monitoring: Continuous sensor data collection
  • Data Logging: Historical data storage in EEPROM
  • Remote Access: WiFi connectivity for cloud upload
  • Power Management: Battery backup with solar charging
  • Alert System: Threshold-based warnings
  • Agricultural Use: Crop monitoring, irrigation control
  • Home Automation: HVAC control, energy management

Software Functions:

  • Sensor Reading: ADC conversion, I2C communication
  • Data Processing: Calibration, filtering, averaging
  • Display Update: LCD formatting, user interface
  • Communication: WiFi data transmission, protocol handling
  • Storage Management: EEPROM read/write, data compression

Mnemonic: “SMART-W” (Sensors, Monitoring, Alert, Remote, Temperature, Weather)


Question 5(a) OR [3 marks]
#

Draw and explain Timer/Counter Control Register 0(TCCR0)

Answer:

TCCR0 Register Bit Structure:

BTiCtC:R0F7OC0W6GM00|5COM014|COM030|WGM201|C1S020CS01|CS00|

Bit Functions Table:

BitNameFunction
FOC0Force Output CompareForce compare match
WGM01:00Waveform GenerationTimer mode selection
COM01:00Compare Output ModeOutput pin behavior
CS02:00Clock SelectPrescaler selection

Clock Select Options:

CS02:00Clock Source
000No clock (stopped)
001clk/1 (no prescaling)
010clk/8
011clk/64
100clk/256
101clk/1024
110External clock on T0 (falling)
111External clock on T0 (rising)

Waveform Generation Modes:

WGM01:00ModeDescription
00NormalCount up to 0xFF
01PWM, Phase CorrectCount up/down
10CTCClear Timer on Compare
11Fast PWMCount up to 0xFF

Mnemonic: “FWC-CS” (Force, Waveform, Compare, Clock-Select)


Question 5(b) OR [4 marks]
#

Explain the function of motor driver L293D.

Answer:

L293D Motor Driver Features:

FeatureSpecification
ChannelsDual H-bridge, 2 motors
Supply Voltage4.5V to 36V
Output Current600mA per channel
Logic Voltage5V TTL compatible
ProtectionThermal shutdown

Pin Configuration:

EIOGGOIVNNUNNUNC11TDDT2C12212345678L293D111111165432109VIOGGOIECNUNNUNNC4TDDT32143+5V)

H-Bridge Operation:

IN1IN2Motor Action
00Stop (brake)
01Rotate CCW
10Rotate CW
11Stop (brake)

Control Functions:

  • Direction Control: IN1, IN2 determine rotation direction
  • Speed Control: PWM on Enable pins (EN1, EN2)
  • Dual Supply: VCC1 for logic, VCC2 for motor power
  • Enable Control: EN pins enable/disable motor operation

Applications:

  • Robotics: Differential drive robots
  • Automation: Conveyor belt control
  • RC Vehicles: Motor speed and direction control

Mnemonic: “DHIE” (Dual-channel, H-bridge, Input-control, Enable-PWM)


Question 5(c) OR [7 marks]
#

Explain Automatic Juice vending machine.

Answer:

System Block Diagram:

graph TD
    A[Keypad Input] --> H[ATmega32
Controller] B[Coin Sensor] --> H C[LCD Display] --> H H --> D[Pump Motors] H --> E[Solenoid Valves] H --> F[Coin Return
Mechanism] H --> G[Level Sensors] I[Power Supply] --> H J[Juice Containers] --> D D --> K[Mixing Chamber] E --> K K --> L[Dispensing Unit]

System Components:

ComponentFunctionInterface
KeypadJuice selectionDigital I/O
Coin SensorPayment detectionInterrupt
LCD DisplayUser interfaceParallel
Pump MotorsJuice pumpingPWM control
Solenoid ValvesFlow controlDigital output
Level SensorsContainer monitoringADC/Digital

Operation Sequence:

  1. Display Menu: Show available juices and prices
  2. User Selection: Customer selects juice type via keypad
  3. Payment Process: Coin insertion and validation
  4. Level Check: Verify ingredient availability
  5. Dispensing: Activate pumps and valves in sequence
  6. Mixing: Control mixing ratios and time
  7. Completion: Display completion message and return change

Control Algorithm:

void dispensJuice(uint8_t selection, uint16_t amount)
{
    // Check ingredient levels
    if(checkLevels(selection))
    {
        // Calculate mixing ratios
        calculateRatio(selection);
        
        // Start dispensing sequence
        activatePump(selection, amount);
        
        // Control mixing time
        startTimer(MIXING_TIME);
        
        // Complete transaction
        displayMessage("Enjoy your juice!");
    }
    else
    {
        displayMessage("Ingredient not available");
        returnCoins();
    }
}

Features:

  • Multiple Flavors: Different juice combinations
  • Payment System: Coin acceptance and change return
  • Inventory Management: Level monitoring and alerts
  • User Interface: Menu display and selection
  • Safety Features: Overflow protection, emergency stop
  • Maintenance Mode: Service and cleaning cycles

Applications:

  • Commercial: Shopping malls, offices, schools
  • Industrial: Factory cafeterias, hospitals
  • Public Places: Airports, train stations

Mnemonic: “JUMPS” (Juice-selection, User-interface, Mixing-control, Payment-system, Sensors-monitoring)

Related

Embedded System & Microcontroller Application (4351102) - Winter 2023 Solution
14 mins
Study-Material Solutions Embedded-System 4351102 2023 Winter
Embedded System (4343204) - Summer 2024 Solution
16 mins
Study-Material Solutions Embedded-System 4343204 2024 Summer
Industrial Electronics (4331103) - Winter 2024 Solution
19 mins
Study-Material Solutions Industrial-Electronics 4331103 2024 Winter
Programming In C (4331105) - Winter 2024 Solution
15 mins
Study-Material Solutions Programming C-Language 4331105 2024 Winter
Electronic Circuits & Networks (4331101) - Winter 2024 Solution
18 mins
Study-Material Solutions Electronic-Circuits 4331101 2024 Winter
Communication Engineering (1333201) - Winter 2024 Solution
23 mins
Study-Material Solutions Communication-Engineering 1333201 2024 Winter