Author Topic: Anyone having target problems?  (Read 9429 times)

Paul L

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
Anyone having target problems?
« on: December 09, 2011, 10:16:16 AM »
Hi,

   I just tired my first target out today and I seem to be having difficulties.  I had planned for a tree to the right of the heliostat and about 3/4 or the way up since it would be easy to see from my livingroom window to monitor tracking.   Anyways, I went out this morn to make sure everything went smoothly and caught the heliostat before it destroyed itself.  The target I imputed was   MachineTargetAlt[0] =30;  MachineTargetAz[0]  =37;.  I think the az was positioned properly, but the altitude was going to the negative direction.  I double checked the numbers, the tried other numbers and found the same thing happening.  The az might have been working screwy too, but I'm not sure.  Anyways, I have it set to Alt=0 and Az=10 right now and it seems like it is in the right place (I don't get sun until around 9:30) but I'll keep my eye on it.  Anyone else encounter similar problems?  Thanks

Paul


Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Anyone having target problems?
« Reply #1 on: December 09, 2011, 02:35:38 PM »
Hi Paul,

I haven't had anything go wrong on my end. See if it is able to track all day with Alt=0 and Az=10 like you said. If it does, then it narrows things down quite a bit.

Also, make sure you are using the latest version of the Sun Tracking / Heliostat Program, V095.

If it keeps acting up, let me know.


Paul L

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
Re: Anyone having target problems?
« Reply #2 on: December 09, 2011, 07:26:31 PM »
Hey Gabriel,

So the heliostat did track all day, so I'm not quite sure what that means.  I'm 90% sure that I have the V095 - it does say v 0.9.4 in the program itself, but I think you probably just forgot to update it when you uploaded it.  I'll change the target again tonight and try the same coordinates as before and see if it magically fixed itself.  Guess I won't be sleeping in tomorrow morning!  :-\

Paul L

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
Re: Anyone having target problems?
« Reply #3 on: December 10, 2011, 10:01:11 AM »
Bright eyed and bushy tailed
 
The same thing happened this morning, with the alt going the wrong direction.  There seems to be no rhyme or reason either.  I tried different target coordinates with different results - alt:-30 and az:-37 seemed to be working properly, alt:5 and az:20 did too.  but input alt:0 and az:37 and the az heads in the wrong direction.  The heliostat also doesn't like to be reset later in the day either, but I thought that that problem was taken care of in V095, so maybe somehow I'm using the wrong version.  I'll download the newest one again and try again.     

Paul L

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
Re: Anyone having target problems?
« Reply #4 on: December 10, 2011, 10:45:15 AM »
So I downloaded V095, and am still having the same resuts

Alt       Az

30        30   = <-
30        20   = ->, down
5          20   = <-
0          20   = <-
0           0    = working


help!! :)


Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Anyone having target problems?
« Reply #5 on: December 10, 2011, 05:25:11 PM »
You have the right version, and you're right about the typo in the code stating the wrong version number. I just double checked what I uploaded, and everything looks as it should. If it is at least working with alt and az = 0, then you have likely found an entirely different bug.

I'm starting to wonder if there may be a bug in the code that calculates the altitude and azimuth of the heliostat. I found the math/algorithm for doing so online, and I'm starting to wonder if it might only work for a certain range of alt and az depending on your location. I may have to rewrite it from scratch at some point.

You might try experimenting with the Range of Movement simulator at the below link and see if your heliostat seems like it is at least following the path the program should be telling it to.
http://www.cerebralmeltdown.com/heliostatprojects/Range%20of%20Heliostat%20for%20Target/index.html


Next week is finals week, so I'm not going to have time to work on this until after Thursday probably, but after that I should have lots of time. :)

How is the tracking at (0,0)? Does the reflection wander around much, or is it pretty much spot on.

