Dear Bob, Trent and Jeff, thanks for your contributions. They have given me several practical ideas to add to this project and even more ideas for me to include in future projects!
(FYI: I have received some very useful suggestions and am currently looking into them and also working on a solution that involves the ASXL335 accelerator, so this thread is not urgent. Thanks.)
Hi all - first post: Newbie warning…
I am building a two axis solar tracker using an Arduino Uno and two linear actuators driven through a four channel relay.
Everything is (almost) sorted, but I have to implement a ‘high wind’ routine in the code.
The object of this routine will be to lay the solar panel flat to minimise the edge profile.
(Prevent it from becoming a kite!)
In order to do this I need to be able to determine the current tilt of the panel.
I anticipate that the crude generic code that I need will read something like:
If tilt sensor value is negative, activate relay one (push)
If tilt sensor value is positive, activate relay two (pull)
If sensor value is zero, stop.
(This code duplicated for second actuator.)
I don’t have much experience with coding the Arduino and worry about having to include libraries and creating an ever-steeper learning curve. (I need to get this prototype done.)
So, my question is: can anyone recommend a suitable sensor that hopefully can run off of 5v, be able to be coded easily and can return an angle or relative position?
If you only need to determine that each of your panel axes has reached a position then the most simple sensor will be reading a limit switch that is activated once your panel is in that position.
Alternatively there are also basic tilt switches that get closed if they are in a certain orientation.
Finally, you could try measuring the panel angle with a magnetometer that tracks the earth’s magnetic field like a compass, but that will mean the magnetometer needs to be calibrated otherwise you might be aligning towards the wrong position.
This magnetometer has logic level shifters so it can work with the Arduinos 5V logic and I2C communication.
Hi John, Trent
I think the simplest method would be 2 LDRs mounted on a triangular piece of material, the whole lot then attached to the panel so when the sun is shining equally on each LDR the resistances are the same. With equal value resistors each side this should be half rail voltage. Using analog inputs this should be an easy matter to compare this with a reference at half rail voltage and manipulate moving mechanism accordingly.
Apply a bit of hysteresis to prevent hunting. A trimpot could be included in either the LDR source (connected between LDRs), or the reference source (connected between the half rail divider resistors) to trim out any mismatch in the LDRs. They would probably be so close that the slight pointing inaccuracy would have little no affect and any trimming not required.
The wind speed detection is another matter. You would have to over ride the elevation and azimuth control systems and go to a predetermined spot. The other alternative would be build the whole thing stronger.
Thanks for the advice.
The miniswitch is a good idea that I will implement as a safety stop, that helps a lot.
I wanted to use the ball switch, but couldn’t get my head around the actuator position, and whether I had to push or pull the piston to get to the required level.
I did have a look at the magnetometer, but was a bit swamped by the use of libraries and code that I have no clue about. It mad it more frustrating.
I am going to see if I can use an ADXL355 to see if I can get that working. It is capable - not sure if I am though!
The LDR solution is really creative! Balancing them with a trim pot is brilliant.
I have four LRDs in operation for the initial actuator movement and will have to resolve that for them, so that was helpful, thanks.
The issue is one of direction though - I can’t see how I will determine if I need to pull or push each of the two actuators to get to ‘zero, zero’.
I am going to try with the ADXL335 accelerator as it seems to give me what I need.
As a newbie to this type of project I am finding it a bit of a challenge getting my head around the new concepts and appreciate the suggestions and assistance.
From now on we are really flying blind here. You are the only one who knows how you are controlling, driving or actuating the moving devices. Are you using Arduino or something else.
In a nutshell you have to compare the voltage at the junction of the LDRs with the half rail reference and do something with that. If using Arduino or other ADC device it is not too hard. You will have 2 numbers. The reference will probably be 255 or something close. The other number will depend on the sunlight on the LDRs. Subtract the LDR number from the reference number. You will have 3 possibilities.
Zero(0). Do nothing
A Positive number. Move panel (with LDRs) in direction which will eventually finish with zero.
A Negative number. Move panel (with LDRs) in direction which will eventually finish with zero.
In effect you are creating a system which is always seeking Zero. At the end of the daylight hours the panel probably stay until next morning when all the light should be on 1 LDR and quickly move the panel across all the while seeking that Zero. If this does not occur you may have to mount a second LDR on each side (making 4 in total) at right angles to the panel to ensure one side gets sufficient dawn light to operate. This may not be required only experimentation will tell.
AHH, missed that bit. That makes it very easy. Manipulate the ADC numbers and move the panel whichever way is appropriate depending on pos or neg number
if XX is < 0 do this and if XX is > 0 do that or something similar. I’m sure it is not that hard even with my limited microcontroller knowledge. I have 2 monitors. I usually have the IDE open on one and the Arduino reference on the other one. Works well.
PS. Was dealing with an analog version of this many years ago (1960’s onwards) in 10kW and 40kW automatic tuned transmitters. This involved a zero seeking dc amplifier. No fancy H bridges in those days, a split +/- 24V to get the volts the correct way around to drive the tuning motors. Worked on the fact that Grid and Anode are 180º out of phase when spot on tune…net zero.During a rehash of these units in the 1980’s the tuning time obtained from 2MHz to 30MHz was less than 10sec for the 10kW unit and less than 20sec for the 40kW TX. Not bad. Of course the modern TX is solid state and broadband but that has some serious and complex drawbacks too which I won’t go into here.
The idea of finding the LDR numbers is very interesting. I will have to stretch my brain a bit to figure it out if I can implement it, but that seems a really good idea.
Just for the sake of completeness, as I have exceeded the 6 analogue inputs of the Uno, I will either change to a Nano (8) or use a MUX board.
(1 for wind, 4 for LRDs, and 2 for the accelerometer.)
The LDR numbers are from the ADC when you use “analogRead”
I don’t quite know what is happening. I don’t know how you are using the LDRs now but as I see it these 4 inputs would be replaced by 3. 1 for the junction of the E/W pair and 1 for the junction of the N/S pair. and a final 1 for the half rail reference. You can use the same reference for both LDR pairs. In other words you would remove 4 and refit 3, gain of 1. You must have something else in mind. I know not what.
By the way I notice you are using digital I/O 1. Not a good idea if for some reason like debugging you want to monitor anything with the serial monitor via USB. I/O 0 and 1 are the same TX and RX lines used for USB communication.
I will do a bit of a sketch to-morrow.
a pair of LDRs are connected in series with equal value resistors on each side across the 5V. The resistors are chosen to limit the current through the network to a safe level for the LDRs. The Arduino is connected to the centre of this ie; at the junction of the LDRs. 2 LDRs - 1 Arduino input. All things being equal and with equal light on the LDRs the voltage at the junction should be very close to 2.5V or “half rail”,“rail” being the 5V “rail”.
Now take say 2 X 10kΩ resistors in series from this 5V “rail” to ground and at the junction you should have 2.5V, assuming you are using good quality resistors, preferably 1% types. This is usually termed “half rail”.
Connect this to another Arduino analog input. Recover the ADC values with the analogRead command and this is what I was referring to as LDR numbers and half rail or reference numbers. This one should be 255 or 256.
Do the same with the other pair of LDRs. You can use the same reference for both N/S and E/W LDRs.
So you surely can see we need only 2 inputs plus the 2.5V reference for 4 LDRs.
Get used to the term 'rail", you will see it often. Some OP Amps for instance are quoted as being “rail to rail” which means the output voltage can swing from very close to ground (or negative V in a split supply system) to very close to the positive supply “rail”. The term is also used with some audio amps where a quasi ground is created at “half rail” which as you surmised is half way between ground and supply,(does not have to be 5V).
I feel that this paragraph has moved me forward about six months more than my usual grinding speed.
The offer to do a sketch is very generous. I pick things up better using images, so thanks heaps for that.
I’m not completely dim, but this issue is proving harder than my normal level of project.
(Enjoying the little successes though!)
PS. You spoke of an accelerometer before. What is that all about and what do you intend to do with it in this project. It really sounds as if you are overcomplicating things for no reason. As I see it the primary objective is to keep the panel pointing as close as possible to the sun. I really can’t see what useful input an accelerometer is going to give you.
Hi Bob, That sketch is great, thanks. The addition of the trimmer pots is a great way to level the playing field.
The issue I am trying to solve is of returning the panel to a 0,0, horizontal plane in high-wind conditions.
An anemometer will give me a reference level that triggers the actuators to move, but as they are dumb, I can’t think of a way of determining if they need to pull or push.
I am hoping that the accelerometer will give me information regarding the real x and y position of the panel which in turn gives me the direction to move the actuators.
Also, it should give me the ability to specify the 0,0 point quite precisely.
Maybe you don’t need that.
The elevation should only have to go one way in the southern hemisphere. Unless you are living close to the equator it is always going to point down toward the northern horizon. A microswitch or sensor could sense the horizontal position. A tilt switch may work. When the wind drops the sun will return it to normal.
The other plane is a bit more awkward. You could use a real time clock to indicate the system when it is past the meridian. Or another way would be to have some sort of switch or other sensor to advise Arduino when the panel has passed the centre point. A tilt switch may work here too.Then the Arduino could have 2 options, pre meridian crank the panel one way and post meridian crank it the opposite direction. The same sensor could indicate centre position. Actually 2 tilt switches would work here, one each side. If you arranged the elevation plane to level first then the tilt switches would indicate which way the other panel was positioned and which way to move it. Approximate centre could be indicated when both switches were off.
I personally feel a system something like this would be preferable to complicating the issue by trying to interpret accelerometer information. As I suggested another option would be strengthen the mechanics.
I also feel you are trying to bite off too much of the pie. I would personally get the 2 planes tracking first then worry about parking everything during high wind later.
Trimpots. Only use them if required. The bit of error you may get without them would probably be insignificant. I don’t know, only trial will tell. Due to DAC resolution there is going to be a bit of hysteresis anyway and the panel will not always point EXACTLY at the sun. The DAC resolution you can do nothing about. If you do use a trimpot use the lowest value possible. The 1kΩ indicated is only arbitrary and is not the final value. Same with the 2 current limiting resistors. The higher the value here the less influence the LDRs will have so use as low a value as practical.
I can’t really make the structure any stronger as it has to be light enough to be portable.
It is quite strong as it is. It is made of 30x30 extruded aluminium and the actuators run at 1500 newtons.
The base is not fixed, only suspended in a tub of concrete. This is a prototype base. The final will be filled with a temporary ballast of sand or water. But that’s an improvement for down the track.
The idea of a timer that determines passing the centre point is okay, but not precise enough. What if the wind gets up near noon? So to know the exact relative position is to be able to correct the position in the right direction at any time.
Also, I intend to put the panel in the 0,0 stow position overnight. This will expose the LDRs to sunlight at dawn, which will start the day-length timer and allow the LRDs to drive the initial position of the panel.
The structure, panel and actuators are already built and working, but are operated from DPDT switches. I am pleased with that part of the design, but am currently working on the software component.
Funny thing - and I would have argued against this black and blue - it turns out that the sun actually crosses to the south side during the forenoon and afternoon. I wouldn’t have believed it had I not been tracking the sun all day! I am at 27 degrees south!
I tried the idea of the tilt switches, and at first thought that they would do the job, they were good at identifying the panel coming to 0,0, but they didn’t give me the direction that I needed to push/pull the actuators.
Sorry if my reply seems negative, but you have given me lots to think about and several great ideas. Thanks.