Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 29

AVR Microcontroller

Prepared by:
Eng. Ashraf Darwish

Ashraf.emad.darwish@gmail.com

Session 3

Interface with keypad


EEPROM

Stepper Motor

Introduction to hardware design

Keypad
Keypad consists of some press buttons
connected together in a matrix way

Keypad
There are many types of keypad
3 4 keypad

Keypad

4 4 keypad

Keypad

Calculator keypad

Keypad

we will deal with 3 4 keypad

we will use library to easy interface


with keypad

keys.lib is our library file , keys.h is


the header file .

Keypad

copy your library file (keys.lib) and


paste it in the (Lib) folder .

copy your header file (keys.h) and


paste it in the (inc) folder .

Keypad

Keypad connection :

Keypad

the only function you need is


getkey( );
Ex:
int x=0;
x= getkey ( );

EEPROM

ATmega16 have 512 KB EEPROM

To define variable in EEPROM :


Define it as a global variable ( After #include
) before your main function

int eeprom x=0;


Char eeprom y=a;

Stepper Motor

Stepper Motor

Stepper motor is a special kind of


motor that moves in individual steps
which are usually .9 degrees each .

Each step is controlled by energizing


one or more of the coils inside the
motor which then interacts with the
permanent magnets attached to the
shaft.

Stepper Motor

Turning these coils on and off in


sequence will cause the motor to
rotate forward or reverse.

The time delay between each step


determines the motor's speed

The operating voltage of the motor


determines the torque .

Stepper Motor

Stepper Motor

Types of Stepper Motors :


Permanent Magnet Stepper Motors
Unipolar
Bipolar
Universal

Variable Reluctance Stepper Motors

Stepper Motor

Types of Stepper Motors :

Stepper Motor

In our course we will study


Permanent magnet unipolar stepper
motor.

unipolar Stepper motor have 5 wires,


one is the center tap and 4 wires are
for the four coils

Stepper Motor
Modes of operation:

Full step mode (low torque)

Half step mode (high torque)

Stepper Motor
Full step mode:
Only one coil is active at a time

Stepper Motor
Half step mode:

Stepper Motor
Stepper motor driver:
we cannot drive stepper motor
directly from microcontroller because
microcontroller output current is very
low to drive the motor

We must have middle circuit


Transistors
ULN2003A

Stepper Motor
Stepper motor driver:
Transistors

Stepper Motor
Stepper motor driver:
ULN2003
ULN 2003 is seven
Darlington pair pack
80 mA output current per
driver
50 V Output voltage

Stepper Motor
Stepper motor interface:

you only need 4 output pins from AVR


for unipoler stepper motor

We will use ULN2003A


you must apply driving supply for ULN2003

+12V
The common of the motor is connected to Vcc
12V

Stepper Motor

For full step mode


Ex:
DDRA=0xff;
PORTA=0xff;
For (i=0;i<=100;i++)
{
PORTA=0x01 ; //0000 0001
Delay_ms(50);
PORTA=0x02 ; //0000 0010
Delay_ms(50);
PORTA=0x04 ; //0000 0100
Delay_ms(50);
PORTA=0x08 ; //0000 1000
Delay_ms(50);
}

Stepper Motor

For half step mode


Ex:
DDRA=0xff;
PORTA=0xff;
For (i=0;i<=100;i++)
{
PORTA=0x01 ; //0000 0001
Delay_ms(50);
PORTA=0x03 ; //0000 0011
Delay_ms(50);
PORTA=0x02 ; //0000 0010
Delay_ms(50);
PORTA=0x06 ; //0000 0110
Delay_ms(50);
PORTA=0x04 ; //0000 0100
Delay_ms(50);

PORTA=0x ; //0000 0001


Delay_ms(50);
PORTA=0x0x0C; //0000 1100
Delay_ms(50);
PORTA=0x0x08 ; //0000 1000
Delay_ms(50);
PORTA=0x0x09 ; //0000 1001
Delay_ms(50);
}

Stepper Motor
TASK#1 :

Security system :
Door lock password, the password is saved even if the

IC is restarted
The program ask the user to Enter the password and
check if the password is right or not
If the user entered wrong password three times the
system make alarm
If the user entered the right password the stepper motor
of the lock will open and wait 5 seconds and close again
The user can change the password

Thank you
Contact:
http://www.facebook.com/groups/263197427113025
/
Ashraf.darwish@ymail.com
Ashraf.emad.darwish@gmail.com
+201064897791

You might also like