MINI PROJECT: PROGRAMMABLE MOTOR CONTROL WITH LCD DISPLAY & LED INDICATOR BY USING PIC18F4550

Published on
Scene 1 (0s)

MINI PROJECT: PROGRAMMABLE MOTOR CONTROL WITH LCD DISPLAY & LED INDICATOR BY USING PIC18F4550

NAME: PREMIKA ASOKAN MATRIX NO: 08DJK19F1033 CLASS: DJK4B LECTURER NAME: TS IR DR AHMAD AZLAN AB AZIZ

EMBEDDED SYSTEM APPLICATION DEC 40053

Scene 2 (15s)

PROBLEM STATEMENT/ PURPOSE OF THE PROJECT

In today world of technology, everything from small device like mobile (cell phone) to automobile is digitalize to solve problem thus make the work easier for human. All of the digitalize device or equipment involved with microcontroller and microprocessor. In this embedded project, our main purpose is to apply the gained knowledge in Embedded subject to build or create something real or something exist in real word. From here, we can observe how make use of gained knowledge to apply on real object instead of the virtual programming we learned . In this project, microcontroller PIC18F4550 will be used as the microcontroller to control motor, LCD display and LED indicator. Beside that, this project also intended to test our soft skill such as problem solving, effective communication, creativity and project management. From the designing the interfacing circuit and building C language programming based on PI18 microcontroller until test and analyze the operation of the system using Proteus ISIS software.

Scene 3 (1m 2s)

FUNCTIONAL DIAGRAM

POWER SUPPLY

PIC18F4550

SW1

SW2

MOTOR FORWARD & LED GREEN ON

MOTOR REVERSED & LED YELLOW OFF

LCD DISPLAY FORWARD

LCD DISPLAY RESERVED

Scene 4 (1m 17s)

When power supply was applied on hardware onto the pin 1 of PIC18f4550 we can to press the switch 1 or switch 2.When switch 1 was pressed, the motor move forward and LED (green) turn on. Automatically the LCD was displayed “FORWARD” to us. But when switch 2 was pressed, the motor was moving reversed and LED (YELLOW) turn on follow by the LCD displayed “REVERSED”.

RAO,'ANO RAI,'ANI RA2AN2'VREF-/CVREF RCO/TIOSOITICKI RC1'T10succP2f1_JOE RB2 RAYAN 3'VREF. RA4,'TOCKWCIOUT/RCV RA5,'ANvSS/LVDlWC20UT RA6'0SC2'CLKO OSCI/CLKI RBIANIO,'INTI/SCK'SCL RB2/AN8/lNT2/VMO RB3,'AN9/CCP2NPO RB4,'AN11/KBlO/CSSPP RB6,'KB12/PGC RB7/KB13'PGD WSB PIC18F4550 RC2/CCP1/PIA RC4/D-/VM RCS/D*/VP RC6fTX'CK RC7'RX,0T/SDO RDO/SPPO RD2/SPP2 RD3/SPP3 RD4/SPP4 RD6/SPP6/PIC RD7/SPP7/PID REO/AWCKISPP REI'AN6,'CK2SPP RE2/AN7'OESPP RE3wcLR,VPP LED-GRE LEO-YE ROI Roa

LED 1 & LED 2 OUTPUT AT PORTS C0 & C1

POWER AT PORTS RE3

RESET AT PORTS RE3

INPUT MOTOR AT PORTS A0 & A1

INPUT SW1 & SW2 AT PORTS B0 & B1

INPUT LCD REGISTER SELECT (RS) AT PORT B2 & ENABLE (E) AT PORT B3

Scene 5 (2m 14s)

I/O REQUIREMENT OF MICROCONTROLLER

Port RB0 and Port RB1 as the input SW1 and SW2. Port RB2 and Port RB3 as the input RS and E for LCD. Port RA0 and Port RA1 as the output for motor. Port RC0 and Port RC1 as the output for LED (GREEN) and LED (YELLOW).

Scene 6 (2m 33s)

INTERFACE REQUIREMENT

PIC18F4550 16 x 2 LCD Display 2 DC Motor 2 Switch Button Green LED Yellow LED Reset switch 2 Power 4 DC Generator 3 Resistor Port 10K

Scene 7 (2m 45s)

SCHEMATICS DESIGN

01 LC02 R 11 Mini project E SA_pdspO Mini project 20/5/2021

Scene 8 (2m 54s)

PROGRAM FLOWCHART

START

PORT A0 & PORT A1 AS THE OUTPUT MOTOR PORT C0 & PORT C1 AS THE OUTPUT LED PORT B0 AS THE INPUT SW1 PORT B1 AS THE INPUT SW2

