soalan praktikal myskills 2013 electronics - akhir

Upload: nabilo20

Post on 02-Apr-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/27/2019 Soalan Praktikal Myskills 2013 Electronics - Akhir

    1/14

    Pertandingan MySkills Ke-7

    1

    PERTANDINGAN MySkills

    2013

    (ELECTRONICS)

    14 JAM

    PERINGKAT AKHIR

    NAMA: __________________________________________

    NO. KP:__________________________________________

    JABATAN PEMBANGUNAN KEMAHIRANKEMENTERIAN SUMBER MANUSIA

  • 7/27/2019 Soalan Praktikal Myskills 2013 Electronics - Akhir

    2/14

    Pertandingan MySkills Ke-7

    2

    Project : Programmable Incubator

    Time Limit: 14 hrs

    This Project accesses each competitor to design PCB, assemble project; write anEmbedded C code and test the developed prototype.

    Project Description:

    The incubator regulates temperature and humidity based on three (3) preset modesdetailed in Table 1. The system monitors present temperature and humidity via the SHT25 (I2C based Humidity and Temperature Sensor). Based on the selectable presetMode, the incubator regulates system temperature and humidity. The block diagram ofthe incubator is shown in Fig. 1.

    Temperature is regulated by regularly switching ON and OFF the heater (bulb) whichdriven by the system through solid state relay (SSR). While humidity is controlled by

    switching ON or OFF the EXHAUST fan or MIX fan. The purposes of the EXHAUST andMIX fan to decrease and increase the system humidity respectively. On top of it,Start/Stop and MODE buttons were provided to start or stop the system and forincremental selecting of MODE. Each pressing of MODE button changes the MODE bya step of one (1). In the case of the present MODE is at a maximum (2) level, anotherpressing of MODE button resulting in the MODE resetting to 0. The completeschematic diagram is provided in Fig. 2.

    Fig. 1: Block Diagram of the Programable Incubator

    Table 1: Relationship of temperature and humidity with the selected mode.

    Type of birds MODE TEMPERATURE HUMIDITY(min) HUMIDITY(max)

    Chicken 0 28 0.5C 10% 14%

    Goose 1 30 0.5C 12% 16%

    Dove 2 32 0.5C 14% 18%

  • 7/27/2019 Soalan Praktikal Myskills 2013 Electronics - Akhir

    3/14

    3

    X1

    16MHz

    C227p

    C127p

    +

    RA0/AN02

    RA1/AN13

    RA2/AN2/VREF-/CVREF4

    RA3/AN3/VREF+5

    RA4/T0CKI/C1OUT/RCV6

    RA5/AN4/SS/LVDIN/C2OUT7

    RA6/OSC2/CLKO14

    OSC1/CLKI13

    RB0/AN12/INT0/FLT0/SDI/SDA33

    RB1/AN10/INT1/SCK/SCL34

    RB2/AN8/INT2/VMO35

    RB3/AN9/CCP2/VPO36

    RB4/AN11/KBI0/CSSPP37

    RB5/KBI1/PGM38

    RB6/KBI2/PGC39

    RB7/KBI3/PGD40

    RC0/T1OSO/T1CKI15

    RC1/T1OSI/CCP2/UOE16

    RC2/CCP1/P1A17

    VUSB18

    RC4/D-/VM23

    RC5/D+/VP24

    RC6/TX/CK25

    RC7/RX/DT/SDO26

    RD0/SPP019

    RD1/SPP120

    RD2/SPP221

    RD3/SPP322

    RD4/SPP427

    RD5/SPP5/P1B28

    RD6/SPP6/P1C29

    RD7/SPP7/P1D30

    RE0/AN5/CK1SPP8

    RE1/AN6/CK2SPP9

    RE2/AN7/OESPP10

    RE3/MCLR/VPP1

    U1

    PIC18F4550

    MCLR

    OSC1

    OSC2

    OSC2

    OSC1

    VUSB

    1 2 3 4 5 6

    J166226-006

    MCLR

    +5V

    PGD

    PGC

    IO8

    IO9

    IO10IO11

    IO12

    IO13

    IO14

    IO15

    PGM

    PGC

    PGD

    ANA0

    ANA1

    ANA2

    ANA3

    T0CKI

    ANA4

    IO0

    IO1

    IO2IO3

    IO4

    IO5

    IO6

    IO7

    PWM1

    PWM0

    TX/RC6RX/RC7

    SDOSDA

    SCL

    SS

    PICKIT3

    IO16

    IO17

    IO18

    VI1

    VO3

    GND

    2

    U27805

    C625v/22uF

    C725V/22uF

    VI1

    VO3

    GND

    2

    U37805

    C1025v/22uF C11

    25V/22uF

    D1

    1N4001

    +12v

    +12v

    0v

    +5V

    C825V/22uF

    +12v +5v Vo

    Coup

    microc

    T1CKI

    D7

    14

    D6

    13

    D5

    12

    D4

    11

    D3

    10

    D2

    9

    D1

    8

    D0

    7

    E

    6

    RW

    5

    RS

    4

    VSS

    1

    VDD

    2

    VEE

    3

    LCD1LM016L

    +5v Vo

    IO1

    IO2

    IO0

    IO4

    IO5

    IO6

    IO7

    RV110K

    VEE

    +5v Vo

    Pin15(lcd

    )

    Pin16(lcd

    )

    R5

    33R

    +5v Vo

    +5v Vo

    R310k

    C12100n

    MODE

    +5v Vo

    R410k

    C13100n

    START/STOP

    IO 10

    IO 11

    X1

    Y2

    C

    13

    U5:A4066

    X11

    Y10

    C

    12

    U5:B4066

    Q1BC547

    R61k

    R710k

    IO 12

    PWM1

    +5v Vo

    R8

    120R

    R1

    120R

    1

    2

    J4

    SIL-156-02

    PWM0

    Output For

    AC 240V bulb 200w

    control via Solid State Relay

    1

    23

    4

    J5

    SIL-156-04

    SCL

    SDA

    SHT25

    HUMIDITY & TEMPERATURE

    SENSOR - I2C

    R1310k

    R1210k

    +5v Vo +5v Vo

    +5vV

    o

    VEE

    12VDC 2AAdaptor

    Fig. 2: Schematic Diagram of the Programable Incubator

  • 7/27/2019 Soalan Praktikal Myskills 2013 Electronics - Akhir

    4/14

    Pertandingan MySkills Ke-7

    4

    Task 1

    Design a single-sided Printed Circuit Board (PCB) based on the GIVEN schematicdiagram in Fig 2.

    Task 2

    Assemble components on the designed PCB.

    Task 3

    Build and fix the prototype with all the accessories

    Task 4

    Write an embedded C code as follows. Use the provided drivers.

    4.1. Upon Power Up / Reset; heater, EXHAUST and MIX fan should be OFF.

    The preset power (P) and Mode (M) should be OFF and 0 respectively.

    These are displayed on the LCD following the format shown below.

    Note:

    XX is the preset temperature

    YY is the preset humidity

    4.2. Upon pressing of the Start/Stop Button (PB1) for the first time; P must

    indicates ON. System regulates heat and humidity based on in the preset

    Mode in task 4.1. The display must be update as shown below.

    Note:

    XX is the preset temperature

    YY is the preset humidity

    4.3. Continuously pressing the Start/Stop Button (PB1), P toggling. System

    turns ON if previous P is OFF or vice versa. Each changing in P should

    be accompanied by changing of the string ON to OFF or vice versa.

  • 7/27/2019 Soalan Praktikal Myskills 2013 Electronics - Akhir

    5/14

    Pertandingan MySkills Ke-7

    5

    4.4. If the MODE button (PB2) is pressed, M advances by one (1). It rolls off

    to 0 when it reaches 3. The display must be updated for each changing

    in M.

    Task 5

    Test and verify the functionality of the designed protoype

    Marking scheme:

    Item Description Weight Score

    1 Funtionality of Developed Protoype 50%

    2 Quality of Wiring 6%

    3 Quality of Component Assembly 6%

    4 Quality of Soldering 6%

    5 Design of PCB board 20%

    6 Quality of Mechanical Assembly 12%

  • 7/27/2019 Soalan Praktikal Myskills 2013 Electronics - Akhir

    6/14

    Pertandingan MySkills Ke-7

    6

    Parts List (Table 2)

    Item Parts name and value Qty Reference number

    1 RESISTORS CORBON TYPE 1/4W 5%

    33R

    120R

    680R

    1K

    10K Trim Pot Preset PCB Type 10K

    121181

    2 CAPACITORS

    22uF 25v (Electrolytic)

    100nF (ceramic) 220nF (ceramic) 27pF (ceramic)

    6

    412

    3 SEMICONDUCTOR COMPONENTS

    PIC 18F4550 c/w socket

    Voltage Regulator 7805 c/wHeatsink

    IC 4066

    Transistor BC547

    MOSFET IRF540N C/W Heatsink Diod IN4001

    12

    11

    23

    4 OTHERS

    Copper board 25cm x 11cm LPKFsingle sided PCB FR4229x305x1.5mm with referencehole fiber glass type

    LCD LM016L

    Crystal 16Mhz

    6 pin PCB Header 45 degree bend

    Random turn ON Solid State Relay CSW2410FPGSH-10

    12V DC Auxiliary Fan Saiz 80mmX 80mm X 25mm

    Normaly Open PCB Miniture PushButton Switch

    16 Pin Female Header

    16 Pin Male Header

    1

    111

    1

    2

    3

    11

  • 7/27/2019 Soalan Praktikal Myskills 2013 Electronics - Akhir

    7/14

    Pertandingan MySkills Ke-7

    7

    AC Bulb C/W Screw type LampHolder - 240VAC 200Watt

    Connector - Header 2 PIN

    Connector - Header 5 PIN

    Ribbon cable - 16 way 10 meter

    Aqua Star Aquarium Tankcompleted with top cover materialis Acrylic ,Saiz 30 x 18 x 25.5cm

    DC Adapter C/W female conector -12VDC 2A

    SHT25 HUMIDITY &TEMPERATURESENSOR- I2C

    1

    311

    1

    1

    1

    The competitor needs to prepare the following equipments, machinery,installations and materials.

    Item Qty Material Description Notes

    1 1 Soldering Iron and equipment

    2 1 Soldering Iron Stand

    3 1 Solder wick or Solder Remover

    4 1 Brush

    5 1 Pincer

    6 1 Nipper

    7 1 Wire Stripper

    8 1 Scissors

    9 1 Tweezers

    10 1 IC pick

    11 1 PCB stand

    12 1 Parts box

    13 1 Precise screwdriver For trimmer resistor

    14 1 Screw driver + type

    15 1 Screw driver - type

    16 1 Spanner

    17 1 Safety Glasses

  • 7/27/2019 Soalan Praktikal Myskills 2013 Electronics - Akhir

    8/14

    Pertandingan MySkills Ke-7

    8

    Filename: main file.c

    Filename: header file 1.h

    Filename: lcd 2 x 16 COM3013.c

    #include "header file 1.h" // include files and global variables

    void main(void){short char CmpTest;

    unsigned char i=0;ADCON1= 0b001111; // Digital I/OCMCON = 0b00000111; // off comparator pg 234

    Initialize_LCD(); // Must be called prior to usage of LCD

    send_control(0x82);putr_lcd("Given Codes");send_control(0xc3);putr_lcd("PKM 2013");

    while(1){

    }// while

    } //Main/* ---------------------End of File --------------------------*/

    #include #include #include #include #include #include #include #include

    #include #include #include #include #include "lcd 2x16 COM2013.c"#include "SHT 25.c"#pragma config FOSC=XT_XT, PWRT = OFF,BOR = OFF, MCLRE = ON, ICPRT = OFF, WDT=OFF, LVP=OFF, DEBUG=OFF

    /* ---------------------End of File --------------------------*/

    /*Filename: lcd 2x16 COM2013.c

    Date: 20/12/2012Author: Ismail b. AdamEmail: [email protected]: 1Depedency: lcd 2x16 COM2013.h*/

    #include "lcd 2x16 COM2013.h"//continue

  • 7/27/2019 Soalan Praktikal Myskills 2013 Electronics - Akhir

    9/14

    Pertandingan MySkills Ke-7

    9

    //continuation

    /*Provide 18 instruction cycles for LCD internal delay*/void DelayFor18TCY( void ){ unsigned char i;

    for (i=0; i

  • 7/27/2019 Soalan Praktikal Myskills 2013 Electronics - Akhir

    10/14

    Pertandingan MySkills Ke-7

    10

    //continuation

    void Four_bit_only (char x){while(check_busy());LCD_DATA_TRIS &= 0x0f; // Set data line as outputLCD_DATA &= 0x0f; // clear previous higher nibble on data lineLCD_DATA |= (x & 0xf0); // put higher nibble

    LCD_RS = 0; // Logic 0LCD_RW = 0; // Logic 0DelayFor18TCY();LCD_E = 1; // pull high clockDelayFor18TCY();LCD_E = 0; // pull down clockDelayFor18TCY();

    }

    void send_data(char x){while(check_busy());

    LCD_DATA_TRIS &= 0x0f; // Set data line as outputLCD_DATA &= 0x0f; // clear previous higher nibble on data line

    LCD_DATA |= x & 0xf0; // put higher nibble

    LCD_RS = 1; // Logic 1LCD_RW = 0; // Logic 0

    DelayFor18TCY();LCD_E = 1; // pull high clockDelayFor18TCY();LCD_E = 0; // pull down clockDelayFor18TCY();

    LCD_DATA &= 0x0f; // clear previous higher nibble on data lineLCD_DATA |= ((x4) &0x0f;LCD_E = 0; // pull down clockreturn x;}

    //Continue

  • 7/27/2019 Soalan Praktikal Myskills 2013 Electronics - Akhir

    11/14

    Pertandingan MySkills Ke-7

    11

    Filename: lcd 2 x 16 COM3013.h

    //continuation

    /* Print the string from the buffer pointed by pointer*/void puts_lcd(char *pointer){

    while(*pointer){ // print till null encounteredsend_data(*pointer);

    pointer++;

    }}

    void putr_lcd(const rom char *pointer){while(*pointer){ // WHILE NOT NULL CHARACTER

    send_data(*pointer);pointer++;}

    }

    void Initialize_LCD(void){LCD_DATA_TRIS = 0b00000000; // Set all lines as outputLCD_E = 0; // Logic 0LCD_RS = 0; // Logic 0LCD_RW = 0; // Logic 0

    Delay1KTCYx(250); // 15msFour_bit_only(0b00100000); // (1)1st Function Set - 4-bit (entry 1 T12)send_control(0b00101000); // (2)2nd Function Set - 4-bit, 2 lines, 5X7 (entry 6 T6)send_control(0b00001110 ); // (3)Display & cursor on/off (entry 4 T6)send_control(0b00000110); // (4)Entry mode - inc addr, no shift (entry 3 T6)}

    /*---------------------End of lcd 2 x 16 COM2013.c --------------------------------------------*/

    /*Filename: lcd 2x16 COM2013.h

    Date: 20/12/2012Author: Ismail b. AdamEmail: [email protected]: 1Depedency: delay.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 thecodes, the author is not responsible for any damageor losses of any kind caused by the use or misuse of the codes.

    The author is under no obligation to provide support, service, corrections,or upgrades to the programs.*/

    /* definitions of PINs connected to 2 x 16 LCD*/#define LCD_DATA PORTD#define LCD_DATA_TRIS TRISD#define LCD_E PORTDbits.RD0 // EN signal for LCD#define TRIS_LCD_E TRISDbits.TRISD0#define LCD_RS PORTDbits.RD2 // RS signal for LCD#define TRIS_LCD_RS TRISDbits.TRISD2#define LCD_RW PORTDbits.RD1 // RW signal for LCD#define TRIS_LCD_RW TRISDbits.TRISD1

    //continue

  • 7/27/2019 Soalan Praktikal Myskills 2013 Electronics - Akhir

    12/14

    Pertandingan MySkills Ke-7

    12

    //continuation

    void DelayFor18TCY( void );/*Provides 18 instruction cycles for LCD internal delay*/

    unsigned char check_busy(void);/* Checks busy flag which is b7 of the LCD lines.It returns 1 on busy or 0 on not busy. It could be calledas:

    while(check_busy()); // wait here till not busy*/

    void send_control(char CMD);/* Sends command (RS=0 and RW =0) to LCD.Returns: NoneExample used:

    send_control(x);where x is any character that define as LCD command

    For detail please refer to HD44780U (LCD-II) - page 199*/

    void Four_bit_only(char CMD);/* Sends only the higher nibble of the given character.Returns: NoneExample used:

    Four_bit_only(x:y);sends x only to LCD

    */

    void send_data(char x);/* Sends data (RS=1 and RW =0) to LCD.Returns: NoneExample used:

    send_data(x);where x is any character to be displayed on the LCD

    For detail please refer to HD44780U (LCD-II) - page 199*/

    char read_data(void);/* Reads data (RS=1 and RW =1) from the set address.Returns: Character whuch is pointed by the CURSORExample used:

    x = read_data();Note:x must be defined as character*/

    void puts_lcd(char *pointer);/* Prints the string from the buffer pointed by pointer.The string can be defined on the program RAM/register aschar array1[]="Just testing";

    Returns: NoneExample used:

    puts_lcd(array1);*/

    void putr_lcd(const rom char *pointer);/* Prints the string from the buffer pointed by pointer.The string can be defined on the program ROM aschar const rom array1[]="Just testing";

    Returns: NoneExample used:

    1. putr_lcd(array1);2. putr_lcd("ASC 2012);

    */

    void Initialize_LCD(void);/*Initializes the LCD and must be called once by the main function.For detail please refer to HD44780U (LCD-II) - page 207*/

    /*---------------------End of lcd 2 x 16 COM2013.h --------------------------------------------*/

  • 7/27/2019 Soalan Praktikal Myskills 2013 Electronics - Akhir

    13/14

    Pertandingan MySkills Ke-7

    13

    Filename: SHT 25.h

    Filename: SHT 25.c

    #define Trig_T_HM 0b11100011#define Trig_H_HM 0b11100101

    unsigned int read_temperature(void);unsigned int read_humidity(void);

    /* ---------------------End of File --------------------------*/

    unsigned int read_temperature(void){char TempHI,TempLO,CHK_SUM;

    StartI2C(); // begin I2C communicationIdleI2C(); // wait till bus idle

    WriteI2C(add2write); //IdleI2C(); // wait till bus idle

    WriteI2C(Trig_T_HM); // trigger TemperatureIdleI2C(); // wait till bus idle

    WriteI2C(add2read); //IdleI2C(); // wait till bus idle

    TempHI = ReadI2C(); // get the MSBIdleI2C();AckI2C(); // Send back AcknowledgeIdleI2C();

    TempLO = ReadI2C(); // get the LSBIdleI2C();AckI2C(); // Send back AcknowledgeIdleI2C();

    CHK_SUM = ReadI2C(); // get the ChecksumIdleI2C();NotAckI2C(); // Send back AcknowledgeIdleI2C();

    StopI2C(); // stop all I2C communicationsreturn (TempHI

  • 7/27/2019 Soalan Praktikal Myskills 2013 Electronics - Akhir

    14/14

    Pertandingan MySkills Ke-7

    14

    //continuation

    unsigned int read_humidity(void){char HumHI,HumLO,CHK_SUM;

    StartI2C(); // begin I2C communication

    IdleI2C(); // wait till bus idle

    WriteI2C(add2write); //IdleI2C(); // wait till bus idle

    WriteI2C(Trig_H_HM); // trigger HumidityIdleI2C(); // wait till bus idle

    WriteI2C(add2read); //IdleI2C(); // wait till bus idle

    HumHI = ReadI2C(); // get the MSBIdleI2C();AckI2C(); // Send back AcknowledgeIdleI2C();

    HumLO = ReadI2C(); // get the LSB

    IdleI2C();AckI2C(); // Send back AcknowledgeIdleI2C();

    CHK_SUM = ReadI2C(); // get the ChecksumIdleI2C();NotAckI2C(); // Send back AcknowledgeIdleI2C();StopI2C(); // stop all I2C communicationsreturn (HumHI