stevep
Posts: 71
Joined: Sat Dec 24, 2011 10:12 am

Re: Solar panel tracking

Tue Dec 27, 2011 4:14 pm

A long time ago I wrote a program for the BBC Master in BASIC. The program read the system date and time, then pulled the readings for azimuth and elevation from a data array to power 2 stepper motors, so that a panel, dish or solar PV panel could be pointed normal to the sun.

I still have the original program somewhere on a 5¼" floppy, though whether it is still readable is questionable.

I'd quite like to have a go at this when the Pi is released, so my questions:

1. Is the Pi a good hardware basis for this project, or would I be better using a PIC?

2. If I used a Pi, presumably running some sort of Linux, would I be able to stick to BASIC (the only language I have any real experience of) or would it be worth investing the time and effort to learn a different language?

3. What topics would I need to research to sort out the interface between the Pi and the stepper motors?

I'm ok with the practical side of things, soldering, using veroboard and so on. Any help or pointers would be much appreciated. Thanks.

Wooloomooloo
Posts: 92
Joined: Fri Nov 25, 2011 10:52 am

Re: Solar panel tracking

Tue Dec 27, 2011 5:01 pm

1) If you are basing your solar control solution on time as opposed to direct sensor reading, you will of course need some sort of a time keeper. Which can pretty much be done in two ways, either with an on-board RTC (which the Pi does not have - but neither do most MCUs, unless you are prepared to consider their obligatory 32KHz-driven internal "clock" as precise enough), or with an external time reference such as NTP via ethernet (which the Pi can do), GPS, or DCF77 long-wave radio. If you have cabled network access on-site and choose to use NTP, the Pi has an advantage over other PICs and AVRs, though you certainly could choose a PIC/AVR based board with network access if you wish.

Either way, objectively speaking, a generic PIC/AVR MCU is perfectly sufficient for the kind of job you have in mind, while a Pi is a massive overkill. It's entirely up to you to use one nonetheless, of course, if you fancy doing so.

2) I'm by far no expert on this, but I assume you could get some flavor of BASIC running on the Pi if you wanted (I don't see much of a chance of you receiving it ready to run though, based on the level of hostility seen around here towards BASIC). On the other hand, there seem to be MCU based boards that can be programmed in BASIC, like the Basic Stamp or the Picaxe. Ultimately, it's really up to you whether you feel like making the effort of learning something new or not.

3) The Pi has some GPIO pins that presumably would be able to drive stepper motor drivers. Since they use a lower-than-5V I/O voltage, you'd need to either buffer them yourself with a simple I/O buffer or use something like the upcoming GertBoard to do it for you. MCUs would probably be able to interface with stepper drivers directly (unless you choose a low-voltage MCU). Either way, you will need some sort of stepper drivers to drive the actual stepper motors anyway - exactly what sort depends on how big of a stepper you want to drive and at what voltage.

Joules
Posts: 87
Joined: Sun Dec 25, 2011 8:50 pm

Re: Solar panel tracking

Tue Dec 27, 2011 5:12 pm

This should do the trick for your clock, you can read it over the I2C line.

http://www.sparkfun.com/products/99

gimp
Posts: 8
Joined: Mon Sep 12, 2011 5:44 pm

Re: Solar panel tracking

Tue Dec 27, 2011 7:16 pm

In my opinion, this is not the optimal solution. I don't know how it's done in industry, but frankly I wouldn't use time/date calculations. I would instead use real-time power data. That is, every so often, change the inclination of the panel until power obtained is maximum. The reason I would do it this way is two-fold: first, it's a lower-power low-cost solution (can use something as low-power as the msp430, which I hate, but is ideal for using only a trickle of power, or any other simple 8-bit micro), and second, it's an autocorrecting method that doesn't rely on precalculated data (which may be corrupted, glitch and use the wrong time, and so on). Basically I think that the r-pi is overkill here; do you really need a 700MHz chip running linux to make solar panels track optimal power?

Joules
Posts: 87
Joined: Sun Dec 25, 2011 8:50 pm

Re: Solar panel tracking

Tue Dec 27, 2011 7:24 pm

The point is lost that you don"t always take the optimal solution when you are experimenting or as someone once said "the journey is the reward"

Please, Raspi is all about playing for the sake of learning.

