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

Bob101

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #30 on: July 22, 2012, 04:36:59 AM »
Absolutely amazing work Gabriel!

Your machine is really looking pretty advanced, I love the joystick addition. It's not just useful for calibrating... it makes for a much clearer and more entertaining demo.

Thanks for making a video and sharing, it's great to see some real action.


stepper121

  • New Member
  • *
  • Posts: 18
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #31 on: August 19, 2012, 03:54:24 AM »
Hello have been trying to vers 0.97_b of the code operating on arduino uno with no luck the test setup is of a linear machine set up as a suntracker
The problem is it will reset at start up but not move after that have put in manual mode and get the following
Quote


Machine #0
 
Local Time: 20:38:12  8/19/12  Day_of_week:1
GMT:        10:38:12   
Machine's Current Altitude:
4.0000
Machine's Current Azimuth:
55.0000
Input Altitude:
5.0000
Input Azimuth:
55.0000
Begin Move? Yes=1, No=0
1

Machine #0
Input exceeds machine bounds, move aborted
 
Local Time: 20:38:37  8/19/12  Day_of_week:1
GMT:        10:38:37   
Machine's Current Altitude:
4.0000
Machine's Current Azimuth:
55.0000
Input Altitude:
4.0000
Input Azimuth:
55.0000
Begin Move? Yes=1, No=0
1

Machine #0
Input exceeds machine bounds, move aborted
 
Local Time: 20:38:51  8/19/12  Day_of_week:1
GMT:        10:38:51   
Machine's Current Altitude:
4.0000
Machine's Current Azimuth:
55.0000
Input Altitude:
Quote

I have uploaded the eeprom_ float. this has not helped.
any ideas ??
Thank you


Bob101

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #32 on: August 19, 2012, 07:53:11 AM »
I'm sure Gabriel will be able to resolve this. I have not used this code yet but a few things I can think of to check.

The warning "Input exceeds machine bounds, move aborted" is issued iff:
MachinesNewAzimuth < azLimitAngle
or
MachinesNewAltitude < altLimitAngle
or
MachinesNewAzimuth > maxAz
or
MachinesNewAltitude > maxAlt

