Answers.Body: <p>PID stands for Proportional-Integral-Derivative - which is an industry standard way of controlling processes and minimizing the deviation from a setpoint. It assigns 3 factors (K_p, K_i and K_d) to three calculated variables all based on the measured process, in this case the deviation from the ideal sensor value coming from the color sensor connected to port 3.</p>
  
  <p>Those three calculated variables contain the proportional deviation (i.e. just the difference between the ideal value and the measured value), the integral of the error (sort of like the sum of all errors over time) and the derivate (the change in the error value over time). The final adjustment the motors need to do is calculated based on those three deviations (P, I and D) to get to a "turn" amount, which is then passed on to the motor to execute.</p>
  
  <p>You can read all about the PID control implemented here in the link in the left top corner of your diagram, which is this: <a href="http://inpharmix.com/jps/PID_Controller_For_Lego_Mindstorms_Robots.html" rel="nofollow">http://inpharmix.com/jps/PID_Controller_For_Lego_Mindstorms_Robots.html</a>. It actually explains the concept pretty well and is relatively easy to follow, as it is targeted towards FLL students (i.e. 9-14 year old kids).</p>
  
  <p>The author of the article also explains why he uses the sensor in RAW mode:</p>
  
  <blockquote>
    <p>Using raw light values (0 to 1023 scale), instead of uncalibrated
    light values, might increase the dynamic range of the light sensors.
    For our example light values black would be 400 and white 500. The
    offset would be 450 with a range of +/-50 instead of +/-5. The raw
    light values is available from a data port on the light sensor block.
    If you calibrate your light sensor under your lighting conditions and
    use the calibrated values then white will be about 100 and black will
    be about 0. This is another way to increase the proportional range of
    the light sensor. In both the raw and calibrated modes the light
    values probably are not accurate in the last digit but hopefully the
    values are somewhat more precise than using a light value range of
    just 10 or so.</p>
  </blockquote>
  
  <p>In short: the range of values coming from the default light sensor is more coarse (0-100) than when using the sensor in raw mode (0-1023), so you get better control over the motor output as there are more light levels to play with.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-10T20:23:45.247Z
Answers.Text: Thank you so much. How to use PID to make robot go just straight. With out light sensor, with encoder. Sorry for being noob
Answers.UserDisplayName: Vuk Lazovic
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-11T01:21:31.967Z
Answers.Text: PID principle stays the same. I assume with encoder you mean the encoder on the motor that tells you the rotation it performed? You'd measure that, compare it with the ideal value, and feed that into the PID loop as above. You will need to tweak your K_p, K_i and K_d variables though, see the inpharmix article on how to do this.
Answers.UserDisplayName: Phil B.
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-10T13:31:54.087Z
Answers.LastActivityDate: 2016-10-10T13:31:54.087Z
Answers.UserDisplayName: Phil B.
Body: <p>What is raw sensor and what is on port 3?</p>
  
  <p>Is this code only for robot to go completely straight without errors?
  <a href="https://i.sstatic.net/FWBtc.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/FWBtc.png" alt="your code"></a></p>
  
Tags: <ev3>
Title: Raw sensor question?
UserDisplayName: Vuk Lazovic
ThreadText: # Raw sensor question?
  
  (Asked by: username_0 on 2016-10-10)
  
  What is raw sensor and what is on port 3?
  
  Is this code only for robot to go completely straight without errors?
  [![your code](https://i.sstatic.net/FWBtc.png)](https://i.sstatic.net/FWBtc.png)
  
  **Tags:** ev3
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-10-10. Score: 3
  
  PID stands for Proportional-Integral-Derivative - which is an industry standard way of controlling processes and minimizing the deviation from a setpoint. It assigns 3 factors (K\_p, K\_i and K\_d) to three calculated variables all based on the measured process, in this case the deviation from the ideal sensor value coming from the color sensor connected to port 3.
  
  Those three calculated variables contain the proportional deviation (i.e. just the difference between the ideal value and the measured value), the integral of the error (sort of like the sum of all errors over time) and the derivate (the change in the error value over time). The final adjustment the motors need to do is calculated based on those three deviations (P, I and D) to get to a "turn" amount, which is then passed on to the motor to execute.
  
  You can read all about the PID control implemented here in the link in the left top corner of your diagram, which is this: <http://inpharmix.com/jps/PID_Controller_For_Lego_Mindstorms_Robots.html>. It actually explains the concept pretty well and is relatively easy to follow, as it is targeted towards FLL students (i.e. 9-14 year old kids).
  
  The author of the article also explains why he uses the sensor in RAW mode:
  
  > Using raw light values (0 to 1023 scale), instead of uncalibrated
  > light values, might increase the dynamic range of the light sensors.
  > For our example light values black would be 400 and white 500. The
  > offset would be 450 with a range of +/-50 instead of +/-5. The raw
  > light values is available from a data port on the light sensor block.
  > If you calibrate your light sensor under your lighting conditions and
  > use the calibrated values then white will be about 100 and black will
  > be about 0. This is another way to increase the proportional range of
  > the light sensor. In both the raw and calibrated modes the light
  > values probably are not accurate in the last digit but hopefully the
  > values are somewhat more precise than using a light value range of
  > just 10 or so.
  
  In short: the range of values coming from the default light sensor is more coarse (0-100) than when using the sensor in raw mode (0-1023), so you get better control over the motor output as there are more light levels to play with.
  
  > **Comments:**
  > **username_0**: Thank you so much. How to use PID to make robot go just straight. With out light sensor, with encoder. Sorry for being noob  
  > **username_1**: PID principle stays the same. I assume with encoder you mean the encoder on the motor that tells you the rotation it performed? You'd measure that, compare it with the ideal value, and feed that into the PID loop as above. You will need to tweak your K_p, K_i and K_d variables though, see the inpharmix article on how to do this.  
  
  ---
  
  