Author Topic: Sun Tracking / Heliostat Program Update  (Read 46155 times)

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Sun Tracking / Heliostat Program Update
« on: March 23, 2012, 04:06:53 PM »
Hey everyone,

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:
xx.xx
Machine's Current Azimuth:
xx.xx

Input Altitude:
(your input here)
Input Azimuth:
(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:
xx.xx
Target's Current Az:
xx.xx

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.

Thanks,
Gabriel

UPDATE: (4/24/12) 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#msg1252

Update: 8/22/2012

Click the link to read about this update.
http://cerebralmeltdown.com/forum/index.php?topic=325.msg1310#msg1310

Update: 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#msg1468

Update: 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


« Last Edit: February 23, 2013, 09:17:14 AM by Gabriel »


Ionut Nita

  • New Member
  • *
  • Posts: 13
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #1 on: March 28, 2012, 08:04:00 PM »
What can i say !  Gabriel you are fantastic !!!
You put in everyone of my old wishes.
My wishes become reality.
Thank you.

I will soon buy a lathe for lots of projects including more robust sun tracker made with steel tubes.
I also in the way to design a smal board that have arduino chip and two stepper drives with step/dir in a smal footprint like arduino uno
Thank you Gabriel


Ionut Nita

  • New Member
  • *
  • Posts: 13
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #2 on: March 28, 2012, 09:13:09 PM »
Few photos from alfa test  ;D

Ionut Nita

  • New Member
  • *
  • Posts: 13
    • View Profile
New suggestion Sun Tracking / Heliostat Program
« Reply #3 on: March 29, 2012, 09:26:58 PM »
It would be nice a  hourReset based on the month of the year since in winter the sun shine less.
It will reduce useless movement after sunset.
Lower power footprint and less wear in mechanical parts.


Ex:   January     hourReset 16:30;
        February   hourReset 17:00;
        March       hourReset 17:30;
       ............................................
       ............................................
       ..........

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #4 on: March 30, 2012, 05:45:06 PM »
Hi Ionut Nita,

Wow your sun tracker is looking really good. It is a lot better than anything I have ever built.

The sun tracking program is set up so that it automatically stops moving the machine(s) after sunset, so there shouldn't be any useless movement at night. At least that is what is supposed to happen. If your machine is still moving after dark, then you should double check the settings and, if you can't find anything wrong, let me know and I'll see if I can figure it out.


Ionut Nita

  • New Member
  • *
  • Posts: 13
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #5 on: March 30, 2012, 08:41:19 PM »
So after sunset until hourReset the machine(s) should not move.

The hourReset make the machine to go in the position for the next sunrise.
Correct me if I'm wrong.

Thank you and i will post new photos with my setup.
Actual power is 210 Watt the two small panels have 50 watt and the big one have 110 watt.

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #6 on: April 01, 2012, 12:19:47 PM »
"So after sunset until hourReset the machine(s) should not move."

Yep, that's correct.

More photos would be awesome!

iamtawon

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
    • Sunsynchronous
Re: Sun Tracking / Heliostat Program Update
« Reply #7 on: April 23, 2012, 08:17:43 PM »
Wow, This is awesome! I start to think that I have to modified the program by my own  :P
I just finish with my third set of heliostat and start looking into software side to support multiple setup
this version look promising, I will give it a try and get back to you soon.

« Last Edit: April 23, 2012, 08:19:26 PM by iamtawon »
May the sun be with you

iamtawon

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
    • Sunsynchronous
Re: Sun Tracking / Heliostat Program Update
« Reply #8 on: April 23, 2012, 09:00:06 PM »
when I try verify the code it return me error and say it can not find AccelStepper.h and flash.h

although I have put flash folder in to library folder like in 9.6 version, what do I have to do?



oh, I just scroll down in the forum and found out how already you can down load it from http://www.open.com.au/mikem/arduino/AccelStepper/
and paste it in the library folder
    <-- not needed

still have problem with flash.h  ??? the file is there but the compiler didn't see it?



Okay, another stupidity of mine  :P . you have to download a new version of flash library which they call Flash4, you can get it here http://arduiniana.org/libraries/Flash/

I have been using an earlier version of it so it doesn't support in arduino1.0 and oh, yes you have to use arduino 1.0 version to open this heliostat v9.7
« Last Edit: April 24, 2012, 07:21:10 PM by iamtawon »
May the sun be with you

iamtawon

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
    • Sunsynchronous
Re: Sun Tracking / Heliostat Program Update
« Reply #9 on: April 24, 2012, 02:38:20 AM »
Some feed back before I actually test with the hardware , excuse me if I get some idea wrong here i'm not really good with coding thing  :P


1.)
Quote
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.

can't find this read me file  ??? and may be it's better if you could put it along with one of those tap