PRESS SWITCH?

SW1

LED YELLOW TURN ON MOTOR MOVE REVERSED LCD “REVERSED”

LED GREEN TURN ON MOTOR MOVE FORWARD LCD “FORWARD”

DELAY

SW2

DELAY

END

Scene 9 (3m 15s)

PROGRAM CODE:

MPLAB IDE v8.43 - project esa.c] File Edit View Project Debugger Programmer Tools Configure Window Help Checksum: oxl g Include =pIEf4SSO . h / / *pragma config OSC *pragma = KS // 4YNz Crystal , (HS oscillator) OFE // pins configured as digital 1/0 Reset) *define data _p.zt // as output LCD *define zs_pin _ // as the 2S pin at LCD *define e_pin // as the pin at LCD void delay_ms (unsigned // Delay igned char ; // Switch igned char s sed ( void void setup (void ) ; // LCD void unsigned char value ) ; // LCD void ( unsigned char value igned igned igned char " char " char i ; void main 'void) // Line has // Line 2 has _ T21SC0= T21SAi O ; // Set O as output, // Set O as output, // Set O as output, // Set O as output. , / / SWI pin as input / / SW2 pin as input // is key pzessed is connected pin is connected pin is connected pin is connected pin // yes ; / 'Display / 'set I ed_daza )

Scene 10 (4m 3s)

MPLAB IDE v8.43 - project esa.cl File Edit View Project Debugger Programmer Tools Configure Window Help else PORTCbits _ aco=o ; P02TAbits _ UO=O ; / / turn off LED / / both motor stop if (is sw2_pzessed I) "I) // is key 2 pressed // yes // turn or LZD2 P02TAbits _ A1—I ; // both motor reversed I cd setup line I led cmd ; // set DDÄ_ÄY Address for i I zd setup // Display line 2 led cmd (ONCO) ; // set DDÄ_AY Address for i led data (Line: til); DelayiKTCYx ; else PORTCbits _ ; // turn off LED2 PORTAbics _ RAI ; / both motor stop led cmd 'OXON); // Delete line 2 while I ) ; void led setup ( void' ; // configure PORTD as output T21SBbits _ TRISB2=O; // configure PORTB3 as RS pin T21SBbics _ TRISBS- —O; // PORTBS as output E pin ADCONObits //AZC OFF ADCONi=ObOOOOIIOI; //ANO and ANI are configured as AZ:C pins ; / "prepare to enable idle low

Scene 11 (4m 46s)

MPLAB IDE v8.43 - project esa.c] File Edit View Project Debugger Programmer Tools Configure Window else / / turn Off LED / /b.ch stop if (is // is key 2 pressed ( // yes // ON . // bath zevezsed led setup D; // Delete line 1 led cmd(OxOA); //set Address for // Display 2 setup led cmd C OxCO); //sec DD2.A2{ Address for lcd_data ; = O // turn P02TAbits . —O; //both moto: stop led cmd (OxOA); // Delete line 2 while ; void led setup (void) ; // as output Hell TRISEbits . TAISEbits . TAISB3=0 ; ADCONObits _ ADON= O ; ; / /pzepaze // configure 202123 as output—:• 2S pin //ADC OFF //ANO and to enable as output Z pin AN I as ADC pins idle

Scene 12 (5m 23s)

MPLAB IDE v8.43 - project esa.cl File Edit View Project Debugger Programmer Tools Configure led cmd 03x3ä); // Function set: LCD 2 lines, Sx7 dot C SO); //De1ay 10ms led (OXOC); // display on, OFF led cmd (Oxal); //clear I'd led cmd (OxO€); // shift cursor right void led Cungigned char value ) ; / / cormand mcde // enable in active state Delay1KTCYx //delay lms —O; enable C 2S); //deiay Sms for execution time void Icd_daVa unsigned char ) da t value ; //DISPIAY DATA ; / mode // enable state CS); //delay milliseconds // strobe enable pin e_pxn //delay S milliseconds Window Help Checksum: // this is delay rcutine // Input: Seconds // Output; none void delay_ms c unsigned // delay milliseconds unsigned int i; for duration ! •O; duration — )

Scene 13 (6m 2s)

