Answers.Body: <p>As far as I see, you have two possible ways of accomplishing this, given that you have already built an <a href="https://en.wikipedia.org/wiki/Altazimuth_mount" rel="nofollow noreferrer">Altazimuth mount</a> or any other two-dimension mount from the two motors that can hold the color sensor and point it in any direction.</p>
  
  <h2>Calculation</h2>
  
  <p>This is the harder way but it grants neater results. It involves taking a precise measurement of the device's location and orientation, setting up a known orientation for both motors as zero, and porting a known solar-tracking algorithm to the EV3 (like <a href="http://heliostat.sourceforge.net/software.html" rel="nofollow noreferrer">this</a> or <a href="https://www.cerebralmeltdown.com/arduino-sun-tracking-heliostat-program-documentation/" rel="nofollow noreferrer">this</a>). The resulting setup then must not be shut down, moved or rotated since the control of the motors is done by an algorithm which only takes into account the starting conditions (spatial and temporal) and the elapsed time. The accuracy of the EV3 internal clock may also factor into the precision if the project is to be left running for a long time. As an added bonus, you don't need the color sensor at all.</p>
  
  <h2>Using iterative methods</h2>
  
  <p>This approach requires a lot less intial setup but offers a not-so polished end result. The basic premise is using the color sensor to get an estimation of the amount of the light incoming from the current direction, then comparing it with the measurement(s) from some other direction(s), finally turning toward the higher value.</p>
  
  <p>There are two problems to be solved here: first, the current position of the Sun (or its equivalent if you are indoors) must be found among all possible orientations. This is an example of the mathematical operation known as finding the global maxima of a two-dimensional function on a constrained range, where the two input dimensions are the <a href="https://en.wikipedia.org/wiki/Altitude" rel="nofollow noreferrer">altitude</a> and the <a href="https://en.wikipedia.org/wiki/Azimuth" rel="nofollow noreferrer">azimuth</a> and the output is the measured amount of light coming from the given direction.</p>
  
  <p>Then, the software must account for the inevitable changes due to the relative movement of the Sun in the sky. Since you have chosen this way and not the first (<strong>Calculation</strong>), you can not know in advance which direction the Sun will move in. So you can only attempt to find it again after a set amount of time or after the measured brightness drops to (or by) a specified amount.</p>
  
  <p>There are countless ways this approach can be fine-tuned, depending on the precision of the motors, the precision, update rate and measuring range of the sensor, the amount of location and orientation information known beforehand, the required precision of the resulting system, the allowed complexity of the software, etc.</p>
  
  <p>The most basic and a <strong>very</strong> ineffective system would consist of the following pseudocode:</p>
  
  <pre><code>repeat forever:
      oldBrightness = read(colorSensor)
      movementXAxis = getRandom(-10, 10) // decide on a random direction to turn to
      movementYAxis = getRandom(-10, 10)
      moveXAxis(movementXAxis)           // turn to the new direction
      moveYAxis(movementYAxis)
      newBrightness = read(colorSensor)
      if(newBrightness &lt; oldBrightness)  // if the new direction is worse than the old
          moveXAxis(-movementXAxis)      // then turn back to the old direction
          moveYAxis(-movementYAxis)
      wait(someTime)                     // bask in the sun for a while :)
  </code></pre>
  
  <p>This of course can be updated with more advanced logic, including but not limited to </p>
  
  <ul>
  <li>paying attention to the amount of difference between the old and new measurements</li>
  <li>moving first in larger steps to get a coarse direction and then refine it further with smaller steps</li>
  <li>staying pointed in a direction longer if the brightness is higher there</li>
  <li>moving continuously in one direction while the brightness is increasing and stopping when it starts to fall</li>
  <li>storing directions and corresponding measurements to create a 2D function which can be analysed using mathematical methods to find the best result</li>
  <li>storing historical data to predict and account for changes in the long run</li>
  <li>(but by now you are practically in the complexity region of the <strong>Calculation</strong>-way)</li>
  <li>etc.</li>
  </ul>
  
  <p>Consult the <a href="https://en.wikipedia.org/wiki/Mathematical_optimization" rel="nofollow noreferrer">relevant Wikipedia page</a> for some advanced reading material and as a starting point if you are interested in learning more about the applicable algorithms.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-21T19:25:41.033Z
Answers.Text: I use mindstorm program for ev3 .I am greatful for you but can you give me a program on mindstorm.i put a link for solar station.thanks very much
Answers.UserDisplayName: morad
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-21T19:26:43.687Z
Answers.Text: https://github.com/diabad/EV3-Solar-Station/blob/master/EV3SolarStation.pdf
Answers.UserDisplayName: morad
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-21T20:24:10.990Z
Answers.Text: @morad sorry, your link seems broken, the browser days the file is too big to display and the PDF reader says it's invalid.
Answers.UserDisplayName: zovits
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-20T15:46:31.450Z
Answers.LastActivityDate: 2018-12-20T15:46:31.450Z
Answers.UserDisplayName: zovits
Body: <p>I want to make a program for an EV3 solar <a href="https://en.wikipedia.org/wiki/Heliostat" rel="nofollow noreferrer">heliostat</a>. </p>
  
  <p>It consists of two motors and a color sensor. I want it to follow the light. The station is fixed. </p>
  
  <p><a href="https://github.com/diabad/EV3-Solar-Station/blob/master/EV3SolarStation.pdf" rel="nofollow noreferrer">EV3SolarStation pdf</a></p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-12-19T19:55:59.413Z