2.) from the code I can setup for several machine but in control part it seem like I can only use 1 machine , i don't see you use those shift register code.
     the way I do it with the earlier version is I turn on (enable) the machine 1 by 1 like this. modified MachineOn function

Code: [Select]
void MachineOn(int number){
  // for easy driver enable pin is active low
  if (number == 0)
    {
      Serial.println("MACHINE 1 ON");
      digitalWrite(Helio1,LOW); //enable helio1
      delay(100);
      digitalWrite(Helio2,HIGH);// disable helio2
      delay(100);
      digitalWrite(Helio3,HIGH);// disable helio3
      delay(100);
    }
  if (number == 1)
    {
      Serial.println("MACHINE 2 ON");
      digitalWrite(Helio1,HIGH);// disable helio1
      delay(100);
      digitalWrite(Helio2,LOW);// enable helio2
      delay(100);
      digitalWrite(Helio3,HIGH);// disable helio3
      delay(100);
    }
   
      if (number == 2)
    {
      Serial.println("MACHINE 3 ON");
      digitalWrite(Helio1,HIGH);// disable helio1
      delay(100);
      digitalWrite(Helio2,HIGH);// disable helio2
      delay(100);
      digitalWrite(Helio3,LOW);// enaable helio3
      delay(100);
    }

this is hard code way to do it ( and only I can manage), may be you could come up with some more flexible way? like polling according to machineNumber variable.

that's all I notice now , will get back if I found out something else.
May the sun be with you

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #10 on: April 24, 2012, 09:39:09 AM »
Hi iamtawon,

I uploaded a new version of the program at the top of this page, so go ahead and re-download it to get the readme file. Thanks for the heads up.


From the picture you sent, it looks like have a driver board for each heliostat. This is fine, but my eventual plan is to have all the machines controlled with just one driver board to help keep the cost down. Basically, by toggling one of the Arduino pins on and off, the power to one of the heliostat's stepper motors would also be toggled on and off. I haven't had the time to figure out how to do the electronics yet with my new driver boards and stepper motors though.

The shift register code wouldn't have worked with the manual control code that I added in this update, so I removed it since it needs to be rewritten before it will work. For my own heliostat project, I am planning on moving over to the leaflabs Maple microcontroller because it is capable of double precision math, has more program space, and a lot more pin outputs. With that many more pins, a shift register isn't really needed.

It looks like you have the right sort of idea for enabling machines on and off with your code, and I think it should work fine. I would probably do something similar if I was only going to control a few machines.

You could move this code to the machineOff function if you wanted to clean it up a little.
      digitalWrite(Helio1,HIGH);// disable helio1
      delay(100);
      digitalWrite(Helio2,HIGH);// disable helio2
      delay(100);
      digitalWrite(Helio3,HIGH);// disable helio3
      delay(100);

I haven't decided exactly how I'm going to write that code for my own heliostats yet. Right now, I only have one, so I haven't needed to figure it out.

I will post it once I do though.




iamtawon

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
    • Sunsynchronous
Re: Sun Tracking / Heliostat Program Update
« Reply #11 on: April 24, 2012, 07:19:51 PM »
true, Those driver board cost me a lot. but to turn on/off the motor after driver board ?? you have to disconnect all the motor wire ( electronically/mechanically)
I bet that there would be a chip to do this just have to digg up some info.

Thanks for the updated code,
May the sun be with you

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #12 on: April 26, 2012, 02:54:17 PM »
"true, Those driver board cost me a lot. but to turn on/off the motor after driver board ?? you have to disconnect all the motor wire ( electronically/mechanically)"

Right. With my old stepper motor / driver board set up, I could do this easily because I was using 8 wire stepper motors, so each coil had a common ground that I could access. This way I could toggle power by just using a relay. I think that a solid state solution would be a better one though than a relay.

If you figure out a way of doing it, I would love to hear about it.

iamtawon

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
    • Sunsynchronous
Re: Sun Tracking / Heliostat Program Update
« Reply #13 on: April 27, 2012, 02:02:09 AM »
I just fiddling with the code and I found this movement problem

when it is start to move and near the end of the movement it appear to be very slow, this might be because of deceleration/acceleration? and if it move in small angle, like when move after reset 4 degree, it slow all the way.

how can I turn it off? since my heliostat is very small

I think you mention you end up didn't use it, is it possible that you forgot to comment it out somewhere? ( I couldn't find it)


found it! it's in moveToPosition function, I just comment out

if (limitSearch==1){...}else{...} section and it work fine for me
« Last Edit: April 27, 2012, 03:39:19 AM by iamtawon »
May the sun be with you

iamtawon

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
    • Sunsynchronous
Re: Sun Tracking / Heliostat Program Update
« Reply #14 on: April 27, 2012, 04:09:14 AM »
I have test manual control mode for multiple machine, it's work!  ;D thumbs up for you
May the sun be with you