USING
Micro-Controllers
Robo Club
BY
WASI QAZI
Introduction
What is a uC ?
Computer uC
• uP • uP
• RAM • Flash Memory
• HDD • EEPROM
• Clock • Clock Unit
• Ports (Serial/USB) • SPI / UART Controllers
• Ports (Parallel) • Digital I/O Ports
• Mic/Headphone Jack (ADC/ DAC) • ADC
• Power Supply Unit • Power Supply Unit
• Reset • Reset
• Mother-board • IC
THE BLOCK DIAGRAM
Clock
12Mhz Main Power Motor Power
Supply Supply
Left
Motor
Microcontroller H - Bridge
HEX DC Motor Control
Inverter Right
Motor
Priority
Encoder
Analog Threshold
Comparators Voltage
NOR Gate
Sensor Array
Sensors
• A sensor is a device which measures a physical
quantity and converts it into a signal which can
be read by an observer or by an instrument.
• They are used to provide feedback from the
external environment
IR Sensor Pair
Object /
IR sensor Pair
Line
Transmitter (Tx)
Receiver (Rx)
Receiver = Photodiode
Principle of Operation
WHITE surface
Maximum reflection
T1 is turned ON
Vout is LOW
BLACK surface
Minimum or No Reflection
T1 is turned OFF
Vout is HIGH
R1< R2
ADC BY OP-AMP:
G
N
D
+5v
Line Follower : Design
4 8bit Parallel Input-Output ports through which you can i/p or o/p digital data.
Power Supply
Port Architecture
P D P
O D I
uC External
R R N
world
T A A
A
Complete Program
A program to o/p 33 (hex) on PortD and configure and read pins 2 and
7 of Port A
#include <mega16.h>
void main( )
{
unsigned int x,y;
PORTD=0x33;
x=PINA.2;
y=PINA.7;
}
L298N Motor Driver
Similarly other 2 o/p are connected /disconnected by I/p 3 & I/P
4
All the O/p’s operate independently, ie if all I/p 1-I/p 4 are 1, all
O/p1 – O/p4 will be connected to +VPP
O/p 3 I/p 3
O/p 4 I/p 4
O/p 3 I/p 3
O/p 4 I/p 4
O/p 3 I/p 3
O/p 4 I/p 4
O/p 3 I/p 3
O/p 4 I/p 4