You are on page 1of 11

Pertandingan Myskills Ke-7

PERTANDINGAN MySkills 2013

(ELECTRONICS)

6 JAM PERINGKAT PRA-KELAYAKAN

NAMA: __________________________________________

NO. KP:__________________________________________

JABATAN PEMBANGUNAN KEMAHIRAN KEMENTERIAN SUMBER MANUSIA 1

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

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 J1 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 T1CKI PWM1 PWM0 TX/RC6 RX/RC7 SDO IO0 IO1 IO2 IO3 IO4 IO5 IO6 IO7 IO16 IO17 IO18 MCLR IO10 IO11 IO12 IO13 IO14 IO15 PGM PGC PGD VUSB 1N4001 18 VUSB PIC18F4550 8 9 10 1 C9 25v/22uF 0v GND 19 20 21 22 27 28 29 30 +12v U2 D2 +12v 1 7805 VI VO 3 +5V C10 25V/22uF C11 25V/22uF Figure 2 3 2 pin15 (lcd) VEE IO2 IO 1 IO 0 IO 4 IO 5 IO 6 IO 7 pin16 (lcd) R9 +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 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 QT’Y 3 3 3 3 3 2 1 3 3 1 REFERENCE NUMBER 2 4 3 2 5 1 2 1 1 1 1 1 1 1 2 1 1 3 4 4 .

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 .type Description Notes 5 .      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 Microchip PIC Kit 3 downloader 1 1 4 1 1 1 The competitor needs to prepare the following equipments. installations and materials. machinery.

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.c #include "header file 1. ADCON1= 0b001111. send_control(0xc3). Initialize_LCD(). putr_lcd("PKM 2013"). CMCON = 0b00000111.h" // definitions.h #include #include #include #include #include #include <p18f4550. PWM0=0. global variables and function prototypes void main(void){ unsigned char i.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 --------------------------*/ 6 . // Digital I/O // off comparator pg 234 // setting Push Button as input and PWM as output // Must be called prior to usage of LCD while(1){ }// while } //Main /* ---------------------End of File --------------------------*/ Filename: header file 1.h" // include files #include "header file 2.count.h> <string. TRIS_PB1=1.h> <stdio.Filename: main file.h> <stdlib. TRIS_PB3=1. TRIS_PB2=1.c" #pragma config FOSC = HSPLL_HS // HS oscillator.h> "lcd 2x16 COM2013. TRIS_PWM0=0. send_control(0x82).h> <delays. putr_lcd("Given Codes").

i++){ x=PORTB>>2&0B0111.Filename: header file 2. y.TRISC2 unsigned char x.c /* Filename: lcd 2x16 COM2013. for(i=0. i<100.TRISB3 TRIS_PB3 TRISBbits. the function terminated by returning 1 */ unsigned short char delay_jab(void){ unsigned char i.RB3 PB3 PORTBbits.RC2 TRIS_PB1 TRISBbits. the USB module must be disabled (UCON<3> = 0) and the on-chip USB transceiver must be disabled (UCFG<3> = 1 /* ---------------------End of File --------------------------*/ Filename: lcd 2 x 16 COM3013. } /* To use pins RC4 and RC5 as digital inputs.h #define #define #define #define #define #define #define #define PB1 PORTBbits.RB4 PWM0 PORTCbits. } return 0. if (x!=y) return 1. if RB3-RB5 different to previous RB3-RB5.h */ #include "lcd 2x16 COM2013.RB2 PB2 PORTBbits.TRISB2 TRIS_PB2 TRISBbits.TRISB4 TRIS_PWM0 TRISCbits. Delay10KTCYx(1).c Date: 20/12/2012 Author: Myskills JPK Revision: 1 Depedency: lcd 2x16 COM2013. /* This function delay the system for the duration determines by i and system clock while checking RB2RB5.h" //continue 7 .

DelayFor18TCY(). LCD_RW = 1. LCD_DATA &= 0x0f. } else{ LCD_E = DelayFor18TCY(). DelayFor18TCY(). LCD_E = 1. LCD_E = DelayFor18TCY(). for (i=0.//continuation /*Provide 18 instruction cycles for LCD internal delay*/ void DelayFor18TCY( void ) { unsigned char i. DelayFor18TCY(). DelayFor18TCY(). 1. if (LCD_DATA&0x80){ LCD_E = DelayFor18TCY(). return 0. DelayFor18TCY(). DelayFor18TCY(). LCD_DATA &= 0x0f. LCD_E = 0. LCD_E = DelayFor18TCY(). } unsigned char check_busy(void){ LCD_RS = 0. LCD_RW = 0. i++) Nop(). LCD_RS = 0. LCD_E = DelayFor18TCY(). // 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. LCD_DATA_TRIS &= 0x0f. LCD_E = DelayFor18TCY(). LCD_E = 1. LCD_E = 1. return 1. LCD_DATA |= ((CMD<<4) & 0xf0). DelayFor18TCY(). LCD_E = 0. LCD_DATA |= (CMD&0xf0). } 0. i<38. LCD_DATA_TRIS |= 0x0f0. 0. DelayFor18TCY(). // if b7 low // pull down clock // complete for another nibble // pull high clock // pull down clock // 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 8 . } } void send_control(char CMD){ while(check_busy()). 0. 1.

DelayFor18TCY(). // Set data line as output LCD_DATA &= 0x0f. LCD_E = 1. DelayFor18TCY(). LCD_E = 0. LCD_RW = 0. LCD_RS = 0. LCD_DATA_TRIS &= 0x0f. LCD_RW = 1. LCD_DATA_TRIS |= 0xf0. LCD_E = 0. LCD_DATA &= 0x0f. while(check_busy()). LCD_DATA &= 0x0f. // clear previous higher nibble on data line LCD_DATA |= x & 0xf0. LCD_RW = 0. LCD_E = 1. } char read_data(void){ char x. DelayFor18TCY(). x = LCD_DATA&0xf0. 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 void send_data(char x){ while(check_busy()). LCD_DATA_TRIS &= 0x0f. DelayFor18TCY().//continuation void Four_bit_only (char x){ while(check_busy()). DelayFor18TCY(). DelayFor18TCY(). LCD_DATA |= ((x<<4) & 0xf0). DelayFor18TCY(). LCD_E = 0. LCD_E = 1. DelayFor18TCY(). LCD_E = 0. return x. DelayFor18TCY(). x |= (LCD_DATA>>4) &0x0f. LCD_RS = 1. 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 9 . DelayFor18TCY(). // put higher nibble LCD_RS = 1. LCD_E = 1. LCD_DATA |= (x & 0xf0). DelayFor18TCY(). LCD_E = 1. LCD_E = 0.

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

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