Answers.Body: <p>There are two attributes in the python ev3dev Motor class called:</p>
  
  <pre><code>ramp_down_sp
  ramp_up_sp
  </code></pre>
  
  <p>Link to documentation: <a href="http://ddemidov.github.io/ev3dev-lang-python/" rel="nofollow">http://ddemidov.github.io/ev3dev-lang-python/</a></p>
  
  <p><strong>ramp_down_sp Ramp Down SP: read/write</strong></p>
  
  <p>Writing sets the ramp down setpoint. Reading returns the current value. Units are in milliseconds. When set to a value > 0, the motor will ramp the power sent to the motor from 100% duty cycle down to 0 over the span of this setpoint when stopping the motor. If the starting duty cycle is less than 100%, the ramp time duration will be less than the full span of the setpoint.</p>
  
  <p><strong>ramp_up_sp Ramp Up SP: read/write</strong></p>
  
  <p>Writing sets the ramp up setpoint. Reading returns the current value. Units are in milliseconds. When set to a value > 0, the motor will ramp the power sent to the motor from 0 to 100% duty cycle over the span of this setpoint when starting the motor. If the maximum duty cycle is limited by duty_cycle_sp or speed regulation, the actual ramp time duration will be less than the setpoint.</p>
  
  <p>Example:</p>
  
  <pre><code>from ev3.lego import Motor
  b = Motor(port=Motor.PORT.B)
  b.ramp_up_sp = 1000
  b.ramp_down_sp = 1000
  b.run_position_limited(position_sp = 0, speed_sp = 300)
  </code></pre>
  
  <p>What the ramp_down_sp does is when the motor is 1000 milliseconds away from its target (doing its own estimations) then ramp down the power from 100% to 0% over exactly 1000 milliseconds.</p>
  
  <p>ramp_up does a similar thing, except ramps up the power from 0% to 100% over 1000 milliseconds.  </p>
  
  <p>This helps avoid unnecessary strain on the motors for applications where building up momentum is important.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-19T16:07:07.857Z
Answers.LastActivityDate: 2015-05-19T16:07:07.857Z
Answers.UserDisplayName: Eric Leschinski
Body: <p>I have Debian jesse installed on a mindstorms EV3 and I'm using the <code>ev3.lego</code> library: <a href="https://github.com/topikachu/python-ev3" rel="noreferrer">https://github.com/topikachu/python-ev3</a></p>
  
  <p>I want to be able to slow down the motor as it reaches its target destination because if it's going full speed when it gets there, it overshoots its target proportional to how fast it was going.</p>
  
  <p><strong>Example Python code: When I use this code to spin the motor:</strong></p>
  
  <pre><code>from ev3.lego import Motor
  b = Motor(port=Motor.PORT.B)
  b.run_position_limited(position_sp = 100, speed_sp = 300)
  </code></pre>
  
  <p>The motor spins to position 100 on the tachometer with speed of 300.</p>
  
  <p>When it gets to its destination, the momentum carries it to position 125 or so.  So next time I tell it to go to position 100.  It spins up, then overshoots to position 75.  </p>
  
  <p>What is the best way to try to minimize this error so I can tell the motor to move to position 100, and it either slows down before it reaches its target, or otherwise freezes the motor when it reaches the destination?</p>
  
Tags: <ev3><motor><ev3dev>
Title: Slow down the mindstorms EV3 motor so target position is not overshot
UserDisplayName: Eric Leschinski
ThreadText: # Slow down the mindstorms EV3 motor so target position is not overshot
  
  (Asked by: username_0 on 2015-05-19)
  
  I have Debian jesse installed on a mindstorms EV3 and I'm using the ev3.lego library: https://github.com/topikachu/python-ev3
  I want to be able to slow down the motor as it reaches its target destination because if it's going full speed when it gets there, it overshoots its target proportional to how fast it was going.
  Example Python code: When I use this code to spin the motor:
  from ev3.lego import Motor
  b = Motor(port=Motor.PORT.B)
  b.run_position_limited(position_sp = 100, speed_sp = 300)
  
  The motor spins to position 100 on the tachometer with speed of 300.
  When it gets to its destination, the momentum carries it to position 125 or so.  So next time I tell it to go to position 100.  It spins up, then overshoots to position 75.  
  What is the best way to try to minimize this error so I can tell the motor to move to position 100, and it either slows down before it reaches its target, or otherwise freezes the motor when it reaches the destination?
  
  **Tags:** ev3, motor, ev3dev
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2015-05-19. Score: 3
  
  There are two attributes in the python ev3dev Motor class called:
  ramp_down_sp
  ramp_up_sp
  
  Link to documentation: http://ddemidov.github.io/ev3dev-lang-python/
  ramp_down_sp Ramp Down SP: read/write
  Writing sets the ramp down setpoint. Reading returns the current value. Units are in milliseconds. When set to a value > 0, the motor will ramp the power sent to the motor from 100% duty cycle down to 0 over the span of this setpoint when stopping the motor. If the starting duty cycle is less than 100%, the ramp time duration will be less than the full span of the setpoint.
  ramp_up_sp Ramp Up SP: read/write
  Writing sets the ramp up setpoint. Reading returns the current value. Units are in milliseconds. When set to a value > 0, the motor will ramp the power sent to the motor from 0 to 100% duty cycle over the span of this setpoint when starting the motor. If the maximum duty cycle is limited by duty_cycle_sp or speed regulation, the actual ramp time duration will be less than the setpoint.
  Example:
  from ev3.lego import Motor
  b = Motor(port=Motor.PORT.B)
  b.ramp_up_sp = 1000
  b.ramp_down_sp = 1000
  b.run_position_limited(position_sp = 0, speed_sp = 300)
  
  What the ramp_down_sp does is when the motor is 1000 milliseconds away from its target (doing its own estimations) then ramp down the power from 100% to 0% over exactly 1000 milliseconds.
  ramp_up does a similar thing, except ramps up the power from 0% to 100% over 1000 milliseconds.  
  This helps avoid unnecessary strain on the motors for applications where building up momentum is important.
  
  
  ---
  
  