Вы находитесь на странице: 1из 14

Pertandingan MySkills Ke-7

Pertandingan MySkills Ke-7 PERTANDINGAN MySkills 2013 (ELECTRONICS) 14 JAM PERINGKAT AKHIR NAMA: NO. KP: JABATAN PEMBANG
Pertandingan MySkills Ke-7 PERTANDINGAN MySkills 2013 (ELECTRONICS) 14 JAM PERINGKAT AKHIR NAMA: NO. KP: JABATAN PEMBANG

PERTANDINGAN MySkills

2013

(ELECTRONICS)

14 JAM

PERINGKAT AKHIR

NAMA:

NO. KP:

JABATAN PEMBANGUNAN KEMAHIRAN KEMENTERIAN SUMBER MANUSIA

1

Pertandingan MySkills Ke-7

Project : Programmable Incubator

Time Limit: 14 hrs

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

Project Description:

The incubator regulates temperature and humidity based on three (3) preset modes detailed in Table 1. The system monitors present temperature and humidity via the SHT 25 (I2C based Humidity and Temperature Sensor). Based on the selectable preset Mode, the incubator regulates system temperature and humidity. The block diagram of the incubator is shown in Fig. 1.

Temperature is regulated by regularly switching ON and OFF the heater (bulb) which driven 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 and MIX 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 “for incremental selecting of MODE. Each pressing of “MODE” button changes the MODE by a step of one (1). In the case of the present MODE is at a maximum (2) level, another pressing of “MODE” button resulting in the MODE resetting to ‘0’. The complete schematic diagram is provided in Fig. 2.

The complete schematic diagram is provided in Fig. 2. Fig. 1: Block Diagram of the Programable

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.5˚C

10%

14%

Goose

1

30

± 0.5˚C

12%

16%

Dove

2

32

± 0.5 ˚C

14%

18%

2

Pertandingan MySkills Ke-7

SDA

SCL

IO8

IO9

LCD1

+5v Vo LM016L PICKIT3 +5v Vo +12v J1 J4 66226-006 Output For 1 AC 240V
+5v Vo
LM016L
PICKIT3
+5v Vo
+12v
J1
J4
66226-006
Output For
1 AC 240V bulb 200w
PWM0
J2
2 control via Solid State Relay
Output For
RV1
R5
1
12V DC
10K
SIL-156-02
D2
2
Auxiliary Fan
33R
(EXHAUST Fan)
1N4001
SIL-100-02
U5:A
4066
Q3
R8
IRF540N
1
2
PWM1
X
Y
+5v Vo
120R
IO 12
R9
+5v Vo
10k
R7
+12v
10k
+5v Vo
+5v Vo
R6
Output For
1k
J3
12V DC
Q1
D3
1
Auxiliary Fan
R3
R4
2
(MIX Fan)
BC547
1N4001
10k
10k
+5v Vo
+5v Vo
SIL-100-02
U5:B
4066
Q2
IO 10
R10
IRF540N
IO 11
11
10
X
Y
R12
R13
120R
10k
10k
R11
J5
C12
MODE
C13
START/STOP
10k
1
100n
100n
SCL
2
3
SHT25
4
SDA
HUMIDITY & TEMPERATURE
SENSOR - I2C
SIL-156-04
U1
SS
+12v
2
15
ANA0
RA0/AN0
RC0/T1OSO/T1CKI
T1CKI
U2
+5V
3
16
ANA1
RA1/AN1
RC1/T1OSI/CCP2/UOE
PWM1
7805
4
17
ANA2
RA2/AN2/VREF-/CVREF
RC2/CCP1/P1A
PWM0
D1
5
23
ANA3
RA3/AN3/VREF+
RC4/D-/VM
6
24
1
3
Coupling for
T0CKI
RA4/T0CKI/C1OUT/RCV
RC5/D+/VP
+12v
VI
VO
7
25
microcontroller
ANA4
RA5/AN4/SS/LVDIN/C2OUT
RC6/TX/CK
TX/RC6
14
26
1N4001
OSC2
RA6/OSC2/CLKO
RC7/RX/DT/SDO
RX/RC7
+5v
+5v
13
C6
C7
C8
OSC1
OSC1/CLKI
SDO
12VDC 2A
R2
Adaptor
25v/22uF
25V/22uF
25V/22uF
33
19
X1
RB0/AN12/INT0/FLT0/SDI/SDA
RD0/SPP0
IO0
680
34
20
RB1/AN10/INT1/SCK/SCL
RD1/SPP1
IO1
0v
35
21
IO10
RB2/AN8/INT2/VMO
RD2/SPP2
IO2
36
22
R1
IO11
RB3/AN9/CCP2/VPO
RD3/SPP3
IO3
37
27
C3
C4
IO12
RB4/AN11/KBI0/CSSPP
RD4/SPP4
IO4
16MHz
10k
38
28
IO13
RB5/KBI1/PGM
RD5/SPP5/P1B
IO5
+12v
U3
+5v Vo
100n
100n
39
29
C1
C2
IO14
RB6/KBI2/PGC
RD6/SPP6/P1C
IO6
40
30
7805
IO15
RB7/KBI3/PGD
RD7/SPP7/P1D
IO7
27p
27p
C5
PGM
8
1
3
PGC
RE0/AN5/CK1SPP
IO16
VI
VO
220n
9
PGD
RE1/AN6/CK2SPP
IO17
10
RE2/AN7/OESPP
IO18
18
1
C10
VUSB
VUSB
RE3/MCLR/VPP
MCLR
C11
25v/22uF
PIC18F4550
25V/22uF
1
VSS
2
VDD
3
VEE
VEE
4 5 6
IO2
RS
IO 1
RW
IO 0
E
D0
D1
D2
10
D3
11
IO 4
D4
12
IO 5
D5
13
IO 6
D6
14 7 8 9
IO 7
D7
+5v Vo
VEE
Pin15 (lcd)
Pin16 (lcd)
1
MCLR
2
+5V
3
4
PGD
5
PGC
6
2
GND
2
GND
OSC1
12
13
C
C
OSC2
MCLR
MCLR