stevep
Posts: 71
Joined: Sat Dec 24, 2011 10:12 am

Re: Solar panel tracking

Tue Dec 27, 2011 7:46 pm

"That is, every so often, change the inclination of the panel until power obtained is maximum."

That was my thought when I first wrote the BASIC program, but discounted it because of the practical difficulties. Firstly, having the collector panning round trying to find what the maximum radiation level is, and how will it know when it finds it, and secondly the problem of what happens when the sun dissappears behind the clouds. Using altitude and azimuth tables will ensure that the panel always points to the right bit of the sky, whether it"s cloudy or not.

User avatar
glenn66
Posts: 55
Joined: Fri Nov 25, 2011 4:06 pm
Location: Belfast
Contact: Website

Re: Solar panel tracking

Tue Dec 27, 2011 7:59 pm

Wouldn't it be best to use both?  A DS1307 I2C clock chip gives an accurate time and then a data table can be used to find where the sun should be.  Once the motors have lined up the panel at those coordinates another algorithm could scan within a few degrees of this point in the up/down and left/right, find the maximum light reading and use that to stay on station.  Every hour or whatever the coarse position could be reset from the time.

I've built a few seek-and-find robots over the years that used coarse and fine location in the same sort of way.

gimp
Posts: 8
Joined: Mon Sep 12, 2011 5:44 pm

Re: Solar panel tracking

Tue Dec 27, 2011 8:00 pm

I wouldn't worry too much about the first point. The second, however, is interesting.

What if the optimum orientation, when there is cloud cover, is not directly at the sun? It is clear that a solar panel can still get significant power by pointing generally upwards, thanks to refraction of the solar rays in our atmosphere. I think we can see many cases, in fact, where when the sun is behind cloud cover, it is significantly brighter in areas of the cloud due to non-uniform thickness. Wouldn't it be better to have the panel point to the brightest areas? Just a bit of alternate thinking.

User avatar
glenn66
Posts: 55
Joined: Fri Nov 25, 2011 4:06 pm
Location: Belfast
Contact: Website

Re: Solar panel tracking

Tue Dec 27, 2011 8:07 pm

Joules said:


This should do the trick for your clock, you can read it over the I2C line.

http://www.sparkfun.com/products/99


$14.95 for one of these or 5 x DS1307 for $4.74 on eBay today including free shipping from Asia.

stevep
Posts: 71
Joined: Sat Dec 24, 2011 10:12 am

Re: Solar panel tracking

Tue Dec 27, 2011 9:08 pm

Thanks for the replies so far, it"s definitely helping to sort a few of the basics out.
First, yes the Pi is overkill in terms of processing power, but in terms of cost it is probably not going to be all that different to a PIC solution. It"s likely that many of us will buy the Pi to do things that will under-utilise the power of the device just because we want to play around with it.
As I understand it, an add-on clock chip might be best assuming it is going to maintain accuracy, whereas some sort of internet based clock solution would obviously need a network connection. A gps based solution might work if only I knew anything about gps!
Re the tracking / seeking solution - while I can see that finding the brightest point in the sky is desirable I"m still not convinced that in practice it is all that easy, (I"m thinking of a bright day with fast moving cloud patches). If the collector was a focussing parabolic dish then maybe, but with a flat panel collector the difference between pointing at the sun and pointing at the brightest point in the sky might not be enough to worry about.
That said, maybe an array of focussing ldr"s covering the southern sky might work to provide the information to point the collector in the right direction.

Wooloomooloo
Posts: 92
Joined: Fri Nov 25, 2011 10:52 am

Re: Solar panel tracking

Tue Dec 27, 2011 9:45 pm

stevep said:


As I understand it, an add-on clock chip might be best assuming it is going to maintain accuracy, whereas some sort of internet based clock solution would obviously need a network connection. A gps based solution might work if only I knew anything about gps!


A GPS-based solution would need a "GPS mouse" which is basically a small puck containing the GPS receiver, that can be connected to a computer via a USB cable. The Pi would probably handle it automatically, and it would likely appear as a serial port to you - from which you periodically receive strings with location and time (if the GPS got a fix), similar to the one below:

$GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W*6A

