I have attached an updated version of the Arduino Sun Tracking / Heliostat program for help with testing and also so that people can give their input for what they might like to have added sometime in the future. I may still add some things before I finally upload it to my site, but these are the new features that I have finished so far. Keep in mind that the uploaded program is set up to be used with the step/dir type driver boards. In particular, it is most similar to the "Simpler Electrics" version of the program. Other types are possible, but will require some code editing to implement.
1. The first addition is the "updateEvery" variable which allows you to choose, in seconds, how often the machine updates its position.
2. Next is the "moveAwayFromLimit" variable which will allow you to choose how many degrees the machine will move away from the limit switch after one has been triggered.
3. One of the larger (i.e. more complicated) improvements is that acceleration has been added to the stepper motor control code (step/dir type driver boards only).
a) The stepper motor speed is now set in revolutions per minute.
b) The alt/azAccel variables signify the number of seconds it will take each stepper motor to accelerate to full speed.
4. I've also added a manual control option which allows the machine(s) to be controlled via the Arduino IDE's Serial Monitor. You'll notice that there is now a manualModeOnOffPin variable to be used to specify which pin a "Manual Mode" switch is connected to. When this pin/switch is high, the program goes into manual control mode. Remember that the Arduino automatically resets itself when the Serial Monitor is opened, so you will also have to wait for the machine(s) to reset itself.
I haven't had the chance to fully test this feature out in the sun yet, but my little test machine sitting on my desk seems to move exactly as it should when inputting commands.
When the Arduino is connected through the Serial Monitor, you will see the following output displayed. (Note: Make sure you have 9600 Baud selected if you see gibberish)
Manual Mode Active:
Type Machine Number:
Here, you can specify which machine you would like to control. If you only have one set up, just type "1".
You will then be asked a series of questions which will differ depending on whether that machine is a sun tracker or if it is a heliostat.
If it is a sun tracker, you will be experience the following:
Machine's Current Altitude:
Machine's Current Azimuth:
(your input here)
(your input here)
Begin Move? Yes=1, No=0
Note: If you enter 1 for yes, the machine will move to the specified coordinates. Note that this move will be aborted if it is beyond the machine's software limits. If you enter 0 for no, the machine will stay where it is.
Once this sequence is finished, the whole process will start over again if the manual control pin is still active.
If the machine is a heliostat, you will see this output.
Target's Current Alt:
Target's Current Az:
Input Target's New Az:
(your input here)
Input Target's New Az:
(your input here)
Begin Move? Yes=1, No=0
Note: If you enter 1 for yes, the machine will move to reflect the light at the specified target. Keep in mind that this move will not occur if it is beyond the machine's software limits. If you enter 0 for no, the machine will stay where it is. Once this sequence is finished, the whole process will start over again if the manual control pin is still active.
The "Manual Mode" while the machine is set to track the sun can be very useful for debugging sense you can type in an a specific altitude and azimuth and double check to see if the machine actually moves to those coordinates. If it doesn't, then perhaps you have input the wrong settings. (Remember that you can put temporarily put heliostats in sun tracking mode to test them)
The "Manual Mode" for a heliostat removes one of the more irritating problems with the older versions of the program, trying to figure out what the altitude and azimuth of your target is. Before, you had to edit the program and then re-upload it to the Arduino every time you wanted to try a new target. Now, you just type it in. Keep in mind that once you take the machine out of Manual Mode the program will not save the current target altitude and azimuth, so make sure you write these values down so that you can hard code them into the program later.
5. Another change to the Sun Tracker program is that you now have to specify the maximum altitude that the machine can safely travel. This is setting #17. Make sure this additional setting is added if you copy and paste settings from an older version of the program.
Also, I moved the explanation for the settings to a separate ReadMe.html file located in the SunTracker_V097 folder.
6. The final major improvement is the addition of a "Wind Protected Mode". I have heard several people express concerns about high wind speeds damaging their machines, so it seemed prudent to add the ability to move the machine into a horizontal position if desired. I make no guarantees that this will definitely save your machine in a high wind situation, but the option is there if you think it will help.
When the "WindProtectionSwitch" pin/switch is set to HIGH, the machine will move into a pre-specified wind protected position and stay there until it is set to LOW again. This pre-specified position is set by the machineAltParkAngle and machineAzParkAngle variables. Note that the machine(s) will automatically reset itself when the Wind Protection Switch is turned off.
I think that pretty well covers the new features. If you have ideas for others, let me know. So far, I'm running out of ideas for things to add, which is probably for the best because I'm running out of space on the Arduino.
Also, keep in mind that these features are still being tested, so let me know if you experience anything weird while you use it.
I forgot to delete the Accelstepper library which is not needed for the program. It was just something I had experimented with earlier, but ended up not using. Any Arduino sketch uploading issues you may have had were probably due to this.
I also forgot to paste in the readme file. Doh!
Finally, as iamtawon mentions below, you will need to download and install the lastest version of the Flash.h library which has been updated to work with the Arduino 1.0 IDE. http://arduiniana.org/libraries/flash/UPDATE: (5/16/12)
Fixed a bug which caused the program to skip updating the position of the sun periodically.
The updated SunTracker_Heliostat code has been attached to this post and the old one deleted.UPDATE: (6/26/12)
There is a bug in V0.9.7 that affects control of linear actuators. Put simply, it doesn't work. I think I have it fixed already, but am still doing some testing and adding some new features before I upload the updated code.UPDATE: -----------------------------------------------------UPDATE: (7/03/12)UPDATE: -----------------------------------------------------
The program has now been updated to Version 0.9.7.b
I have left the earlier version attached to this post, but there shouldn't be any reason to use it.
There have been several improvements in this version.
They are as follows:
1. It is now possible to mix and match gear reduction with linear actuators. Previously, it was only possible to have either only linear actuators or only a gear reduction system for the altitude and azimuth motion. Now you can also have a linear actuator on the altitude and a gear reduction system on the azimuth or
a gear reduction system on the altitude and a linear actuator on the azimuth. Check out the readme file in the download for more info.
2. Code for controlling two shift registers was added to the program. Wiring up the shift registers will give the Arduino 16 more outputs. These outputs are used to turn additional machines on and off so that you can control multiple machines with just one set of driver boards. (Note: I'm still figuring out what the best way is to do the electronics for this, but the code should be good to go.)
3. When using manual control for heliostat targets, the input is now automatically saved to the Arduino's EEPROM. This means that the heliostat will continue to reflect at the selected target after manual mode is deactivated, or even if the Arduino is reset or the program is re-uploaded.
Note that the target values programmed for the heliostat(s) are not saved to EEPROM until after
you switch the manual control switch off
One more thing to mention regarding manual control is that machine #0 is now the first machine, #1 is the second, #2 is the third
, etc. So, you are counting from zero now. This was done to prevent confusion when (if) the time comes to hard code the target values into the program.
4. A heliostat to sun tracker switch was added to the program which will make a heliostat instead act as a sun tracker. When aligning my heliostat, I find it easiest to make it track the sun and then use a "shadow stick" to determine how I must adjust the heliostat to make it point directly at the sun. This stick is set up so that it is perpendicular to the mirror, which means that it won't cast a shadow when the heliostat is properly oriented.
The addition of the switch means that you don't have to re-upload the program every time you want to change a heliostat to a sun tracker.
5. The code for setting the time on the RTC has been moved out of void setup() to just underneath of where the settings for the machine(s) are programmed.
6. When viewing the Serial Monitor, you will now see both local time (ignoring daylight saving time) and Greenwich Mean Time displayed. If the print out of GMT is different than actual GMT (something which you can find through a web search) then odds are that you probably have your RTC set to the wrong time.
Note: Make sure that you are viewing GMT as 24hr, not AM PM.
7. A significant bug was fixed regarding the use of linear actuators. It was accidentally introduced in vesion. 0.9.7 and should be fixed now in this version, 0.9.7.b.
8. A few other miscellaneous things to mention are:Watch out for pin reassignments.
I have been rearranging the Arduino's wiring in my own circuit, so you may need to change the pin assignments back to what they were before if you already have your circuit wired up.
I've also gone through the code and tidied things up quite a bit. I also tried to make things easier to understand. Watch out when adding any of your own code from previous version because there has been some variable renaming.
On another, random note, I changed the heliostat alt and az calculations so that the positive x-axis is now considered south, and the positive y-axis is now considered west. It doesn't change the final output any, it just makes more sense to me to do it that way.
Finally, note that this version of the program is only compatible with Arduino IDE 1.0.
Don't try to use an earlier IDE, and don't try to use a newer one. Arduino IDE 1.0 can still be downloaded from the Arduino website, so you are not out of luck if you don't have it.
As always, keep in mind that these features are still being tested, so let me now if you notice anything that doesn't seem quite right.UPDATE: 7/04/2012
Click the link to read about this update.http://cerebralmeltdown.com/forum/index.php?topic=325.msg1252#msg1252Update: 8/22/2012
Click the link to read about this update.http://cerebralmeltdown.com/forum/index.php?topic=325.msg1310#msg1310Update: 11/6/2012
Here's a quick update to the Arduino Mega version of the Sun Tracking / Heliostat program. The file name is MegaSunTracker_Heliostat_Program_V097_c2.zip and is attached to this post. This program is identical in function to the Arduino Uno version of the program except that it now uses the sun calculations that are optimized for both speed and accuracy (you can thank Bob101 for this improvement!).
Make sure you copy the folders inside of the "libraries" folder into the Arduino IDE's libraries folder.Update: 11/8/2012
The MegaSunTracker_Heliostat_Program_V097_c2.zip folder uploaded previously mistakenly did not have the correct libraries. I have attached a new folder, Mega_SunTracker_Heliostat_Program_V097_c3.zip, which should have the correct ones. Make sure you reinstall the libraries in the new attached folder as one of the old ones were incorrect.Update: 12/01/2012
The Sun Tracking / Heliostat Program has been updated to SunTracker_Heliostat_Program_V097_e for the Uno and Mega_SunTracker_Heliostat_Program_V097_e for the Mega.
Click the link to read about this update.http://cerebralmeltdown.com/forum/index.php?topic=325.msg1468#msg1468Update: 2/23/2013
The Sun Tracking / Heliostat Program has been updated to V0.9.8. Click the link below to read about the changes and download the program. (The latest version has also been attached below for convenience.)http://cerebralmeltdown.com/forum/index.php?topic=325.msg1540#msg1540