Professional Documents
Culture Documents
Tracker Cu Pic - Tailanda
Tracker Cu Pic - Tailanda
Tracker Cu Pic - Tailanda
SOLAR TRACKING
!
"#$%
SOLAR TRACKING
!
"#$%
SOLAR TRACKING
KEDKANOK HONGTHONG
THEERANAN WIRUNPUTI
) #
,"-
0 !) #
.............................................................."$"-'1! 2334
(=(-19! . *! %% !
)
ii
!
"
#"$!
% !
&"'
(
" " )&
**
!$+* )%'+ ' &"+
'
'$&"
#+ 2 ' ) !+!$
% !
+ 90 ,
'+
**&"+
&
PIC16F877 -.
'%%
iii
ABSTRACT
This project is proposed to make the Solar cell Controller to move follow the sun. The
aim is the Solar cell can get the lightest intensity from the sun by using Microcontroller.
In processing and controlling of moving accurately and using low energy and used 2 Light
Dependent Resistor ( LDR ) to search for the location to make the Solar cell stay 90 degree
with beam of light. And because of Microcontroller PIC16F877 has input and output ports
more than 5 ports and Analog to Digital Converter (A/D) , used PIC16F877 in processing
and controlling of Solar cell moving that call axel 1 . The motor was controlled to move slowly
for generate the electric energy t hat increase the energy more than lay the Solar cell and
stay still in 15 degree about 20 %. From controlling the Solar cell to move follow the sun , can
get more energy from the sun and vary it to electric energy to collect in battery.
Keywords : Solar cell, Microcontroller, Light Dependent Resistor ( LDR ), Motor, Battery
iv
+
/#("
%
%*
78%
+(*&334(
/
+
5#&"" "((.#
-9 #.':%'7 /
'
$ !(
*$2 /-
;0!
"(- *!$+$
.*1#'"+((.#$ !1$2
#!<=%'
" !
)$
!
.$2 ((.9' !(1*
'
% )
*
"((.%2 !+*+
)
$
( !
(1$2* !+-9
'&
((.
%2 )$
**' !+' # *!$+*2 &"
$) . "
..
Abstract...
..
....
.......
..
..
ii
iii
iv
v
vii
ix
x
1 .....
1.1 ..........
1.2 !"....
1.3 #$## %.....
1.4 %& '().........
1
1
2
2
4
5
5
12
18
21
24
25
29
34
34
34
36
38
39
40
41
vi
( )
3.8 %). 43
4 5 ...
4.1 5 '#5$,
'#
5$,
.
4.2 "
65$,
...
4.3 $$ "
65$,
52
55
71
5 "
' ...........
5.1
$6% .....
5.2 "5% ....
5.3 :6 )(#......
5.4 0;.
73
73
73
73
74
$ )
.....
75
<5
77
<5 <0!%). 78
<5 # Datasheet... 81
<5 Source Code 90
5)'%. 103
vii
2.1
2.2
2.3
2.3
2.4
2.5
2.6
2.7
2.8
2.9
2.10
2.11
2.12
2.13
2.14
2.15
2.16
2.17
2.18
2.19
2.20
2.21
2.22
2.23
2.24
2.25
3.1
3.2
.. 6
.. 9
()
! "## $%
... 10
( )
! "## $%
..................... 11
!'((
..... 12
!( "
... 13
)
*!!
... 14
+!,$$%
*!!
............................................ 16
-
-
-!
- 17
.
/-
I-V curve .. 18
.
/-
0-
,$$%
*!!
12 I-V curve 19
LDR.... 20
$
,)
()
3 LDR 4 2 -- --
,
21
+!
!(
11
- LDR.. 22
.
/
,$$%
23
.
/4 )5!6!
!
)5!6(
7
-$.. 24
.
/.................................................................................. 25
.
/
"
!'((
()................................................ 25
,!! PIC 16F877. 27
$=
..................... 28
$=(Spur gear)................................................ 28
$=5 (Worm gear)............................................. 29
$=
(Bevel gear).. 29
$>$=. 30
$=-.
!.
1 30
2
$=5. 31
?
... 35
--
) LDR 36
viii
(
)
3.3
3.4
3.5
3.6
3.7
3.8
3.9
3.10
3.11
3.12
3.13
3.14
3.15
3.16
3.17
3.18
3.19
4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
A
B
C
-/'(
--.
-...........................................................................................
2
-
( ..........................................
6! (Regulator)................
!
@
..
?
5) LDR
++
?
,!..
--
..................................................................................................
Solar Tracking..........................
5
Solar Tracking
Solar Tracking
$=
...
.
5
!)
!
PCB ,!!-....
!
PCB 2
,$-
( ..
2
-
(
)(12 1
!..
$
?
!,$$%
'(+*!!
?
15 "
.
$
?
!,$$%
C!()! *!!
?
15 "
..
$
?
!,$$%
'(+*!!
!'((
.
$
?
!,$$%
C!()!*!!
!'((
.
$--?
!,$$%
+*!!
15 "
- *!!
!'((
.
$--
!
!---
-?
5+*!!
..
(1)** LDR.
..
45
37
38
39
40
41
41
42
43
44
45
46
47
49
50
50
51
51
53
55
62
62
69
69
70
72
78
78
79
ix
ix
1.1
....
4
3.1 ........................................... 48
4.1
.. 54
4.2
15 !" 6
$%&' ( '.. 2552 +
&
,
%-+ %.
/' 56
4.3
15 !" 7
$%&' ( '.. 2552 +
&
,
%-+ %.
/' 57
4.4
15 !" 8
$%&' ( '.. 2552 +
&
,
%-+ %.
/' 58
4.5
15 !" 9
$%&' ( '.. 2552 +
&
,
%-+ %.
/' 59
4.6
15 !" 10
$%&' ( '.. 2552 +
&
,
%-+ %.
/' 60
4.7 $0
1!" Solar Cell %$% 15 . 61
4.8
Tracking !" 8
$%&' ( '.. 2552 +
&
,
%-+ %.
/'. 63
4.9
Tracking !" 9
$%&' ( '.. 2552 +
&
,
%-+ %.
/'. 64
4.10
Tracking !" 10
$%&' ( '.. 2552 +
&
,
%-+ %.
/'. 65
4.11
Tracking !" 13
$%&' ( '.. 2552 +
&
,
%-+ %.
/'. 66
4.12
Tracking !" 14
$%&' ( '.. 2552 +
&
,
%-+ %.
/'. 67
4.13 $0
2" !"%
68
4.14
15 !" 9
$%&' ( '.. 2552 +
&
,
%-+ %.
/' 71
A
Eg
Ia
Lsol
N1
N2
Ra
Rbottom
Rtop
T
Vin
Vout
Vt
Z1
Z2
A
V
A
W
n
n
ohm
ohm
ohm
C
V
V
V
-
( Back emf )
!"#$%
&
'
&
'
1
1.1
!"#
$%&'
( &(%$ !)& *($
+$"
(,"&#-. !$)/$01!$ # *
*0-$>$)"$%$4#<<=($6
*&#&&$6
$
*0-$>$,*"
*0-$>$%#',,'
*0-$>$%
$
*0-$>$%"&,"#" (Light Independent Resistor)
6
,* .+$$)"
#&
6
2"
1 $ #&
&46
40 "
1 4
$))&,"),6
&,*"2"',("
"& #',,'
$
- 0-$>$,*"
- 0-$>$%#',,'
- 0-$>$%
4. "4&!
5. $))))
6. &
7. @)$&#
8. "()$%
9. (%$',
! "
#$%
&$'%
#(($((
(
!"
1
4
3
3
4
4
4
PLAN
FINISH
4
4
1.5
1.
2.
3.
4.
5.
6.
7.
8.
!
"# "$
%&
'
%&
(#&
)
"*+&
,(
(
'
+
,(
(
!-
' -' #-
-
&
( Light Independent Resistor )
!%&
+1(' %(
23
"4
2
2.1
[5]
74
25 !
"#
$% & '()
* '+* G2V ,-% G2 . /
#(.01$23
( 5,780 / (
( 5,515 8,, + .$ 9,940 8: )
-+< !.)=+.$ $%
<!+ + V (< 5)
'>*.*31* .'.= !
'+01+#
#*.$< *
. 8
*?3$=
( 26,000
A!+ '?//*
( 225-250 A * )'/ 215
.$ 1 A!+ #& 1,400 A
2.1 /+<
[5]
* =BC
#% 3 ,-%+*CE* *<-2 "1<.%
'& 1
/1"#.* ? />!
'(,-%"#.2
F /
?/<(
%. .$,*'BC
#+%
,-%
6
2.1.1
+38
G%
/ +8
+
*8%+8
+
/!H
1$2%3
/.!G%
/I%3
6.955108
9106
6.0881018 (2.351012
) (11,900 <
)
1.41221027 8
(3.381017 8
) (1,300,000
<)
#(.0 %!
#(.0 /
>*++ (Lsol)
/<<++
G% (Isol)
~3.751028
(~98 *
)
2.009107 *
7
=BC
%'.1*! ,-%(<1*2.-%. 1$2%
//*+#
(solar constant) (.$
1 . 8+
) /
/*+#
G% % 1,370 *
1*%*/ 1
8+**2 .$1 1,000 *
$%
.$
8C
!
:H ** .!"?'.1$?>1*.2'?
-!J+/
,
'.=?!
$%1$?.*2 )
*I
'1$2=I.!
2>* 2 )+I% #2B'.=+
>,
+#
*2! 1$%!1*!+
'.=1*::H
!*+*
=*%>'.3.*/2>+ !) */#(+*
'>*!/ ,-%>'. .?!1$%'.)<-2 !
*=*
? +*/
.
*+*+I+**2 ?*2 8 !
# *
1$2 1$2%
* /<<*+ ) /* %-=.#3% >'.
<
?#C
+3 & *
* =BC
%>!.).-% ,-%>!.)2%>'.
#>3
1+#
(solar flare) !
% !<+#
%+*
)/$ !+.$!+' !
<*<
+$%+ *8+
?$% +%2
+>/*K '*L<
+#
2.1.2 !"#
=*I#%'.K+% #'
+#
/=
99 <
+#
=BC
% $=
/!%<*2 1 .-%'
,-%
. //!<+38
%<*2*+38
%+8
+1 10
%
G1
+%=1+ +%=<!<) >'.*)<
.#*'!
+/* ?%+8
+
.#)%<*2 %+8
+
<
/.#* 25 * +%<*2 / 35 * !$%+*!
1/<.#*%+8
+ <
/$ 28 *
/.!%+# (! ,-%=!.31* !
/
$=)1?
%.! !
!0 '
*2
+I.)
!* 8+
)+I8-C0 '3'?/$%+
$'
8
2.1.3 %
%
&'(
**2!F #(.0/
(thermonuclear reaction) ''
!3
1*'</$%!.)::H!
1*%+
+0 '#0/ '?*.$%
*!+A
*%I-3
!
8 * '<!+%.)
*+! *+),
!
*+$%& </#(?*2 8%+%%=* .2
*1*)I- *1$2 *2'./# '<. .$!!'./+ -
>/K'< 1*
)I,*<'1$?!
1+
*21$?)
+I-/
,
8=2> 3
+*/
.
!+
2>%*2 1$?)
>!=*23*,
$% .#,
!
0 ',
MM
.$"#.% <-2
$%1$?=33 (!% /$3!) .1*!+
)>'.+*
.
+& <1$?'+ .<+*
+%+>/*K%+#.%*!)/$
,
,-%=<+ '
+*/
.
!+
1$%*)*+# '
+ +.
*,
<(
* +*
). '!J+/
,
,-%=
+1*%> 1$%%1?$
-/*2=*F*
2.2 !++*!+! [5]
2.1.4 "*+
** (Tracking) !
#(
8+
? !3*!+! !3,
!+
(Solar cell)
*8
= +>.*<>./#(+*1$2 E<:H *2
1. '.I$:H*8=*
(Infinity)
2. **23+*(
( >!.'1$2
+-+$ */ %#
8
<:H+
3. '.I$/
.
BC
!
$%& =+% % 30 '<
:H +>.**
/
.
!
. /$%%
3
9
4. :H.#!,-%3#8
< ,-%=>!.<3
+*(
**
=3$%.#*< **2*I#
:H&
F.#3+*(
*
F(
2
/$%%
>* (Diurnal Motion or Daily Motion)
5. 3+*(
,-% /
>!. I?2.$) * *!%?.2 $)*2
=+%<* 32+$$%< 1 !
.*</(%+%
<*
1*%*
2.3() ++#
I!
+8
+ <:H [5]
10
2.3 ( ) ++#
I!
+8
+<:H [5]
2.1.5
# -#!
.
11
>#.,'%+# !
**% 22 "./.<#A !
+%3+
<:H'8.$-' 5+ 6 (Meridian) 2/!<>!.
:H'?*) *=3! !./=)
.)
*3+ '% #* ,-%/'? *2
2.4 !+/$%%<
[15]
'$ ./.
'>!.%
%+#!
)
/$%%? +
$ ./.
'
<-2 !
)
/)<-2) '/<* 3<
% !/).2 /
/$%
3+ )<-2.$?
) ,-%<-2 * ( >!..'/ .
'>!., <
+
/$%?
*3+ .* 12.00 . +
%?<
+
/$%%)
*3+ %
*8+
F(
2 50
+#<6 (equation of time) ,-%
#'
Q!> 0
+#<2> './?*</!
.%
F:H !
G% %
#.NQ *2A*2 2 /
!* 16
12
+>.*F(
%<'
%+# '*% 4 ./.2
.*
= 147,093,602 +
%
%+# '*% 7 ./.
= 152,097,053 ,-%/!
.#% '
+% #!
%+#
5,003,451 .$
( 3.3% ,-%=/!%1
'.B !
!A
2
<'
%+#%/ ',.$) */=B.
2.5 !+% 8<
[13]
2.2 /0
(Solar Cell) [8]
Solar Cell .$ PV ?$% *. ? ,
!+
,
+#
.$,
13
2.6 !+* <,
!+
[8]
**2 +#,
!+
/$ +%
CE
%>+-%*> ? ,/ (Silicon),
!%
,
(Gallium Arsenide), :+:
(Indium Phosphide), !/
(Cadmium Telluride) !
/
,
(Copper Indium Diselenide) =
,-%$%*!+
)
% =1.
>::H !
I! =
#::H!
1$%'.!*::H<% *2*2+<,
!+
$%><*2::H<,
!+
<*
#(
::H
!+
!+::H
.<+ #(
.*2 >'.+I>
2.2.1 3+#
04/0
!3,
!+
(Solar Module) >.%% 1*!+
'.=1*
::H ,-%=::H
!+!
. =*
(Watt) >!3,
!+
. & ,
14
2.2.2 (+ /0
1. ,
!+
%> ,/ ?3-% (Single Crystalline Silicon Solar Cell)
.$%**'?$% Monocrystalline Silicon Solar Cell !
?3- (Polycrystalline Silicon
Solar Cell) *C(
=!3,/!<)!
2. ,
!+
% >
:N+,/ (Amorphous Silicon Solar Cell) *C(
=
:R
1 0.5 / (0.0005 .) 2>.* !
+"011 5-10%
,
!+
%>+-%*>$%& ? !%
,
, !/
!
/
,
= *2?3-% (Single Crystalline) !
3-
(Polycrystalline)
3. ,
!+
%> !%
,
'.
+"01+I- 20-25%
2.2.3 !"# /0
/+% %+# ! 1)<+-%*> +-%*>% /I%+# !
%+# /$ ,/ -I>+,
!+
>,/I# !
3<*2
>'.+#"S
*%>'.=3- *2>3
!1,-+$1$% +
1) $%+$:+:*+
=+-%*>?) (1
>::H
),-%
#) !
$%+$
=+-%*>?1 (1
>::H
,-%
#) **2 $%>+-%*>?1!
)*
1)<-2 /+
<,
!+
?,/ =!3.$+%.% *# *+ /. 200-400
/ (0.2-0.4 .)
3*!+
?*2!1,-%>::H <*2::H.% *
!+
*C(
/ 1$%'.1$2%*!+%+#
+<*2 ::H.*=<*2.
)
1$23
2.2.4 3
5 + /0
5,
!+
6 =+%
CE
%+<-21$% =#(
+>.*% 1*!+'.
=1*::H >+-%*> ? ,/ ,-%/I%+# !
%+#1$2
>3
8+
3'.=!3+#"S !
'*%! +
15
!3,
*+<!+% #0/<1*
% Photon
I 1*'.*
Electron '+-%*> 1*1%
!-< Atom !
+I
/$%% +
**2$% Electron /$%%/ )
>'.::H
!+<-2
/
.*< 5,
!+
6 /$ +-% *> (Semi Conductors) 2 ?
* ,-% P-N Junction $%!+
,
!+
)
I 1*'.
<+-%*> >'./+
!
+
+
<% *2 **2$%?$% *
0 ? .::H/<*2 )
.</+
/+
%'.1*
::H
!+*0 !
'.1*::H $% % *!+
,
,-%+I>'?
?
* .$>*)'!% 1$%'?
0 .*
2.7 !+3::H ,
!+
[8]
/+
+
<% *2 - !
+ +
+
<% *2 + :!+
I 1* '.
<, >'./ !
+
+
2.2.5 %5 . /0
0
. -(# +
16
2.2.6 704/0
'*2!3,
!+
*2'./ 1 11$%%
'.*
!+!%+# !
.-%1$%'.
>O )1$% =?>
+%
+% / !3,
$#/ !
8<!3 %.
+*2
<-2 *>!.<+I%*2 +#+>.*
8 %+# /$ 15 8 8
.*.8'! ) I>,
!+
.*/# <!3
*%
'? 15 - 45 8 .$<-2*/ <.*/=+>/*K
2.8 !+!+
*!
[8]
".-%% >'.,
!+
>
+"01++#)/$*!3'.
/<
(Tracking) !" 2
+2$/'? **2'W*-*2
!3'./ %/'/.-%*2
2.2.7 ".'%
9: /0
/#(+*::H<,
!+
+I!+ '? I-V curve ,-%
?
+>.*'?+>*3++#<,
!+
. I-
!+::H ,-%! +:'
! Y !
V . I- !/$%::H! +:'! X
17
2.9 01
!+ + I-V curve [8]
I-V curve E%'?+>.*.>*3++# .$ Wp (peak watts) <!3,
!+
*2 +'+0
E%>. '?!+++E (Solar
simulator) %#(.0<,
/% 25 8,, '+ I-V curve +%!*)/$
!/$%::H ( V) %. Open circuit voltage
'./!/$%::H
'! X (V) 1
!+.3 *% 2.9 ###< *
= I-V curve
$%.%/ & */<
!+!
!/$%
I*-) $%0 '+0
G1
< Irradiance !
#(.0 & *+%% +'%+#)/$ >*++# (Maximum
power) %'!
0 '+0
*2 & '::H>*%. =*
( Watt) ,-%
!/$%!
!+::H+>.*>*++# ( Maximum power)
I! +%.% 3$3
%1$2%%+# 0 '+ I-V curve #+*3*+% + curve knee *% 2.1 ,-%
. =*
++# (Wp) .$ peak watt /2
I
#'<>. (Speciflcation) <!3,
!+
C*33
2.10 01
!+ /#(+*::H< ,
!+
'? I-V curve [8]
18
*
::H,%=
!++* 230
>*>#(
!+
>'.*1
# ( charge carrier) 1 / **2(
!+::H-<-2*(
/<<!+
I,
!+
I>'.* '?!X
/%* Short circuit
current ,-%
'./! Y (I) 1
'+0(
?*2/!/$%::H/ +% # .
.#(
> '.*',
!+
'./+ . *!3,
!+
* LDR %! *. ?$% ? :/*:, ( photoconductive cell )
.$ * !+ ( LSR - light sensitive resistor ) +'.K
> +!/ ,*:
2.11 !+/+< LDR [3]
19
<*
.)'% 1 +%<=!)&+ >*%!.
%>.%=*
!+ !
!+> *2
!1$2%<**= 2 < ,-%I <
.)
+*2 =*>::H%>.%+*3*+ **!+ =%+>.*<0
.$ ) %.$)
=E, !
#(
+>.*..#* ,-%.
2.3.2 '%
0 LDR
>< LDR ) & 1
*=+-%*> !+
)
I 1*'.*+%G > '.*)%*1%*)
+
2)* /*% %/<<!+%
/
) %*2
2.12 * :!+/!+/I% & < LDR *2 2 ! $% */
</ [3]
20
'+%!+
*2
'?
=!+
)G1
!+'?/ /$%
( 4,000 *+ (1 *+ * 10 - 10 ) I-
( 10,000 *+*2%
'? (+ /
.) '?
( 4,000 *+ I- 7,000 *+) ,-%/!)=
?/$%1 !/& $% *><#(
!+
0$%& !I- !+'?
/$%2 ) '!+
!+.:!+ !
!+.:+,
.$ I
/I-/ /$%% LDR
+%+# ! ) . / /$% *% LDR %>
!/ ,*:
!+%/ /$%'? 5,000 *+ ,-%
.)=+
< I-+.$ +>.**!/ /$%%%+#<*'/ */ /$%%
%+#</ (// /$%
( 5,550 *+) -*
'?>=/$% *
!+'I I LDR >!/ ,
)
/ /$%'? 7,000
*+ ,-% '?:!
2.3.3 4%+
9: LDR
2.13 !+3<% /<!+'**'* LDR [3]
21
I-// %*/
='
* !!%*
. #
* *
*1% <-2!-
'
*.$**/ !
'>
*I )*'%/<!+ & ! % /<=
** *'+ (<)
/)
%>
*!-<-2 '. %/<<!+* LDR
!!/ ,
'? '<++0
%*/
= !!/ ,*:
!)
% !
.-% /)'%
*//.-%
/.-%? ,-%
'?<.$)= ->'. LDR '? *
/I%%>& *2
2.4 '0 [11]
/$ /$% ::H%% 1*::H'.=1*
!= 2
0'.K& /$
::H
!+ (DC Motor) !
::H
!++* (AC Motor)'
%%
I-G1
::H
!+ (DC Motor) *2
::H
!+*2
'?'
'<*/$%'!& %* )+* $%
::H
!+*2
!%%+ (starting torque) +I//#//#*)/< !< + /$
/+%/<,*,->.
%
'?'%*)/+&
2.14 01/+<
::H
!+ [11]
22
$% !*::H'.
::H.'
,-%
+!!.)!
+3'.!
->'.
.#
/$!%<-2'*>,-%8*2G*
!+::H>'*>
!+::H.<<, $ !
.<
<$ W$, < : -8*>'.!+* =3>'.
.#!
+1* !
!*::H%
+ .-%% 8*
<*!*::H% H'.
/$ !*::H* ( Back emf ) *+
(2.1)
=
=
=
=
!<*2!.) +2
*:!
<
+!.) (Field coil) %1* & !<*2!.)
>.%*
!+0 !
+
+!.) ,-%
>'.!<-2 (Torque)
2.15 01<*2!.)!
<!.)% - *: [11]
23
&+
"*+
&+
"*+
3*! (rotor)
<
(Armature Winding )%1*
!.)
(Armature core) !
/
- % <<
*
% 2.16
2.16 01
<
!+ [11]
,-%'+2 /
>.%'+*3*+*!I/
(Carbon Brushes)%
'
1$%%
'.
!+.3 *<
>'.++!.)<-2
1$%'..*!
+***+!.)%<!.) ,-%
>'.
>'.
.#,-%'.#*2
=W$, <:%
(flemingHs left hand rule)
2.17 01!+8/$%<%
(
) [11]
24
2.4.2
*7+; + '
1$2E<
%
>1($'?* & %
I- 4
/$ !*::H (voltage) .<
!+ (current dawn) /) (speed) !
(torque)
25
2.5.1 ".'% PIC16F877
/$
/
1#%
//
= 0 * 1 !)+I>
#
?$%*#(
0 &
<< PIC16F877 /+I!
<.$*
.%!*
,-%! = PORT A, PORT B, PORT C, PORT D, PORT E 1$2E!1
!
1
+I>=1#!
1# = PORT A !
PORT E %+I>
=**+*KK(!=/ 1$%>*(:R++
&
%.)
?* /$ >*/8*
2.18 //
PIC 16F877 [9]
2.6 = [4]
I .#>**2 >. " ? '?+ 1 , /OY
= /OY)/$ +I% '.* $% .-%.# .$=<*)
>'.
.-%.# 1
3.<*2+/OY $%+*3*+ !I.0
& ?
+>*+&
>'.$%I +>*-! > 1$%%
!<<+ .2-
>:N:Y%3< -*C(
=:N:Y ,-%&-
":Y" ,-%=?2++% I+>*.$I .#! > % !
$%I *% 2.19
26
2.6.2 (+ =
2.19 :Y [4]
2.20 :Y (Spur gear) [4]
27
2.6.2.2 =3++ (Worm gear)
:Y?#2
* .!
:Y. .
+>*.#<*'.:Y..# *% 3 :Y?2 '?*
/)+& '.=/)%>&? '(<
2.21 :Y. (Worm gear) [4]
2.6.2.3 => (Bevel gear)
:Y?2*C(
= (Cone) :N<:Y
3< !
<*!<:Y *% 2.22 :Y
'?+>.*
% 8+>*
.1<%*2G* ? +>* *
1<I =
2.22 :Y (Bevel gear) [4]
28
2.6.3 " '< =
2.23 !+:N:Y [4]
$%:Y*<*/$%%.-%:N :N<:Y*)
<*'.:Y*/$%%
.-%:N !
<*<:Y<*0 .$0 ')*% 2.23
2.24 !+:Y<0 !
0 ' [4]
:Y=+
</$% *%I >*1*.-% **.-%
I >**2<-2 **)!
>:N<:Y>=
/$ ?<:Y
/+*1*"
<>:N:Y (Z) !
*)<:Y (N) *%& . */)
<:Y * =>
**2*)<:Y*<*/#( >:N<:Y*<***)<:Y*
/#( >:N<:Y .$< *2
29
N1Z1 = N2Z2
(2.2)
2.25 ?#:Y. [4]
30
2.7.1 ?
0%
!% I
* 2 ? /$
1. !A '?*=+'.K ! = 2 ! /$ !% !
!2>*% & +*.
/*2 * !! (Maintenance Free) ,-%
2>*% *2 2 !2
OR-R+>.*2>*% '!!2
#
'?
( 1.5-2 A !/ 3 A *22)<-2 *+01'? !
!*C
I!*C +%>+)
>'.!%I
#'?%
<-2 )$%I- #'?<*)+/%
% !% '.
!
2. !!. 2>*% / #'?% !
/!1
!!% !.2
#'?
( 5-10 A !!% 2OR-R
+>.*2>*% .$)I,*O !
!+>.*/ ?)/
*
2> !
*:?
2.7.2 .3?'%
. -(# +
.*>*/:?
<!%!
I1/:?
%>
*%>.
?
:'. ,-%
>I!%I *IO#+!
!%<*/$%?
: %+ (+!) <*<*2<!% !
+
(+>) <*<*2 R+?
/$%?
: 2
( 1 * !-+ :/$%?
!% !)/$%?
:?%+I?
:'%+*2 '?
(
31
1-2 ?*% *2 ,-%
3+>.*3% *'? !'/*2
>'.#(.0< !%
+<-2 >'..:+ . !
'?
?
:*2 $%R+?
/$%?
'.?
:! -+ :
/$%?
!!%
'?
/:/*2 1*
*<2>
!*221$% '.%<-2
.?
. ?)/+<!% RO#
! <-2'+I !I>*/:?
! *) )/>?
!
I?
)!
:. ))I-% !%'.!
2.7.4 *0%
<<!% %'? *%
<-2 *
(<3'?!
/ !%<
'.K< /$ >*:+
+ +I>'?(%+0
8$2 >
#:!3,
!+
? !.$! '? *%
>.<<!% %'?
<-2 *(:
%'?'!
*=+>/*K!
+*1*"
*
!+%!3!+
'!
* <<
!+%'?'!
*
/
. 20-25
,)
<<!.% $ +/ 30
,)
? !<% 100 !X /'?:*
( 20-25 !X .$ + 30 !X
+* *22$%'?:2
>'.!% #'?+*2!
%
!% >.<<!%%.
+ -/>((::H%
'?'!
*
2.7.5 %5 . 0%
/
%3!% *2
- #(.0<!
% +
-
*2>*%',
!% %>.$+
- /+
.+
1:!
$,
-
!+:'?
!%
- #(
$%& ? *\ +
1: !
+ :
- #(.0<!%+
32
#(.0< !%3>'. #><!% !
+"01 .$ <-2 *
!+:%?
!% !
//# '*,
!%
/ 2>*%%
',
!% G% #(.00 '!%E % 45C50 8 $%!3"#
0 ',
!%
3
*%%*! / ,-%
/.! /.-%
.#(.0<!+% E
>'.3
*%<!%.#
3>'.
)
#<!%%>!
!%
+$%+01) **2-//#
#(.0< !%'.E >#*C
-
*2>*%',
!% %>.$+
*2>*%',
!%
=*!+>/*K .-%
%
>'.
+"01<
!% .2>*% .$%> !3"#',
!%
>'.
/
3,
!% ,-%/
<-2+ !
>'.!3"#* =3>'.
!%+$% +01)<-2(2>*%
>'.,*:/% 0 ',
!%
$ $%
<2> *%?
./<<<,*:/
>'.
+"01<!%%> **2%/ >#*C/
//#
*2>*% !
/<<<,*:/<< +
-
!+:'?
!%
/$%
#:.$?
)=*!+>.* #'?<!%
$%
!+:%?
'?
!%!
/*2
3>'.!%?
).$?
<-2 */
!+<?
!
.
!+:'?
!%/+
>'.
?
!%)<-2
!
>'.#(.0'?
<(
*2+
!
>'.!%
+$%+01)<-2 **2-/>(81$%'.?
!
!%/+*1*"
33
/+*1*"
* C*
8%+I*,)/
!+:'?
'(
?
!
'? 1$%'.
+"01'?
!
'?<!%+%+#
- #(
$%& ? *\ +
1: !
+ :
#(
%+
%>'.
!+:. I #(
& .2
3
>'.'?
+"01.$<-2 *#(
.2 **2! & 1$%'.
!+:3+
)++>/*K %> '.
+"01<><!%+.$%>
/ !'.1.$.#=+.-%<%/ !?)/
3
3.1
!
"#
$%#
"& !'
!$('))*!
! !#
$ $%#
!'
!+
,-! #
&
( !%#
%
('))* !'
! #&
!$$-$-&%#
!$. $# $
'
! #!/-#! $$-
%#
'
!$# !+ +
,-!#
-" '))* #0-" '))*'+1!+/1'
!
!1
-" '+1!+/1/
- '++2 '))* # ! $/
$1
3!#(%
+%-!
#$! !%#
'))* #'-'#04(
++--!# $!
' '+
+2 ('))* ! $/
$+4 !
'))* #-!-
.'
!$!1! 5$( #0##('!1!+/1
'
!
! !
$1!
- '
! ('))*#04(
'))* 5- #'))*'
! %#
/
!
- #0 5$(##'!'+1! - '#
'
!
!
3.2
35
3.2.1
36
3.3
!""
- $+
,-!##!! +
+2
'))* /
0!-!## 5 !-
'))* 0!--
!##+
,! -
'))*'
! 5-!'+
! /
+-!##+2
'))* 7 $ '+1!
#
7+!
( 3.1)
=
=
=
=
!! (/)
! (/)
37
7+1! LDR +2! +-'
!-!##0!--
!## --! LDR -! 0!-!##!-
-! LDR - --! LDR
++--!'
!-!##+2
#' %
!+$-'
! 0!--!## !--! LDR -
-!!- #' %!+$-'
!(
-!
(Vo) !0!--!#+
,!--! LDR
--! ! #' % -!+$-'
!
! !
-
!+$-'
! (Vo) -! '
! !!! 1!
$$$#( +$$1! Sensor #$
- LDR -!+-# /
1!
38
7+1! LDR +2! +-'
!-!# 5-
'
!$-!# LDR 5+-! !-! LDR
!'
!$-!#! LDR 5+-!
!-! LDR #71 --! LDR 7 +,
20 / 0 30
//
'++$$ # Output 1!
'/--/+2 +$$
3.4 )**
+&,
$$-$-& -$-&
#
7+
39
##0 ! 01# !
(� 0
(� 1 ! Q5 #0 off !
! Q1 #0off '+
!
(& 1 %
!#0 0 ++2 1 ! Q6
#0 on ! ! Q3 #0 on '+
! ##0 1
(& 2 ! Q7 #0
on ! ! Q2 #0 on '+
!
(& 2 %
!#0 1 ++2
0 ! Q8 #0 off ! ! Q4 #0 off
!
!! ! &!##0 !10# !
(& !
" &
"! $ ##0 !01# !
(&
##0 !00# !11# !
(& ! &
&
40
7+1$1!(
# %/$ /
+*
%#
%/ 1!'
/
#' $ $
/ $ %#
#0+$--!+$
-'
!(
+&$ ! # $
!! %#
+*
+&
(Over Voltage) $ !
-# '
!
3.6 2
+ (Regulator)
5 7+2# ! 6
(& !- (1!
$
+*!#7'/--/ #!5 7'
!1!' LM 7805
41
3.7
/*+
$$#$
1! LDR +25## $#$/
1!
$+
,-!#+ +2
'))*/
1!'/--/
7+
3.7 #
+-!#+2
42
3.7.1 66
*/*+
43
3.8 '
$$+2 $ #
8 07
'! !+27+
44
3.8.2 %
'
+ $
! 1 - &+
LDR
100 x 100 cm
120 Cm
45
3.12
! !/-#! Solar Tracking
46
3.13
!!/-#! Solar Tracking
47
#.)&08&
#7
.
Z1N1
Z2
Z2
Z2
Z2N2
160
)H
(.)H)G
- 160 )H
0.5 $
$
$
)H)GJ5
)H)GJ F
48
3.1
)G
&
08
2
08
9$:%
" <
4 mm
3 mm
2.15 mm
2.15 mm
20 mm
15 mm
25 mm
190 mm
0;
*
0;
*$
'6%="+
16 0;
160 0;
3.8.3
&
.)&,+<
"+!
*&<
"+
1. $$#!&+ ,1&
#
-
2.
&+ ,8
- 5 2
- 5 #
1
x 2
- 5 #
1
x 2
- 1&
)G
1 1&
7. 1+ $K
%#
/
! &
&
!! #
& (
"#
49
8. +$%
1
#+* #
#
-+2#
!
(
##! #% $#+-#
50
51
4
4.1
4.1.1
LDR LDR
!"#$"#%&#
& ' $!"#() * LDR ( ) LDR
" #
#& ( (!"#+ " LDR ,#
53
4.1.2
&
"
'"
1.4 7#))$" #5
%&#
&
2.4
#$"
)#$"#5
#$"
3.$$$" 2 3 # LM741
4.
,)
)(
!"#3*-)
(
,(
54
4.1.3
'"
1.
)#3 4.2 4 ) 12 '
&6
#& (Regulator)
#
#&$$
2. 7# 5 '
&#( '#'#&
3.
- % #
1. ' #
#&4 #!"
)# #&!##&
"4 ) 2.00 Volt
2. *
)# 3 ) 2.00 Volt )( )5$5# -"
)6 (
)
18:00 = )
3. #
#& ( !"#
)# #&
"4 )#&
0.05 Volt
4. #
#& ( !"#
)# #&
"4 )#&
0.05 Volt
$" 4.1 $,
" 4.1 4
%&#
&
*
55
4.2
*
4.2.1 $""$
'+,
A
($" 4.2
)#$"
#
#'4 ) #%&#
&$" 4 15 #@#3)
$" %&#
&$"!"#$
" *$ '##
&5!"#$$5
$"( &#
&
'"
1. 4%&#
& 15 #@ %&#
&
!"#$"
#
&
2.
3. - % #
56
* 15 -
" 4.2 6) 15 #@ $" 6 5B& 5.@. 2552 >7
@ (>>7
35
6.00 .
7.00 .
8.00 .
9.00 .
10.00 .
11.00 .
12.00 .
13.00 .
14.00 .
15.00 .
16.00 .
17.00 .
18.00 .
0"
(V)
15 -
(A)
* (W)
0.51
0.005 m
2.55
53.9
0.04
2.16
58.0
0.19
11.02
58.1
0.52
30.21
58.5
0.79
46.22
58.4
1.01
58.98
58.1
1.14
66.234
58.4
1.10
64.24
58.9
0.99
58.31
58.8
0.77
45.28
58.0
0.51
12.76
56.8
0.22
12.50
50.6
0.03
1.52
52.847
0.562
31.495
57
" 4.3 6) 15 #@ $" 7 5B& 5.@. 2552 >7
@ (>>7
35
6.00 .
7.00 .
8.00 .
9.00 .
10.00 .
11.00 .
12.00 .
13.00 .
14.00 .
15.00 .
16.00 .
17.00 .
18.00 .
0"
(V)
15 -
(A)
* (W)
0.62
0.006 m
3.72
53.8
0.04
2.15
58.0
0.20
11.60
58.1
0.47
27.30
58.9
0.84
49.48
59.4
0.95
56.43
60.1
0.98
58.90
57.6
1.01
58.18
57.6
0.88
50.69
57.5
0.64
36.80
56.9
0.34
19.35
55.1
0.12
6.61
50.9
0.03
1.53
52.655
0.500
29.155
58
" 4.4 6) 15 #@ $" 8 5B&5.@. 2552 >7
@ (>>7
35
6.00 .
7.00 .
8.00 .
9.00 .
10.00 .
11.00 .
12.00 .
13.00 .
14.00 .
15.00 .
16.00 .
17.00 .
18.00 .
0"
(V)
15 -
(A)
* (W)
0.54
0.005 m
2.55
53.7
0.03
1.61
58.0
0.20
11.6
58.1
0.50
29.05
58.7
0.82
48.13
58.9
0.98
57.72
59.1
1.06
62.65
58.0
1.04
60.32
58.3
0.94
54.80
58.2
0.70
40.74
57.5
0.50
28.75
56.0
0.17
9.52
50.7
0.03
1.52
52.749
0.536
31.262
59
" 4.5 6) 15 #@ $" 9 5B& 5.@. 2552 >7
@ (>>7
35
6.00 .
7.00 .
8.00 .
9.00 .
10.00 .
11.00 .
12.00 .
13.00 .
14.00 .
15.00 .
16.00 .
17.00 .
18.00 .
0"
(V)
15 -
(A)
* (W)
0.56
0.002 m
1.12
53.9
0.04
2.156
57.0
0.17
9.690
58.1
0.55
31.955
58.5
0.79
46.215
59.4
1.05
62.370
59.1
1.12
66.192
58.9
1.10
64.790
58.5
1.02
59.670
58.2
0.80
46.560
58.0
0.40
23.200
56.8
0.25
14.200
50.9
0.05
2.545
52.912
0.564
33.042
60
" 4.6 6) 15 #@ $" 10 5B& 5.@. 2552 >7
@ (>>7
35
6.00 .
7.00 .
8.00 .
9.00 .
10.00 .
11.00 .
12.00 .
13.00 .
14.00 .
15.00 .
16.00 .
17.00 .
18.00 .
0"
(V)
15 -
(A)
* (W)
0.49
0.002 m
0.98
54.1
0.02
1.082
57.0
0.20
11.400
57.5
0.51
29.325
58.1
0.81
47.061
58.5
1.05
61.425
58.7
1.10
64.570
58.4
1.08
63.072
58.4
1.00
58.400
58.3
0.75
43.725
58.0
0.49
28.420
56.9
0.23
13.087
49.9
0.02
0.998
52.638
0.558
32.505
61
$ * 15 -
" 4.7 6)#%&#
&&#
& 15 #@
"
1
2
3
4
5
(A)
* (W)
52.847
0.562
31.495
52.655
0.500
29.155
52.749
0.536
31.262
52.912
0.564
33.042
52.638
0.558
32.505
62
63
"
" 4.8 6) Tracking $" 8 5B& 5.@. 2552 >7
@ (>>7
35
6.00 .
7.00 .
8.00 .
9.00 .
10.00 .
11.00 .
12.00 .
13.00 .
14.00 .
15.00 .
16.00 .
17.00 .
18.00 .
0"
"
(V)
(A)
* (W)
0.51
0.005 m
2.55
57.2
0.07
4.004
57.9
0.40
23.160
58.3
0.71
41.393
58.7
0.96
56.352
58.7
0.99
58.113
58.5
1.12
65.520
58.7
1.02
59.874
57.3
0.99
56.727
57.5
0.97
55.775
57.7
0.82
47.314
56.9
0.57
32.433
50.1
0.07
3.507
52.924
0.724
42.014
64
" 4.9 6) Tracking $" 9 5B& 5.@. 2552 >7
@ (>>7
35
6.00 .
7.00 .
8.00 .
9.00 .
10.00 .
11.00 .
12.00 .
13.00 .
14.00 .
15.00 .
16.00 .
17.00 .
18.00 .
0"
"
(V)
(A)
* (W)
0.5
0.003 m
1.5
58.2
0.06
3.492
58.8
0.35
20.58
58.5
0.69
40.365
58.7
0.95
55.765
57.6
0.96
55.296
57.6
1.14
65.664
57.5
1.05
60.375
57.5
1.00
57.5
57.9
0.95
55.005
57.7
0.85
49.045
55.9
0.54
30.186
49.9
0.06
2.994
52.792
0.717
41.356
65
" 4.10 6) Tracking $" 10 5B& 5.@. 2552 >7
@ (>>7
35
6.00 .
7.00 .
8.00 .
9.00 .
10.00 .
11.00 .
12.00 .
13.00 .
14.00 .
15.00 .
16.00 .
17.00 .
18.00 .
0"
"
(V)
(A)
* (W)
0.52
0.009 m
4.68
58.5
0.12
7.020
58.9
0.49
28.861
58.5
0.67
39.195
58.5
0.91
53.235
57.9
0.95
55.005
57.8
1.05
60.690
58.1
1.05
61.005
57.6
0.92
52.992
56.9
0.96
54.624
57.9
0.75
43.425
56.1
0.49
27.489
50.4
0.06
3.024
52.894
0.702
40.547
66
" 4.11 6) Tracking $" 13 5B& 5.@. 2552 >7
@ (>>7
35
6.00 .
7.00 .
8.00 .
9.00 .
10.00 .
11.00 .
12.00 .
13.00 .
14.00 .
15.00 .
16.00 .
17.00 .
18.00 .
0"
"
(V)
(A)
* (W)
0.51
0.007 m
3.57
58.5
0.11
6.440
59.1
0.50
29.550
58.7
0.66
38.740
58.5
0.89
52.070
57.8
0.96
55.490
57.8
1.07
61.850
57.3
1.03
59.020
57.6
0.91
52.420
57.9
0.96
55.580
57.9
0.76
44.000
56.1
0.50
28.050
50.2
0.05
2.150
52.916
0.700
40.447
67
" 4.12 6) Tracking $" 14 5B& 5.@. 2552 >7
@ (>>7
35
6.00 .
7.00 .
8.00 .
9.00 .
10.00 .
11.00 .
12.00 .
13.00 .
14.00 .
15.00 .
16.00 .
17.00 .
18.00 .
0"
"
(V)
(A)
* (W)
0.55
0.004 m
2.2
54.8
0.07
19.73
58.6
0.36
21.10
58.9
0.68
40.05
59.4
0.93
55.24
57.8
0.96
55.49
57.8
1.10
63.58
57.4
1.07
61.42
57.7
0.99
57.12
57.8
0.97
56.07
57.8
0.81
46.82
55.9
0.55
30.75
50.1
0.05
2.15
52.658
0.712
42.460
68
$ "
" 4.13 6)#%&#
&!"#$"
#
&
"
1
2
3
4
5
(A)
* (W)
0.724
42.014
52.792
0.717
31.356
52.894
0.712
40.547
52.916
0.700
40.447
52.658
0.712
42.460
52.924
69
70
60
(W)
50
1
40
2
30
3
4
20
5
10
0
6.00 . 7.00 . 8.00 . 9.00 . 10.00 . 11.00 . 12.00 . 13.00 . 14.00 . 15.00 . 16.00 . 17.00 . 18.00 .
45
40
(W)
35
42.014
30
40.547
40.447
42.46
31.356
25
20
15
10
5
0
1
2
3
4
5
()
70
$
#
& ) %&#
& 15 #@ #3) $"(@
'
)
71
$""
*
" 4.14 6) 15 #@ $" 9 5B& 5.@. 2552 >7
@ (>>7
35
6.00 .
7.00 .
8.00 .
9.00 .
10.00 .
11.00 .
12.00 .
13.00 .
14.00 .
15.00 .
16.00 .
17.00 .
18.00 .
0"
(V)
15
(A)
15
* (W)
15
0.5
0.56
0.003 m
0.002 m
1.5
1.12
58.2
53.9
0.06
0.04
3.492
2.156
58.8
57.0
0.35
0.17
20.580
9.690
58.5
58.1
0.69
0.55
40.365
31.955
58.7
58.5
0.95
0.79
55.765
46.215
57.6
59.4
0.96
1.05
55.296
62.370
57.6
59.1
1.14
1.12
65.664
66.192
57.5
58.9
1.05
1.10
60.375
64.790
57.5
58.5
1.00
1.02
57.500
59.670
57.9
58.2
0.95
0.80
55.005
46.560
57.7
58.0
0.85
0.40
49.045
23.200
55.9
56.8
0.54
0.25
30.186
14.200
49.9
50.9
0.06
0.05
2.994
2.545
52.792
52.912
0.717
0.564
41.356
33.042
72
5
5.1
(Solar
Tracking) $%
&
%'%
(
) '*+,
%' +(%+(-
.(
)
(
/
5.2
$
,$) / /'01/
%223 (Solar Tracking)
-4-
)
/(
)'
'5
/(
%223
%'6'$6
+/(
%
(-
(6'$6
%%+&+
)78/(
)
(
9%+%'01/7 )94:/
+
),/(
%223%+'01/
(
- )
(-.(
)4),%(
/(
%
,$) //'01/
%223 (Solar Tracking)
(
(
7+(
15 9
%223 (Solar Tracking)
(
,/(
%223%/+7+(
15 9,4 20 %
5.3
$
(-%,74-
+
)('=8
+
,)%
/(>
+%'% 6+
$ )%$
$ )(
/'01/
4-
$$
-%
+
'=8'5
+
? (
-
74
5.3.1
$%+%
47+
+
+
&+)4%$
++
5.3.2
!"!#
)
4%
)%$
$)(
4-
(
(
(
(
9%+%'01/7+ (
(-
)
(
@7/),/(
%223%+'01/
(-
)(-.(
)4),%(
/(
%
- ,%
4
(
//'01/
/(
%223+4-
@7
4
6
'5
('
(
%$
$
%+
+
6)%
+
+
6'5
(
75
[1]
, www.klangbattery.com [Online]. 2551
!"#$ : http://www.klangbattery.com/how_to.html [ 2552].
[2] %&! # #, '(! #%)&$(, *#(+#,!!'#$- !*$
#$ , $./)00%%' 12 3%4556
1&%%' $! 7", 2537.
[3] 8 91 .(1, $) "4
, electronics.se-ed.com, 2542. [Online]. !"#$ :
http://electronics.se-ed.com/contents/040h085/040h085_p04.asp ['# 2551].
[4] )&'$/? (87*##, 5@#" , www.ipst.ac.th, [Online]. !"#$ :
http://www.ipst.ac.th/design/design/article/rotary-fun.html [/ 2551].
[5] .
'(',
#$, th.wikipedia.org [Online]. !"#$ :
http://th.wikipedia.org/wiki [ 2551].
[6] &($/ '&., / .(" , *# +# '#
-
A "#
#$
$./)00%%' 12 3%4556
1&%%' $! 7", 2547.
[7] (
+#, '# $# . B%C$, 80. !%'/, &
#$
()188 A "#
#$#
8! $./)00%%' 12 '7$DD!.! ## 1&%%' $! ', 2548.
[8] 00
8, ,!!'#$, www.leonics.co.th [Online].
!"#$ : http://www.leonics.co.th/html/th/aboutpower/solar_knowledge.php
[ 2551].
[9] 8E #, A", 4DD$!!, www.rayongwit.ac.th [Online].
!"#$ : http://www.rayongwit.ac.th/scibox/microcon.htm [ 2551]
[10] A8 '(7%,
!&*#*
$#4556 $./)00%%' 12 3%4556 1&%%' $! 7", 2546.
[11] Adisak Chinawong, &'#, www.adisak51.com, 2543 [Online].
!"#$ : http://www.adisak51.com/page21.html [/ 2551].
[12] Jonathan W. Valvano, Developing Embedded Software in C , users.ece.utexas.edu, 2551.
[Online]. !"#$ : http://users.ece.utexas.edu/~valvano/embed/toc1.htm
['# 2551].
[14] K. German, Tracking solar power systems , solarserver.de, 2551. [Online]. !"#$ :
http://www.solarserver.de/solarmagazin/anlageapril2000-e.html ['# 2551].
76
[15] T. GLOBAL_MODERATORS, Example Source code , wara.com, [Online]. !"#$ :
http://www.wara.com/modules.php?file=listart&name=News&ttid=11 ['# 2551].
[16] T. Wattsun, THE WATTSUN TRACKING ADVANTAGE:A CASE STUDY IN
SPRINGFIELD, MO , wattsun.com, [Online]. !"#$ :
http://www.wattsun.com/pdf/Wattsun_Tracking_Advantage.pdf ['# 2551].
77
78
79
A
LDR
80
C
81
Datasheet
82
Datasheet
83
84
PIC16F877
85
86
87
88
MJE 3055
89
90
Source Code
91
/************************************************************************************/
// osc configurations :
// high speed crystal/resonator
// watchdog :
// enable watchdog timer
// power up timer :
// enable power up timer
// brown out reset :
// enable brown out reset
// Low Voltage Programmable :
// low voltage programming disabled
// data code protected :
// Do not read protect EEPROM data
// Flash memory write enable/protect : // flash memory write protected/disabled
// code protection
// protect program code
/************************************************************************************/
CONFIG(HS & WDTEN & PWRTEN & BOREN & LVPDIS & DUNPROT & UNPROTECT);
/************************************************************************************/
/* Define Constant
*/
/************************************************************************************/
#define STEP
(5.00/1023)*100
92
#define TBREL 3
// Time base for release switch
/************************************************************************************/
/* Function Prototype
*/
/************************************************************************************/
void sysinit(void);
void a2d_init(void);
unsigned int read_a2d(unsigned char channel);
void check_light(void);
void delay(void);
void scansw(void);
void swserv(void);
/************************************************************************************/
/* Declare Global Variable
*/
/************************************************************************************/
unsigned char T10MS;
unsigned char T100MS;
unsigned int LDR_CLEFT;
unsigned int LDR_CRIGHT;
unsigned int LDR_LEFT;
unsigned int LDR_RIGHT;
signed int DIFF;
unsigned char SIGN;
unsigned int VCLEFT;
unsigned int VCRIGHT;
unsigned int VLEFT;
unsigned int VRIGHT;
unsigned int AVERG1;
unsigned char SWBUF;
unsigned char SWREG;
unsigned char DBCNT;
unsigned char RELCNT;
struct{
93
unsigned F10MS:1;
unsigned F100MS:1;
} Timer;
struct{
unsigned DBDone:1;
unsigned DBFlag:1;
unsigned RELFlag:1;
unsigned Enable:1;
} Sw;
/************************************************************************************/
/* Bits Assignment
*/
/************************************************************************************/
#define MOTOR_B RC1
#define MOTOR_A RC2
#define SW_LEFT RE1
#define SW_RIGHT RE2
/************************************************************************************/
/* Main Program
*/
/************************************************************************************/
void main(void)
{
sysinit();
a2d_init
while(1)
{
asm("clrwdt");
check_light
94
scansw();
swserv();
/************************************************************************************/
/* This is function Syetem Initialization
*/
/************************************************************************************/
void sysinit(void)
{
TRISA = 0xFF;
TRISB = 0x00;
TRISC = 0x00;
TRISD = 0x00;
TRISE = 0xFF;
OPTION = 0x0F;
PORTB = 0x00;
PORTC = 0x00;
PORTD = 0x00;
PORTE = 0x06;
T10MS = TB10MS;
T100MS = TB100MS;
Timer.F10MS = 0;
Timer.F100MS = 0
Sw.DBDone = 0;
Sw.DBFlag = 0;
Sw.RELFlag = 0
Sw.Enable = 0;
95
INTCON = 0xA0;
/************************************************************************************/
/* This is function set up the A2D module
*/
/************************************************************************************/
void a2d_init(void)
{
ADCON0 = 0x80;
// ADC clock = Fosc/32 @20MHz
ADCON1 = 0x82;
// Select right justify result,
// config AN<7:5> as digital I/O AN<4:0> as analog input
}
/************************************************************************************/
/* This is function Read a2d value and return an 10 bit a2d result
*/
/************************************************************************************/
unsigned int read_a2d(unsigned char channel)
{
unsigned int ADRESULT;
ADON = 1;
ADCON0 &= 0xC1;
ADCON0 |= (channel<<3
delay();
GODONE = 1;
while(GODONE == 1)
{
}
96
ADON = 0;
ADRESULT = ADRESH << 8;
ADRESULT |= ADRESL;
}
return(ADRESULT);
/************************************************************************************/
/* This is function Check Light by LDR from port RA<0>(AN0) and RA<1>(AN1)
*/
/************************************************************************************/
void check_light(void)
{
if(( Timer.F100MS == 1)&&( Sw.RELFlag == 0))
{
Timer.F100MS = 0;
LDR_CLEFT = read_a2d(0);
VCLEFT = LDR_CLEFT * STEP;
LDR_CRIGHT = read_a2d(1);
// LDR #
VCRIGHT = LDR_CRIGHT * STEP;
//
LDR_LEFT = read_a2d(2);
VLEFT = LDR_LEFT * STEP;
LDR_RIGHT = read_a2d(3);
VRIGHT = LDR_RIGHT * STEP;
97
}
else
// $52!
{
DIFF = VCLEFT - VCRIGHT;
// .$#2
if(DIFF < 0)
// $ !"$# ?
{
//
SIGN = '-';
// +.!&%12."&*6('7 (-)
DIFF = DIFF * (-1);
//
}
//
else
// $2&3(.%2#!
{
//
SIGN = '+';
// +.!&%12."&*6(7 (+)
}
//
if(DIFF > 5)
// $)&3( ?
{
//
if(SIGN == '-')
// $3 !"3# ?
{
// +.!2&2:.0()*3 !"
MOTOR_B = 0;
// *;2&2:#< B (RC2)
MOTOR_A = 1;
// &*;2&2:#< A (RC1)
}
else
// $3#3 !" !
{
// +.!2&2:.0()*3#
MOTOR_A = 0;
// *;2&2:#< A (RC1)
MOTOR_B = 1;
// &*;2&2:#< B (RC2)
}
}
else
// $ !"$=#&3( !
{
//
AVERG1 = (VCLEFT + VCRIGHT)/2; // .&>41"#2$$/ solar cell
98
MOTOR_A = 0;
MOTOR_B = 0;
// *;2&2:#< A (RC1)
// *;2&2:#< B (RC2)
}
else
// $3 !".%2#$!
{
//
if(AVERG1 > VLEFT)
// $3 !"$ ?
{
// +,! +.! Solar cell .0()*3 !",
MOTOR_B = 0;
// *;2&2:#< B (RC2)
MOTOR_A = 1;
// &*;2&2:#< A (RC1)
}
/************************************************************************************/
/* This is function Delay Time
*/
/************************************************************************************/
void delay(void)
{
unsigned int dcnt1;
for(dcnt1=0;dcnt1<2;dcnt1++)
{
}
99
/************************************************************************************/
/* This is function Scan Left Switch and Right Switch
*/
/************************************************************************************/
void scansw(void)
{
if( Timer.F10MS == 1)
{
Timer.F10MS = 0;
SWBUF = PORTE & 0b00000110;
if(SWBUF != 0b00000110)
// ',:?@+,). ?
{
// +,
if( Sw.DBDone == 0)
{
if( Sw.DBFlag == 1)
{
if(SWREG == SWBUF)
{
DBCNT = DBCNT - 1;
if(DBCNT == 0)
{
Sw.DBDone = 1
Sw.Enable = 1
Sw.RELFlag = 1;
RELCNT = TBREL; .
}
}
else
{
Sw.DBFlag = 0;
}
}
else
100
{
Sw.DBFlag = 1;
DBCNT = TBDB;
SWREG = SWBUF;
}
else
{
RELCNT = TBREL;
SWBUF = PORTE & 0b00000110
if(SWREG != SWBUF)
{
MOTOR_A = 0;
// *;#< A #22&2:
MOTOR_B = 0;
// *;#< B #22&2:
}
}
}
else
// ',:)?@
{
if( Sw.RELFlag == 1)
{
RELCNT = RELCNT - 1;
if(RELCNT == 0)
{
Sw.RELFlag = 0;
Sw.DBDone = 0;
Sw.DBFlag = 0;
MOTOR_A = 0;
MOTOR_B = 0;
}
} } }
}
/************************************************************************************/
/* This is function Switch service routine
*/
101
/************************************************************************************/
void swserv(void)
{
if( Sw.Enable == 1)
{
Sw.Enable = 0;
if(SWREG == 0x04)
{
// +.!2&2:.0()*3 !"
MOTOR_B = 0;
// *;#< B #22&2:
MOTOR_A = 1;
// &*;#< A #22&2:
}
else if(SWREG == 0x02)
{
// +.!2&2:.0()*3#
MOTOR_A = 0;
// *;#< A #22&2:
MOTOR_B = 1;
// &*;#< B #22&2:
}
else
{
MOTOR_A = 0;
// *;#< A #22&2:
MOTOR_B = 0;
// *;#< B #22&2:
}
}
}
/************************************************************************************/
/* This is functin Interrupt Service Routine
*/
/************************************************************************************/
void interrupt isr(void)
{
/***** Timer 0 Code *****/
102
if((T0IE)&&(T0IF))
{
T0IF = 0;
if(--T10MS == 0)
{
T10MS = TB10MS;
Timer.F10MS = 1;
if(--T100MS == 0)
{
T100MS = 10;
Timer.F100MS = 1;
} } }}
/************************************************************************************/
/* End of Program
*/
103
!"#
D#08 #'9H?. .
! "
#%$ &'(()&*
+, #&-
./
0'(()"
#
!1
%+ 2#2!&
. .!# ! "
#$%&'(() &*
+, #&-
./
0'(()"