Course project: Solar panels that follow the sun

Solar panels that automatically follow the sun and thus maximize energy production. The idea is not unique, but the implementation here is deserves a post.

The Client of the project provided the hardware and the idea was that a multipurpose PC platform doubles here as a controlling device with its I/O capabilities: a native parallel port. Later, with cheap Raspberry PIs and GPIO’s I know now to stick with simple single-purpose devices.

The project started as a course project for TIES523 Laitteistoläheinen ohjelmointi (C & Embedded programming) with four great fellows.

The half-open box in the right is the initial heart of the project: an older Dennard device that is capable of turning a camera with its two axles with step motors. It can withstand some load and is able to carry an arm holding two solar panels.

I already mentioned controlling the pins would be dead easy with Raspberry PI GPIO’s. But while we’re talking about green energy, the control board is so non-green that the fan-out of Phidgetboard’s InterfaceKit 8/8/8’s ports was not enough to drive the above board. Parallel port to the rescue.

Controlling the step motors through a ready interface board with the parallel port was fun. It took us some time to figure out that the pulse frequency needs to be between 100 Hz and 1000 Hz to have something happening and the parallel port only supports that in some modes. Also, a BIOS option called High Precision Event Timer if left to true surprisingly disturbed high precision events.

While the initial C API draft was simple, we still managed to introduce some mess to first versions by using ambiguous terms like UP, DOWN, LEFT and RIGHT.

There was some wondering on whether or not the Dennard housing can withstand wind loads that the flat solar panel surfaces can transmit to the hardware. Everybody thought that it’s probably ok.

We integrated rotating this with a library for determining the sun’s position relative to any position on Earth: Solar Position Algorithm (SPA). This library is several orders of magnitude more precise than what would satisfy our need.

We managed to seed doubt to project’s external Hardware Guy. He decided to make new build that had a new property: it can withstand wind loads with no worrying needed. It was also nicely mounted to a desk chair’s bottom.

After having everything 80 % or so ready, we continued this together as two man group to fulfill project work of another course. We rewrote the turning API and figured out how to integrate this to the GNU/Linux Ubuntu PC. While I think our idea was great, mixing two needs with same appliance is source for mess.

The idea was to play with Linux runlevels. Normally the GRUB starts Linux to runlevel 2, which is meant for normal desktop use. The default GRUB option was to start to runlevel 3 which starts only necessary services. So if a human wanted to use the PC as a desktop, (s)he should select this now non-default “Desktop use” mode at startup menu.

As part of shutdown procedures the PC was set to wake itself again in 20(?) or so minutes. If the default GRUB setting isn’t changed, the system only starts up, adjusts the panels and shuts itself down and scheduling a new wake-up while doing so.

Finally, as the last thing in the evening, the panels are turned towards the direction the sun will be rising up next morning.

Then, I thought, the project is ready (it was not).

(The above picture shows also a nice little joystick for turning the panels)

Courses are now done, I was the last man standing in the delivery team. Just some installing and testing left to do.

This was the project that taught me that while having 10 lines of Bash is fine, over 100 lines of Bash scripting contains plenty of opportunities for edge cases to fail. There were variables being sometimes empty, arithmetic fails, logic fails, etc. A “set -e” line at the top is great start, but figuring out causes requires something else.

Slapping a few mosquitoes every test cycle makes you wish you only needed a couple of rounds.

After surprisingly many difficulties, the whole project was a success and was great fun to work on! Good company and beer make up for any amount of mosquitoes.