Author Topic: calculating heliostat mirror position  (Read 6122 times)

tomnagel

  • New Member
  • *
  • Posts: 2
    • View Profile
calculating heliostat mirror position
« on: April 26, 2012, 11:45:06 PM »
I am studying the control software for Arduino that Gabriel posted on this website for my Heliostat.
I do not understand the piece where the Heliostat position is calculated. It uses more or less complex formulas, while I would think it could be very simple. My reasoning is: the angle of the mirror should be halfway between the sun and the target, for both Azimuth and Altitude. Also I would think Azimuth and Altitude do not influence each other. In the formulas, they do!
Example:
suppose my target is at Alt, Az=0;0 and the sun is at 45;45. According to the Heliostat software, the mirror must be at 18;24.
I would think the mirror should be at 22.5;22,5 (halfway)

Can someone explain the calculation in the software to me (the reasoning)?
« Last Edit: April 27, 2012, 05:36:07 AM by tomnagel »


Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 648
    • View Profile
Re: calculating heliostat mirror position
« Reply #1 on: April 27, 2012, 08:04:28 PM »
Hi tomnagel, and welcome to the forum!

During some of my earliest attempts at getting a heliostat to work, I thought that calculating the heliostat's position could be done the way you described. After some experimenting with some CAD drawings in Sketchup though, I realized that it doesn't work. The calculated angle is sort of in the ballpark, but can still be several degrees off from where it should be. The method is perfectly sound in 2D, but once you move to 3D it gets a fair bit more complicated.

I have pasted most of the "FindHeliostatAngle" function below. I just realized that I never got around to writing comments to explain what everything does. I would need a good picture to explain it in depth, but if you know your trig and a little bit of vector math, you should still be able to get the gist of it.


First, the code takes the altitude and azimuth of the sun and turns it into a vector, v1=<x1,y1,z1>.
  z1 = sin(to_rad(altitude));
  hyp = cos(to_rad(altitude));
  x1 = hyp*cos(to_rad(azimuth));
  y1 = hyp*sin(to_rad(azimuth));


It also turns the target altitude and azimuth into a vector, v2=<x2,y2,z2>.
  z2 = sin(to_rad(targetalt));
  hyp = cos(to_rad(targetalt));
  x2 = hyp*cos(to_rad(targetaz));
  y2 = hyp*sin(to_rad(targetaz)); 
 

The "half way vector" is then calculated with the below code. This represents the direction that the normal vector of the mirror's surface needs to point.
Note: The below code can be written more succinctly in vector notation as v3=(v1-v2)/2+v2 where v3=<x,y,z>
  x=(x1-x2)/2+x2;
  y=(y1-y2)/2+y2;
  z=(z1-z2)/2+z2;
 

The below code has a very low likelihood of ever running, but is present to avoid getting z/0 (which is undefined) if the variable "dist" turns out to be 0. This would only happen if the target vector v2 is pointing in the exact opposite direction as v1, so essentially if the target is exactly 180 degrees from the sun in relation to the heliostat.
  dist=sqrt(x*x+y*y+z*z);
  if ((dist>-0.000001) && (dist <0.000001)){
  dist=0.000001;
  }