Comments.Text: i want it to follow light .also the station is fixed
Comments.UserDisplayName: morad
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-12-20T03:37:40.870Z
Comments.Text: Can you provide more details then this, currently it's too vague
Comments.UserDisplayName: Ankit Sharma
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-12-20T09:44:24.697Z
Comments.Text: Hi @morad ! Could you please provide either a detailed description or a picture of this solar station? Knowing the orientation of the motors and the general idea would allow us to help you better. Thanks!
Comments.UserDisplayName: zovits
Tags: <ev3><programming>
Title: How I can program a solar panel heliostat?
UserDisplayName: morad
ThreadText: # How I can program a solar panel heliostat?
  
  (Asked by: username_0 on 2018-12-19)
  
  I want to make a program for an EV3 solar [heliostat](https://en.wikipedia.org/wiki/Heliostat).
  
  It consists of two motors and a color sensor. I want it to follow the light. The station is fixed.
  
  [EV3SolarStation pdf](https://github.com/diabad/EV3-Solar-Station/blob/master/EV3SolarStation.pdf)
  
  **Tags:** ev3, programming
  
  > **Comments:**
  > **username_0**: i want it to follow light .also the station is fixed  
  > **username_1**: Can you provide more details then this, currently it's too vague  
  > **username_2**: Hi @username_0 ! Could you please provide either a detailed description or a picture of this solar station? Knowing the orientation of the motors and the general idea would allow us to help you better. Thanks!  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2018-12-20. Score: 2
  
  As far as I see, you have two possible ways of accomplishing this, given that you have already built an [Altazimuth mount](https://en.wikipedia.org/wiki/Altazimuth_mount) or any other two-dimension mount from the two motors that can hold the color sensor and point it in any direction.
  
  ## Calculation
  
  This is the harder way but it grants neater results. It involves taking a precise measurement of the device's location and orientation, setting up a known orientation for both motors as zero, and porting a known solar-tracking algorithm to the EV3 (like [this](http://heliostat.sourceforge.net/software.html) or [this](https://www.cerebralmeltdown.com/arduino-sun-tracking-heliostat-program-documentation/)). The resulting setup then must not be shut down, moved or rotated since the control of the motors is done by an algorithm which only takes into account the starting conditions (spatial and temporal) and the elapsed time. The accuracy of the EV3 internal clock may also factor into the precision if the project is to be left running for a long time. As an added bonus, you don't need the color sensor at all.
  
  ## Using iterative methods
  
  This approach requires a lot less intial setup but offers a not-so polished end result. The basic premise is using the color sensor to get an estimation of the amount of the light incoming from the current direction, then comparing it with the measurement(s) from some other direction(s), finally turning toward the higher value.
  
  There are two problems to be solved here: first, the current position of the Sun (or its equivalent if you are indoors) must be found among all possible orientations. This is an example of the mathematical operation known as finding the global maxima of a two-dimensional function on a constrained range, where the two input dimensions are the [altitude](https://en.wikipedia.org/wiki/Altitude) and the [azimuth](https://en.wikipedia.org/wiki/Azimuth) and the output is the measured amount of light coming from the given direction.
  
  Then, the software must account for the inevitable changes due to the relative movement of the Sun in the sky. Since you have chosen this way and not the first (**Calculation**), you can not know in advance which direction the Sun will move in. So you can only attempt to find it again after a set amount of time or after the measured brightness drops to (or by) a specified amount.
  
  There are countless ways this approach can be fine-tuned, depending on the precision of the motors, the precision, update rate and measuring range of the sensor, the amount of location and orientation information known beforehand, the required precision of the resulting system, the allowed complexity of the software, etc.
  
  The most basic and a **very** ineffective system would consist of the following pseudocode:
  
  ```
  repeat forever:
      oldBrightness = read(colorSensor)
      movementXAxis = getRandom(-10, 10) // decide on a random direction to turn to
      movementYAxis = getRandom(-10, 10)
      moveXAxis(movementXAxis)           // turn to the new direction
      moveYAxis(movementYAxis)
      newBrightness = read(colorSensor)
      if(newBrightness < oldBrightness)  // if the new direction is worse than the old
          moveXAxis(-movementXAxis)      // then turn back to the old direction
          moveYAxis(-movementYAxis)
      wait(someTime)                     // bask in the sun for a while :)
  
  ```
  
  This of course can be updated with more advanced logic, including but not limited to
  
  * paying attention to the amount of difference between the old and new measurements
  * moving first in larger steps to get a coarse direction and then refine it further with smaller steps
  * staying pointed in a direction longer if the brightness is higher there
  * moving continuously in one direction while the brightness is increasing and stopping when it starts to fall
  * storing directions and corresponding measurements to create a 2D function which can be analysed using mathematical methods to find the best result
  * storing historical data to predict and account for changes in the long run
  * (but by now you are practically in the complexity region of the **Calculation**-way)
  * etc.
  
  Consult the [relevant Wikipedia page](https://en.wikipedia.org/wiki/Mathematical_optimization) for some advanced reading material and as a starting point if you are interested in learning more about the applicable algorithms.
  
  > **Comments:**
  > **username_0**: I use mindstorm program for ev3 .I am greatful for you but can you give me a program on mindstorm.i put a link for solar station.thanks very much  
  > **username_0**: https://github.com/diabad/EV3-Solar-Station/blob/master/EV3SolarStation.pdf  
  > **username_2**: @username_0 sorry, your link seems broken, the browser days the file is too big to display and the PDF reader says it's invalid.  
  
  ---
  
  