- project esa.c] MPLAB IDE v8.43 File Edit View project Debugger Programmer Tools Configure Window Help / / this is cheek keyl pzessings_ / / input : none / "output: O is pzessed_ is pzessed_ unsigned char C ) _ // is SWI pressed 2 delay_ms 10); // Vait I Oms for debounce. if // is still has pzessed status aEtez 10mS delay? ( // yes, Ve have key press return ; return O; // if key is not pressed. return O / / this routine is to check key: pressings - // input: none / /output: O if svitch is not pressed- i if svitch is pressed. unsigned char void ) if // is SW2 pressed? ( // yes delay_ms 110),• // wait 10 •mS for debounce. _ 221=0) // is S7i has pressed status after 10mS delay? // yes, have key press return I ; return O; // key is pzessed, Checks

Scene 14 (6m 46s)

mini project esa - MPLAB IDE v843 - (Output) File Edit View Project Debugger Programmer Tools Debuq find Configure Window Help Oxd048 Debug build of project project eserncp• started. Language tool versions: mpasmwin_exe vS 54. mplinkexe VS.OJ mccl 8 exe v3.47. mplib exe V5_OO Preprocessor symbol • _OEEIJG' is defined. sun May 23 2021 Clean: Deleting intermediary and output tiles. Clean: Deleted file project esao" Clean: Deleted file project esacof" Clean; Deleted file project esahex Clean: Deleted file •CWsers\prem project esa_mcs" Clean Done. Executlng: •Ciprogram files 8_exe -pel 8F4550 "rn.ni proJeCt esa.c• MPLÅB C18 3 .47 (feature limited) Copyright 2000—2011 Micrcchip Technology Inc This version of MPLÅB CIB does not support the extended mode and not perform all optimizations. To purchase a full copy of MPLAB C18. please contact your distributor or visit buy . microchip. con. mini project esa.o" -D _DEBUG -Ou- -Ot- -Ob- -O -Or- -Od- -Opa- MPLA8_8UlLO-l Iz x MPLA8 0 Executing: •CAPrograrn Files IPl 8F4650 /VC.\Progrem Files 47\lib" •mini project esao" /u_CRUNTlME /u_DEBUG Iz MPLINk S no. LINKER Device I Copyright (c) 1998—2013 hicrcchip Technology Inc Errors MP2HEX S. 00. COFF to HEX File Converter Copyright (c) 1998—2013 Errors Loaded project esacof. Debug build of projed project eserncp• succeeded Language tool versions: mpasmwin_exe vS 54, mplinkexe vE.00. mccl 8 exe v3.47. mplib exe v5_00 Preprocessor symbol • _OE8LlG' is defined. Sun May 23 23'8•48 2021 BUILD SUCCEEDED

Scene 15 (7m 48s)

RESULT AND ANALYSIS:

From the program we did. We realize that LCD,LED, Push Button Switch and motor able to combine using the PIC18F4550 controller . The input for this project embedded is the Switch 1 and Switch 2 at thr Ports B0 and B1. Meanwhile the output is on the LED1, LED2, LCD and motor. Where the Led output at the ports B0 and B1. Motor output at the ports A0 and A1. For the LCD Register Select (RS) and Enable (E) are set at Port B2 and B3. Ports D from D0 until D7 are set as output to connect LCD .

Scene 16 (8m 20s)

When SW1 is pressed, the Green LED will turn on while the both Motor will move forward and at the same time, LCD will display the word “FORWARD” at the 1st row of LCD display as shown in the diagram below..

e tJ2 VES VS cx.JT' 0_JTA LCOI FOR I,.IPRO mini project embedded sy mini project embedded m.pdspl

Scene 17 (8m 39s)

When SW2 is pressed, both motor will reverse while the Green LED will goes off and the Yellow LED will light up. At the same time, the LCD will display the word “REVERSE” at the 2nd row of LCD display as shown in the diagram below.

RABA" RB"B t ' FCW VS 00 00 0-rra LCDI REWERSEO mini project embedded sys mini project ernbedded sy c:w..nV.m1RauppoatMLoca 2].pds BY: OAuTHOR REv-.EV

Scene 18 (9m 2s)

CONCLUSION

For the conclusion, we had learned the creativity way to design the interfacing circuit based on PIC18 microcontroller. The components LED, LCD, Push Button and motor was successfully connected to microcontroller PIC18F4550. Beside that, we also successfully build program to control the motor forward and reverse by using MPLAB software. The program was write to control LED, LCD and Motor simultaneously. When each button switch is triggered, the motor will either move forward and reverse and at the same time LCD and LED will display it output according to the created program. Other than that, we learned to cooperate with each other through discussion to solve the problem when this project is in progress in order to make this project successfully. Finally, we feel so happy and gratefully that we can make use of gained knowledge to apply in the real environment successfully through our patient, creativity, tolerant and cooperation. Through these movement, we learned a lot of things out of syllabus