Finally, the vector v3  is turned into an angle measurement which gives the altitude and azimuth of the mirror's normal vector of the heliostat.
  machinealt=to_deg(asin(z/dist));
  if (x==0){x=0.000001;}   (looking at this line of code again, I'm doubtful that it is needed)
  machineaz=to_deg(atan2(y,x));


I'm sure there are other ways of doing these calculations, but this is what I came up with. I've done a lot of testing with some simulations I wrote in Matlab, and the code worked perfect in them, so I'm pretty happy with it.

An earlier version of this program used the calculations on this pdf. http://www.tapthesun.com/PDF/PSTC%20-%20Heliostat%20Reflection%20Equations.pdf
I eventually realized that they would break when certain inputs were used, so I had to upgrade to the current calculations. It could be that I over looked something on the pdf, but I figured that it would be easier to just come up with something from scratch instead of trying to figure out what was wrong.

Hope that helps,
Gabriel




tomnagel

  • New Member
  • *
  • Posts: 2
    • View Profile
Re: calculating heliostat mirror position
« Reply #2 on: May 03, 2012, 01:25:06 PM »
Thank you Gabriel, for your explanation. While I believe your code is right, I still cannot imagine why the heliostat position must be calculated like this, and why the situation is different in 3D than it is in 2D.
Anyway, I have my heliostat (dry) running in my living room since a few days, and I am waiting for some sunny days in the Netherlands to test it  outside. Unfortunately, lots of rain is predicted in the weekend...

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 648
    • View Profile
Re: calculating heliostat mirror position
« Reply #3 on: May 05, 2012, 05:57:23 AM »
"Unfortunately, lots of rain is predicted in the weekend.."
Ha ha, yeah that always seems to be the case when testing these things.
Good luck!

metalbag

  • New Member
  • *
  • Posts: 2
    • View Profile
Re: calculating heliostat mirror position
« Reply #4 on: February 27, 2014, 07:52:33 AM »
Hi Gabriel,

I'm trying to understand how to possition one heliostat.
 
Your algorithm ir really good, and helps me a lot, but i'm not able to solve the "inverse problem".

With his algorithm if you have Alitude and Azimuth for the Sun, and Alitude and Azimuth for the target, you can get Altitude and Azimuth for the Heliostat,

Now, I want to calculate the Target Alt and Az, knowing the sun and the heliostat Alt and AZ. And I'm not getting good results.

Using your CODE

First, the code takes the altitude and azimuth of the sun and turns it into a vector, v1=<x1,y1,z1>.
  z1 = sin(to_rad(altitude));
  hyp = cos(to_rad(altitude));
  x1 = hyp*cos(to_rad(azimuth));
  y1 = hyp*sin(to_rad(azimuth));


It also turns the target altitude and azimuth into a vector, v2=<x2,y2,z2>.
  z2 = sin(to_rad(targetalt));
  hyp = cos(to_rad(targetalt));
  x2 = hyp*cos(to_rad(targetaz));
  y2 = hyp*sin(to_rad(targetaz)); 
 

The "half way vector" is then calculated with the below code. This represents the direction that the normal vector of the mirror's surface needs to point.
Note: The below code can be written more succinctly in vector notation as v3=(v1-v2)/2+v2 where v3=<x,y,z>
  x=(x1-x2)/2+x2;
  y=(y1-y2)/2+y2;
  z=(z1-z2)/2+z2;

 dist=sqrt(x*x+y*y+z*z); (* Asuming than never is 0, to simplify *)
  machinealt=to_deg(asin(z/dist));
  machineaz=to_deg(atan2(y,x));    (* For me, in excel, atan2 must be atan2(x,y) *)

So, now I have Helistat Alt and Az
So, using these Helistat Alt and Az and the original Sun Alt and Az, I want to "recover" Target Alt and Az.


I turn the Helistat altitude and azimuth into a vector, v3=<x3,y3,z3>.
  z3 = sin(to_rad(machinealt));
  hyp = cos(to_rad(machinealt));
  x3 = hyp*cos(to_rad(machineaz));
  y3 = hyp*sin(to_rad(machineaz)); 

   (* If you ckeck you can see that this point mantains proportions x/x3 == y/y3 == z/z3, but   x!=x3 and  y!=y3 and z!=z3 *)

I try to calculate the "double way vector" with the below code. I'm pretty sure that is here where I have the problem.

  x4=x1-((x1-x3)*2);
  y4=x1-((y1-y3)*2);
  z4=z1-((z1-z3)*2);

This should be the coordinates of the target vector, but it not mantains the same proportions that original target vector (x2), so... x2/x4 != y2/y4 != z2/z4

 distT=sqrt(x4*x4+y4*y4+z4*z4); (* Asuming than never is 0, to simplify *)
  newtargetalt=to_deg(asin(z4/distT));
  newtargetaz=to_deg(atan2(y4,x4));    (* For me, in excel, atan2 must be atan2(x4,y4) *)

But, it is not really close to be the same as the original target angles.

Lots of thanks in advance


Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 648
    • View Profile
Re: calculating heliostat mirror position
« Reply #5 on: March 01, 2014, 05:37:16 AM »
There might be an easier way, but here is what I'm trying to do to solve this.

Basically, I thought that if I rotated the sun's vector 180 degrees around the heliostat's target, then that should give me the target vector.

I found the matrix for this on wikipedia. http://en.wikipedia.org/wiki/Rotation_matrix (Scroll down to where it says "Rotation matrix from axis and angle")
Since theta is 180, the trig functions simplify to 0 for sin and -1 for cos.
Out axis is the heliostat's vector, so I also substituted that it. The vector is named u in this case.

Then I just multiplied matrix R by the sun's vector (v) to get the rotated vector, which is the target vector.

I only did one simple test case to double check. It gave me the right answer, but go ahead and test it out for yourself just to be sure it works for everything.

I scanned the work and attached it to this post. I don't have the time just now to type it into code, but I figure you can do that for me. :)

I tried writing the vector clearly at the bottom, but let me know if you have trouble reading my handwriting.

What is this for by the way?

Hope that helps,
Gabriel

metalbag

  • New Member
  • *
  • Posts: 2
    • View Profile
Re: calculating heliostat mirror position
« Reply #6 on: March 04, 2014, 09:32:55 AM »
Thanks a lot!

It has been really useful.



marcusbehrens

  • New Member
  • *
  • Posts: 6
    • View Profile
Re: calculating heliostat mirror position
« Reply #7 on: March 17, 2014, 02:05:41 PM »
Do I really need to know where the target is? Can't I simply turn the heliostat with half the speed at which the azimuth and the elevation of the sun are changing and it will automatically continue to hit the same target?

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 648
    • View Profile
Re: calculating heliostat mirror position
« Reply #8 on: March 18, 2014, 07:28:07 AM »
Do I really need to know where the target is? Can't I simply turn the heliostat with half the speed at which the azimuth and the elevation of the sun are changing and it will automatically continue to hit the same target?


There is a device called a coelostat that works a bit like what you mentioned. The downside of it though is that it will only work with targets located on the north / south line. Also, the mirror's tilt would have to be adjusted every so often to compensate for the fact that the sun's declination angle changes over the course of the year, which I suppose you may be able to do mechanically.

Also, if you take a look at this picture at the analemma, you'll see that the sun doesn't end up at the same spot at the same time everyday. http://www.perseus.gr/Astro-Solar-Analemma-130000.htm So if you were to just set the mirror to rotate at half the "speed" of the sun, the reflection would drift over the course of the year. I've never experimented to see by how much, so depending on what kind of accuracy you need, it might be good enough.

It's really hard to explain without drawing a lot of pictures (or even some sort of animation), but there are just so many subtle, complicated changes in the sun's path over the course of the year (or even over many years) that it is in my opinion a lot easier to just use the calculations, which do require you to know the angles of the target.

marcusbehrens

  • New Member
  • *
  • Posts: 6
    • View Profile
Re: calculating heliostat mirror position
« Reply #9 on: March 20, 2014, 02:23:01 PM »
I created a sketchup like Gabriel did to find out that the "half of suns angle changes" way of calculating the change of azimuth and elevation is not correct and yes - I came to the same conclusion as Gabriel.

But still even in this sketchup it becomes clear that there is one vector of movement that the mirror needs to move that is half the length of the suns vector and has the same direction.

The delta comes from the fact, that  the mirror change vector is starting at a different angle then the sun change vector - hence the azimuth change is less in the case shown in the sketch.

I attached the sketchup for your reference. Here is how to read it.

The sun enters an imaginary globe at "sun position 1". It is reflected in the center of the globe by a mirror that is point towards "heliostat position 1". It leaves the globe again at "target". the distance between "Target" and "Heliostat position 1" is the same as the distance between "heliostat position 1" and "sun position 1". Then some time passes and now let's assume the sun enters the globe at sun position 2. Now again the "heliostat position 2" can be found in the middle of a line from "target" to "sun position 2". The triangle formed by "Sun position 1 and 2" and "target" is cut in half by the line between "heliostat position 1 and 2" - hence the length between those last 2 points is half the length of the line between the sun positions.

Now check out the azimuth angles projected on the floor down from the heliostat and the sun positions. The azimuth delta divided by 2 between the 2 sun positions is 7,5. The azimuth delta between the heliostat positions is only 6.3 - this is proof that Gabriel is right and taking half of the changed angles is not correct.

Diarmaede

  • New Member
  • *
  • Posts: 3
    • View Profile
Re: calculating heliostat mirror position
« Reply #10 on: July 22, 2014, 04:05:25 PM »
  dist=sqrt(x*x+y*y+z*z);
  if ((dist>-0.000001) && (dist <0.000001)){
  dist=0.000001;

Thanks so much for your post, Gabriel.  It is immensely helpful.

Quick question about the code quoted above.  If dist is the square root of three squared numbers, won't it always be positive?  If so can we eliminate the "dist>-0.000001" term?  I know this is a small point, but I wanted to check my understanding.

Also, what does "dist" stand for?  This is not a distance measurement, is it?  If so, I REALLY need to keep studying what you've written until I understand it better.

Thanks again!

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 648
    • View Profile
Re: calculating heliostat mirror position
« Reply #11 on: July 22, 2014, 05:04:10 PM »
Hi Diarmaede,

Yeah that does make sense. The dist > -0.000001 isn't necessary is it. Nice catch!

"dist" is just an arbitrary variable name that was probably copied from a piece of scratch paper I used when trying to figure out the math for this. Magnitude would be a better term now that I think of it since we are doing vector math here.
I actually figured this out before taking very many math courses, and probably before I had any classes that used vectors, so I didn't know what the proper terminology was I guess.







Diarmaede

  • New Member
  • *
  • Posts: 3
    • View Profile
Re: calculating heliostat mirror position
« Reply #12 on: July 23, 2014, 09:18:27 AM »
Thanks, Gabriel.  It's been decades since I've done vector math, so I want to make sure I am doing it right.

I am taking your equations and writing code with them.  The following inputs:

Target Alt = 15.84 deg
Target Az = 0 deg
Sun Alt = 34.83 deg
Sun Az = 88.27 deg

yield the following outputs:

machinealt = 50.18 deg
machineaz = 47.64 deg

Do you have a quick program that can check my results against known good results?  If so, a quick math check would be much appreciated.  In the meantime, I will check with a laser and see if I can get my brain fully around the math.

Thanks again!

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 648
    • View Profile
Re: calculating heliostat mirror position
« Reply #13 on: July 23, 2014, 11:10:24 AM »
I probably have a program around somewhere, but I think it's in the MatLab programming language. Unless you have experience with it, it might be easier to just do what I did and draw the angles in Sketchup and measure them.

My result for these values was...
machinealt = 33.334
machineaz = 39.724

It looks like your numbers are off. In general, I would expect the machinealt to be roughly halfway between the target and sun's alt. Same is true for the az. There are cases where this isn't so true, but for the values you have chosen here it would be.

Hope that helps!
Gabriel

Diarmaede

  • New Member
  • *
  • Posts: 3
    • View Profile
Re: calculating heliostat mirror position
« Reply #14 on: July 23, 2014, 11:34:43 AM »
Thanks.  My numbers looked off to me, but I wanted to make sure.  Now that I have the answers, I should be able to figure out how to get to them.  You are a life saver!