Arduino Sun Tracking / Heliostat Program Setup


Subscribe to my Feed!

This page explains how to customize the Arduino Sun Tracking / Heliostat Program’s settings for your location and machine design.

At this point, you should have already downloaded the program from the link below. If not, go ahead and do it now.

Sun Tracking / Heliostat Program Download Page

Which Tab

When you open the program, you should see 6 or 7 tabs located near the top of the Arduino IDE.

The only tab you really need to worry about for now is the one labeled “SunTracker_Heliostat_Program_Vxx “or “Mega_SunTracker_Heliostat_Program_Vxx ” depending on which version of the program you are using.

Note: I have noticed that all of these tabs don’t always show up when they are first opened after being downloaded. Sometimes you have to close the Arduino IDE and open it again to get them to pop up. Also, make sure you unzip the downloaded zip folder before you try opening the program.

Setting your Latitude, Longitude, and Timezone

At the very top of the program, you will see where to input your latitude, longitude, and time zone. It is very important that these values are correct since your machine(s) will not track correctly if they are wrong.

Here is one good link where you can find the latitude and longitude for your location. http://www.getlatlon.com/

You can find your time zone at this website http://www.worldtimezone.com/. Warning! Make sure that you use the same timezone value that you used in the Setting the Time on the RTC Tutorial.

Northern or Southern Hemisphere Option

The “useNorthAsZero” setting allows you to specify whether you want the program to use north or south as the direction where the azimuth equals zero. I highly recommend that you read the explanation at this link before using this option.

Setting the Update Interval

The “updateEvery” variable allows you to change how often the machines update their position to keep up with the sun. There is no “perfect” value to use here, so you might try experimenting with it to see what suites your situation the best.

Setting the Move Away from Limit Variable

The “moveAwayFromLimit” variable tells the program how far to move the machine away from the limit switches after they have been triggered. This can be useful if your machine has to move especially far away from the limit switches before they deactivate. Since the limit switches for all of the machines are wired in parallel, if one limit switch stays activated, the rest of the machines will not reset correctly.

Setting the Reset Hour

The hourReset variable specifies the time at which your solar machines will reset their position on the limit switches. You should choose an hour that occurs after nightfall for every day of the year. Also remember that daylight saving time is not used, so the hour the machines reset might be one hour off from the clocks in your home.

Setting the Wind Protection Park Angle

These two variables specify the position that the machines move to when the “Wind Protection Mode” Switch is activated. Make sure that your machine is physically capable of moving to this position before using it.*

*Notice that the “machineAltParkAngle” is set to 65 degrees here instead of the optimum 90 degrees. This is because the machine I was  using while writing this documentation wasn’t capable of moving to 90 degrees, so I had to use a smaller value.

Setting the Number of Steps for your Stepper Motors

The “steps” variable is where you set the number of steps it takes for your stepper motors to make one revolution. This is not necessarily the number that is written on your stepper motors since you must also take into account the settings on your driver board (i.e. whether it is set to microstepping, half stepping, etc).

 

Setting the Speed of the Stepper Motors

There are three places where you can set how fast the stepper motors move. The values you use depend largely on your machine. You will have to experiment to see what is best for your situation. Note that since there is no acceleration while the machines reset, you may want to set the alt and az reset speed to a lower value if your machine is an especially large one.

Setting the “Acceleration” rate of the Stepper Motors

The “altAccel” and “azAccel” variables let you change the acceleration* of the stepper motors by specifying how long it takes them to reach full speed. If your stepper motors are set to a low rpm, then acceleration probably won’t be beneficial. You can set this value to 0 for no acceleration.

*Strictly speaking, this isn’t technically an acceleration value, but I find that controlling the amount of time it takes to reach full speed is easier to conceptualize.

Setting the Maximum Number of Steps your Machine will Take when Resetting

The Sun Tracking / Heliostat Program is only able to move one machine at a time, so if one gets stuck and isn’t able to trigger its limit switch during a reset then all of the other machines will also cease to operate. For this reason you have the option of specifying the maximum number of steps each stepper motor will take before giving up. That way, the program will simply move on to the next machine in the array instead of spending the whole day trying to move a stuck machine.

This value is calculated by determining how many steps it takes the stepper motors to move the machine from its max alt/az position to its min alt/az position (adding on an extra say 2000 steps wouldn’t hurt). Thus if the machine were to try to take more steps than this, then something must have gone wrong during its reset sequence.

Note: don’t try to use a value larger than 2,147,483,647 for these variables as it will cause unpredictable behavior during resets.

Enable Motors on LOW or on HIGH

 I find that the majority of Stepper Motor Driver Boards turn the motors OFF when the enable pin is toggled HIGH. There are some driver boards where the opposite is true. The motors turn ON when the enable pin is toggled HIGH. The enableHIGHorLow setting allows you to choose between either one of the two options. You should check the documentation for your driver boards if you aren’t sure which to use.

Setting the Number of Machines that you want to Control

The numberOfMachines variable is used to specify how many machines you want to control. Unlike the other variables which were set above, you so not want to have a “;” at the end of the line here.

For every machine that you want to control, you will also have to add a line to the “MachineSettings” array.

So if you want to control one machine, you will only need one line like this.

const float MachineSettings[][20] PROGMEM = {

{…, …, …, …}

}

If you want to control two machine, then you will need two lines like this.

const float MachineSettings[][20] PROGMEM = {

{…, …, …, …}

,{…, …, …, …}

}

If you want to control three machines, then you will need three lines like this.

const float MachineSettings[][20] PROGMEM = {

{…, …, …, …}

,{…, …, …, …}

,{…, …, …, …}

}

