You are on page 1of 13

Pertandingan Myskills Ke-7

PERTANDINGAN MySkills 2013 (ELECTRONICS)

6 JAM

PERINGKAT PRA-KELAYAKAN

NAMA: __________________________________________ NO. KP:__________________________________________

JABATAN PEMBANGUNAN KEMAHIRAN

assemble.Perrtandingan MySkills Ke-7 KEMENTERIAN SUMBER MANUSIA Project : Heater Display Input Panel Time Limit: 6 hrs This project accesses each competitor to design. buzzer beeps for three (3) times. If the correct selection is made by pressing any of the push button. Project Description: In this project. Buzzer is activated two (2) times at the end of selection. three (3) switches were provided for user preference. the selected option will be displayed on the first row of the LCD. This is done by centered displaying the string represents the selection made such “HOT” for “HOT” selection. the string “ERROR” will be centered displaying on the second row of the LCD. In the case of more than one (1) button were pressed. Figure 1 (Block Diagram) 2 . write an embedded C code and test project.

Pertandingan Myskills Ke-7 Schematic Diagram MCLR Coupling for microcontroller OSC1 OSC2 +5v +5v PICKIT3 LCD1 LM016L +5v IO VEE X1 C6 C5 27p 100nF 680R 66226-006 16MHz C7 100nF R8 10k 1 2 3 4 5 6 VSS VDD VEE RS RW E D0 D1 D2 D3 D4 D5 D6 D7 C4 27p R10 33R C8 220n MCLR MCLR +5V PGD PGC 1 2 3 4 5 6 7 8 9 10 11 12 13 14 +5v IO SDA SCL IO8 IO9 SS ANA0 ANA1 ANA2 ANA3 T0CKI ANA4 OSC2 OSC1 U1 2 3 4 5 6 7 14 13 33 34 35 36 37 38 39 40 RA0/AN0 RC0/T1OSO/T1CKI RA1/AN1 RC1/T1OSI/CCP2/UOE RA2/AN2/VREF-/CVREF RC2/CCP1/P1A RA3/AN3/VREF+ RC4/D-/VM RA4/T0CKI/C1OUT/RCV RC5/D+/VP RA5/AN4/SS/LVDIN/C2OUT RC6/TX/CK RA6/OSC2/CLKO RC7/RX/DT/SDO OSC1/CLKI RB0/AN12/INT0/FLT0/SDI/SDA RB1/AN10/INT1/SCK/SCL RB2/AN8/INT2/VMO RB3/AN9/CCP2/VPO RB4/AN11/KBI0/CSSPP RB5/KBI1/PGM RB6/KBI2/PGC RB7/KBI3/PGD RD0/SPP0 RD1/SPP1 RD2/SPP2 RD3/SPP3 RD4/SPP4 RD5/SPP5/P1B RD6/SPP6/P1C RD7/SPP7/P1D RE0/AN5/CK1SPP RE1/AN6/CK2SPP RE2/AN7/OESPP RE3/MCLR/VPP 15 16 17 23 24 25 26 19 20 21 22 27 28 29 30 8 9 10 1 T1CKI PWM1 PWM0 TX/RC6 RX/RC7 SDO IO0 IO1 IO2 IO3 IO4 IO5 IO6 IO7 IO16 IO17 IO18 MCLR +12v IO10 IO11 IO12 IO13 IO14 IO15 PGM PGC PGD VUSB U2 7805 1 VI GND VO 3 +5V D2 +12v 1N4001 C9 25v/22uF C10 25V/22uF 18 VUSB PIC18F4550 0v Figure 2 2 pin15 (lcd) VEE IO2 IO 1 IO 0 IO 4 IO 5 IO 6 IO 7 C11 25V/22uF pin16 (lcd) R9 J1 +5v IO .

Pertandingan MySkills Ke-7 Marking scheme: Item 1 2 3 4 5 Description Design circuit Functionality Component assembly Soldering quality Wiring/jumper quality Weight 30% 40% 10% 10% 10% Score .

