Notifications
Clear all

Help with code please

56 Posts
6 Users
16 Likes
3,734 Views
(@ianns)
Member
Joined: 3 years ago
Posts: 18
Topic starter  

@inq I was limiting my start & finish position, have I done wrong?


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2535
 
Posted by: @ianns

I mounted mine at either end of the panel.

Please show us a picture of your device with special emphasis on the location and orientation of the LDRs. From your description, it sounds like you've separated them so far apart that they can't operate as intended, which is causing your problem. They should be close to each other with a divider between them.

Anything seems possible when you don't know what you're talking about.


   
Inst-Tech reacted
ReplyQuote
(@ianns)
Member
Joined: 3 years ago
Posts: 18
Topic starter  

@will I agree, they are a least 300mm apart.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2535
 
Posted by: @ianns

@will I agree, they are a least 300mm apart.

I'm pretty sure that's your problem (or at least one of them). The operational principle is the there are two sensors (ideally 4 sensors actually) separated by a wall. As sunlight shines down and hits the sensors, the light level is sensed on both sides.

Since the sun's rays are practically parallel when they reach Earth, both LDRs should receive equal amounts of sunlight while the device is pointing at the sun. However, as the sun moves, one of the sensors comes into the shadow of the central wall and the light level on it falls. The device senses this inequality and moves the solar panel toward the more brightly lit side until the two sensors again read equal exposure

By having the LDRs far apart and without a suitable dividing wall, your device can't possibly decide where the sun is because the angle of incidence is the same for both and there's no wall to cause a shadow. The shadow is the essential part of the decision making and you've effectively removed the wall that creates it.

Furthermore, the device assumes that both sensors have equal sensitivity to the light falling on them, so you always test a batch and use the closest matching quadruple (or  two, in your case) to try to equalize them.

The methodology I explained above uses the upper and lower light levels (as you measured them side by side under identical conditions) and then maps them from the observed reading to an equivalent value in a new fixed range. These compensated values should then be representative of the strength of the sun relative to the capability of each LDR, so that it is meaningful to compare them.

Of course, I just used the range 0-1023 because that is the range for analogRead. You can equally well convert them to values 0-100 or 0-your birthday. The whole exercise if to map both raw values int a scale which should be equivalent for both sensors.

Anything seems possible when you don't know what you're talking about.


   
Inst-Tech, Ron and darup reacted
ReplyQuote
(@ianns)
Member
Joined: 3 years ago
Posts: 18
Topic starter  

@will Thank you


   
Inst-Tech reacted
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2043
 

   
Inst-Tech reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7026
 

@ianns Should be more like 30mm up to about 90mm depending on the height of the divider.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
 
Posted by: @ianns

@inq I was limiting my start & finish position, have I done wrong?

Slow response - Been traveling.

Nah!  I don't think you did wrong.  You would do that kind of thing once it is fundamentally working.  More about this below.

The code is quite simple and I don't see anything else that might cause the trouble.  I think the problem is related to the configuration of the sensors.  You saying they're 300mm apart is way too far apart UNLESS you have a vertical wall next to both sensors.  A picture is worth a thousand words.  I hope.

Sun
  • At noon, the sun is directly overhead.  Both sensors get equal sun.  Follower still.
  • At 2pm, the sun moved, casting shadow on right sensor.  Follower, starts up and starts moving till the central wall is pointing at the sun... again both sensors getting equal sun.

Back about the angle limiting... think of it this way.  If the sun is strait up... the servo should be at 90 degrees (centered).  If at sunrise, the servo would be at 0 degrees.  Sunset 180 degrees.  By limiting the code at 112 degrees, you're follower would stop following at 1:45 PM.

 

Hope this helps.

 

VBR,

Inq

 

 

 

 

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
Inst-Tech reacted
ReplyQuote
(@ianns)
Member
Joined: 3 years ago
Posts: 18
Topic starter  

@inq I will move the sensors today, going forward I may direct drive the pivot shaft the same as Jessica did. At the minute I am lifting the panel as far as I can with a lift arm & connecting rod.

Thank you for all your help.


   
Inst-Tech reacted
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

   
Ron reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7026
 

@frogandtoad I could not have said/did it better! This is super excellent advice

@ianns you would be well advised to take it to heart.

BTW, I have 7.2kWh of LiFePO4 batteries, over 1,000 W of solar panels, and a 3K inverter. Right now my panels are flat as there is nothing to be gained in tilting them let along tracking given my orientation and location.

Good Luck

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
frogandtoad reacted
ReplyQuote
(@ianns)
Member
Joined: 3 years ago
Posts: 18
Topic starter  

@zander I am ready to give up it is still rocking backwards & forwards.

I believe here in Nova Scotia there is something to be gained by moving the panel three times in one day.

I do not have data to support that statement but please point me in the right direction on how I would do that. I  want to remove the ldr's and move it to three-set positions throughout the day.

 


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@zander

Posted by: @zander

@frogandtoad I could not have said/did it better! This is super excellent advice

@ianns you would be well advised to take it to heart.

BTW, I have 7.2kWh of LiFePO4 batteries, over 1,000 W of solar panels, and a 3K inverter. Right now my panels are flat as there is nothing to be gained in tilting them let along tracking given my orientation and location.

Good Luck

Thanks Ron!

If I ever go off grid, and boy how I wish to in these times... I'll know who to ask 🙂


   
Ron reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7026
 

@ianns What you want to do is done all the time. Just follow the advice you have been given re sensor design and placement plus this code

https://forum.dronebotworkshop.com/postid/29197/

For the sensors, all you need is a board, not sure of size but get a sheet of 1/8" masonite and start cutting different sizes. Once you find what you want swap the masonite for something weatherproof, HOME DEPOT should have small pieces of galvanized tin.

The other thing you need to experiment with is placement of the sensors relative to the blocking panel.

Now go to this website HERE and do several passes of calculations for different tilt angles. You may be surprised to learn it changes during the year and NOT how you think. In the RV community we learned that adding one flat panel to the array was better than the cost and agro of tilting.

2 dimensional tilting has even less payback especially with modern panels. BTW, what panels are you using?

Here is a sample of a 2 dimensional sensor you can buy but you really only need a 1 dimension. A 2/4 with a saw blade cut and a piece of weatherproof plastic 6" x 6" would be a place to start. Place sensors about 3"/75cm from the vertical piece and centered on the vertical piece.

Screen Shot 2022 05 05 at 13.47.29

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@ianns

Posted by: @ianns

@zander I am ready to give up it is still rocking backwards & forwards.

I believe here in Nova Scotia there is something to be gained by moving the panel three times in one day.

I do not have data to support that statement but please point me in the right direction on how I would do that. I  want to remove the ldr's and move it to three-set positions throughout the day.

 

Even the original you saw and downloaded (even if you replicated it exactly), from "Jessica" still suffers from exactly the same problem you're trying to eliminate.  Without a PID controller to combat that (and that would also require constant power to be applied), let alone any pauses in your implementation of it when it aligns to its target, it can never be solved.

What she has provided is a very very basic of the principles, of tracking for educational purposes - she wasn't trying to teach you how to build a Mars Rover 😉

Don't be discouraged... its part of the learning curve!


   
ReplyQuote
Page 2 / 4