You can continue on in this pattern for up to 16 machines. Warning! Don’t forget to add the comma before every line except the first one. Otherwise the program won’t compile.

[bad]

Setting the Parameters for your Solar Machine(s)

Every line in the “MachineSettings” array holds the parameters for one machine. By editing these values, you can customize the program to work with a variety of different machine designs. Additionally, since each line is unique, each machine can be of a completely different design from all of the others.

Note that much of the information in this section can also be found inside the ReadMe.txt file that is located inside of the program’s folder.

There are 20 settings total which are labeled 0-19. As you can see in the image below, these settings are roughly labeled with an abbreviated explanation for what they do (LorG   SorH  …) and also with their location in the line of code (Setting #  0  1  2 …).

As you edit these settings, I recommend that you either add or remove blank space so that each setting stays underneath of its label. That way, you can hopefully avoid getting them mixed up.

Setting #0

Setting #0 allows you to specify whether the machine uses a gear reduction system, a linear actuator system, or some combination of the two.

Put a 0 here if your machine uses a gear reduction system for both the altitude and azimuth motion.

Put a 1 here if the machine uses linear actuators for both the altitude and azimuth motion.

Put a 2 here if the machine has a linear actuator for the altitude motion and a gear reduction system for the azimuth motion.

Put a 3 here if the machine has a gear reduction system for the altitude motion and a linear actuator for the azimuth motion.

Setting #1

Setting #1 specifies whether the machine is a sun tracker or a heliostat.

Put a 1 here to make the machine track the sun.

Put a 2 here to make the machine act as a heliostat.

Settings 2-8 (Altitude Rotation) and Settings 9-15 (Azimuth Rotation)

Settings 2-8 are used to specify the various design aspects that the machine uses for its altitude motion while settings 9-15 do the same for the azimuth motion.

You’ll notice that the description for these settings differs depending on whether the machine uses gear reduction or a linear actuator for its altitude motion.

When using a linear actuator, you will have to decide which units to use for your length measurements. It doesn’t matter what units you use (inches, meters, centimeters, etc) just so long as you use them consistently throughout the program.

Setting #2 and #9

If using a gear reduction system, put the number of rotations it takes for the stepper motor to turn the machine 360 degrees here (even if it isn’t physically possible).

If using a linear actuator system, put the number of rotations it takes for the stepper motor to move the linear actuator 1 unit of length here.

Setting #3 and #10

This setting is used to reverse the direction of your stepper motor should you find that it is spinning in the wrong direction. You can also use this setting to make the program skip over this stepper motor so that it never moves.

To make the stepper motor reverse its direction, either change this setting from 1 to -1 or from -1 to 1 depending on what it is currently set at.

To make it so that the stepper motor never moves, put 0.

Setting #4, #5, #11, #12

These settings are used to specify the length of one side of the triangle formed by the linear actuator. The picture below is perhaps easier to understand than a verbal description.

If you are using a gear reduction system, put 0 for both settings since they aren’t used.

For a linear actuator system, put Length A for Setting 4 and Length B for Setting 5. (Or Length B for 4 and Length A for 5. It doesn’t actually matter.)

heliostat setup

Setting #6 and #13

This setting  is used to specify the angle between the two sides of the triangle when the machine is at zero degrees.

For the altitude motion, the machine is at zero degrees when the front surface of the machine is vertical.

For the azimuth motion, the machine is at zero degrees when the front surface of the machine runs parallel with the east and west line.

In the above picture, the angle is 90 degrees when the machine is at zero degree, thus Setting #6 would be 90 here.

Setting #7 and#14

This setting specifies whether the lever arm becomes more “acute”  or more “obtuse” when it moves away from zero degrees in the positive direction.

If you look at the picture on the left below, you will see that the machine has moved in the positive direction from zero degrees. In doing so, the triangle has become more acute.

If you look at the picture on the right, you will see that the machine has still moved in the positive direction from zero degrees, but the triangle has instead become more obtuse.

img62img64

Essentially, the acute or obtuse option simply lets the Arduino Sun Tracker program know which side of the machine the linear actuator attaches.

If the machine uses a gear reduction system, put a 0 here because it is not used.

If the machine uses a linear actuator system, put a 1 here if the machine becomes more acute or a 2 here if it becomes more obtuse.

Setting #8 and #15

These settings let the program know where the limit / homing switch is located. It is measured as an angle from the machine’s zero position. Although it can (theoretically) be a positive angle, it is generally best to set your  switch so that the machine will be ready for the morning sun after it resets. With the way the program is set up, this location is always negative.

Also, don’t use 0 for these settings. The program is able to figure out which direction it needs to move the machine to find the limit switch based off of whether the number is either positive or negative. 0 is neither positive nor negative.

Settings #16-19

Settings 16-19 are used to restrict the machine’s range of motion. This is where you set the software limits to prevent the machine from moving beyond its physical boundaries.

Setting #16

Put the minimum azimuth angle that your machine can move to here. Typically, this angle should be the same as your azimuth reset limit switch’s location.

Setting #17

Put the minimum altitude angle that your machine can move to here. Typically, this angle should be the same as your altitude reset limit switch’s location.

Setting #18

Put the maximum azimuth angle that your machine can move to here.

Setting #19

Put the maximum altitude angle that your machine can move to here.

The End

We’ve finally reached the end of this documentation! At this point, we have covered each of the user settings that can be customized for different locations and machine designs.

Misc. Relevant Links

This documentation is part of the Open Sun Harvesting Project. Click the link for more information.

Arduino Sun Tracking / Heliostat Program Setup

Setting the Time on the Real Time Clock

Forum Link

Sun Harvester Shield Wiring

Using the Arduino Sun Tracking / Heliostat Program

Subscribe to my Feed!