Download presentation
Presentation is loading. Please wait.
Published byRafe Page Modified over 8 years ago
1
INTERFACING HARDWARE WITH MICROCONTROLLER GUIDED BY: Prof. ASIF SIR 1. AKSHAY KIRAN 2. DEEP PARIKH 3. JIGAR PATEL 4. TILAK PATEL 130010111002,05,D2D06,09 EC 3 rd YEAR
2
. What is a Microcontroller ? A microcontroller (or MCU) is a computer-on-a-chip. It is a type of microprocessor emphasizing self- sufficiency and cost-effectiveness, in contrast to a general-purpose microprocessor (the kind used in a PC). The only difference between a microcontroller and a microprocessor is that a microprocessor has three parts - ALU, Control Unit and registers (like memory), while the microcontroller has additional elements like ROM, RAM etc.
3
. ATMEGA32/ATMEGA32L High-performance, Low-power AVR 8-bit Microcontroller Up to 16 MIPS Throughput at 16 MHz 32K Bytes of In-System Self-Programmable Flash 1024 Bytes EEPROM 2K Byte Internal SRAM Two 8-bit Timer/Counters, One 16-bit Timer/Counter In-System Programming by On-chip Boot Program Four PWM Channels 8-channel, 10-bit ADC Programmable Serial USART Internal Calibrated RC Oscillator External and Internal Interrupt Sources Power-on Reset 32 Programmable I/O Lines
4
. ATMEGA32 Operating Voltage 4.5 - 5.5 V Speed Grades 0 – 16 MHz
5
. Pin Diagram
6
c. C - CODECOMPILERHEX - CODE COMPUTER MICRO CONTROLLER
8
. Configuring PORT PINS Each PORT consists of three registers DDRX (Data Direction Register) PORTX PINX Where X = A, B, C, D
10
. DDRX The DDXn bit in the DDRx Register selects the direction of pin n. If DDXn is written logic one, PXn is configured as an output pin. If DDXn is written logic zero, PXn is configured as an input pin. Where n = 0,1,2 - - -,7 For Example If DDRA = 0x0F ( 0000 1111) The Lower bytes of PORTA are configured as output pins The Higher bytes of PORTA are configured as input pins
11
. PORTX When PORTXn is configured as Input Pin Writing logic ONE to this pin, activates pull-up resistor. Writing logic ZERO to this pin, deactivates pull-up resistor When PORTXn is configured as Output Pin Writing logic ONE to this pin, drives the port pin HIGH Writing logic ZERO to this pin, drives the port pin LOW
12
. PINX PINXn is used to read the value of particular port pin Independent of the setting of Data Direction bit DDRXn, the port pin can be read through the PINXn Register bit
13
. Interfacing with Microcontroller LED Switches DC Motor Sensors Stepper Motor
14
INTERFACING LED.
15
. LED – Light Emitting Diode Maximum potential drop across LED will be approximately 2V. Maximum current tat can be allowed through am LED is approximately 30ma. Resistor should be added in series with LED to limit the current through it.
16
. Calculating LED resistor value R = (Vs – V L )/I Vs = supply voltage V L = Voltage drop across LED ( around 2V) I = 15 to 30 ma
17
LED’s connected to 1. PORTA0 2.PORTB0
18
LED BLINK PROGRAM.
19
#ifndef F_CPU #define F_CPU 16000000UL // 16 MHz clock speed #endif #include #include int main(void) { DDRC = 0xFF; //Makes PORTC as Output while(1) //infinite loop { PORTC = 0xFF; //Turns ON All LEDs _delay_ms(1000); //1 second delay PORTC= 0x00; //Turns OFF All LEDs _delay_ms(1000); //1 second delay } }
20
INTERFACING DC MOTOR.
21
. DC Motor DC Motors are small, inexpensive and powerful motors used widely. These are widely used in robotics for their small size and high energy out. A typical DC motor operates at speeds that are far too high speed to be useful, and torque that are far too low. Gear reduction is the standard method by which a motor is made useful. Gear’s reduce the speed of motor and increases the torque
22
. Choosing a DC Motor DC Motor with Gear head Operating voltage 12V Speed Depends on our application Some available speeds in market 30 RPM 60 RPM 100 RPM 150 RPM 350 RPM 1000 RPM
23
. Drive basics of DC Motor Red wireBlack wireDirection of rotation Positive Negative Clock wise Negative PositiveAnti clock wise Logic Direction 1 0Clock 0 1Anti clock
24
. Direction Pulse to Clock wise A and C Anti Clock wise B and D Bi-Direction control of DC Motor H-Bridge Ckt using transistors for bidirectional driving of DC motor
25
. H-Bridges in IC’s to reduce the drive circuit complexity The most commonly used H-Bridges are L293D and L298 L293D has maximum current rating of 600ma L298 has maximum current rating of 2A Both has 2 H-Bridges in them These are designed to drive inductive loads such as relays, solenoids Can be used to drive 2 DC motors or 1 stepper motor
28
DC MOTOR CODE. #ifndef F_CPU #define F_CPU 8000000UL // 16MHz clock speed #endif #include int main(void) { DDRC = 0xFF; //PORTB as Output while(1) { //Rotates Motor in Anticlockwise PORTC = 0x01; //00000001 _delay_ms(4000); //Stops Motor PORTC = 0x00; //00000000 _delay_ms(4000); //Rotates Motor in Clockwise PORTC = 0x02; //00000010 _delay_ms(4000); //Stops Motor PORTC = 0x03; //00000011 _delay_ms(4000); }
29
INTERFACING SWITCHES.
30
. Switches Active Low When pressed shorts the corresponding pin to ground Active high When pressed shorts the corresponding pin to Vcc
31
Active low Active high
32
. Sensors Commonly used sensors in the field of robotics are IR Digital sensors IR analog sensors
33
. IR Digital sensors Transmitter IR led connected to 38KHz oscillator Receiver TSOP1738 IR Analog sensors Transmitter IR LED Receiver IR Photodiode
34
. IR Analog sensor
36
. STEPPER MOTOR STEPPER MOTOR is a brushless DC motor whose rotor rotates in discrete angular increments when its stator windings are energized in a programmed manner. Rotation occurs because of magnetic interaction between rotor poles and poles of sequentially energized stator windings. The rotor has no electrical windings, but has salient and/or magnetized poles.
37
. 4 – Lead stepper 5 – Lead stepper 6 – Lead stepper8 – Lead stepper
38
www.raghu.co.in Full Step driving of Stepper Motor Full step wave drive 4 3 2 1 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
39
www.raghu.co.in Full Step driving of Stepper Motor Full step 2 phases active 4 3 2 1 1 1 0 0 0 1 1 0 0 0 1 1 1 0 0 1
40
. Half Step driving of stepper motor 4 3 2 1 1 0 0 0 1 1 0 0 0 1 0 0 0 1 1 0 0 0 1 0 0 0 1 1 0 0 0 1 1 0 0 1
41
. Choosing a Stepper motor 12 V operating voltage 1.8 degree step 6 Lead 250 t0 500 ma of current or Coil resistance of 20 ohms to 40 ohms Size and shape depends on application In most of the robotics cube shaped motors are preferred with frame size of 3.9 to 4 cm
42
. Commonly used IC’s for driving Stepper motor ULN2803 It has 8 channels It channel has maximum current rating of 500ma can be used to drive 2 unipolar stepper motors L293d L297 & L298
43
. ULN2803
45
. A B C D 1 1 0 0 0 1 1 0 0 0 1 1 1 0 0 1 Bi – Polar driving of Stepper Motor
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.