The floats azLimitAngle,altLimitAngle,maxAz,maxAlt are set by the call to moveMachine which in the main program is given by: pgm_read_float(&MachineSettings[machineNumber][1]) (for Machine #0)

Where MachineSettings are set by the line:
const float MachineSettings[][18] PROGMEM = { ... };

Looking at the defaults for Machine #0
azLimitAngle = -1
altLimitAngle = -110
maxAz = 130
maxAlt = 160

Which should be fine for the moves you've specified.

What settings have you entered for entires 8,15,16,17 of PROGMEM?

Have you tried printing out azLimitAngle,altLimitAngle,maxAz,maxAlt inside "moveMotor" to check it's reading these limits correctly? What did it output?

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 654
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #33 on: August 19, 2012, 08:20:44 AM »
Hi stepper121,

I think Bob has the right idea about the machine trying to move outside of the machine's software limits.

I have attached a newer version of the Sun Tracking / Heliostat program to this post. This one has two new settings that let you specify the minimum azimuth and altitude that your machine is capable of moving to. Before, it automatically got these values from the position of the limit switches, but this causes problems if you ever try to use positive values for the position of the reset limit switches.

I haven't uploaded v097_c officially yet because I'm trying to make some changes that will make it easier for people who are living south of the equator. This seems like a great time to test it since you are in Australia.

The program probably still has a bug or two in it, so if you could copy everything above the text that says "//END OF USER SETTINGS" and send it to me either by posting it here on the forum or through email, I can double check the program's output and make sure that everything is working the way it should.

Also, a brief description of your machine might help too.

Thanks,
Gabriel

Attachment has been removed as it was obsolete.
« Last Edit: August 22, 2012, 12:05:21 PM by Gabriel »

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 654
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #34 on: August 22, 2012, 11:45:36 AM »
Update: (8/22/2012)

I have attached the "official" release of version 0.9.7.c of the Arduino Sun Tracking / Heliostat Program to this post.

The changes are as follows:

1. To start, I have cleaned up the code that operates the electronics I showed in the video I posted earlier in this forum thread. The stepper motors run a lot smoother now when using manual control via joystick.

2. There are now two more machine parameters that need to be specified under each machine's settings. You will see them labeled as MinAz and MinAlt. Before, the program automatically set these values based on the locations of the reset limit switches. This would cause problems though if you tried to use positive values for a limit switch's location, so now you can specify them individually.

If your limit switch is located at a negative angle, you should, in the majority of situations, give the "Min" setting the same value as the limit switch location.

If your limit switch is located at a positive angle, you should, in the majority of situations, give the "Max" setting the same value as the limit switch location.


3. Some of the code has been moved into libraries to make it easier to integrate into other programs if need be and to make the code a little cleaner. Make sure you put all of the libraries inside the downloaded "libraries" folder (not the folder itself) into the Arduino IDE's library folder.

4. I have moved the code that sets the time on the RTC to another Arduino sketch. It is inside the zip folder named "Set_RTC_Time.zip". It is set up so that you can now use a push button wired to pin 12 on the Arduino to synchronize the time you have input the instant you press it. This is a lot easier than trying to synchronize the time by figuring out how long it takes the Arduino sketch to upload and then trying to upload it at the precise moment.

If you don't have a push button wired to pin 12 on the Arduino, you can give the "SetTime" variable a value of 1, and it will automatically set the time when you upload the Sketch. As mentioned before though, it can be tricky to do this precisely. Also note that it will also set the time anytime you reset the Arduino, and the Arduino will reset anytime you open the Serial Monitor or upload a Sketch.

5. I have added an option for controlling a single axis sun tracker. This is activated when setting #1 is set to 3. Keep in mind that this feature is untested, and there isn't any documentation on it yet. If anybody wants to help test this feature, let me know.

6. One of the bigger changes in this update is the way the program behaves for people who live in the southern hemisphere. After some thinking, I realized that the program was set up in a way that was unnecessarily confusing, and may not have really even worked quite right anyway.

The two attached images show how the program is now set up. The first one, named NorthernHemisphere.jpg, shows how people in the northern hemisphere view positive and negative azimuths. South is considered the direction that the azimuth equals zero. Negative azimuths point more toward the east, and positive azimuths point more towards the west.

The second image, named SouthernHemisphere.jpg, shows the new way that people living in the southern hemisphere should view positive and negative azimuths. North is considered the direction that the azimuth equals zero. Negative azimuths point more toward the east, and positive azimuths point more towards the west.

Another way of looking at these images is that negative azimuths point more towards where the sun rises, and positive azimuths point more toward where the sun sets.

By having the program set up this way, people in the northern hemisphere can share machine settings with people in the southern hemisphere without having to make any changes (or vice versa). This should make solar machine designs a lot more universal and help minimize mistakes.

Keep in mind that I can't thoroughly test this feature myself (my machine does seem to point in the direction I would expect though when I use it) since I don't live in the southern hemisphere, so if anybody can verify that this works correctly, let me know.


Thanks!
Gabriel

« Last Edit: August 23, 2012, 04:28:38 PM by Gabriel »


Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 654
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #35 on: August 23, 2012, 04:29:26 PM »
BUG FIX (8/23/2012)
The program I first uploaded, V097_c, in the previous post had a mistake in it. I had added some code to take atmospheric refraction into account that had a typo in it. I have commented it out for the time being until I have the chance to test it.
I uploaded a fixed version, V097_c2, to replace the one with the typo. Don't try to use the old version, it won't work.
Sorry for the inconvenience to anyone who may have accidentally downloaded it.

stepper121

  • New Member
  • *
  • Posts: 18
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #36 on: August 25, 2012, 05:28:34 AM »
Hi Gabriel
I am having  problems with the arduino uno as the sketch size is 30426 bytes it will not upload to my arduino uno this looks to be a problem with my bootloader not taking  sketches over 28k or so
Error I get are:
avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x64
avrdude: stk500_cmd(): programmer is out of sync

From google have found an update bootloader that I will try on a new atmega328p pu chip when I get one.
As not knowing code that well could you point me in a direction to reduce the size of the sketch by commenting out parts not need.
eg joystick, Wind protection
to reduce the size of the skecth.
This is on the latest version 97_c2
Thank you
David

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 654
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #37 on: August 25, 2012, 06:01:46 AM »
Hi David,

I had thought that the Arduino Uno would have a bit more space than that, but I guess maybe it doesn't. I don't actually have one myself. I have been using one of the older Arduino Duemilanove.

Anyway, I have attached a modified version of the program without the joystick code. Not having it brings the size down to 28202 bytes, which will hopefully be enough. If not, let me know.

freespeech

  • New Member
  • *
  • Posts: 5
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #38 on: August 25, 2012, 06:47:04 AM »
Thanks.
I have been looking at using this for my caravan.
I was going to use GPS + compass' but now with the joystick I will just aim and set up so that it tracks all the time….
That will save hours of code and loads of hardware.
I am wondering has anyone got anywhere with linear actuators rather than linear stepper motors ?
I would be so much cheaper.
I have a few in mind am am deciding which ones I should use.
Also where can I get those driver boars you use ?
Thanks.
« Last Edit: August 25, 2012, 07:12:35 AM by freespeech »

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 654
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #39 on: August 25, 2012, 05:12:10 PM »
Hi freespeech,

I know Bob on this forum is working on a similar project as yours. He has started a thread here which I imagine he will add to as he works through his machine build. http://cerebralmeltdown.com/forum/index.php?topic=349.0

"I was going to use GPS + compass' but now with the joystick I will just aim and set up so that it tracks all the time…."
That's not really how the joystick controls are programmed to operate, so I think that you would still need the GPS + compass. It's not something I've really thought about though, so maybe you have an idea that I missed.

"I am wondering has anyone got anywhere with linear actuators rather than linear stepper motors ?"
I'm assuming you mean to ask if someone is working on getting linear actuators with DC motors working. I've heard some people mention on the forum that they are working on this, but I personally am not. For my own heliostat project, I think that stepper motors and DC motors would end up costing about the same, so I'm sticking with stepper motors since they can be controlled more precisely.

Bob101

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #40 on: August 27, 2012, 07:22:09 AM »
Hi freespeech,

Gabriel is right. I am working on a solar tracker for motorhomes.

My design will use a GPS and compass. Remember, you can't just point the panel at the sun with a joystick then expect it to track... which way the sun will move depends on where you are on earth and the time. Maybe you have some other way to deal with this?

I hope to post more details/code and hopefully pictures and video on this forum when the project nears completion. Already it is in a good shape and partially assembled but some design issues (placement of limit switches) and a busy schedule have delayed progress.

For now I have posted quite a lot of information along with a very, very long discussion of the difficulties faced when mounting a solar tracker on a vehicle over at MotorHomeFun. I post (along with an older friend) under the name of "Snowbird". Pictures and details of our design are given on page 7 onwards: http://www.motorhomefun.co.uk/solar-power/40301-homebrew-solar-tracker.html

Feel free to comment!  :D


Bob101

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #41 on: August 29, 2012, 02:39:48 AM »
Hey Gabriel,

Thought I'd mention that I own both an Arduino Uno and an Arduino Mega now. To confirm, the arbitrary precision code will not fit on the Uno even if I remove the calls to the native trig functions and all optional extras (joystick control etc...). The code has to run in native accuracy on the Uno.

In another thread we spoke about Meeus' algorithm which is implemented in your tracking program and I wondered if you would convert the code to work entirely in radians saving some messing around with converting degrees to radians and vice versa. You said that this looks like a reasonable suggestion. I also produced the arbitrary precision library which implemented the ArcTan and ArcSin functions that were previously lacking.

Do you plan to utilise the library and make the change to radians? I am especially interested in the Mega tracking program as this is what I will be using for my solar tracker. If so, would you like any help in the conversion?

Just to let you know my plan... with your permission I intend to use the sun position algorithm implemented in your code along with the arbitrary precision library. I expect I will write most of the rest of my code myself utilising other libraries. For example, I intend to use the TinyGPS library to neatly read out my GPS position and UTC time. I will use the pololu library for my tilt compensated compass and will certainly use the pololu library for the motor driver (with modifications to make the pwm ultrasonic on the Mega... in discussions with them about this currently on the pololu forums).

I have already written test programs for all of this along with recalibration and motor speed ramping code for setting the machine up and moving it smoothly. It is working well with this code. I will write code for enforcing physical limits myself I expect but it could be inspired from your code.

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 654
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #42 on: August 29, 2012, 07:35:52 AM »
Hi Bob,

If you want to update the arbitrary precision library based code, that would be great. I have a lot of other things I'm trying to get finished (electronics, heliostat design, documentation, etc), so I probably won't get around to updating it myself for quite a while. I can at least double check the output of your code though using a MatLab script I wrote.

I wanted to include the Mega code in this last Sun Tracking / Heliostat code update, but I just haven't had the time for it yet.

Thanks,
Gabriel
P.S. If you want to use my code for anything, please feel free to do so.

Bob101

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #43 on: August 29, 2012, 02:19:20 PM »
Hey Gabriel,

I decided not to convert the program to radians. The issue is that BigNumbers are not floating point and so very small angles like 0.00000048 degrees when expressed in radians require larger strings, more memory and a larger calculationScale to maintain accuracy. This doesn't seem worth the time and effort. What do you think?

I have altered the code to utilise the BigNumberMath library including arctan2 and arcsine. I also increased calculationScale to 30 and reduced arcSinePrec to 10. This now compiles but since my Mega is currently in my solar tracker far from my computer I have not been able to test it at all. I expect the Mega might crash with such a large calculationScale given all of the other variables in memory but this needs testing. If so, reducing calculationScale to 25 should retain most of the accuracy (hopefully) and stop the crashing (hopefully).

Sorry to upload such untested code but if you have a Mega handy and a test routine already written I would like to know if this works at all.
EDIT: I will test this when I get a chance. First I will need to unplug my Mega from my solar tracker.

== Changes ==

In Mega_SunTracker_Heliostat_Program_V097_b.ino
- Renamed to Mega_SunTracker_Heliostat_Program_V097_b_BigNumberMath.ino

- Removed
Code: [Select]
#include "BigNumber.h"
Inserted at top
Code: [Select]
#include <BigNumber.h>
#include <BigNumberMath.h>

- Changed
Code: [Select]
int calculationScale=30;
- Changed
Code: [Select]
int arcSinePrec=10;

- Commented out "HOUR ANGLE TABLE". Should this even be here? It causes the program to fail to compile and does not seem to be called.

Removed BigNumberMathFunctions.ino

In SunCalculations.ino
- Changed all references to sine, cosine, arctan2, arcsin, to_BigRad, to_BigDeg to reference the static library eg... BigNumberMath::sine
- Utilised arbitrary precision arctan2 and arcsin rather than native functions if calculationSpeed==0

Updated code attached. All changes are tagged with // sj so you can track what I have done.

« Last Edit: August 29, 2012, 02:21:46 PM by Bob101 »

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 654
    • View Profile
Re: Sun Tracking / Heliostat Program Update
« Reply #44 on: September 01, 2012, 05:59:54 PM »
Hi Bob,

It's been a busy week, so I haven't had the chance to look at the changes yet.

Leaving it in degrees is fine. Whatever you think is best works for me.

The hour angle table doesn't have to be there. I had considered using both sets of calculations in case some situations required faster calculation speed (i.e. when using manual control) but I decided that it wasn't really necessary after experimenting with it.
I'm assuming that the reason it didn't compile for you was because you didn't have the Flash.h library installed?

Hopefully I'll have a chance to go over the in a couple of days.

Thanks!
Gabriel