Pertandingan MySkills Ke-7 Parts List (Table 1) ITEM 1 PARTS NAME AND VALUE RESISTORS CORBON TYPE 1/4W ± 5% • 33R • 120R • 200R • 390R • 680R • 1K • 10K • 12K • 20K • Trim pot preset 10K PCB type CAPACITORS • 10uF 25v (Electrolytic) • 22uF 25v (Electrolytic) • 10nF • 100nF (ceramic) • 220nF (ceramic) • 27pF (ceramic) SEMICONDUCTOR COMPONENTS • PIC 18F4550 c/w socket • Voltage regulator 7805 c/w heatsink • Transistor 2N3904 • Transistor 2N3903 • Diode IN4001 • Diode IN4008 • Diode IN914 OTHERS • Strip board 25cm x 11cm • LCD LM016L • Crystal 16MHz • 6 pin PCB Header 45 degree bend • Buzzer 12Vdc PCB type • Normaly Open PCB Miniture Push Button Switch • 16 Pin Female Header • 16 Pin Male Header QT’Y 1 3 1 1 1 2 1 3 3 1 REFERENCE NUMBER 2 4 3 2 5 1 2 1 1 1 1 1 1 1 3 4 2 1 1 1 1 4 1 1 1 .

Item 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Qty 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Material Soldering Iron and equipment Soldering Iron Stand Solder wick or Solder Remover Brush Pincer Nipper Wire Stripper Scissors Tweezers IC pick PCB stand Parts box Precise screwdriver Screw driver Screw driver Spanner Safety Glasses For trimmer resistor + type . installations and materials.Pertandingan MySkills Ke-7 • Microchip PIC Kit 3 downloader The competitor needs to prepare the following equipments.type Description Notes . machinery.

send_control(0x82). putr_lcd("PKM 2013").h> <delays.h" // global variables and definitions void main(void){ /*select accordingly . while(1){ } }// //Main while Filename: header file 1.h> <string.3V voltage regulator #pragma config WDT = OFF // Disable Watchdog timer #pragma config MCLRE = ON // Enable MCLR Enable #pragma config LVP = OFF // Disable low voltage ICSP #pragma config ICPRT = OFF // Disable dedicated programming port (44-pin devices) #pragma config CP0 = OFF // Disable code protection /* ---------------------End of File --------------------------*/ . // Must be called prior to usage of LCD send_control(0xc3).Pertandingan MySkills Ke-7 Filename: main file.c" #pragma config FOSC = HSPLL_HS // HS oscillator.h> <stdlib.h" // include files #include "header file 2. ADCON1= 0b001111.h> "lcd 2x16 COM2013.Stand alone MPLAB 8 use next */ //short char CmpTest. // off comparator pg 234 Initialize_LCD().h #include #include #include #include #include #include <p18f4550. putr_lcd("Given Codes").c #include "header file 1. short CmpTest.h> <stdio. unsigned char i=0. PLL enabled (HSPLL) #pragma config PLLDIV = 4 // Divide by 4 (16 MHz oscillator input) #pragma config CPUDIV = OSC4_PLL6 // [Primary Oscillator Src: /4][96 MHz PLL Src: /6] #pragma config USBDIV = 2 // USB clock comes from 96 MHz PLL output / 2 #pragma config FCMEN = OFF // Disable Fail-Safe Clock Monitor #pragma config IESO = OFF // Disable Oscillator Switchover mode #pragma config PWRT = OFF // Disable Power-up timer #pragma config BOR = OFF // Disable Brown-out reset #pragma config VREGEN = ON // Use internal USB 3. // Digital I/O CMCON = 0b00000111.

*/ /* ---------------------End of File --------------------------*/ Filename: lcd 2x16 COM2013.TRISB4 TRIS_PWM0 TRISCbits.com Revision: 1 Depedency: lcd 2x16 COM2013. the USB module must be disabled (UCON<3> = 0) and the on-chip USB transceiver must be disabled (UCFG<3> = 1).c /* Filename: lcd 2x16 COM2013.RB3 PB3 PORTBbits. Delay10KTCYx(1). } return 0.Pertandingan MySkills Ke-7 Filename: header file 2.TRISB2 TRIS_PB2 TRISBbits.TRISC2 unsigned char x.h #define #define #define #define #define #define #define #define PB1 PORTBbits.RC2 TRIS_PB1 TRISBbits. i++){ x=PORTB>>2&0B0111.h */ #include "lcd 2x16 COM2013.Stand alone MPLAB 8 use next */ //unsigned short char delay_jab(void){ unsigned short delay_jab(void){ unsigned char i.RB2 PB2 PORTBbits.RB4 PWM0 PORTCbits.h" //continue . for(i=0. /*select accordingly . Adam Email: ismail_adam@yahoo.TRISB3 TRIS_PB3 TRISBbits. if ((x!=y)&&(x!=0b000)) return 1. i<100. y. } /* To use pins RC4 and RC5 as digital inputs.c Date: 20/12/2012 Author: Ismail b.

