Author Topic: Arduino Sun Harvester Program: Next Generation Update and Ideas  (Read 4600 times)

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 648
    • View Profile
Arduino Sun Harvester Program: Next Generation Update and Ideas
« on: September 02, 2015, 09:07:23 AM »
Hi all,

I have attached some updated versions of the Arduino Sun Harvester Program. There aren't any "exciting" changes in this particular version aside from a few bug fixes, but I have a lot of ideas for things that I hope to add.

Since there is probably going to be a lot posted under this topic, I went ahead and started this new thread to replace the old one here. http://cerebralmeltdown.com/forum/index.php?topic=325.0

This program (as always) is released under the [url = http://creativecommons.org/licenses/by-nc-sa/3.0/us/]Creative Commons Attribution-NonCommercial-ShareAlike 3.0 license[/url].

Note that I haven't tested these programs much yet, but figured I would go ahead and post them to hurry up and get the ball rolling. This version only fixes a few bugs...

1. The program should now work with the latest version of the Arduino Software.
2. Fixed a bug which would cause the program to sometimes not go into wind protection mode.
3. Added a no potentiometer option which allows you to leave out the potentiometer when using a heliostat.

Like I said, I haven't tested this much yet, so keep an eye out for odd behavior. I haven't changed anything major though, so basic functions should still be fine.

Future Update Ideas!

Now that that's out of the way, it's time to think about what to add. Here are some ideas that I have heard or come up with since the last major update. Note that these are just ideas, so I'm not going to hold back. When it actually comes time to implement them, we will see what is actually doable. :)

In no particular order...

Find ways of simplifying the program so that it isn't so much of a pain to input custom settings.

Add simultaneous movement to the stepper motors instead of having them take turns.

Add calculations for heliostat designs with the mirror mounted away from the axes or rotation to make them more accurate.

Add options for trackers besides just the altitude and azimuth type machines currently supported.

Add better support for machines close to the equator. (Altitude angles greater than 90 degrees perhaps?).

Add code for GPS support.

Add code for Compass support.

Write Android app that sends lat, long, and time to Sun Harvester program using phone's GPS and time. (maybe)

Add standard settings for a heliostat / sun tracking machine so user doesn't have to input their own. (Will require a couple of good machine designs.

Try and get the program to play well with 32-bit Arduinos.

Try and get rid of libraries wherever possible so that newbies don't have to worry about installing them. (This was already mostly taken care of in the last update).

Maybe add a way to do data logging into the program.

Add the option to change settings through the Serial Monitor, or perhaps separate PC based program.

Write separate PC based program to interface with Arduino program. This has already been started to a degree. You can check out the attached Processing program if you wish. It is no where near finished, but you can still see where it's headed. I had already started the program under Visual C#, but have started porting over to Processing because it plays well with multiple platforms.

That's all I can think of at the moment. Although I'm sure there is probably more to add. Please post any ideas for the program that you may have.

Thanks!
Gabriel




solardude

  • New Member
  • *
  • Posts: 8
    • View Profile
Re: Arduino Sun Harvester Program: Next Generation Update and Ideas
« Reply #1 on: September 02, 2015, 02:48:58 PM »
I'm so happy to see you still working on improving the code :D

I'll be digging in really soon and help with testing the latest version of the code.

Looking at your list of possible upgrades I'll list the ones that I think are most important for my goal of creating a really nice portable lightweight solar tracking device that is easy to use and as automatic as possible by the regular every day person.

Here is what I think is most important, with a person comment next to each one:

Add simultaneous movement to the stepper motors instead of having them take turns. - Code not jamming up is of most important, if this feature has the possibility to cause a MicroController to lock up then leave it out. The solar tracker is going to move minimally anyways. I do think the biggest benefit of having both motors move at the same time is that it would look cooler.


Add better support for machines close to the equator. (Altitude angles greater than 90 degrees perhaps?).  - As somebody who wants to build a low cost easy to use portable tracker I'm very interested in having the code and design work anywhere in the world. Needing altitudes greater than 90 degrees is something I never knew was needed but if it is then I think adding support for this would be beneficial.



Add code for GPS support.  -  Ideally I would like to not use a GPS receiver due to the cost of adding it and the fact that I'm looking to keep the cost to manufactuer as low as possible but I see a real benefit of having a GPS receiver on board to auto populate the GPS position. So maybe only use the GPS location data once it shows you have a 3D location fix. So adding GPS support that can or can not be used would be perfect.



Add code for Compass support.   -      Does the code right now not rely on a digital compass sensor? If not does the solar array have to be aligned manually to noon sun or what?  I have been using a different library with GPS & digital compass for position tracking but I have to admit that the digital compass can be easily thrown off by motor magnets or large metal objects.




Write Android app that sends lat, long, and time to Sun Harvester program using phone's GPS and time. (maybe)    -  I have also thought about this when it comes to making it easier to set the location coordinates. Everybody has a smartphone these days it seems and it would be a easy way to eliminate the need for a on board GPS sensor. My other thought was to just add a LCD screen and a couple cap touch buttons to make entering the GPS coordinates into the tracker. I figured that most people would use their smart phone to look up the coordinates anyways. Have you made a Android app before? I know its getting easier to do these days.


Try and get the program to play well with 32-bit Arduinos.  -   My micro processor of choice right now is the Teensy 3.1 which is a 32 bit ARM https://www.sparkfun.com/products/12646?gclid=CIO6q5mo2ccCFQGUaQodO6IMDw . I'm pretty sure it will run your current Arduino code but if running it at 32 bit is beneficial then I think adding that support would be good. Does 32 bit math allow more accurate tracking?


Just my 2 cents. I know not everybody is using this for solar panels but heliostats which is another great use of solar energy.



ben

  • New Member
  • *
  • Posts: 29
    • View Profile
Re: Arduino Sun Harvester Program: Next Generation Update and Ideas
« Reply #2 on: September 06, 2015, 04:50:18 AM »
Hi All,

I have downloaded the version for the MEGA (Mega_Sun_Harvester_Program_V01.zip) and tried compiling with the Arduino IDE v1.0.6.

No compile errors, seems to download into the MEGA2560 board OK.

Not too sure how to verify if it works because I only have the MEGA board, and no steppers/shields/etc.

But when I start the (Tools -> Serial Monitor) within the IDE and press the reset button on the MEGA, I get the following output in the Serial Monitor window:

Code: [Select]
Time: 45:165:85  165/165/165  Day_of_week:165
Sun's Alt: -53.633
Sun's Az: 164.674
Number of Machines 1
Machine Number 0
Resetting

Maybe printing the version of SW within this output would be useful.

I dont have a Arduino UNO so have not downloaded the cut down version (Sun_Harvester_Program_V01.zip). Can I suggest you prefix this file with UNO or similar so that it is inline with the 'MEGA' prefix?

ben

  • New Member
  • *
  • Posts: 29
    • View Profile
Re: Arduino Sun Harvester Program: Next Generation Update and Ideas
« Reply #3 on: September 06, 2015, 04:51:57 AM »
Two other comments:

The "Sun_Harvester_Shield_Interface4.zip" code looks interesting, but how is this compiled and used?
I have loaded it into the IDEv1.0.6 but get a heap of compile errors, a snippet below:
Code: [Select]
Sun_Harvester_Shield_Interface4:329: error: stray '#' in program
Sun_Harvester_Shield_Interface4:331: error: stray '#' in program
Sun_Harvester_Shield_Interface4.pde:331:11: error: invalid suffix "BB931" on integer constant
Sun_Harvester_Shield_Interface4:333: error: stray '#' in program
Sun_Harvester_Shield_Interface4.pde:333:11: error: invalid suffix "F08FF" on integer constant
Sun_Harvester_Shield_Interface4:349: error: stray '#' in program
Sun_Harvester_Shield_Interface4.pde:349:9: error: invalid suffix "CAF57" on integer constant

And the version numbering of this new release being v01 seems strange coming from v098.

Paul L

  • Jr. Member
  • **
  • Posts: 94
    • View Profile
Re: Arduino Sun Harvester Program: Next Generation Update and Ideas
« Reply #4 on: September 06, 2015, 08:08:02 PM »
Oooo, I love thinking of new ideas/suggestions!!

Here's what I think: a GPS and compass addition would be great - especially for a portable system.  Having a feature where it self levels (or maybe compensates for being off level) for  would also be dreamy, but hard/costly to setup.  As far as GPS modules go, cost really shouldn't be a concern - you can get them on ebay for 11.00, free shipping and they work super.  You could also remove the RTC if you had a GPS, so that would save some costs there.  If there was a set design, preferably with worm gears, the homing microswitch could be removed with the addition of an LDR/LED array.  Just turn the heliostat on, let it get the gps position.  The program will already know the position of the sun depending on the GPS location, so if the steppers are then programmed to move to the brightest location in the sky according to the LDR/LED array and then set that as the position of the sun, that's all it needs to know.  A self setting heliostat; no figuring angles or cardinal directions!  That's be great...
 
Any step that removes human input is a step in the right direction.

I like dual acting steppers - though not super important.  Agree with solardude, it would look cooler.
Not sure what the benefits would be with 32 bit mc's?  More accurate?

I'll think on this for a while and may add more later!

Cheers,

Paul   


Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 648
    • View Profile
Re: Arduino Sun Harvester Program: Next Generation Update and Ideas
« Reply #5 on: September 08, 2015, 06:49:01 PM »
Hi All,

Wow that's a lot of input!

I haven't had a lot of time to work on much over the last few days, but I did experiment with a couple things. First, I played around with an Arduino Due for awhile. I have tried it in the past, and I still can't seem to get the RTC to work right on it. It's probably a code issue, but I also wonder if there might be something wrong with my DUE. I will still have to try a few things I guess. If anybody has a DUE and is able to get an external RTC to work on it let me know.

I also played around a little bit with making an Android app. It seems like it will probably be headache inducing. Not so much for writing an app for my phone, but for writing an app that works on everybody's phone. Things change so often with those things that even a lot of the older tutorials are out of date enough to make reverse engineering apps a pain. I'm just getting started though, so I may be being overly pessimistic.

I will probably miss some things, but here's my attempt at adding to everyone's input in more or less the order it was posted.

@Solar Dude

Add simultaneous movement to the stepper motors instead of having them take turns. -
I think I agree with everyone here in that the main motivation for this is that it would look cooler. It does have the practical application though for reducing the time it takes to move machines into position. This is especially good for large machines that take forever to get anywhere. There is a downside though in that doing this would basically halve the max possible "step frequency" for the stepper motors.


Add better support for machines close to the equator. (Altitude angles greater than 90 degrees perhaps?).
This is mostly only an issue for especially large machine that take a long time to move, or that are incapable of turning a full 360 degrees along the azimuth. Small machines can basically just quickly whip around to face any direction that the program calculates for it, but the larger ones might take upwards of a half an hour to make such a move. It would make more sense to make the program a bit more intelligent to better utilize the full range of motion that a machine might be capable of moving.


Add code for GPS support.  - 
I honestly have never even used a GPS with an Arduino, but I suspect that it would probably only take maybe 10 minutes to add the code for it, so why not have it? The code may only exist as something that needs to be uncommented to work, but that would at least be good enough for some rough experimenting. Actually, if anyone has a GPS wired up maybe you can help me test the code.


Add code for Compass support.   -     
Realistically, there is a good chance this will never happen, but like the GPS code I might just stick it in the code commented out so that people can play around with it if they feel like it. It would definitely be cool, but I'm not sure if the compass modules are reliable enough or not.


Write Android app that sends lat, long, and time to Sun Harvester program using phone's GPS and time. (maybe)   
I've never written an app before, but I have recently considered learning how for this and other unrelated projects. I wouldn't be surprised if there are already Serial Monitor apps that could be made to modify the program using simple text commands. For example, it could ask What is your latitude? to which you might type 12.34 and have the program remember it.

Try and get the program to play well with 32-bit Arduinos.
It seems that things are headed towards 32-bit so it seems to make sense to try and adapt for them. Their real selling point though is that they are much cheaper than the Mega while being more powerful / faster than it. I was able to get the 8-bit Mega to be just as accurate as the 32-bit boards as far as math goes, but it wasn't easy. In general, the 32-bit boards are capable of double precision math which has about twice as many significant figures as the 8-bit boards which are only capable of single precision.

If you try the code on the Teensy, let me know what issues come up. I would be surprised if it worked perfectly without some changes.


@Ben

"The "Sun_Harvester_Shield_Interface4.zip" code looks interesting, but how is this compiled and used?"
Sorry, I forgot to mention that it runs in Processing, which looks very similar to the Arduino programming environment. It can be downloaded at processing.org.


"And the version numbering of this new release being v01 seems strange coming from v098."
I actually changed the name of the program and sort of arbitrarily decided to restart the counter because of the difference. This may have been a dumb idea on my part.

@Paul
Yeah having things be as hands free as possible would definitely be nice.

I have considered getting a fish eye lens webcam to basically watch the sky and log how much sun is available over the course of the year. I also thought that it would be cool to watch the trajectory of clouds and try to predict when they would block the sun. That way you could predict on a minute by minute basis whether you would have energy available for a long enough period of time to do a certain task. Baking a load of bread might be an example.

Anyway, I suppose that same webcam set up could be used to track the position of the sun and move the sun tracker or heliostat accordingly. That would get rid of the GPS altogether. I'm not sure how accurate it would be, but it's an idea.

alobo

  • New Member
  • *
  • Posts: 33
    • View Profile
Re: Arduino Sun Harvester Program: Next Generation Update and Ideas
« Reply #6 on: September 17, 2015, 10:21:56 PM »
My suggestions:

While working with the ESP8266 (which I am really really hooked on right now, in case you can't tell), a couple things came up that I think you will find useful as you upgrade the program.
  • Blynk.
    This thing is effing amazing. I got the ESP8266 and my Android phone talking blinky lights to each other over WiFi pretty goddamn fast. In the case of Arduino (or most other boards they support) you'd need a Wifi or Ethernet module, or have to leave it plugged in to the computer via Serial, to get this working. This will be literally the easiest way to add wireless control and feedback to your heliostat program.
  • The Arduino Time library.
    Assuming you experiment with connecting the program to a network and regularly fetching time from the network (NTP), the Arduino Time library can be used like a clock with or without an RTC. Worth looking into.
I'll put in other things as I come across them.

Paul L

  • Jr. Member
  • **
  • Posts: 94
    • View Profile
Re: Arduino Sun Harvester Program: Next Generation Update and Ideas
« Reply #7 on: September 18, 2015, 09:51:46 AM »
Quote
Anyway, I suppose that same webcam set up could be used to track the position of the sun and move the sun tracker or heliostat accordingly. That would get rid of the GPS altogether. I'm not sure how accurate it would be, but it's an idea.


It would, wouldn't it?!  All you'd need is a single board computer like a Raspberry Pi (or this $9 competitor - http://arstechnica.com/information-technology/2015/05/move-over-raspberry-pi-this-startup-is-building-a-9-computer/) that can run openCV and a webcam.     

Here's a relevant paper if anyone wants to take a look - http://www.jmest.org/wp-content/uploads/JMESTN42350280.pdf

Also, having it be able to track clouds and predict sun availability would be a really cool addition - great idea!

New to me and could be of interest to others: pcDuino.  It's a single board computer with arduino pinouts so you can just plug existing shields into it!   
« Last Edit: September 20, 2015, 09:16:57 AM by Paul L »

solardude

  • New Member
  • *
  • Posts: 8
    • View Profile
Re: Arduino Sun Harvester Program: Next Generation Update and Ideas
« Reply #8 on: October 11, 2015, 09:47:03 AM »
Hey Gabriel  :)

Below are my comments on your reply.

I know your a busy man like the rest of us so I say lets work on adding one new feature at a time and see how that goes. I know others have had the main code up and running for 2 years now with no problems so we know the base sun tracking code is working just fine.

I say forget about any Iphone & Android apps for now since I think your right about it probably driving you nuts when it comes to trying to get it working on all devices and software versions without issues. Plus as Alobo says Blynk is a software platform that has already created a Iphone and Android app that allows you to connect to Arduino boards as long as your Arduino is wirelessly connected to the net which is probably unlikely for a sun tracker but still it worth checking out.

I plan on just adding a low power Sharp Memory LCD to the tracker with a simple button interface that will allow you to enter the GPS coordinates which you can source from a phone, gps tracker, or the internet or a built in GPS receiver. I see no real big benefit of having a custom application for entering GPS coordinates when setting up the tracker but that's just my personal opinion.

What do you think?
---------------------------------------------------------------

Add code for GPS support.  -
I honestly have never even used a GPS with an Arduino, but I suspect that it would probably only take maybe 10 minutes to add the code for it, so why not have it? The code may only exist as something that needs to be uncommented to work, but that would at least be good enough for some rough experimenting. Actually, if anyone has a GPS wired up maybe you can help me test the code.

I have a Adafruit Ultimate GPS receiver that I can use to help test your code. If it's really easy to add support for a GPS Receivers Data Output then lets add it for quick, automatic system GPS coordinate population.

I plan on making portable units that are not permanent so having automatic location entry via GPS would be really nice. Having the option to also enter it manually via a LCD screen and a couple capacities touch buttons is a good backup for the unlikely event that the GPS system fails. A lot preppers buy our systems just to be prepared for the collapse of the financial system, government, or electricity grid, and any of those situations could cause the loss of the GPS system for civilian use should the government want to shut it down. These situations would make renewable energy production even more valuable and important.

If you add GPS support to the code I can and will test it for you and provide detailed testing data for you to review. Let me know what you think.



Add code for Compass support.   -     
Realistically, there is a good chance this will never happen, but like the GPS code I might just stick it in the code commented out so that people can play around with it if they feel like it. It would definitely be cool, but I'm not sure if the compass modules are reliable enough or not.

I've been testing a digital compass with a different solar tracking setup and it can be tricky when you have them close to DC motor magnets since they will throw off the compass readings.

But what I find interesting is that they are using these digital compass chips in quad copters to provide the direction of the travel accuratly even though the compass is surround  by 4 heavy duty DC motors no more than 12 inches apart that are running at high RPM while the quad copter is flying around. So I think there is a digital compass solution that will probably work but more testing is required to find the right digital compass chip for the job.

I have been using a old Honeywell compass and its OK but have a newer compass on hand that I have not had the time to test yet. I picked this compass because guys are successfully using them in their custom quadcopter builds without problems. Here is the compass I have on hand along with a few Adafruit Ultimate GPS modules: https://www.adafruit.com/products/1746

If you add the code for compass support I will do testing on this also and provide detailed testing reports.   


-----------------------------------------------------------------------------

I'm using worm gear drive motors for the dual axis movement and they are very nice because they only require power when the motor is moving and zero power when stopped. This setup has tons of power and holding power when not moving. I see no backlash from my little testing.

I have attached some images of the prototype motor setup I'm testing and happy with so far.



 
« Last Edit: October 11, 2015, 12:20:27 PM by solardude »

kenssurplus

  • New Member
  • *
  • Posts: 4
    • View Profile
Re: Arduino Sun Harvester Program: Next Generation Update and Ideas
« Reply #9 on: October 21, 2015, 03:00:41 PM »
Gabriel,

Congrats on the new updates and continued development. I have a thought about this idea:

Quote
Add simultaneous movement to the stepper motors instead of having them take turns. -
I think I agree with everyone here in that the main motivation for this is that it would look cooler. It does have the practical application though for reducing the time it takes to move machines into position. This is especially good for large machines that take forever to get anywhere. There is a downside though in that doing this would basically halve the max possible "step frequency" for the stepper motors.

While it does indeed reduce the time of travel, what it also would do is to double the current usage at movement time.  On some power limited installations,  this could cause a brown out in the supply voltage, potentially hanging the system in a voltage induced coma.
I don't know how many systems might have trouble of this sort, but it was a thought I had about possible unforseen effects.
Anyway, not trying to dissuade you about this idea, just stating a scenario that may come up.


ben

  • New Member
  • *
  • Posts: 29
    • View Profile
Re: Arduino Sun Harvester Program: Next Generation Update and Ideas
« Reply #10 on: October 22, 2015, 04:37:28 AM »
Add simultaneous movement to the stepper motors instead of having them take turns.

i would like to see this, but not because it looks cooler, but for better accuracy.

DISCLAIMER: i have not got a working system yet, but I do understand electronics and programming.

firstly, I thought the hardware was incapable of real simultaneous movement
-> it moves motor-A, then moves motor-B, then rests, then repeats every 30-sec -or-so

i suggest modifying the algorithm to implement the following:

instead of waiting 30-sec -or-so between movement of motor-A then motor-B,
why not move the motors when they are due to be moved (allowing some minimal threshold).

by this, to describe what i mean, lets consider for example:
that after each 30-sec -or-so, motor-A needs to move 60 pulses, and motor-B needs to move 10 pulses,
then the algorithm could calculate and implement:
- motor-A is moved 2 pulses every second (resulting in the same 60 pulses in 30-sec), and
- motor-B is moved 1 pulse every 3 seconds (resulting in the same 10 pulses in 30-sec).
Get it?

From an observer, due to the very small movements, the machine would not seem to move at all, but would very slowly move and keep aligned to target better than the existing algorithm, in my opinion.

ben

  • New Member
  • *
  • Posts: 29
    • View Profile
Re: Arduino Sun Harvester Program: Next Generation Update and Ideas
« Reply #11 on: October 22, 2015, 04:44:53 AM »
here is a crazy idea:

track the moon at nighttime

i would enjoy the moonlight shining into our windows, when we have a full-moon and clear-sky. :)

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 648
    • View Profile
Re: Arduino Sun Harvester Program: Next Generation Update and Ideas
« Reply #12 on: October 22, 2015, 07:42:25 AM »
@Solardude

I have experimented some with the GPS and Compass code, but it looks like it is probably a bit too complicated to learn to code for it without actually owning the devices. I still need to take another stab at it though.

@kenssurplus
That is a good point. I will probably end up giving the option for sychronized-ish motion, and not make it required. Another fact is that moving both motors at the same time basically halves the max speed of the stepper motor because there is a limit to how fast the Arduino can generate the pulses. With the newer, faster 32-bit Arduinos coming out though, it is less of an issue.

@Ben
"why not move the motors when they are due to be moved (allowing some minimal threshold)."
Now that I think of it, you can already do this in the program by turning the "updateEvery" value down to 1 second. This probably needs to be tested more though because I'm not sure if having small differences between the previous and present calculated sun's position leads to errors.

"track the moon at nighttime"
This has actually been on my mental list for a while now, but I didn't think to add it to the above list. I have looked into it before, and I actually have the calculations in the same book I used to get the sun position calculations. They are somewhat lengthy sense they require an entire table to be typed in, but it looks doable. I don't think it would all fit in the Arduino Uno (at least not with the complete Sun Harvester Program) but it should be fine on the Uno.

ben

  • New Member
  • *
  • Posts: 29
    • View Profile
Re: Arduino Sun Harvester Program: Next Generation Update and Ideas
« Reply #13 on: October 22, 2015, 09:52:13 PM »
Quote
>> why not move the motors when they are due to be moved (allowing some minimal threshold).
Now that I think of it, you can already do this in the program by turning the "updateEvery" value down to 1 second. This probably needs to be tested more though because I'm not sure if having small differences between the previous and present calculated sun's position leads to errors.

Good idea. When I get my system up and going, I will probably work on this.

i would probably calculate the suns position every 30-sec or-so, and every 1-sec or-so drive the motors the required number of pulses (ie 2 for motor-A and 0.333 for motor-B as (in the above example))

solardude

  • New Member
  • *
  • Posts: 8
    • View Profile
Re: Arduino Sun Harvester Program: Next Generation Update and Ideas
« Reply #14 on: October 23, 2015, 12:48:45 PM »
@Solardude

I have experimented some with the GPS and Compass code, but it looks like it is probably a bit too complicated to learn to code for it without actually owning the devices. I still need to take another stab at it though.


Give me your address and I'll ship over a Adafruit Ultimate GPS Module + good digital compass for you to play with. I'll also include a Teensy 3.1 micro controller so we will have the same setup to work with for testing into the future.

Here is some code I have been testing that uses the GPS & Compass to track the sun. There may be something in there that you can easily use. https://github.com/polyideas/Outdoor_Solar_Robot

--------------------------------------------------------------------------------

How hard is it to use your current code to power 2 separate worm gear driven 12v motors?