Where:
RMC Recommended Minimum sentence C
123519 Fix taken at 12:35:19 UTC
A Status A=active or V=Void.
4807.038,N Latitude 48 deg 07.038' N
01131.000,E Longitude 11 deg 31.000' E
022.4 Speed over the ground in knots
084.4 Track angle in degrees True
230394 Date - 23rd of March 1994
003.1,W Magnetic Variation
*6A The checksum data, always begins with *

It has the advantage of not needing to ever be initialized thus working "out of the box" without special batteries and even after a complete power failure (and it might be fun to get accustomed with as a technology) but it's definitely not the cheaper solution (one can buy about half a fistful of RTC chips for the price of a GPS-receiver - anywhere from $40 to $90)

Tomo2k
Posts: 127
Joined: Mon Dec 19, 2011 10:00 pm

Re: Solar panel tracking

Tue Dec 27, 2011 10:01 pm

Glenn said:


Joules said:


This should do the trick for your clock, you can read it over the I2C line.

http://www.sparkfun.com/products/99


$14.95 for one of these or 5 x DS1307 for $4.74 on eBay today including free shipping from Asia.



DS3232 or DS321 are probably better solutions, as those don't need an external crystal.

stevep
Posts: 71
Joined: Sat Dec 24, 2011 10:12 am

Re: Solar panel tracking

Wed Dec 28, 2011 8:58 am

@wooloo- thanks, now you mention it I do remember the data string, and it is actually more useful than just providing the time data - the position data could also be used to calculate the suns elevation and azimuth, which would be better than referring to a table as I did in my old BBC Basic routine. I think I have seen the gps mice fitted on boats, and they seem to be around £25 for a cheap version. It might even be possible to use a gps chip to reduce the cost further.
Thanks for all the replies.

Bootsy
Posts: 11
Joined: Sat Dec 24, 2011 10:52 am

Re: Solar panel tracking

Wed Dec 28, 2011 9:25 am

As a non-tech, non-computer person - would it be easier to attain the results with a simple program controlling a step motor (c). Two sensors (a and b), one on either side of the array feeding signal to the program.

If a>b step motor -1

If a<b step  motor +1

If a=b wait 5 seconds

You could add in more sensors and motors for inclination as required.

It just seems a little less complicated to my mind.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 20902
Joined: Sat Jul 30, 2011 7:41 pm

Re: Solar panel tracking

Wed Dec 28, 2011 10:01 am

Wooloomooloo said:


stevep said:


As I understand it, an add-on clock chip might be best assuming it is going to maintain accuracy, whereas some sort of internet based clock solution would obviously need a network connection. A gps based solution might work if only I knew anything about gps!


A GPS-based solution would need a "GPS mouse" which is basically a small puck containing the GPS receiver, that can be connected to a computer via a USB cable. The Pi would probably handle it automatically, and it would likely appear as a serial port to you - from which you periodically receive strings with location and time (if the GPS got a fix), similar to the one below:

$GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W*6A

Where:
RMC Recommended Minimum sentence C
123519 Fix taken at 12:35:19 UTC
A Status A=active or V=Void.
4807.038,N Latitude 48 deg 07.038' N
01131.000,E Longitude 11 deg 31.000' E
022.4 Speed over the ground in knots
084.4 Track angle in degrees True
230394 Date - 23rd of March 1994
003.1,W Magnetic Variation
*6A The checksum data, always begins with *

It has the advantage of not needing to ever be initialized thus working "out of the box" without special batteries and even after a complete power failure (and it might be fun to get accustomed with as a technology) but it's definitely not the cheaper solution (one can buy about half a fistful of RTC chips for the price of a GPS-receiver - anywhere from $40 to $90)


Bluenext USB GPS receivers, was £17 from EBay. Still trying to get it working on the Pi but works fine in Ubuntu.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.

User avatar
TheTap
Posts: 25
Joined: Fri Dec 23, 2011 11:26 am
Location: Edinburgh

Re: Solar panel tracking

Wed Dec 28, 2011 10:05 am

What about using the pi's forthcoming (AFAIK) camera and a bit of image analysis to determine the brightest part of the sky ?

Bakul Shah
Posts: 305
Joined: Sun Sep 25, 2011 1:25 am

Re: Solar panel tracking

Wed Dec 28, 2011 10:21 am

