Professional Documents
Culture Documents
TeamDesignandPrototyping
fora
SunTrackingSolarEnergyCollector
System
ForMechanicalEngineering4B03
Authors:
TylerKenyon
YajieJiang
AllanD.Spence
August2010
i
TableofContents
1.Introduction................................................................................................................................1
2.Fixedvs.TrackingSolarPanels....................................................................................................1
3.OrbitalMechanicsReview..........................................................................................................2
4.SystemRequirementsSummary.................................................................................................3
5.ComponentsandEquipment......................................................................................................4
6.ConceptualMechanicalDesign...................................................................................................7
6.1AzimuthTrackingBase..........................................................................................................8
6.2ZenithTrackingUpperStage.................................................................................................9
7.CADDetailDesignandAssembly..............................................................................................14
7.1AzimuthTrackingBase........................................................................................................14
7.2ZenithTrackingTop.............................................................................................................14
9.PhysicalModelRealizationfromCAD.......................................................................................18
10.Summary.................................................................................................................................18
Acknowledgements.......................................................................................................................18
11.Appendix.................................................................................................................................19
AppendixA1ElectricalImplementation.................................................................................19
AppendixA2ArduinoSoftwareTutorial................................................................................32
AppendixA3SoftwareImplementation.................................................................................37
AppendixA4CADDrawings....................................................................................................38
AppendixA5RapidPrototypedComponentCosts................................................................39
References....................................................................................................................................40
1.Introduction
Harnessingsolarphotovoltaicenergyisapromisinggreenenergytechnology.Toensure
highest energy collection efficiency, it is proposed that an automatic sun tracking system be
developed to continuously align the collector surface normal with the instantaneous solar
vector(thedirectionfromthecollectortowardsthesun.Anexampleofafullscalesystemis
showninFig.1.Thefocusofthisprojectistwofold:
1. Mechanicaldesignandprototyping
2. Electronicandsoftwaredesignandimplementation
For consistency with established industry and scientific standards, the system will track using
Azimuth and Zenith angles (Fig. 2) [1]. The project deliverables are design documents and an
actual scale model prototype that faithfully represents the design required for a full size
system.CoordinatedteameffortofstudentsinbothMechanicalandMechatronicsEngineering
ismandatory.
TheCADdesignforthesolartrackingsystemwascreatedusingAutodeskInventor2010
[2].PrototypeplasticcomponentswereproducedusingaDimensionBST[3]rapidprototyping
machine. The software and electronics are based on an Arduino Duemilanove [4]
microcontroller.
2.Fixedvs.TrackingSolarPanels
Small solar panels are frequently installed at a fixed orientation, whereas larger installations
typicallytrackthesolarvectorusing2axisAzimuth/Zenithaxes.Thereturnoninvestmentfor
theaddedexpenseoftrackingcanbeestimatedbyreferringtoinsolationdataavailablefrom
[7]. For Canada, the preferred fixed orientation is a due South facing Azimuth, with Zenith
angle corresponding to the latitude. Using Hamilton as an example, selected mean daily
insolation values [8] are reproduced in Table 1. During December days, when the days are
short and the sun is predominantly towards the South, there is a limited gain from 2axis
tracking. During the long days of June and July, the 2axis advantage is 8.9 kWh/m2 / 5.5
kWh/m2=62percent.Thereasonforthe2axisadvantageisthegreaterAzimuthrangeinthe
summer.Recognizingthattheextremeweathersummerairconditioningloadcausesagreater
electricityloadthanwinterheating[9],harnessingtheextraenergyfromsolartrackingonhot
summerdaysisattractive.Itisabalancebetweeninitialcapitalcost,extramaintenance,and
powerconsumedfortrackingvs.extraenergycollectedessentiallyaneconomyofscale.This
optimizationisanessentialengineeringdesignissueforfullscaleimplementation.Forthescale
model project in this course, it is sufficient to recognize the significant potential gain for
1
tracking, but limit activity to demonstrate application of the course product design and
developmentconcepts.
Figure1.ExampleFullScaleSunTrackingSolarPhotovoltaicEnergyCollectionSystem(photo
byA.Spence)
Table1.MeanDailyInsolation(inkWh/m2)forHamilton,Ontario(summarizedfrom[8])
South-facing
South-facing,
vertical
tilt=latitude
(tilt=90)
South-facing,
tilt=latitude+15
South-facing, Two-axis
Horizontal
tilt=latitudesun(tilt=0)
15 tracking
January
2.8
2.8
2.9
2.5
3.3
1.6
June
2.6
5.4
4.7
6.0
8.8
6.2
July
2.7
5.5
4.8
6.1
8.9
6.3
December
2.2
2.2
2.3
2.0
2.6
1.2
Annual
2.9
4.2
4.0
4.3
5.9
3.7
4.SystemRequirementsSummary
Forthisreport,theprototypesolartrackeristobeascalemodelofaproposedfullsizedesign
withthefollowingrequirements:
3
ItisintendedforuseinCanadaatlatitudesbetween40and60degreesNorth.
Sofarasispossible,itistoutilizethecomponentsandequipmentdescribedherein.
Itistocalculateazimuth/zenithanglesusingthecurrenttimeobtainedfromtherealtime
clock.
Itisassumedthattherealtimeclockremainspoweredupfromitsbackupbatteryandis
alwaysreliable,evenifpowerislosttotheArduinoandsteppermotors.Uponpowerup
(includingafterapowerfailure),thesystemmustrecoverinawaythatavoidsovertravel
orwindupofeithertheazimuthorzenithstage.
Powerwillbeprovidedusingawalltransformersupplying9VDC1000mAtotal.
Duringdaylighthours,thesystemmusttracktowithin1degree.Afterdarkthesystem
istoparkwithazimuthSouthandZenithanglezero(upwards).Apinholeorothermeans
toverifytrackingfidelitymustbeincluded.
Theprototypemustbereasonablysafetooperatewithlowriskofinjurytooperators,or
damagetoequipment.
5.ComponentsandEquipment
Components
The project involves mechanical/electrical/software (mechatronic) product development.
Emphasis is on the mechanical aspects, with judicious choice of electrical/software interface.
Thefollowinglistdescribesthesuppliedcomponentsavailabletocompletetheproject.
ArduinoDuemilanovemicrocontroller:
This microcontroller provides a very simple programmable interface to the electrical
switches, motor, clock, etc. For communication and customization, it is connected to a
Windows/MacOScomputerusingastandardUSBcable.Theassociatedprogramming
softwareisavailableatnocharge.Implementationofthecurrenttimetoazimuth/zenith
angleconversionprogram[1]isprovidedforyoutouse.RefertoAppendixA1fordetails.
ArduinoDuemilanovecustomexpansionshield:
To provide a standard interface for the project, an expansion shield is provided. This
custommadeshieldincludes(seebelow)aDS1307realtimeclock,twoMC3479stepper
motor drivers, and support components for the mechanical limit and optical homing
switches.RefertoAppendixA2fordetails.
ElectroMechanicalComponents:
Autodesk Inventor CAD drawings are provided in Appendix A3, and computer readable
modelfilesareavailableonthecoursewebsite.
4
JapanServoKP35FM2035StepperMotors
Thesemotorshaveafullstepresolutionof1.8degrees(200stepsperrevolution).
Maximumtorqueis700gcmoftorqueat24VDC/500mA.Installedconditionsare
9VDC,andhenceamaximumtorqueof250gcmisrealistic.
MechanicalLimitSwitch
A mechanical limit switch is used. On the provided prototype, the switch will be
triggered when the azimuth stage approaches North, and can be sensed by the
microcontroller. Together with the optical homing switches, checking for
unintended azimuth windup after power loss can be programmatically detected
andrecoveredfrom.
OpticalHomingSwitches
Optical switches are used to sense, with high repeatability, both the azimuth and
zenithhomepositions.ByinterruptingtheLEDlightbeam,theprovidedprototype
homestheazimuthat90degrees(East),andtheZenithat90degrees(horizon).
SignificantMechanicalHardware:
o
AzimuthStageLazySusanBearing:
Thechosen3inchDiameterLazySusanbearing(LeeValleyToolsSKU12K01.01)is
usedtotakethegravityweightthrustloadfortheAzimuthrotationalstageonthe
prototype. This bearing is quite loose, and a higher quality choice would be
requiredforafullsizeimplementation.
o
MountingHardware:
Unlessstatedotherwise,thethreadedfastenersare#632threadinstalledin4mm
diameterclearanceholes.Forsnugness,pivotsusemetricM40.7thread.Alength
of#1032threadedbrassrod,withcorrespondingnuts,wasusedfortheprototype
Zenithstageleadscrew.
SheetPlastic:
Smallquantitiesof0.125inchand0.250inchthickclearsheetplasticareavailable
fromtheMechanicalEngineeringTechnicalServicesstafflocatedatJHE205.
Equipment
DigitalMultimeterCircuitTestKit:
TheelectricalcomponentsareprewiredforconnectiontotheArduinocustomexpansion
shield. For convenience, minor circuit testing can be accomplished using the Canadian
Tirekit#52-0064-4 digital multimeter, wire strippers, and pliers.
5
SmallWrenches,ElectricDrills,etc.:
Smallwrenchesforsecuringfasteners,etc.areavailablewiththemultimeterkits.Electric
drills for drilling sheet plastic are available from the Mechanical Engineering Technical
ServicesstafflocatedatJHE205.Successfulcompletionofashopsafetytrainingcourse
atthebeginningofthetermisrequiredbeforeusingpoweredequipment.
RapidPrototypingPrinter:
RapidPrototypingservicesareprovidedbyMechanicalEngineeringTechnicalServicesfor
afeeof$12percubicinchofpartmaterial.TheDimensionBST768maximumbuildsize
is 8 inches (~200 mm) 8 inches (~200 mm) 12 inches (~300 mm). The printing
resolutionis0.010inches(~0.25mm).Supportmaterialwillautomaticallybeaddedby
theDimensionCatalystsoftware.Thereisnochargeforsupportmaterial,butyoushould
considertheneedtomanuallyremovethesupportmaterialinyourdesign.
TheprinterusesABSplastic,amaterialwithapproximatematerialproperties:
Youngsmodulus=2.89GPa
PoissonsRatio=0.38
YieldStrength=40MPa
Density=1.06g/cm3
Becausethematerialisnottrulysolid,itisrecommendthatyourdesignassumestiffness
and strength values that are 50% of solid ABS. Using a wall thickness no thinner than
0.060inches(1.5mm)toavoidrapidprototypinglayerdelamination.Tomostfaithfully
emulateplasticinjectionmoulding,constantwallthicknessesshouldbeused.
ComputerAidedDesignSoftware:
The faculty has now standardized on Autodesk Inventor for general CAD use. All work
submittedforgradingmustbecreatedusingInventor(noexceptions).Itisexpectedthat
a kinematically correct mechanism solution will be completed before physical
prototyping. Finite element analysis is not essential, but reasonable judgment of part
stiffnessisexpected.
When saving parts in STL format for rapid prototyping, select the option to use highest
resolution.Designswillbereviewedbytheinstructor/TAs/TechnicalServicesstaffbefore
printing. Advice to revise designs are provided to avoid wasted printing, and the final
decisionwhenandiftoprintanypartrestssolelywiththeinstructionalteam.
Figure2.SolarVectorAngleDefinitions(from[1]).TheAzimuthangle( )ismeasuredfrom
True North towards True East. Therefore True North corresponds to 0 , True East
corresponds to 90 degrees, True South corresponds to 180 degrees, and True West
correspondsto 270 degrees.TheZenithangle( Z )ismeasuredfromdirectlyoverhead.
Hence Z 0 means that the sun is directly overhead, casting no shadow. This occurs, for
example, at local solar noon on the equator on an Equinox (approximately March 20 or
September22).
6.ConceptualMechanicalDesign
Inordertofullytrackingthesunfromsunrisetosunsetusingthesuppliedrealtimeclockand
Azimuth/Zenith calculation algorithm, the preferred mechanical design should employ
matchingrotaryaxes.Foramaximumlatitudeof60degreesNorth(suchasnearYellowknife,
NWT),atthesummersolsticethesunrisesat27degrees(measuredEastfromNorth),andsets
at333degrees.At40degreesNorth(suchasnearWindsor,ON),theZenithstage,onwhich
thesolarpanelismounted,mustcoverarangefrom90degrees(horizon)to16.5degreesfrom
overhead.
To avoid dependence on electric motor torque to maintain position against wind and gravity
forces, good balancing and selflocking gear reduction should be used. For rotary motion, a
wormgearcanbeused.Forlinearmotion,aleadscrewcanbeused.Forlearningpurposes,
theprototypedescribedinthisreportusesawormgearfortheAzimuthstageandaleadscrew
fortheZenithstage.Thisisnotnecessarilyoptimal,andyouareexpectedtocriticallyevaluate
choices for your teamdesign based on specific requirements announced for the current year
courseoffering.
6.1AzimuthTrackingBase
Forlearningpurposes,andtopermitcustomization,theAzimuthwormgeardrivewasdesigned
using the Design Accelerator within Autodesk Inventor. Sizes were approximated to fit the
supplied stepper motors, switches, and Lazy Susan bearing. For a demonstration prototype,
this is somewhat a best judgment approach. Full size designs must include optimization for
technicalcapability,attractiveness,environmentalcompatibility,cost,etc.Aworm(thescrew
likegearthatattachestothesteppermotor)pitchdiameterof20mmwaschosen.Thecenter
distance (from the center of the worm/motor axis to the center of the large worm gear axis
(alignedwiththeAzimuthaxis)wassetto82mm(Fig.6).
A coarse approximation for the ABS dry coefficient of friction is c f 0.5 . For the chosen
lead/helix angle 11.3 degrees, tan 11.3 0.2 0.5 c f and hence self locking is
assured.
Withthechosenratioof36,themotor/wormwillrevolve36timesforeachrevolutionofthe
larger(LazySusanaxis)wormgear.Eachmotorrevolutionequals10wormgeardegrees,and
hencewith200fullstepspermotorrevolution,theresolutionis10degrees/200steps=0.05
degreesperstep.
Atpowerup,themicrocontrollerhasnoinformationonthecurrentAzimuthangle,andhence
an initialization procedure is needed. After initial installation, a properly operating system
shouldneverbeoutsideofthe27to333degreeAzimuthrange,evenifpowerislost.Hencea
power up motion that turns the Azimuth stage Eastward to an initialization position of 22.5
degreesshouldalwayssucceed.Intheprototype,thisisaccomplishedusingasmallscrewthat
protrudes downward from the Azimuth worm gear and interrupts the optical homing switch
LED light beam. The microcontroller senses the change in switch status, stops the stepper
motor, and initializes its internal Azimuth angle counter to correspond to an angle of 22.5
degrees.If,foranyreason,theopticalswitchsensingprocedurefails,motionwillcontinueuntil
an angle of zero degrees (due North) is reached. At this point a second, upward protruding
screwwillcontactthemechanicalrollerleverlimitsafetyswitch,disconnectingsteppermotor
powerindependentofthemicrocontroller.Thisisconsideredtobeafaultconditionthatcan
8
onlybeclearedbydepressingtheoverridelimitswitchandcommandingthesteppermotor
to move the Azimuth stage Westward, or by manually moving the Azimuth worm gear
Westwardbeyond22.5degreeswhilethesteppermotorisunpowered.
6.2ZenithTrackingUpperStage
TheZenithtrackingstagesimilarlymustbeselflockingtoavoiduncontrolledmovementinthe
eventofelectricalpowerloss,highwinds,andthegravityforceduetothesolarpanelmass.A
wormgeardrivesimilartothatusedfortheAzimuthstagemaybethebestchoiceforpractical
implementation.Foracademicillustration,theprototypedescribedhereinusesaselflocking
leadscrewimplementation.ThekinematicconceptisshownasaCADsketchinFig.7.Allunits
areinmillimetersanddegrees.Theleadscrewnutpivotislocatedatpoint A X , 0 ,where
X 0 whenthepivotislocatedatpoint D .Asthesteppermotorturnstheleadscrew,the
nut pivot is constrained to travel along the horizontal lead screw bounded by points
M 24, 0 and N 88, 0 .Thesolarpanelpivotsarelocatedatpoints B and C .
Usingtrigonometry,thenonlinearkinematicrelationshipbetweenthelinearmotionofthenut
pivot A andtheZenithangle (theta)canbeexpressedusingthesystemofequations
X
BC cos AB cos
15 BC sin AB sin
ForadesiredZenithangle ,iterativeNewtonRaphsonzerofindingtechniquescanbeusedto
solve for the corresponding nut pivot position A X , 0 . Details are presented in the
softwarealgorithmimplementation(AppendixA1).
The lead screw used has a #1032 thread (32 threads per inch), and hence the nut pivot
advancesby 1/ 32*25.4 0.79375 mm perrevolutionor 0.79375 / 200 0.004 mm perstep.
Figure3.EarthOrbitandAxisTiltEffectonSeasons(from[5])
10
Figure4.SunriseandSunsetDataforJune21,2010atToronto,Ontario(from[6])
(a)
(b)
Figure5.SummerSolsticeGeometryatToronto,Ontario.Theearthaxistiltis23.45degrees.
Thelatitudeis43.7degreesnorth.Thesliceofearth(inthechestnutbrowncolour)isfrom90
degrees east back to where the day/night boundary is on June 21. (a) At a latitude of 43.7
degrees,thislengthensthemorningby24.49degreesoflongitude,or1hourand38minutes.
The evening length increases by an equal amount, for a total of 3 hours and 16 minutes,
makingthegeometricdaylength15hoursand16minutes.TheextratimeshowninFigure4
isduetorefractionnearthehorizon(upto7minutesneartheequator).(b)Toanobserveron
thesurfaceoftheearthatToronto,thesunappearsatthedawnhorizon56.6degreesnorth
ofeast.
11
Figure6.AzimuthStageAutodeskInventorDesignAcceleratorWormGearParameters
12
(a)
(c)
(b)
Figure7.LeadscrewZenithTrackingStageKinematicConceptSketch:(a)pointandangle
labels; (b) geometry at Zenith angle of 90 degrees; (c) geometry at Zenith angle of 0
degrees.
13
7.CADDetailDesignandAssembly
Computer Aided Design of all major system components was performed using Autodesk
Inventor,withassembliesandkinematicmechanismconstraintsusedtoverifycorrectmotion.
As before, the CAD design is separated into the Azimuth and Zenith tracking stages. A brief
summaryispresentedhere.DetaileddrawingsarecontainedinAppendixA3.
7.1AzimuthTrackingBase
Fig.8(a)showsthegeneralCADdesignoftheazimuthtrackingbaseanditsassemblysituation.
Otherthanpurchasedhardware,thedetaildesignedcomponentsincludeanacrylicbaseplate,
arapidprototypedwormwheelgearring,theworm,andamotorbracket.Thebaseplate#632
clearancemountingholesweremadeusingaworkshopdrillpress/millingmachine.Therapid
prototyped stepper motor bracket is mounted to the baseplate andadjusted so that correct
gear engagement is achieved. The Lazy Susan bearing is positioned 10 mm above the plate
usingspacersandlonger#632screws,washers,andnuts.Thewormgearisdesignedasaring
shapetoreducerapidprototypingmaterialconsumption.Acorrespondingholepatternmates
to the top plate of the Lazy Susan bearing. The optical switch is used to home the system at
powerup.AlimitswitchmustbeaddedtoyourdesigntoavoidAzimuthwindup.
Fig. 8(b) shows the design of worm and motor shaft coupling. The worm is designed with a
centralshaftdiameterhole.Twoholesaredrilledandtapped90aparttoaccept#632plastic
screws.Theplasticscrewsprotectthemotorshaftfromdamage.
7.2ZenithTrackingTop
Inadditiontohardwarecomponents,theZenithtrackingtopassembly(Fig.9(a))consistsofan
acrylicsupportplate,motorhub,motorbracket,leadscrewslidebridge,slidingnutandpivot,
crank, front pivot, pinhole sun locator, solar panel plate, homing optical switch mount, and
homingtab. Thecrankframeisdesignedina'C'shapewithstrengtheningcornerribs.The
pinholesunlocatorisinstalledabovethepanelusinglong#632screwsandnuts,andisusedto
verify the system performance. If the tracking system performs well the pinhole will aim
sunlightontothecentermarkonthesolarpanel.Thetwothroughholesintwouppercorners
of the panel can be used to install analog Light Dependent Resistors for optimal solar panel
operationoncloudydays,andtotakeadvantageofgroundsnowreflection.Thisoptimization
isbeyondthescopeofthecourse.
14
Thehomingopticalswitchismountedontothefrontsideofthepivot(Fig.9(b)).Anextension
tab, mounted on the solar panel plate, interrupts the optical switch at the 90 degree Zenith
homeposition.Clearanceslotsareincludedtoaccommodateelectricalwirerouting.
(a)
(b)
Figure8.AzimuthTrackingStage:(a)BaseDesignandAssembly;(b)WormGearCoupler
15
(a)
(b)
Figure9.(a)ZenithTrackingTopAssembly;(b)OpticalSwitchDetails
The rapid prototyped nut housing has axial #1032 hexagonal depressions to accept the lead
screwnut.Thepivotaxishasdepressionstoaccept#632nutsforthecrankjoint.Thebridge
hasaslottoallowtheslidingmotionalongtherail(Fig.10).8.KinematicSimulation
16
Figure10.LeadScrewDetails
(b)
(a)
Figure11.Final(a)CAD;and(b)PhysicalModels
To simultaneously simulate the Azimuth and Zenith tracking motion, the Autodesk Inventor
Assembly Studio application was used. First, the joint constraints were defined, including the
positional constraint for the slider, the gear ratio constraint between worm and worm gear
ring,andtherotationalangularconstraintfortheleadscrewrod.Foreachoftheconstraints,
thecorrespondingmotionspeedsaresetupaccordingtothesystemkinematicproperties.
17
9.PhysicalModelRealizationfromCAD
TherapidprototypedpartswerecreatedbysavingfromInventorto.stlformat,andthenusing
the prototyping machine specific software to print the plastic parts. These parts were finally
assembledwiththeelectronics,fastener,andotherhardware.Alistofcomponentsandcosts
canbefoundinAppendixA4.FinalCADandphysicalmodelsareshowninFig.11.
10.Summary
Theestablishedprototypeofsolartrackingsystemwasdesignedwithtwodegreesoffreedom
sothatitisabletotrackthesunthroughAzimuthandZenith.Itcontainstwomajorassemblies:
Zenithtracking top and Azimuthtracking base. The parts for each assembly were rapid
prototyped. The Azimuth assembly consists of a worm gear drive and the Zenith assembly
containsaleadscrewmechanism.
An Arduinocompatible printed circuit board (PCB), called a shield, was designed and
manufactured to mount and connect the supporting electronic components. The shield was
modifiedtobefixedabovetheArduinoboard andthelayoutwasarrangedtomatchthepin
locations of the Arduino Duemilanove. The solar collectors PCB design was created using
CadSoftEAGLESchematicCaptureandLayoutEditor.
Acknowledgements
TheauthorsgratefullyacknowledgereceiptoffinancialsupportfromanImperialOilCharitable
Foundation Departmental Grant, administered through the McMaster University Centre for
Leadership in Learning. The Department of Mechanical Engineering, Faculty of Engineering,
and McMaster Engineering Undergraduate Student Laboratory Endowment Fund (MacLAB)
providedfundingtopurchasetherapidprototypingmachineandsupplies,andtheelectronic
components.TheMechanicalEngineeringTechnicalServicesstaffprovidedvaluableadviceand
shopservices.
18
11.Appendix
AppendixA1ElectricalImplementation
ArduinoDuemilanove
To improve the efficiency of a solar energy collector, an active tracker that continuously
accommodatesthevaryingpositionofthesunisnecessary.Tomeettheserequirements,the
Arduino Duemilanove [4] microcontroller board is responsible for calculating the solar vector
andcontrollingthesteppermotors.TheArduinoDuemilanoveisbasedontheAVRATmega328
andincludes14digitalinput/outputpinsand6analoginputs(FigA11).
FigureA11.AcircuitschematicsymbolfortheArduinoDuemilanovedemonstratingthedevice
pinout.
19
RealTimeClock
ForthepurposeofZenithandAzimuthanglecalculations,thesolartrackerrequiresanaccurate
estimation of the current Coordinate Universal Time (UTC). The DS1307 Real Time Clock
integratedcircuit is used to provide precise timekeeping(Fig. A12). The DS1307 requires a5
voltsupplywiredtopin8,anda32.768kHzcrystaloscillatorconnectedbetweenpins1and2.
To utilize the I2C serial interface supported by the Arduino Duemilanove, the Serial Data Line
and Serial Clock Line from the DS1307 must be wired to analog input pins 4 and 5 of the
Arduino,respectively.TheDS1307chipalsousesanexternalbatterythatcanprovideover10
yearsofbackuppowerintheeventofpowerfailure.
External components such as resistors or capacitors are not required for the supporting
circuitryoftheDS1307.However,a32.768kHzcrystaloscillatorisrequiredtogenerateaclock
signal.
Figure A12. The circuit schematic illustrates the Arduino Duemilanove interfaced with the
DS1307RealTimeClock
20
StepperMotorDriver
TocontroltheAzimuthandZenithsteppermotors,anMC3479steppermotordriver(Fig.A13)
wasused.
FigureA13.TheMC3479StepperMotorDriverconfiguredforusewiththesolartrackerdesign.
Thesteppermotordriverusesfourinputpinstoconfiguretheoperationofasteppermotor.
For the purpose of this solar collector design, only two pins from the Arduino controller are
required.Digitaloutputpin6oftheArduinoDuemilanoveiswiredtoCW/CCWofthedriverto
control the clockwise/counterclockwise direction of the motor. Arduino digital pin 5 is
connectedtotheCLKpinoftheMC3479totriggereachmotorstep.MC3479pins8and9are
21
tiedtogroundtorestrictoperationtohighimpedanceandfullsteppingmode,respectively.A
seconddriverisusedtocontrolthesolarZenithtrackingstage.Arduinodigitaloutputpin7is
connectedtoCW/CCWanddigitaloutputpin8isconnectedtoCLK.Controlandconfiguration
oftheMC3479driverissummarizedinTableA11.
Pin Name
7
CLK
Input
PositiveEdgeTriggered
Description
The motor takes a step for each rising edge of
theinputsignal.
8
OIC
GND
OutputImpedanceControlonlypertainstohalf
steppingoperation.
9
A logic low (ground) input signal enables full
FULL/HALF GND
stepping.
10 CW/CCW
DigitalSignal
Thelogicleveloftheinputsignaldeterminesthe
direction of rotation. The rotor steps clockwise
if the input signal is logic low (ground) or
counterclockwiseiftheinputislogichigh(+5V).
TableA11.FourpinsoftheMC3479driverareusedtoconfiguretheoperationofthestepper
motor.
_______________
____________
The supporting circuitry for each stepper motor driver includes a 1N5221A Zener diode
connectedbetweenVmandVdtopreventdamagefromvoltagespikesduringcurrentswitching
in the motor coils. There also exists 4 ground pins on each MC3479 driver to improve heat
dissipationwithintheintegratedcircuitfromthemotorcoils.Thebias/setresistor,RB,iswired
between Bias (pin 6) and ground. The resistor value was selected to encourage low power
operation.Bylimitingthebiascurrent,IBS,thebiasresistorreducestheoutput(motor)current
andtherebyreducespowerconsumption.FromtheformulaforRbias,thevalueischosentobe
51.1k.
1000
0.86
0.7
22
LimitSwitches
Toensurerobustoperation,thesolarenergycollectorisfittedwithlimitswitchestopreventa
stepper motor from exceeding the angular bounds of the design. A micro roller switch
mountedonthebaseofthesolarenergycollectorpreventsmultiplerevolutionwindupofthe
Azimuthtrackingstage.ThesolarcollectoralsoincludestwomorelimitswitchesontheZenith
trackingstagetopreventovertraveldamagetotheleadscrewmechanism.Eachswitchisrated
upto2Aat30VDC
FigureA14.LimitSwitchescontributetofailsafeoperationofthesolarcollector.
Thelimitswitchesareconnectedinserieswiththepowersupplyline(Fig.A14)andoperate
completelyindependentoftheArduinoDuemilanove.Theswitchesareorganizedinthiswayto
immediatelycutpowertothemotordriversintheeventoffailure.Assoonaseachswitchis
triggered,thecircuitisopenedandunabletosupplypower.
Afterthesourceofthefaulthasbeencorrected,onecancontinueoperationofthesolarenergy
collector. To resume supplying power to the motors, a jumper shunt can be applied
momentarily to a pair of header pins marked RESET_MTR on the printed circuit board.
A full scale implementation would require relays and additional software to automatically
correctthepositionuponfaultcorrection.
23
OpticalHomingSensor
Twoopticalslotsensorsareusedtodetectwhenthesolarenergycollectorhasbeenoriented
inthehomeposition.Ahomingsensormountedonthebaseofthesolartrackeristriggeredby
a#256screw.ThescrewisdesignedtopassthroughtheslotsensorastheAzimuthtracking
stageofthecollectorpositionsitselfforsunriseat22.5degreesEastofNorth.Asecondslot
sensor detects when the Zenithtracking stage is oriented directly towards the horizon (90
fromZenith).
FigureA15.Anopticalslotsensorisusedtohomethedevice.
The optical slot sensors are connected to the printed circuit board through a polarized
connector.Eachhomingsensorrequiresa5Vandgroundconnection.Thesensoroutputsare
wired to digital input pins 2 and 3 on the Arduino Duemilanove (Fig. A15). A 10k pullup
resistorwiredtoeachdigitalinputpinensuresthatthesensoroutputavoidsanindeterminate
digital logic state. Upon activation, each individual optical slot sensor produces a logical low
signal(0V).Otherwise,thesensoroutputsalogicalhighsignal(+5V).
24
PrintedCircuitBoard
The PCB consists of several core logical components (Fig. A16). The Arduino Duemilanove
controlstheoperationofthesteppermotordriversandrequiressensorinputfromtheslotted
homingsensorsandtherealtimeclock.
Fig.A16.Hierarchyofcoresolarenergycollectorcomponents.
CircuitSchematic
First,thecircuitschematicdiagramwasdesignedanddrawnwiththeCadSoftEAGLESchematic
Editor(Fig.A17)[10].
25
Fig.A17.SolarTrackerv4.4completecircuitschematic.
26
PCBPrototype
Usingasolderlessbreadboard,aprototypeofthefinaldesignwasconstructedandtestedusing
adigitalmultimeter,andbyobservingsensorsandmotorresponses(Fig.A18).
FigureA18.Eachaspectofthedesignwastestedwiththeuseofasolderlessbreadboard.
PCBFabrication
The printed circuit board layout was designed using CadSoft EAGLE Layout Editor. The
dimensionsoftheprintedcircuitboard(PCB)weredesignedtocorrespondwiththestandard
Arduino dimensions so that it could be easily mounted above the Arduino Duemilanove (Fig.
A19). To interface with the Arduino, male header pins from the printed circuit board are
matched to mate with female headers on the Arduino Duemilanove. Three 0.125 diameter
holesaredrilledforthepurposeofmountingthePCB.
27
FigureA18.ThePCBmeasures2.4x2.1.
The board design consists of a top and bottom copper layer. Extra copper areas are used to
reduce noise and ensure all components share a common ground potential. Components are
useathroughholemountingscheme.Forthepurposeofsolderingcomponentstotheboard,
eachthroughholeontheprintedcircuitboardisdrilled0.019largerthanthediameterofthe
componentleadandplatedwithcoppertoprovideanelectricallyconductivesurface.Polarized
connectorsandsocketsareusedextensivelythroughoutthedesigntopreventincorrectwiring
duringinstallation.Aswell,connectors,jumpersandotherrelevantcomponentsarelabeledon
thesurfaceoftheprintedcircuitboardbymeansofsilkscreenprinting(Fig.A110).
28
FigureA110a.ThetoplayeroftheSolarTrackerv4.4.
FigureA110b.ThebottomlayerofSolarTrackerv4.4.
29
ThefinallayoutoftheprintedcircuitboardwasbrandedSolarTrackerv4.4(Fig.A112).ACAM
processorintegratedwithEAGLEwasusedtoproduceanindustrystandardfileformatforPCB
manufacturingmachines,GerberRS274X.
FigureA112.SolarTrackerv4.4fabricated.
FigureA113.Thefinalproductoftheprintedcircuitboardafterassembly.
30
BillofMaterials
Allmaterialsarethroughholemountedwith2.54mmspacing.
1xSolarTrackerv4.4PrintedCircuitBoard
2xMC3479StepperMotorDriver
2xDIPSocketSolderTail16Pin
3x4PinMolexSLSeriesHeaderSocket
2x0.1FElectrolyticCapacitors
2x1N5221AZenerDiode
1x330Resistor
2x51.1kResistor
1x10kResistor
2xKP35FM22PhaseBipolarStepperMotor
2xOpticalSlotHomingSensors
3xNormallyClosedLimit(roller)Switches
4x40PinMaleHeaderPins
1x6PinFemaleWiretoBoardconnector
1x2PinJumperShunt
1xDIPSocketSolderTail8Pin
1xDS1307RealTimeClockIC
1x32.768kHzCrystalOscillator12.5pFInternalCapacitance
1x3V48mAh12mmBR1225LithiumCoinCellBattery
1x12mmCoinCellBatteryHolder
31
AppendixA2ArduinoSoftwareTutorial
ArduinoInstallationandTestProcedure
To setup and familiarize yourself with the Arduino Duemilanove, you can try blinking the on
boardLED(connectedtopin13)onandoff.Thestepsbelowoutlinetheprocedure:
1. DownloadtheArduinointegrateddevelopmentenvironment(IDE)fromthemain
Arduinowebsitehttp://arduino.cc/en/Main/Software.Arduinoprovidesdistributions
forWindows,MacOSX,andLinux.Forthiscourse,theinstallationontheJHE219A
computers(WindowsXP)isofficiallysupported.Instructionsbelowcanbeusedifyou
wishtotestwithyourpersonalcomputer.
2. ConnecttheArduinoDuemilanovetoyourcomputerwithastandardUSBcable.
3. InstallthenecessarydriversforUSBserialconversion.Ifthedriversarenot
automaticallyinstalled,followthedirectionsofthewizardtosearchforUSBserial
converterdrivers.FTDIUSBDriverscanbefoundinthedriversfolderoftheArduino
distribution.
4. ConfirmthataUSBSerialPorthasbeensuccessfullyinstalled.InWindows,openthe
DeviceManager(ControlPanel>System>Hardware>DeviceManager)andnotethe
nameoftheserialportused(e.g.COM3).
32
5. LaunchtheArduinoapplication.
6. Changethesettingstoworkwithyourconfiguration.Selecttheserialporttobe
programmed(Tools>SerialPort>YourPort).Next,ensurethattheArduino
environmentisconfiguredtoprogramtheArduinoDuemilanove(Tools>Board>
ArduinoDuemilanoveorNanow/ATmega328).RefertoAppendixA1formoredetail
regardingtheArduinoDuemilanove.
7. OpentheBlinkexample(File>Examples>Digital>Blink).
8. Click
tocompilethecode.
9. Click touploadthesoftwaretotheArduinoboard.Executionwillautomaticallystart
afewsecondsafterthesoftwarehasfinisheduploading.
33
ArduinoProgrammingTutorial
Software is written using the C/C++ based Arduino programming language. Each software
program written using the Arduino platform is called a sketch. Sketches do not include a
main()functionbutinsteadusefunctionssetup()andloop()workinginconjunctionto
perform similar functionality. The setup()function will run only once at the beginning of
execution.Itmaybeusedtoinitializeserialportsettingsorconfigureinput/outputports,for
example. Any local variables defined within setup() cannot be used in loop(). The
loop()functionwillexecuterepeatedlyuntiltheArduinoisreset.
TheArduinoplatformprovidesitsownIntegratedDevelopmentEnvironment(IDE)todevelop
software, upload programs, and communicate with Arduino hardware (Fig. A21). The
developmentenvironmentcontainsatexteditorforwritingcode,aconsoleforerrormessages,
andatoolbar(TableA21).Aswell,thereareanumberofprojecttemplatesandotherfeatures
thatcanbeaccessedfromthedropdownmenus.
FigureA21.
34
Verify/CompileCheckssoftwareforerrorsandcompilescode.
StopStopstheserialmonitor.
NewCreatesanewsketch.
OpenPresentsamenuofallthesketchesinyoursketchbook.Clickingonewillopenit
withinthecurrentwindow.
SaveSavesyoursketch.
UploadtoI/OBoardCompilesyourcodeanduploadsittotheArduinoI/Oboard.
SerialMonitorOpenstheserialmonitor.
TableA21.
TheSerialMonitorrecordsallactivityovertheserialportanddisplaysitonscreen.Thistoolis
particularly useful for debugging your software because it can verify all input/output. After
openingtheSerialMonitor,adjustthebaudratesothatitcorrespondswiththebaudratethat
wasselectedduringinitializationoftheconnection.
AtutorialontheArduinolanguageanddevelopmentenvironmentfollowsbelow.Thetutorial
willintroduceserialcommunicationwiththeDS1307RealTimeClock.
RealTimeClockCommunication
TheDS1307isaRealTimeClockwithcalendarfunctionalitywhichtracksthesecond,minute,
hour,date,andyearinanindependenttimekeepingregister.Settingtheindividualparameters
ofthetimekeepingregistersorretrievingthecurrenttimefromtheRealTimeClockrequires
communicationusingInterIntegratedCircuit(I2C)serialcommunicationprotocol.
TheI2Ccommunicationprotocoloperatesinamaster/slaveconfigurationandrequiresonlythe
SDA (Serial Data) and SCL (Serial Clock) lines for bidirectional data transmission. The Arduino
Duemilanove operates as the master device, which supplies the clock line (SCL) and initiates
datatransfers.TheslaveDS1307respondstothemasterArduinorequests.A7bitaddressing
systemisusedtodifferentiatebetweeneachindividualslavedeviceontheI2Cbus.TheDS1307
address(assignedbyindustrystandard)ishexadecimal0x68.
TheArduinoDuemilanovehardwarenativelysupportstheintegratedI2Cinterfacefoundonthe
ATmega328microcontroller.TheArduinoarchitectureassignsSDAandSCLtoanaloginputpins
35
4and5respectively.Associated20kpullupresistorsarebuiltintotheArduinohardware,as
requiredforcorrectI2Coperation.TheArduinoWireLibrary(Wire.h)isusedtosimplifyserial
communicationwithI2Cdevices.
SettingParameters
For the DS1307, the contents of each clock and calendar register are encoded with Binary
Coded Decimal (BCD). BCD represents each decimal digit with a halfbyte (4 bits) binary
sequence.Sinceonlytwodecimaldigitsarerequiredtorepresenteachunitoftime,1byte(8
bits) can store each timekeeper register. This facilitates data transmission since the Wire.h
librarycansendandreceiveindividualbytessequentially.Becauseahexadecimaldigitisalso
encodedusingahalfbyte,wecansimplywritehexadecimalvaluestothetimekeeperregisters
insteadofworryingaboutconvertingtoBCD.
ThefirstbyteofanI2Ctransmissionincludestheslavedeviceaddressanddatadirection(7bits
areusedforthedeviceaddressfollowedby1bittodesignatethereadorwritedirection).If
thedirectionbitisazero,themasterwillwritetotheDS1307.Ifthedirectionbitisaone
themasterwillreadfromtheDS1307.
TosetthedateandtimeforSaturday,March14,2022,at1:59AMUTC,forexample:
Wire.begin();
// Join I2C Bus
Wire.beginTransmission(0x68); // Slave address byte for DS1307
Wire.send(0);
// Set register pointer
Wire.send(0x26);
// Second
00-59
Wire.send(0x59);
// Minute
00-59
Wire.send(0x01);
// Hour
00-23
Wire.send(0x07);
// Day of week 01-07
Wire.send(0x14);
// Date
01-31
Wire.send(0x03);
// Month
01-12
Wire.send(0x22);
// Year
00-99
Wire.send(0x10);
/* Control register defines square wave
operation on pin 7 */
Wire.endTransmission();
36
AppendixA3SoftwareImplementation
37
Page 1 of 10
//
//
//
//
Azimuth / Zenith
#include <Wire.h>
#include
#include
#include
#define
#define
#define
#define
#define
#define
ASCIIZERO
pi
twoPI
rad
dEarthRadius
dAstroUnit
48
// '0' = 48
3.1415926535897932384
(2.0*pi)
(pi/180.0)
6371.01
// in km
149597890 // in km
#define
#define
#define
#define
#define
#define
OPTOPINAZ
OPTOPINZE
MOTZECWCCW
MOTZECLK
MOTAZCWCCW
MOTAZCLK
2
3
5
4
7
6
#define
#define
#define
#define
#define
MAXAZHOMESTEP
MAXZEHOMESTEP
STEPSAZHOME
ANGLEZEHOME
STEPDLY
6250
10000
1800
90.0
5
#define ZENITHHOMENUTPOSITION 24
#define STEPSPERDEGAZ 20.0
#define STEPSPERMMZE 100
//Latitude and Longitude for McMaster (JHE) = 43.260181 (N), 79.920892 (W). Latitude is considered positive to the North and longitude to the East.
//Use decimal format (Latitude = 43 + 26.0181/60 = 43.434; Longitude = -1 * (79 degrees + 92.0892/60) = -80.535;)
const double MCMASTERLATITUDE = 43.434;
const double MCMASTERLONGITUDE = -80.535;
struct cTime {
int iYear;
int iMonth;
int iDay;
double dHours;
double dMinutes;
double dSeconds;
};
struct cLocation {
double dLongitude;
double dLatitude;
};
file://C:\Users\adspence\Documents\Courses20102011\MechEng4B03\SampleReport\Arduino\SolarTrackerHTML.html
20/08/2010
Page 2 of 10
struct cSunCoordinates {
double dZenithAngle;
double dAzimuth;
};
struct cTime utcTime;
struct cLocation utcLocation;
struct cSunCoordinates utcSunCoordinates;
int iErrorAZFlag;
int iErrorZEFlag;
//*************************************************************************************************************************************************
void setup()
{
// setup serial communication
Serial.begin(9600);
Wire.begin();
Serial.println("SolarTracker v4.4");
Serial.println("Serial Connection initalized");
Serial.println("");
pinMode(MOTAZCWCCW,OUTPUT); // AZ motor
pinMode(MOTAZCLK, OUTPUT);
pinMode(OPTOPINAZ, INPUT); // opto slot sensor AZ
digitalWrite(MOTAZCWCCW,HIGH); // always go home CCW = HIGH
pinMode(MOTZECWCCW,OUTPUT); // EL motor
pinMode(MOTZECLK, OUTPUT);
pinMode(OPTOPINZE, INPUT); // opto slot sensor ZE
digitalWrite(MOTZECWCCW,HIGH); // always go home CCW = HIGH
utcLocation.dLatitude = MCMASTERLATITUDE;
utcLocation.dLongitude = MCMASTERLONGITUDE;
Serial.println("Location: McMaster University, Hamilton, ON");
Serial.print("Latitude (Decimal Format): "); Serial.println(utcLocation.dLatitude);
Serial.print("Longitude (Decimal Format): "); Serial.println(utcLocation.dLongitude);
Serial.println("");
// home the AZ stepper by looking for blocked opto slot, when home = East = 90 degrees = 1800 steps
homeAzimuth();
// home the Zenith stepper
homeZenith();
} // end setup()
//*************************************************************************************************************************************************
void loop() {
file://C:\Users\adspence\Documents\Courses20102011\MechEng4B03\SampleReport\Arduino\SolarTrackerHTML.html
20/08/2010
Page 3 of 10
getCurrentTime();
beginTracking();
Serial.println("");
delay(2000);
} // end loop()
//*************************************************************************************************************************************************
void getCurrentTime() {
Wire.beginTransmission(0x68);
Wire.send(0);
// point to address of the timekeeping registers
Wire.endTransmission();
Wire.requestFrom(0x68, 7); // request 7 bytes from DS1307
utcTime.dSeconds = convertHEX(Wire.receive());
utcTime.dMinutes = convertHEX(Wire.receive());
utcTime.dHours = convertHEX(Wire.receive());
Wire.receive();
// disregard the day of the week
utcTime.iDay = convertHEX(Wire.receive());
utcTime.iMonth = convertHEX(Wire.receive());
utcTime.iYear = 2000 + convertHEX(Wire.receive());
Serial.println("");
Serial.println("Universal Coordinate Time");
Serial.print("Time (Hh:Mm:Ss):
");
if ((int)utcTime.dHours < 10) Serial.print("0");
Serial.print((int)utcTime.dHours, DEC);
Serial.print(":");
if ((int)utcTime.dMinutes < 10) Serial.print("0");
Serial.print((int)utcTime.dMinutes, DEC);
Serial.print(":");
if (utcTime.dSeconds < 10) Serial.print("0");
Serial.println((int)utcTime.dSeconds, DEC);
Serial.print("Date (Dd/Mm/YYYY) ");
if (utcTime.iDay < 10) Serial.print("0");
Serial.print(utcTime.iDay, DEC);
Serial.print("/");
if (utcTime.iMonth < 10) Serial.print("0");
Serial.print(utcTime.iMonth, DEC);
Serial.print("/");
if (utcTime.iYear < 10) Serial.print("0");
Serial.println(utcTime.iYear, DEC);
Serial.println("");
} // end getCurrentTime()
//*************************************************************************************************************************************************
void homeAzimuth() {
Serial.println("");
Serial.println("Homing the Azimuth-tracking stage to 90 degrees East of North");
// Home the AZ stepper by looking for blocked opto slot. Home = East = 90 degrees = 1800 steps
file://C:\Users\adspence\Documents\Courses20102011\MechEng4B03\SampleReport\Arduino\SolarTrackerHTML.html
20/08/2010
Page 4 of 10
iErrorAZFlag = 0;
int iCount;
int optoStateAZ;
for (iCount=0; iCount// should be home in 180 deg worth of steps
optoStateAZ = digitalRead(OPTOPINAZ);
if (optoStateAZ == HIGH) {
// HIGH is blocked (home)
break; // now home
} // end if
digitalWrite(MOTAZCLK, HIGH); // STEP 1.8 DEG (with 36 reduction = 0.05 deg)
delay(STEPDLY);
digitalWrite(MOTAZCLK, LOW);
delay(STEPDLY);
} // end for
if (iCount < MAXAZHOMESTEP) {
// safely home
iErrorAZFlag = 0;
iStepsAZ = STEPSAZHOME;
}
else {
// didn't get home in 270 deg
iErrorAZFlag = 1;
} // end if
} // end homeAzimuth()
//*************************************************************************************************************************************************
void homeZenith() {
Serial.println("Homing the Zenith-tracking stage to +90 degrees (Horizon)");
Serial.println("");
// home the Zenith stepper
iErrorZEFlag = 0;
int iCount;
int optoStateZE;
for (iCount=0; iCount// should be home in 180 deg worth of steps
optoStateZE = digitalRead(OPTOPINZE);
if (optoStateZE == HIGH) {
// HIGH is blocked (home)
break; // now home
} // end if
digitalWrite(MOTZECLK, HIGH);
delay(STEPDLY);
digitalWrite(MOTZECLK, LOW);
delay(STEPDLY);
} // end for
if (iCount < MAXZEHOMESTEP) {
// safely home
iErrorZEFlag = 0;
dAngleZE = ANGLEZEHOME;
}
file://C:\Users\adspence\Documents\Courses20102011\MechEng4B03\SampleReport\Arduino\SolarTrackerHTML.html
20/08/2010
Page 5 of 10
else {
// didn't get home
iErrorZEFlag = 1;
} // end if
} // end homeZenith()
//*************************************************************************************************************************************************
void beginTracking() {
Serial.println("Solar Tracking Initalized.");
Serial.println("-----------------------------------------------------");
int iDeltaStepsAZ,iDeltaStepsZE;
GetSunPos(utcTime,utcLocation,&utcSunCoordinates); // get the current solar vector
Serial.print("Azimuth = "); Serial.println(utcSunCoordinates.dAzimuth);
Serial.print("Zenith = ");
Serial.println(utcSunCoordinates.dZenithAngle);
Serial.print("Motor AZ= "); Serial.print((double)iStepsAZ/(double)STEPSPERDEGAZ);
Serial.print(" Current iStepsAZ= "); Serial.print(iStepsAZ);
iDeltaStepsAZ = (int)(utcSunCoordinates.dAzimuth*STEPSPERDEGAZ) - iStepsAZ;
Serial.print(" iDeltaStepsAZ= "); Serial.println(iDeltaStepsAZ);
MoveMotorAZ(iDeltaStepsAZ);
iStepsAZ = (int)(utcSunCoordinates.dAzimuth*STEPSPERDEGAZ);
Serial.print("Motor ZE= "); Serial.print(dAngleZE);
Serial.print(" Current dAngleZE= "); Serial.println(dAngleZE);
Serial.print("utcSunCoordinates.dZenithAngle = ");
Serial.println(utcSunCoordinates.dZenithAngle, DEC);
if (utcSunCoordinates.dZenithAngle > 00.1 && utcSunCoordinates.dZenithAngle < 89.9) {
int iFutureZEsteps = getZenithSteps(utcSunCoordinates.dZenithAngle);
int deltaZenithSteps = iCurrentZEsteps - iFutureZEsteps;
//store in getZenith result in variable
MoveMotorZE(deltaZenithSteps);
dAngleZE = utcSunCoordinates.dZenithAngle;
iCurrentZEsteps = iFutureZEsteps;
}
else {
Serial.println(" The sun has set - no update");
homeAzimuth();
homeZenith();
} // end if
Serial.println("-----------------------------------------------------");
} // end beginTracking()
//*************************************************************************************************************************************************
void MoveMotorAZ(int iDeltaStepsAZ) {
int iCount;
Serial.print("Moving Azimuth motor this many steps: ");
Serial.println(iDeltaStepsAZ);
file://C:\Users\adspence\Documents\Courses20102011\MechEng4B03\SampleReport\Arduino\SolarTrackerHTML.html
20/08/2010
Page 6 of 10
if (iDeltaStepsAZ == 0) {
return;
} // end if
if (iDeltaStepsAZ > 0) {
digitalWrite(MOTAZCWCCW,LOW); // positive CW = LOW
}
else {
iDeltaStepsAZ = -iDeltaStepsAZ;
digitalWrite(MOTAZCWCCW,HIGH); // negative CCW = HIGH
} // end if
delay(10);
if (iErrorAZFlag == 0) {
for (iCount=0; iCountdigitalWrite(MOTAZCLK, HIGH); // STEP 1.8 DEG (with 36 reduction = 0.05 deg)
delay(STEPDLY);
digitalWrite(MOTAZCLK, LOW);
delay(STEPDLY);
} // end for
} // end if
} // end MoveMotorAZ()
//*************************************************************************************************************************************************
void MoveMotorZE(int iDeltaStepsZE) {
int iCount;
Serial.print("Moving Zenith motor this many steps: ");
Serial.println(iDeltaStepsZE);
if (iDeltaStepsZE == 0) {
return;
} // end if
if (iDeltaStepsZE > 0) {
digitalWrite(MOTZECWCCW,HIGH); // positive CW = LOW
}
else {
iDeltaStepsZE = -iDeltaStepsZE;
digitalWrite(MOTZECWCCW,LOW); // negative CCW = HIGH
} // end if
delay(10);
if (iErrorZEFlag == 0) {
for (iCount=0; iCountdigitalWrite(MOTZECLK, HIGH); // STEP 1.8 DEG (with 36 reduction = 0.05 deg)
delay(STEPDLY);
digitalWrite(MOTZECLK, LOW);
delay(STEPDLY);
} // end for
} // end if
} // end MoveMotorZE()
//*************************************************************************************************************************************************
void GetSunPos(struct cTime utcTime, struct cLocation utcLocation, struct cSunCoordinates *utcSunCoordinates)
{
// Main variables
double dElapsedJulianDays;
double dDecimalHours;
double dEclipticLongitude;
double dEclipticObliquity;
double dRightAscension;
double dDeclination;
file://C:\Users\adspence\Documents\Courses20102011\MechEng4B03\SampleReport\Arduino\SolarTrackerHTML.html
20/08/2010
Page 7 of 10
// Auxiliary variables
double dY;
double dX;
// Calculate difference in days between the current Julian Day
// and JD 2451545.0, which is noon 1 January 2000 Universal Time
{
double dJulianDate;
long int liAux1;
long int liAux2;
// Calculate time of the day in UT decimal hours
dDecimalHours = utcTime.dHours + (utcTime.dMinutes
+ utcTime.dSeconds / 60.0 ) / 60.0;
// Calculate current Julian Day
liAux1 =(utcTime.iMonth-14)/12;
liAux2=(1461*(utcTime.iYear + 4800 + liAux1))/4 + (367*(utcTime.iMonth
- 2-12*liAux1))/12- (3*((utcTime.iYear + 4900
+ liAux1)/100))/4+utcTime.iDay-32075;
dJulianDate=(double)(liAux2)-0.5+dDecimalHours/24.0;
// Calculate difference between current Julian Day and JD 2451545.0
dElapsedJulianDays = dJulianDate-2451545.0;
}
// Calculate ecliptic coordinates (ecliptic longitude and obliquity of the
// ecliptic in radians but without limiting the angle to be less than 2*Pi
// (i.e., the result may be greater than 2*Pi)
{
double dMeanLongitude;
double dMeanAnomaly;
double dOmega;
dOmega=2.1429-0.0010394594*dElapsedJulianDays;
dMeanLongitude = 4.8950630+ 0.017202791698*dElapsedJulianDays; // Radians
dMeanAnomaly = 6.2400600+ 0.0172019699*dElapsedJulianDays;
dEclipticLongitude = dMeanLongitude + 0.03341607*sin( dMeanAnomaly )
+ 0.00034894*sin( 2*dMeanAnomaly )-0.0001134
-0.0000203*sin(dOmega);
dEclipticObliquity = 0.4090928 - 6.2140e-9*dElapsedJulianDays
+0.0000396*cos(dOmega);
}
// Calculate celestial coordinates ( right ascension and declination ) in radians
// but without limiting the angle to be less than 2*Pi (i.e., the result may be
// greater than 2*Pi)
{
double dSin_EclipticLongitude;
dSin_EclipticLongitude= sin( dEclipticLongitude );
dY = cos( dEclipticObliquity ) * dSin_EclipticLongitude;
dX = cos( dEclipticLongitude );
dRightAscension = atan2( dY,dX );
if( dRightAscension < 0.0 ) dRightAscension = dRightAscension + twoPI;
dDeclination = asin( sin( dEclipticObliquity )*dSin_EclipticLongitude );
}
// Calculate local coordinates ( azimuth and zenith angle ) in degrees
{
double dGreenwichMeanSiderealTime;
double dLocalMeanSiderealTime;
file://C:\Users\adspence\Documents\Courses20102011\MechEng4B03\SampleReport\Arduino\SolarTrackerHTML.html
20/08/2010
Page 8 of 10
double dLatitudeInRadians;
double dHourAngle;
double dCos_Latitude;
double dSin_Latitude;
double dCos_HourAngle;
double dParallax;
dGreenwichMeanSiderealTime = 6.6974243242 +
0.0657098283*dElapsedJulianDays
+ dDecimalHours;
dLocalMeanSiderealTime = (dGreenwichMeanSiderealTime*15
+ utcLocation.dLongitude)*rad;
dHourAngle = dLocalMeanSiderealTime - dRightAscension;
dLatitudeInRadians = utcLocation.dLatitude*rad;
dCos_Latitude = cos( dLatitudeInRadians );
dSin_Latitude = sin( dLatitudeInRadians );
dCos_HourAngle= cos( dHourAngle );
utcSunCoordinates->dZenithAngle = (acos( dCos_Latitude*dCos_HourAngle
*cos(dDeclination) + sin( dDeclination )*dSin_Latitude));
dY = -sin( dHourAngle );
dX = tan( dDeclination )*dCos_Latitude - dSin_Latitude*dCos_HourAngle;
utcSunCoordinates->dAzimuth = atan2( dY, dX );
if ( utcSunCoordinates->dAzimuth < 0.0 )
utcSunCoordinates->dAzimuth = utcSunCoordinates->dAzimuth + twoPI;
utcSunCoordinates->dAzimuth = utcSunCoordinates->dAzimuth/rad;
// Parallax Correction
dParallax=(dEarthRadius/dAstroUnit)
*sin(utcSunCoordinates->dZenithAngle);
utcSunCoordinates->dZenithAngle= (utcSunCoordinates->dZenithAngle
+ dParallax)/rad;
}
} // end GetSunPos()
byte convertHEX(byte value) {
//This works for decimal 0-99
return ((value/16*10) + (value%16));
} // end convertHEX
//*************************************************************************************************************************************************
int getZenithSteps(double
double beta0;
double beta;
double epsilon;
int
maxIterations;
int
iterations;
int
converged;
theta) {
// Initial guess
// Approximate solution
// Maximum error
// Maximum number of iterations
// Actual number of iterations
// Whether iteration converged
file://C:\Users\adspence\Documents\Courses20102011\MechEng4B03\SampleReport\Arduino\SolarTrackerHTML.html
20/08/2010
Page 9 of 10
Serial.println("");
Serial.print("|AD| length (mm): ");
Serial.println(nutPosition, DEC);
Serial.println("");
return beta;
} // end newtonsMethod
//*************************************************************************************************************************************************
double f(double thetaRAD, double beta) {
return 15 + 25*sin(thetaRAD) - 53*sin(thetaRAD + beta);
} // end f
//*************************************************************************************************************************************************
file://C:\Users\adspence\Documents\Courses20102011\MechEng4B03\SampleReport\Arduino\SolarTrackerHTML.html
20/08/2010
Page 10 of 10
file://C:\Users\adspence\Documents\Courses20102011\MechEng4B03\SampleReport\Arduino\SolarTrackerHTML.html
20/08/2010
AppendixA4CADDrawings
38
5
6
4
1
9
C
ITEM
1
2
3
4
QTY
1
1
1
7
5
6
7
5
11
2
8
9
1
2
PARTS LIST
PART NUMBER
panel
SensorBlockBracket
sunlocVerif
ANSI B18.22.1 - No. 8 narrow - Type B
ANSI B18.21.1 - 0.138
ANSI B18.6.3 - 6 - 32
ANSI B18.6.3 - 6-32 UNC 1.25
foil
ANSI B18.6.3 - 6-32 UNC 0.75
DESCRIPTION
DRAWN
A. Dolgopolov
2/4/2010
McMaster University
CHECKED
QA
MFG
TITLE
APPROVED
SIZE
C
SCALE
REV
DWG NO
SubassemblyPanel-Sunloc
1:1
SHEET
1 OF 1
1
2.5
A
A
R2 TYP
R4.59
DETAIL A
SCALE 2 : 1
R5.00
2x
B
4.17
.15 A
B
4 TYP
0 A
100.00
94.00
70.00
62.00
55.10
50.00
45.30
7.3
38.00
30.00
6.00
6.00
15.00
A
30.0040.0050.00
94.00
100.00
A
5.00
DRAWN
A. Dolgopolov
2/10/2010
McMaster University
CHECKED
QA
TITLE
MFG
APPROVED
0.5
Panel
SIZE
DWG NO
panel
SCALE
1:1
REV
SHEET
OF
6.5 THRU
5.5
0 AB
4.2 THRU
3.6
0 A
2x
B
2.0 A B
R30
30
20
20
0.5
DRAWN
A. Dolgopolov
11/23/2009
QA
TITLE
MFG
APPROVED
SunlocVerif
SIZE
REV
DWG NO
A
SCALE
McMaster University
CHECKED
SunlocVerif
1:1
SHEET
OF
2
B
1
4.2 THRU
3.6
0 AB
11
C
10
B
4.2 THRU
3.6
0 BAC
5
2.5
VIEW5
SCALE 1 : 1
11
2.5
6.75
A
16
DRAWN
A. Dolgopolov
A
MATERIAL: BLACK ABS PROTOTYPE PLASTIC
UNLESS OTHERWISE
STATED ALL DIMENSIONS
IN MILLIMETERS
TOLERANCES:
LINEAR +0/-0.15
11/9/2009
QA
TITLE
MFG
APPROVED
0.5
SCALE
REV
DWG NO
A
ANGULAR
McMaster University
CHECKED
SensorBlockBracket
4:1
SHEET
OF
0.05 A
B
G
4.2 THRU
3.6
H
B
AB
10
PT H
PT G
VIEW4
SCALE 1 : 1
7
12
10
A
35
DRAWN
A. Dolgopolov
0.5
TITLE
MFG
Foil1
SIZE
REV
DWG NO
A
SCALE
McMaster University
QA
APPROVED
ANGULAR
11/18/2009
CHECKED
Foil1
3:1
SHEET
OF
4
2
6
12
1
6
9
12
10
ITEM
1
2
3
4
QTY
1
2
2
4
5
6
7
8
9
1
1
1
10
8
10
11
8
4
12
PARTS LIST
PART NUMBER
Bridge
TIL159Mount
TIL159
ANSI B18.6.3 - 6 - 32 x 1
1/4 SP HMS
screwholder
TopbasePlate
Pivotversion2
ANSI B18.6.3 - 6 - 32
ANSI B18.22.1 - No. 8 narrow - Type B
ANSI B18.21.1 - 0.138
ANSI B18.6.3 - 6-32 UNC 0.6
ANSI B18.6.3 - 6-32 UNC 1.25
8
11
DESCRIPTION
DRAWN
A. Dolgopolov
2/4/2010
McMaster University
CHECKED
QA
MFG
TITLE
APPROVED
SIZE
C
SCALE
REV
DWG NO
TopPlateBridgePivot
1:1
SHEET
1 OF 1
1
4.00 YP.
5.00
13.00
14.47
19.00
24.50
27.00
32.50
37.00
47.50
5.00
25.00
30.00
42.00
47.00
67.00
Scale: 1:1.5
Unit: mm
Plate Thickness: 5mm
95.25
101.00
110.00
130.00
DRAWN
Jiang
11/1/2009
CHECKED
QA
MFG
TITLE
APPROVED
SIZE
REV
DWG NO
TopbasePlate
SCALE
SHEET
1 OF 1
4x
4.2
3.6
0 A
B
40.0
A2
A3
30.0
27.0
24.1
15.9
13.0
10.0
A4
A1
76.0 84.0
8.0
11.4
4.0
A
DRAWN
HOLE TABLE
HOLE
XDIM YDIM
A1
4.00
5.00
4.00 35.00
A2
A3
80.00 35.00
A4
80.00 5.00
4
A. Dolgopolov
11/23/2009
McMaster University
CHECKED
TITLE
QA
Bridge
MFG
APPROVED
ANGULAR
0.5
SIZE
B
SCALE
REV
DWG NO
Bridge
1:1
SHEET
1 OF 1
2:1
5.0
5
5.1
4.2
.15 A
.15 B
16.1
2
R4 TYP
43
4
.15 C
SCALE 1 : 1
15
R1 TYP
3
16
22
46
4
0
10
54
DRAWN
A. Dolgopolov
2/8/2010
McMaster University
CHECKED
QA
TITLE
MFG
APPROVED
Pivot
SIZE
0.5
SCALE
REV
DWG NO
Pivotversion2-1
2:1
SHEET
OF
2x
4.2
3.6
0 A
.15 C
40
B
4
VIEW2
SCALE 1 : 1
30
4.83
.15 A
C
16.5
R3 TYP 11.5
2.50
A
DRAWN
A. Dolgopolov
12/16/2009
QA
TITLE
MFG
APPROVED
Screw Holder
SIZE
SCALE
REV
DWG NO
0.5
McMaster University
CHECKED
screwholder
2:1
SHEET
OF
12
13
10
4
11
9
7
6
PARTS LIST
B
ITEM
QTY
MotorBracket
10-32thread
MotorHub
ANSI B18.6.3 - 6 - 32 x 1
1/4 SP HMS
TopbasePlate
JapanServoKP35FM2-035
JapanServoKP35FM2-035Sh
aft
ANSI B18.6.3 - No. 4 - 40 - Cross Recessed Binding
1 1/8
Head Machine Screw - Type
I
ANSI B18.6.3 - 6 - 32
Hex Machine Screw Nut
10
11
12
13
PART NUMBER
DESCRIPTION
DRAWN
A. Dolgopolov
2/4/2010
McMaster University
CHECKED
QA
MFG
TITLE
APPROVED
SIZE
C
SCALE
REV
DWG NO
TopPlateMotorBracket
1:1
SHEET
1 OF 1
1
2.0
1.5
A
2x
4.3
3.5
0
BAC
21
B
9
2x
33
14.0
13.5
3.3
2.9
11
ABC
6.5
R12
H
G
40.0
39.5
0.5 A B C
H
36
3.0
2.5
23
14
B
10
4.0
3.5
20
37.0
36.5
DRAWN
A. Dolgopolov
11/6/2009
QA
TITLE
MFG
APPROVED
A. Spence
11/11/2009
0.5
SCALE
REV
DWG NO
A
ANGULAR
McMaster University
CHECKED
MotorBracket
1:1
SHEET
OF
1
4
5
ITEM
1
2
3
4
5
DRAWN
A. Dolgopolov
QTY
1
1
1
7
1
PARTS LIST
PART NUMBER
10-32thread
Hub#1Assem
screwholder
ANSI B18.6.3 - 10 - 32
Subassembly Slider & Nuts
2/17/2010
DESCRIPTION
McMaster University
CHECKED
QA
TITLE
MFG
APPROVED
SIZE
REV
DWG NO
SubassemblyCrankRodScrewholder
SCALE
1:1
SHEET
OF
2x
4.2
3.6
0 A
.15 C
40
B
4
VIEW2
SCALE 1 : 1
30
4.83
.15 A
C
16.5
R3 TYP 11.5
2.50
A
DRAWN
A. Dolgopolov
12/16/2009
QA
TITLE
MFG
APPROVED
Screw Holder
SIZE
SCALE
REV
DWG NO
0.5
McMaster University
CHECKED
screwholder
2:1
SHEET
OF
1
PARTS LIST
ITEM
1
2
3
4
QTY
1
2
4
2
PART NUMBER
DESCRIPTION
slider
ANSI B18.6.3 - 6 - 32
ANSI B18.6.3 - 10 - 32
ANSI B18.22.1 - No. 8 narrow - Type B
1
3
SCALE 1 : 1
DRAWN
A. Dolgopolov
2/17/2010
McMaster University
CHECKED
QA
TITLE
MFG
APPROVED
A
SCALE
REV
DWG NO
SubassemblySlider&Nuts
2:1
SHEET
OF
1
5.2 10.5
15
11.9
15
11.9
9.7
7.3
5.3
3.1
2.8
B
B
6
7.9
6.5
15.8
13.1
21
SCALE 1 : 1
7
3.7 7.5
11.3
15
6
6
3.5
4
6.5
DRAWN
0.5
A. Dolgopolov
2/18/2010
QA
TITLE
MFG
APPROVED
Slider
SIZE
DWG NO
slider
SCALE
McMaster University
CHECKED
2:1
REV
SHEET
OF
B
B
9.8
B
23.03
34.03
6.62
4
3.32
9.12
R2 TYP
3
.5
2.5
12
SCALE 1 : 1
4.17
.15 A
B
DETAIL A
SCALE 4 : 1
3.51
A
R3 TYP
R5 TYP
2
2.00
6.00
53
32
A
DRAWN
SECTION B-B
SCALE 2 : 1
A. Dolgopolov
2/18/2010
McMaster University
CHECKED
QA
TITLE
MFG
APPROVED
0.5
Crank
SIZE
DWG NO
crank
SCALE
2:1
REV
SHEET
OF
AppendixA5RapidPrototypedComponentCosts
RP Part Name
# of
Pieces
Cost
(CAD)
Gear Ring
8.68
3.64
104.16
Worm Gear
4.88
1.36
58.56
Bridge Rail
0.45
0.89
5.4
Crank Arm
0.38
0.24
4.56
Motor Shaft
Hub
0.23
0.11
2.76
Screw Holder
0.13
0.04
1.56
Pivot Stand
0.58
0.11
6.96
Slider
0.25
0.09
Panel
1.75
0.53
21
10
Motor Bracket
1.5
0.45
18
11
Switch Block
Bracket
0.08
0.04
0.96
12
Sun Beam
Locator
0.22
0.09
2.64
13
LDR Mount
0.12
0.08
1.44
14
TIL159 Mount
0.11
0.07
1.32
39
Total Cost
(CAD)
232.32
References
[1]
BlancoMuriel,M.,AlarcnPadilla,D.C.,LpezMoratalla,T.,andLaraCoira,M.,
ComputingtheSolarVector,SolarEnergy,70(5),431441,2001.
[2] AutodeskInc.,SanRafael,CA,www.autodesk.com.
[3] Dimension,Inc.,EdenPrairie,MN,www.dimensionprinting.com
[4] Banzi,M.,Cuartielles,D.,Igoe,T.,Martino,G.,andMellis,D.,ArduinoAlphav17,
www.arduino.cc
[5] Vogt,N.,Astronomy110G03LectureNotesFall2007,NewMexicoStateUniversity,
http://astronomy.nmsu.edu/nicole/teaching/astr110.
[6] www.timeanddate.com
[7] CANMETSolarPaper,http://canmetenergycanmetenergie.nrcan
rncan.gc.ca/eng/renewables/standalone_pv/publications/2006046.html
[8] PhotovoltaicPotentialandSolarResourceMapsofCanada,NaturalResourcesCanada,
https://glfc.cfsnet.nfis.org/mapserver/pv/index_e.php
[9] OntarioIndependentElectricitySystemOperator,OntarioDemandForecast:18Month
OutlookfromApril2007toSeptember2008,
http://www.ieso.ca/imoweb/pubs/marketReports/18Month_ODF_2007mar.pdf
[10] EagleLayoutEditor,http://www.cadsoftusa.com/
40