LCD_RW = 1. } 0. i++) Nop(). 0. LCD_E = 0. DelayFor18TCY(). DelayFor18TCY(). DelayFor18TCY(). DelayFor18TCY(). LCD_DATA &= 0x0f. LCD_E = 1. LCD_DATA |= (CMD&0xf0). DelayFor18TCY(). LCD_DATA_TRIS &= 0x0f. // if b7 low // pull down clock // complete for another nibble // pull high clock // pull down clock } void send_control(char CMD){ while(check_busy()). LCD_DATA &= 0x0f. LCD_E = 0. LCD_DATA_TRIS |= 0x0f0. DelayFor18TCY(). DelayFor18TCY(). return 0. 1. LCD_E = DelayFor18TCY(). } // Set data line as output // clear previous higher nibble on data line // put higher nibble // Logic ‘0’ // Logic ‘0’ // pull high clock // pull down clock // clear previous higher nibble on data line // put lower nibble // pull high clock // pull down clock //continue . LCD_E = DelayFor18TCY().Pertandingan MySkills Ke-7 //continuation /*Provide 18 instruction cycles for LCD internal delay*/ void DelayFor18TCY( void ) { unsigned char i. LCD_E = DelayFor18TCY(). 1. LCD_RW = 0. LCD_E = DelayFor18TCY(). if (LCD_DATA&0x80){ LCD_E = DelayFor18TCY(). LCD_E = 1. 0. return 1. LCD_RS = 0. LCD_E = 1. for (i=0. LCD_DATA |= ((CMD<<4) & 0xf0). // Logic ‘0’ // Logic ‘1’ // Set data line as input // pull high clock // if b7 high // pull down clock // complete for another nibble // pull high clock // pull down clock 0. } unsigned char check_busy(void){ LCD_RS = 0. DelayFor18TCY(). i<38. } else{ LCD_E = DelayFor18TCY().

LCD_RW = 0. LCD_DATA |= (x & 0xf0). LCD_RW = 0. DelayFor18TCY(). LCD_E = 0. // clear previous higher nibble on data line LCD_DATA |= x & 0xf0. DelayFor18TCY(). // Set data line as output LCD_DATA &= 0x0f. DelayFor18TCY(). LCD_E = 1. LCD_DATA &= 0x0f. LCD_RS = 1. DelayFor18TCY(). DelayFor18TCY(). LCD_E = 1. LCD_DATA_TRIS &= 0x0f. LCD_RS = 0. LCD_DATA |= ((x<<4) & 0xf0). DelayFor18TCY(). LCD_E = 1. DelayFor18TCY(). LCD_E = 0. LCD_E = 0. DelayFor18TCY(). LCD_E = 0. DelayFor18TCY(). while(check_busy()). } // Set data line as output // clear previous higher nibble on data line // put higher nibble // Logic ‘0’ // Logic ‘0’ // pull high clock // pull down clock void send_data(char x){ while(check_busy()). LCD_DATA_TRIS |= 0xf0. return x. DelayFor18TCY(). } // Logic ‘1’ // Logic ‘0’ // pull high clock // pull down clock // clear previous higher nibble on data line // put lower nibble // pull high clock // pull down clock // Set data line as input // Logic ‘1’ // Logic ‘1’ // pull high clock // pull down clock // pull high clock // pull down clock //Continue . LCD_RW = 1. // put higher nibble LCD_RS = 1. DelayFor18TCY().Pertandingan MySkills Ke-7 //continuation void Four_bit_only (char x){ while(check_busy()). LCD_E = 1. x |= (LCD_DATA>>4) &0x0f. LCD_DATA_TRIS &= 0x0f. DelayFor18TCY(). } char read_data(void){ char x. DelayFor18TCY(). x = LCD_DATA&0xf0. LCD_DATA &= 0x0f. LCD_E = 1. LCD_E = 0.