Fig. 2: Schematic Diagram of the Programable Incubator

3

Pertandingan MySkills Ke-7

Task 1

Design a single-sided Printed Circuit Board (PCB) based on the GIVEN schematic diagram 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.

are displayed on the LCD following the format shown below. Note: XX is the preset temperature

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.

Mode in task 4.1. The display must be update as shown below. Note: XX is the

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.

4

Pertandingan MySkills Ke-7

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.

3. The display must be updated for each changing in M. Task 5 Test and verify

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%

 

5

Pertandingan MySkills Ke-7

Parts List (Table 2)

Item

Parts name and value

Qt’y

Reference number

1

RESISTORS CORBON TYPE 1/4W ± 5%

   

33R

1

120R

2

680R

1

1

1K

10K

Trim Pot Preset PCB Type 10K

8

1

2

CAPACITORS

   

22uF 25v (Electrolytic)

6

100nF (ceramic)

4

220nF (ceramic)

1

27pF (ceramic)

2

3

SEMICONDUCTOR COMPONENTS

   

PIC 18F4550 c/w socket

1

Voltage Regulator 7805 c/w Heatsink

2

IC 4066

1

Transistor BC547

1

MOSFET IRF540N C/W Heatsink

2

Diod IN4001

3

4

OTHERS

   

Copper board 25cm x 11cm LPKF single sided PCB FR4 229x305x1.5mm with reference hole – fiber glass type

1

LCD LM016L

1

Crystal 16Mhz

1

6 pin PCB Header 45 degree bend

Random turn ON Solid State Relay –

1

1

CSW2410FPGSH-10

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

2

Normaly Open PCB Miniture Push Button Switch

3

16 Pin Female Header

16 Pin Male Header

1

1

6

Pertandingan MySkills Ke-7

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

1

Connector - Header 2 PIN

3

Connector - Header 5 PIN

1

Ribbon cable - 16 way 10 meter

1

Aqua Star Aquarium Tank completed with top cover – material is Acrylic ,Saiz 30 x 18 x 25.5cm

1

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

1

SHT25 HUMIDITY & TEMPERATURE SENSOR - I2C

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

Pertandingan MySkills Ke-7

Filename: main file.c

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

