title: Servo Issues while using PWM with Raspberry Pi
body: <p>My setup is simply the servo JX-PDI-6221MG being directly activated with raspberry pi's PWM through GPIO library. The servo is brand new, I followed <a href="http://www.toptechboy.com/raspberry-pi/raspberry-pi-lesson-28-controlling-a-servo-on-raspberry-pi-with-python/" rel="nofollow noreferrer">this tutorial</a> and set duty cycle values between 0 and 100. The angles it makes have no pattern, it seems to go one way from 20 to 50 and them from 60 to 90 the other. </p>
  
  <p>I decide to loop through all possible duty cycles (code is below) and I confirm that the variations aren't smooth and it doesn't look precise. After trying to set fix values again it suddenly starts to spin in multiple directions, even without I changing anything. Not even <code>GPIO.cleanup()</code> or killing python related processes made it stop.</p>
  
  <p>Is my Raspberry Pi getting jitter and being very imprecise or was I a victim of falsification?</p>
  
  <p>Code:</p>
  
  <pre><code>import RPi.GPIO as GPIO
  import time
  
  GPIO.setmode(GPIO.BOARD)
  GPIO.setup(11,GPIO.OUT)
  pwm=GPIO.PWM(11,330) #which is the same as shown in datasheet
  pwm.start(0)
  
  for i in range(0,100):
       pwm.ChangeDutyCycle(i)
       time.sleep(0.02)
  
  for i in range(0,100):
       i = 100 - i
       pwm.ChangeDutyCycle(i)
       time.sleep(0.02)`
  </code></pre>