Paul L

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
Re: Anyone having target problems?
« Reply #6 on: December 10, 2011, 07:26:31 PM »
Hey Gabriel,

     I figured you'd be neck deep in exams right about now - my fiance (and vicariously, me) is dealing with the same situation.  Three cheers for stress!!  Good luck on your finals. 
   When you do get some time though, I'd really appreciate your help with this - it's driving me absolutely crazy!  The tracking at 0,0 is pretty good I think.  I only get about 15 minutes of sun in the morn and then about two hours in the afternoon from 1:30-3:30, but from what I can see, it's tracking really well.  It's not the best place for a heliostat, I know,  but it's the best I've got for now...
    I'm wondering if maybe you should input my lat. and long. (48.464 , -123.344389, time zone -8) with your setup just to make sure you get the same results that I got.  I'd hate for you go over the code just because my cat walked over my keyboard and erased something important (really I just want conformation that I'm not insane).  Thanks Gabriel, and again, good luck with the exams!

Paul 
     

iamtawon

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
    • Sunsynchronous
Re: Anyone having target problems?
« Reply #7 on: December 12, 2011, 06:55:04 AM »
Hi Paul

I'm just curios, what happen when you reset your heliostat after you get the error have you try that?

if you just finish yours, may be you could try make it to track the sun first and see how things go.
mine didn't go through  :'( it so I haven't the heliostat function

now waiting for manufacturer quoting for my heliostat part, hope they want to do it.

All the best for the exam ;)
May the sun be with you

Paul L

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
Re: Anyone having target problems?
« Reply #8 on: December 12, 2011, 10:53:38 AM »
Hey Iamtawon,

     Some targets seem to work, while others don't.  I've tried the ones that don't work a few times, just to be sure, with the same results.  It does track the sun at 0,0, however, so things are going good there. 
     There was a two week or so stretch that I couldn't get it to track, even at 0,0.  I double checked all the measurements, then triple and quadruple checked the measurements, moved some things around, but nothing seemed to fix the considerable drift.  Eventually I realized that I had done something really dumb - the magnetic declination for my area is 17 degrees east, but I was using 17 degrees west, so I was off of true south by 34 degrees.  It would reset to where I "though" south was, but always drifted.  Once that was taken care of, things worked great.  Maybe that's your problem??  Good luck, hopefully you get it up and running soon!
       

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Anyone having target problems?
« Reply #9 on: December 16, 2011, 07:57:13 AM »
I think I've narrowed down the problem. It is the code behind calculating the altitude and azimuth of the heliostat that is at fault. I wrote a simple simulation program that lets me play an animation of a heliostat moving for the entire day in just a few seconds. This is something I really wish I had known how to do when I was writing the program in the first place. Before I had to check the output of the program basically by hand. Now I can run through thousands of possible variable combinations in hardly anytime at all.

Interestingly enough, the algorithm outputs the correct heliostat altitude and azimuth when the sun is higher in the sky, but, when the sun is lower in the sky, say in the winter months or at higher latitudes, it has a greater tendency to act up. This is why you are having a problem with it and I'm not. Although, even I would have had trouble if I had ever experimented with higher target altitudes.

I'll have to rewrite the code for calculating the altitude and azimuth of the heliostat from scratch most likely. I'll let you know when it's done. Hopefully, it shouldn't take too long, but we'll see how complicated it gets.

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Anyone having target problems?
« Reply #10 on: December 19, 2011, 05:49:43 PM »
OK, I think I have it ready to go. Give one of the attached files a try and see how it does. There was definitely a bug in the earlier version regarding the calculations that found the altitude and azimuth of the heliostat. I found them in some obscure pdf on the web, but, unless I missed something, it doesn't look like they quite work in all scenarios. It just goes to show that you shouldn't trust anything you find on the web. ;) Anyway, I managed to completely re-wright the algorithm and test it throughly with computer simulations, so it should be good to go.

Let me know if you have anymore trouble.

Gabriel

Paul L

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
Re: Anyone having target problems?
« Reply #11 on: December 20, 2011, 10:58:13 AM »
Hey Gabriel!

    Hope all went well with exams!  Now you can relax a little and enjoy yourself!  I appreciate you re-writing the code, but I'm having another problem now - I'm using the Stepper.h library stepper motor setup and you are using the two wire step/dir code.  When I comment out the two wire code and uncomment the Stepper.h and verify it, I get lots of bugs.  Which wouldn't be a problem if I knew what I was doing/how to code, but I don't! :)  What I did do though was copy the code from the Functions tab:

//This code calculates the angles for the heliostat (returnaltaz = 1 will return alt, 2 returns az)
float FindHeliostatAngle(float altitude, float azimuth, float targetalt, float targetaz, int returnAltAz){

  float x,y,z,z1,z2,x1,x2,y1,y2,hyp,dist,machinealt,machineaz;
 
  z1 = sin(to_rad(altitude));
  hyp = cos(to_rad(altitude));
  x1 = hyp*cos(to_rad(azimuth));
  y1 = hyp*sin(to_rad(azimuth));

etc, and pasted it into my old file.  The heliostat still didn't work  - 0,0 works as a target, but 37,30 does not.  So I'm wondering if if maybe you could debug the code using the stepper.h library instead or the two wire setup.  Not sure if that is a lot of work or not, but I've already spent about five hours trying to figure the code out, so your help would be gladly welcomed.   Thanks!

Paul

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Anyone having target problems?
« Reply #12 on: December 20, 2011, 12:25:58 PM »
I uploaded both versions to my last post. The Arduino_SunTracker_V096_Simpler_Electronics.zip has the two wire code and the Arduino_SunTracker_V096.zip has the four wire stepper code. The four wire code should be identical to what your old code was except for the heliostat alt and az calculation change, unless of course I missed something. The only things you should have to change are the basic settings like your lat, long, time zone, etc.

If you are still having trouble, I'll have to look through everything from scratch.  :-\

Gabriel

Paul L

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
Re: Anyone having target problems?
« Reply #13 on: December 20, 2011, 02:11:27 PM »
Ahhh, yes, I see now! :)

But the Arduino_SunTracker_V096 is still doesn't want to compile without errors, even if I don't change any of the settings.  Something wrong in the Functions tab....

Paul

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Anyone having target problems?
« Reply #14 on: December 20, 2011, 02:37:19 PM »
Gah, sorry about that. There was a bad copy and paste involved there. I thought I had done a test upload of it too, but I guess not. Try the attached file.