Professional Documents
Culture Documents
6 Interfaces
6 Interfaces
7 – Segment LED
Types – Common Anode
Types – Common Cathode
Number Pattern
Driver Circuit
LCD Display
LCD Display
LCD Display
LCD Display Commands
• 0x06-Entry mode
• 0x0E-Display on cursor on
• 0x01-To clear display
• 0x38-5x7 matrix pixel
• 0x80-select first row first character
• 0xc0-select second row first character
• 0x0c-display on cursor off
LCD Display Initialization
void lcd_init()
{
command(0x01);
command(0x06);
command(0x0c);
command(0x38);
}
LCD Display Command
void command(unsigned char y)
{
TRISB = 0x00;
PORTB = y;
rs = 0;
en = 1;
for(i=0;i<30000;i++);
en=0;
}
LCD Display Data
void write(unsigned char x)
{
TRISB = 0x00;
PORTB = x;
rs=1;
en=1;
for(i=0;i<30000;i++);
en=0;
}
Matrix Key Board
Matrix Key Board
Matrix Key Board Initialization
#define X_1 RB0
#define X_2 RB1
#define X_3 RB2
#define X_4 RB3
#define Y_1 RB4
#define Y_2 RB5
#define Y_3 RB6
#define Y_4 RB7
#define Keypad_PORT PORTB
#define Keypad_PORT_Direction TRISB
Matrix Key Board Initialization
Keypad_PORT = 0x00; // Set Keypad port pin values zero
Keypad_PORT_Direction = 0xF0;
Matrix Key Board Scanning
X_1 = 0; X_2 = 1; X_3 = 1; X_4 = 1;
if (Y_1 == 0)
{ __delay_ms(100); while (Y_1==0); return '1'; }
if (Y_2 == 0)
{ __delay_ms(100); while (Y_2==0); return '2'; }
if (Y_3 == 0)
{ __delay_ms(100); while (Y_3==0); return '3'; }
if (Y_4 == 0)
{ __delay_ms(100); while (Y_4==0); return 'A'; }
Matrix Key Board
X_1 = 1; X_2 = 0; X_3 = 1; X_4 = 1;
if (Y_1 == 0)
{ __delay_ms(100); while (Y_1==0); return '4'; } if
(Y_2 == 0)
{ __delay_ms(100); while (Y_2==0); return '5'; } if
(Y_3 == 0)
{ __delay_ms(100); while (Y_3==0); return '6'; } if
(Y_4 == 0)
{ __delay_ms(100); while (Y_4==0); return 'B'; }
Key Bouncing
Servo Motor
Stepper Motor
Stepper Motor
• The rotation angle of the motor is proportional to the input pulse.
• The motor has full torque at standstill.
• Precise positioning and repeatability of movement since good
stepper motors have an accuracy of 3 – 5% of a step and this error
is non cumulative from one step to the next.
• Excellent response to starting, stopping and reversing.
• Very reliable since there are no contact brushes in the motor.
Therefore the life of the motor is simply dependent on the life of
the bearing.
• The motors response to digital input pulses provides open-loop
control, making the motor simpler and less costly to control.
• It is possible to achieve very low speed synchronous rotation with a
load that is directly coupled to the shaft.
• A wide range of rotational speeds can be realized as the speed is
proportional to the frequency of the input pulses.
Stepper Motor - Unipolar
Full Step
1a 1b 2a 2b Position
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
Full Step
Full Mode Sequence
Step A B A\ B\
0 1 1 0 0
1 0 1 1 0
2 0 0 1 1
3 1 0 0 1
Half Step
Step A B A\ B\
0 1 1 0 0
1 0 1 0 0
2 0 1 1 0
3 0 0 1 0
4 0 0 1 1
5 0 0 0 1
6 1 0 0 1
7 1 0 0 0
Stepper Motor - Bipolar
Bipolar
Polarity Sequence
Step A A\ B B\
0 +ve -ve -ve -ve
1 -ve -ve +ve -ve
2 -ve +ve -ve -ve
3 -ve -ve -ve +ve
Step Sequence
Step A A\ B B\
0 1 0 0 0
1 0 0 1 0
2 0 1 0 0
3 0 0 0 1
EEPROM
• PIC16F877a – EEPROM- 256 X 8
• 8 bits wide, 256 locations 256 bytes
• EEPROM is not directly accessible.
• Indirectly accessed through SFR
Contd…
• EEDATA - Data to be written or read
• EEADR - addresses of EEPROM to be accessed
• EECON1- bits controlling read and write
operation.