void main(void){ short char CmpTest; unsigned char i=0; ADCON1= 0b001111; CMCON = 0b00000111;

Initialize_LCD();

send_control(0x82);

putr_lcd("Given Codes");

send_control(0xc3);

putr_lcd("PKM 2013");

while(1){

}//

while

// Digital I/O // off comparator pg 234

// Must be called prior to usage of LCD

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

Filename: header file 1.h

#include <p18f4550.h> #include <string.h> #include <stdlib.h> #include <stdio.h> #include <delays.h> #include <math.h> #include <adc.h> #include <stdio.h> #include <delays.h> #include <pwm.h> #include <timers.h> #include <i2c.h> #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 2 x 16 COM3013.c

/* Filename: lcd 2x16 COM2013.c Date: 20/12/2012 Author: Ismail b. Adam Email: ismail_adam@yahoo.com Revision: 1 Depedency: lcd 2x16 COM2013.h */

#include "lcd 2x16 COM2013.h"

//continue

8

Pertandingan MySkills Ke-7

//continuation

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

{

unsigned char i; for (i=0; i<38; i++) Nop();

}

unsigned char check_busy(void){

LCD_RS

= 0;

LCD_RW = 1;

LCD_DATA_TRIS |= 0x0f0;

DelayFor18TCY();

= 1;

DelayFor18TCY();

LCD_E

// Logic ‘0’ // Logic ‘1’ // Set data line as input

// pull high clock

if (LCD_DATA&0x80){ LCD_E

= 0;

// if b7 high // pull down clock

DelayFor18TCY();

// complete for another nibble

LCD_E

= 1;

// pull high clock

DelayFor18TCY();

LCD_E

= 0;

// pull down clock

DelayFor18TCY();

return 1;

}

else{

// if b7 low

LCD_E

= 0;

// pull down clock

DelayFor18TCY();

// complete for another nibble

LCD_E

= 1;

// pull high clock

DelayFor18TCY();

LCD_E

= 0;

// pull down clock

DelayFor18TCY();

return 0;

}

}

void send_control(char CMD){

while(check_busy());

LCD_DATA_TRIS &= 0x0f;

LCD_DATA &= 0x0f;

// Set data line as output

// clear previous higher nibble on data line

LCD_DATA |= (CMD&0xf0);

// put higher nibble

LCD_RS

= 0;

// Logic ‘0’

LCD_RW = 0;

// Logic ‘0’

DelayFor18TCY();

LCD_E

DelayFor18TCY();

LCD_E

= 1;

= 0;

// pull high clock

// pull down clock

DelayFor18TCY();

LCD_DATA &= 0x0f;

// clear previous higher nibble on data line

LCD_DATA |= ((CMD<<4) & 0xf0);

// put lower nibble

DelayFor18TCY();

LCD_E

DelayFor18TCY();

LCD_E

DelayFor18TCY();

= 1;

= 0;

}

// pull high clock

// pull down clock

//continue

9

Pertandingan MySkills Ke-7

//continuation

void Four_bit_only (char x){ while(check_busy()); LCD_DATA_TRIS &= 0x0f; LCD_DATA &= 0x0f; LCD_DATA |= (x & 0xf0);

// Set data line as output // clear previous higher nibble on data line // put higher nibble

LCD_RS

= 0;

// Logic ‘0’

LCD_RW = 0;

// Logic ‘0’

DelayFor18TCY();

}

LCD_E

DelayFor18TCY();

LCD_E

DelayFor18TCY();

= 1;

= 0;

// pull high clock

// pull down clock

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

LCD_DATA_TRIS &= 0x0f; LCD_DATA &= 0x0f;

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

// Set data line as output

// clear previous higher nibble on data line

LCD_RS

= 1;

// Logic ‘1’

LCD_RW = 0;

// Logic ‘0’

DelayFor18TCY();

LCD_E

DelayFor18TCY();

LCD_E

DelayFor18TCY();

= 1;

= 0;

LCD_DATA &= 0x0f; LCD_DATA |= ((x<<4) & 0xf0);

DelayFor18TCY();

LCD_E

DelayFor18TCY();

LCD_E

DelayFor18TCY();

= 1;

= 0;

}

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

// pull high clock

// pull down clock

// clear previous higher nibble on data line // put lower nibble

// pull high clock

// pull down clock

LCD_DATA_TRIS |= 0xf0;

// Set data line as input

LCD_RS

= 1;

// Logic ‘1’

LCD_RW = 1;

// Logic ‘1’

DelayFor18TCY();

LCD_E

DelayFor18TCY();

= 1;

x = LCD_DATA&0xf0;

LCD_E