pointer++. The author is under no obligation to provide support.TRISD1 . Delay1KTCYx(250).RD2 #define TRIS_LCD_RS TRISDbits.h This free 2 x 16 LCD driver are provided as is without any guarantees or warranty. Although the author has attempted to find and correct any bugs in the codes. (entry 6 T6) send_control(0b00001110 ).4-bit.com Revision: 1 Depedency: delay. service. LCD_RS = 0.c --------------------------------------------*/ Filename: lcd 2x16 COM2013.h Date: 20/12/2012 Author: Ismail b. LCD_RW = 0. pointer++. the author is not responsible for any damage or losses of any kind caused by the use or misuse of the codes. no shift (entry 3 T6) /*---------------------End of lcd 2 x 16 COM2013. } // Set all lines as output // Logic ‘0’ // Logic ‘0’ // Logic ‘0’ // 15ms // (1)1st Function Set .RD0 TRISDbits. LCD_E = 0.h /*Filename: lcd 2x16 COM2013. 5X7 // (3)Display & cursor on/off (entry 4 T6) // (4)Entry mode . Adam Email: ismail_adam@yahoo. } } // print till null encountered void putr_lcd(const rom char *pointer){ while(*pointer){ // WHILE NOT NULL CHARACTER send_data(*pointer). send_control(0b00000110).TRISD0 // EN signal for LCD // RS signal for LCD // RW signal for LCD //continue /* #define LCD_RS PORTDbits. 2 lines.Pertandingan MySkills Ke-7 //continuation /* Print the string from the buffer pointed by pointer*/ void puts_lcd(char *pointer){ while(*pointer){ send_data(*pointer). Four_bit_only(0b00100000). */ /* definitions of PINs connected to 2 x 16 LCD*/ #define LCD_DATA PORTD #define LCD_DATA_TRIS TRISD #define LCD_E #define TRIS_LCD_E PORTDbits. send_control(0b00101000). or upgrades to the programs. corrections. } } void Initialize_LCD(void){ LCD_DATA_TRIS = 0b00000000.inc addr.4-bit (entry 1 T12) // (2)2nd Function Set .RD1 #define TRIS_LCD_RW TRISDbits.TRISD2 #define LCD_RW PORTDbits.

h --------------------------------------------*/ . sends x only to LCD */ void send_data(char x). Note: x must be defined as character*/ void puts_lcd(char *pointer). putr_lcd(array1). Returns: None Example used: */ puts_lcd(array1). /* Reads data (RS=1 and RW =1) from the set address. /* Prints the string from the buffer pointed by pointer. /*Provides 18 instruction cycles for LCD internal delay*/ unsigned char check_busy(void). /*Initializes the LCD and must be called once by the main function. void putr_lcd(const rom char *pointer). /* Sends only the higher nibble of the given character. Returns: None Example used: send_control(x). The string can be defined on the program ROM as char const rom array1[]="Just testing".Pertandingan MySkills Ke-7 //continuation void DelayFor18TCY( void ). It could be called as: while(check_busy()). /* Sends command (RS=0 and RW =0) to LCD. putr_lcd("ASC 2012).page 199*/ char read_data(void).page 199*/ void Four_bit_only(char CMD). 2. where x is any character to be displayed on the LCD For detail please refer to HD44780U (LCD-II) . Returns: None Example used: send_data(x). /* Sends data (RS=1 and RW =0) to LCD. /* Checks busy flag which is b7 of the LCD lines. */ void Initialize_LCD(void).page 207*/ /*---------------------End of lcd 2 x 16 COM2013. where x is any character that define as LCD command For detail please refer to HD44780U (LCD-II) . /* Prints the string from the buffer pointed by pointer. Returns: None Example used: Four_bit_only(x:y). Returns: None Example used: 1. For detail please refer to HD44780U (LCD-II) . Returns: Character whuch is pointed by the CURSOR Example used: x = read_data(). // wait here till not busy */ void send_control(char CMD). It returns 1 on busy or 0 on not busy. The string can be defined on the program RAM/register as char array1[]="Just testing".

Pertandingan MySkills Ke-7 .