You'll need 2 H-bridges to drive a stepper. If your two steppers are independent, multiply by 2 (if they are not, you can probably just wire them in parallel?). Your panels would rotate may be 0.1 to 0.2 degree a minute so you need to gear down quite a bit (worm gear). One choice is to use a readymade motor controller boards for about $24 (such as Grove I2C motor driver) that can be connected to an Arduino (or a Raspi). But it'd be more fun build something. Either directly control a L298 (dual H-bridge) from Raspi's GPIO pins, or use an Atmel ATtiny chip + L298 and also log some analog signals (such as solar power output, use etc) and control it from a Raspi. The afore mentioned DS3232 is accurate to within 2 minutes per year so you can do without a GPS!

davidgoodenough
Posts: 74
Joined: Wed Sep 21, 2011 11:55 am

Re: Solar panel tracking

Wed Dec 28, 2011 11:40 am

You could try the Pololu Baby Orangutan board.  It has an Atmel chip and a TB6612FNG dual H bridge on a little carrier board, all for a rediculously low price (and no I do not work for Pololu).

David

stevep
Posts: 71
Joined: Sat Dec 24, 2011 10:12 am

Re: Solar panel tracking

Thu Jan 05, 2012 12:08 pm

Done some more thinking, have installed VirtualBox and Debian on my Mac (thanks to Liam Frazer) so I can play with Python. I have provisionally decided on the following setup:

1. Python (I'm told it is fairly simple to learn, and there seems to be plenty of low-level help available)

2. gps mouse, possibly the Bluenext model JamesH mentions, to give an NMEA data string from which lat and long, date and time data can be read.

3. An interface to connect the PI to two stepper motors - presumably this means the Gertboard (in due course)

Questions:

I've found a package called python-gps (along with an associated one called libgps19) which I have added to my Debian install. Is that the right package? I have no idea how to access it from Python to read the data string, so I need some pointers.

I have searched for information on stepper motor control, but have not found anything basic enough for me to understand*. Presumably I need to install another package to allow me to access either the interface board or the GPIO pins?

*except maybe this page

spamel
Posts: 196
Joined: Sun Jan 01, 2012 8:43 pm

Re: Solar panel tracking

Thu Jan 05, 2012 12:52 pm

This is another subject I will be watching, as once on the narrowboat any electrical generation will be very useful and solar panels is a consideration. If I can leave it to align by itself, more the better.

TFSN
Posts: 6
Joined: Mon Jan 22, 2018 3:35 am

Re: Solar panel tracking

Tue Feb 13, 2018 6:42 pm

I am looking into solar tracking as well... This thread came up in my search results and I very much like the discussion. I use GPS to synch my clock (as well as ntp) for my Greenhouse monitor Pi. GP wasn't too bad to setup and I can find the link around I used for it somewhere if anyone would like. I recommend the GPS as GPS clock is VERY accurate... and of course... if you end up moving your panels to a new location... the software could be written to support it and auto-grab new coordinates and tracking data. Here's a link to my greenhouse Pi on youtube:
https://www.youtube.com/watch?v=Rdnt_tzh7Vc

Here's the setup GPS info I used:
https://area-51.blog/2012/06/18/getting ... pberry-pi/

It was then synched using ntp... so a combo of GPS and NTP to obtain accurate time and cross-check.

Let's keep this discussion going!

-TFSN

Yak_Forger
Posts: 6
Joined: Tue Feb 20, 2018 12:05 am

Re: Solar panel tracking

Tue Feb 20, 2018 6:18 pm

Hey TFSN, you were talking about moving the panels to other locations, but I"ve got a question about going one level further: can I program the Raspberry to be able to track solar panels in different countries? I've got a couple panels at my house, had some installed at my parents' house, and of course, now that I'm looking at these https://tranio.com/spain/valencia/detached/, of course... I'd like to solarize that house as much as I can.

Do you think it is doable? I have the panels slaved to a eedomus domotics system, but of course, right now, the system is locally controlled by myself and my father at his house, I use my Raspberry while he uses an iPad. Of course, it requires the panels all the way in Spain (I'm in Belgium) to be connected, and thus a computer and a router to be online all year long, but it's what I intend to do anyways since the panels are not going to be the only remote controlled thing in the house.

Thanks!

Return to “Other projects”