DelayFor18TCY();

LCD_E

= 0;

= 1;

DelayFor18TCY();

x |= (LCD_DATA>>4) &0x0f;

LCD_E

return x;

= 0;

}

// pull high clock

// pull down clock

// pull high clock

// pull down clock

//Continue

10

Pertandingan MySkills Ke-7

//continuation

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

while(*pointer){

send_data(*pointer);

pointer++;

}

}

// print till null encountered

void putr_lcd(const rom char *pointer){

while(*pointer){

send_data(*pointer);

pointer++;

}

}

void Initialize_LCD(void){

// WHILE NOT NULL CHARACTER

LCD_DATA_TRIS = 0b00000000;

LCD_E

= 0;

// Set all lines as output // Logic ‘0’

LCD_RS

= 0;

// Logic ‘0’

LCD_RW = 0;

// Logic ‘0’

Delay1KTCYx(250);

Four_bit_only(0b00100000);

send_control(0b00101000);

send_control(0b00001110 );

send_control(0b00000110);

// 15ms // (1)1st Function Set - 4-bit (entry 1 T12)

// (2)2nd Function Set - 4-bit, 2 lines, 5X7 (entry 6 T6)

// (3)Display & cursor on/off (entry 4 T6)

// (4)Entry mode - inc addr, no shift (entry 3 T6)

}

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

Filename: lcd 2 x 16 COM3013.h

/* Filename: lcd 2x16 COM2013.h Date: 20/12/2012 Author: Ismail b. Adam Email: ismail_adam@yahoo.com Revision: 1 Depedency: 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 the codes, the author is not responsible for any damage or 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

#define LCD_DATA_TRIS TRISD

#define LCD_E

#define TRIS_LCD_E TRISDbits.TRISD0

#define LCD_RS

#define TRIS_LCD_RS TRISDbits.TRISD2

#define LCD_RW

#define TRIS_LCD_RW TRISDbits.TRISD1

PORTD

PORTDbits.RD0

PORTDbits.RD2

PORTDbits.RD1

// EN signal for LCD

// RS signal for LCD

// RW signal for LCD

//continue

11

Pertandingan MySkills Ke-7

//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 called as:

*/

while(check_busy());

// wait here till not busy

void send_control(char CMD); /* Sends command (RS=0 and RW =0) to LCD. Returns: None Example 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: None Example 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: None Example 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 CURSOR Example 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 as char array1[]="Just testing";

Returns: None

Example 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 as char const rom array1[]="Just testing";

Returns: None

Example 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 --------------------------------------------*/

12

Pertandingan MySkills Ke-7

Filename: SHT 25.h

#define Trig_T_HM

0b11100011

#define Trig_H_HM

0b11100101

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

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

Filename: SHT 25.c

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

StartI2C();

// begin I2C communication

IdleI2C();

// wait till bus idle

WriteI2C(add2write); //

IdleI2C();

// wait till bus idle

WriteI2C(Trig_T_HM); // trigger Temperature

IdleI2C();

// wait till bus idle

WriteI2C(add2read);

//

IdleI2C();

// wait till bus idle

TempHI = ReadI2C();

// get the MSB

IdleI2C();

AckI2C();

// Send back Acknowledge

IdleI2C();

TempLO = ReadI2C();

// get the LSB

IdleI2C();

AckI2C();

// Send back Acknowledge

IdleI2C();

CHK_SUM = ReadI2C(); // get the Checksum

IdleI2C();

NotAckI2C();

// Send back Acknowledge

IdleI2C();

StopI2C();

// stop all I2C communications

return (TempHI<<8)+ TempLO

}

//continue

13

Pertandingan MySkills Ke-7

//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 Humidity

IdleI2C();

// wait till bus idle

WriteI2C(add2read);

//

IdleI2C();

// wait till bus idle

HumHI = ReadI2C();

// get the MSB

IdleI2C();

AckI2C();

// Send back Acknowledge

IdleI2C();

HumLO = ReadI2C();

// get the LSB

IdleI2C();

AckI2C();

// Send back Acknowledge

IdleI2C();

CHK_SUM = ReadI2C(); // get the Checksum

IdleI2C();

NotAckI2C();

// Send back Acknowledge

IdleI2C();

StopI2C();

// stop all I2C communications

return (HumHI<<8)+ HumLO

}

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

14