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

Bernard

  • New Member
  • *
  • Posts: 24
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #15 on: May 03, 2012, 12:48:46 PM »
Hello Gabriel,

I transformed my code for the actuators to your latest V097 version and compiled it.
I had one error: in Functions: MachineOn and MachineOff asked for the EnablePin variable which I thougt I did not needed. I noticed that you changed both functions completly and now use this EnablePin. But you declared this EnablePin in "//TWO WIRE STEP/DIR DRIVER BOARD CODE " which I dont need( I think)
I use pin 6 for the AZ enablepin.

So what is the purpose of this variable and why didnt you used it in earlier versions?

Bernard


Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 648
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #16 on: May 05, 2012, 06:30:10 AM »
Hey Bernard,

In previous versions, I was using the MachineOn and MachineOff functions to turn the shift registers on and off. I ended up removing it though since the shift register code would have broken the manual control code. Also, since I hope to move this code over to 32-bit microcontrollers which have a lot more pins available, shift registers probably wouldn't be needed in most cases.
Right now, the code is only set up to control one machine, but it would be easy to make it control more by changing the MachineOn and MachineOff functions to turn pins on and off which, in turn, would turn different machines on and off.

In my set up, the enablepin toggles the power on and off to the stepper motors. The driver boards I'm using have this feature built in to them, which is nice because it helps save electricity.
It wouldn't hurt anything to comment out the all of the enablepin code, so go ahead and remove it if you don't need it. There are only four lines in the whole program that refer to it.


Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 648
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #17 on: May 16, 2012, 05:49:52 PM »
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 the first post and the old one deleted.

billduck

  • New Member
  • *
  • Posts: 8
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #18 on: May 30, 2012, 07:10:21 PM »
I was looking at the code, and I want to ask, what does the array called Hour Angle / Flash array represent?

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 648
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #19 on: May 31, 2012, 03:09:35 PM »
Hi billduck,

I have an explanation for how the sun calculations work on this page, but it is of an earlier version of the program.
http://www.cerebralmeltdown.com/projects/arduino-sun-position-program/

A more up to date version is on the pdf at this link.
http://www.cerebralmeltdown.com/wp-content/uploads//2012/05/OpenSourceSunTrackingHeliostat3.pdf

The links should explain everything, let me know if you have any questions.


iamtawon

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
    • Sunsynchronous
Re: Sun Tracking / Heliostat Program Update
« Reply #20 on: June 02, 2012, 12:46:27 AM »
yeahhh, you have my heliostat on the poster  ;D
such a honor  :D :D
May the sun be with you

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 648
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #21 on: June 02, 2012, 04:45:19 AM »
 :)

Brendan

  • New Member
  • *
  • Posts: 30
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #22 on: June 03, 2012, 05:59:46 PM »
You got the A right?

 :)
Brendan

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 648
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #23 on: June 04, 2012, 05:46:26 PM »
Ha ha, I actually didn't do the poster for a grade. It was just for fun. Everybody at the symposium liked it though. I got asked a ton of questions about the project.

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 648
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #24 on: June 26, 2012, 07:15:00 PM »
Update: 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: This should be fixed in V0.9.7.b
« Last Edit: July 03, 2012, 04:29:56 PM by Gabriel »

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 648
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #25 on: July 03, 2012, 04:31:10 PM »
The program has now been updated to Version 0.9.7.b
You can download it from the first post on this thread.

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.

iamtawon

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
    • Sunsynchronous
Re: Sun Tracking / Heliostat Program Update
« Reply #26 on: July 03, 2012, 10:35:59 PM »
is this version using those double precision calculation you mention before?

now it's monsoon season here but I will give it a test when I could
May the sun be with you

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 648
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #27 on: July 04, 2012, 06:05:32 AM »
Hi iamtawon,

No this version doesn't use the double precision calculations. I have managed to get more accurate sun calculations to work on the Arduino Mega by using the Big Number library, but there isn't enough space on a typical Arduino for them.
I hope to upload the Arduino Mega code sometime today once I get it updated to the newest version.

Thanks for helping me test it!

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 648
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #28 on: July 04, 2012, 10:15:56 AM »
1. I just re-uploaded V097_b with a quick bug fix regarding the display of GMT. I must of accidentally did a ctrl+z in there somewhere because a negative sign somehow got switched to a positive.
Anyway, if you downloaded V097_b on or before 7/04/2012,  go ahead and delete that one and re-download the fixed version attached to this post.

2. I have also uploaded a version of this program that uses more accurate sun position calculations. These calculations along with the rest of the sun tracking / heliostat program take up far too much space for a normal Arduino, 53770 bytes!
They will however fit on an Arduino Mega with lots of room to spare.

The new calculations make use of the BigNumber library, which you will have to download and place in your Arduino IDE's library folder before you can upload it to the Mega.
Here is the link http://arduino.cc/forum/index.php/topic,85692.0.html

Please note that I still need to do some testing to confirm the accuracy of these calculations, so you may want to hold off on buying one until I do that.

Also note that the Arduino Mega's SDA and SCL pins are the same as other versions of the Arduino, so you may have to rewire the RTC.


3. On one last note, I noticed another "bug" in the V09.7.b which is caused by the new EEPROM code I just added.
Basically, it seems that if you have never written to the EEPROM before, the Arduino will not be able to correctly read the alt/az values for the targets from it.
When I had this problem, I would see
Target's Altitude: 0
Targets's Azimuth: 0
Heliostat's Altitude: 0
Heliostat's Azimuth: 0
"Input exceeds machine bounds, move aborted" displayed even though the move was within machine bounds and the heliostat's altitude and azimuth shouldn't have been 0.
I'm not sure if this is a problem for all the Arduino boards or just the Mega, but either way the fix is easy if you encounter it.

To fix the problem, just download the EEPROM_FLOAT_FORMAT Arduino program that is attached to the first page of this thread and upload it to the Arduino.
When you open up the Serial Monitor, you should see "Writing to EPPROM" displayed.
After this has been done, you can upload the Sun Tracking / Heliostat program to the Arduino and it should work as normal.
Note that you will only have to upload the EEPROM_FLOAT_FORMAT program one time.

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 648
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #29 on: July 20, 2012, 08:17:09 AM »
Sun Tracking / Heliostat Electronics and Program Update


This is a "quick" video of some of the updates to the electronics and Arduino program for the Sun Tracking / Heliostat Project. There's not much to say here that I haven't already said in the video, so um, I guess that's all for now.

Note: I have attached the program I used in the video to this post. I'm still smoothing out the rough edges in some places, but you can take a look at it if you want.

Attachment has been removed since it is now obsolete.
« Last Edit: August 22, 2012, 12:06:39 PM by Gabriel »