Hi There,
I have a question regarding the raspberry pi 3 and 2 with pwm servo control.
My development board is a Pi3 with touch screen, Pi Cobbler and powered bread board.
My Robot is a pi 2, 2 x stepper motors, battery pack and a servo operated ultrasonic module.
I test everything on the development board and can control the servo perfectly - my code works
however when I use the same program on the robot (pi2), the servo rotates all way left and refuses to move to any other position - all GPIO ports and wiring are the same - if I ground both pi together move the signal pin then it ' ll run on the PI3
Anyone got any ideas???
Peers
Re: Rpi2 and 3 servo controi difference
Power supply?
When you say pwm servo control how are you generating the PWM?
When you say pwm servo control how are you generating the PWM?
Re: Rpi2 and 3 servo controi difference
Here is the test code that I used from my PC I may have changed some details on the PI's
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
servoPin=19
GPIO.setup(servoPin, GPIO.OUT)
pwm=GPIO.PWM(servoPin,50)
pwm.start(10)
for i in range(0,3):
desiredPosition=i * 80
DC=(desiredPosition) / 14 + 2.5
pwm.ChangeDutyCycle(DC)
time.sleep(5)
pwm.stop()
GPIO.cleanup()
yeah just checked the pin out on the pi - it's 13 not 19
any ideas?
Peers
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
servoPin=19
GPIO.setup(servoPin, GPIO.OUT)
pwm=GPIO.PWM(servoPin,50)
pwm.start(10)
for i in range(0,3):
desiredPosition=i * 80
DC=(desiredPosition) / 14 + 2.5
pwm.ChangeDutyCycle(DC)
time.sleep(5)
pwm.stop()
GPIO.cleanup()
yeah just checked the pin out on the pi - it's 13 not 19
any ideas?
Peers
Re: Rpi2 and 3 servo controi difference
Sorry - just noticed it didn't copy the indents in the loop just cut and pasted DOH!!
it's supposed to cycle through left center and right.
Peers
it's supposed to cycle through left center and right.
Peers
Re: Rpi2 and 3 servo controi difference
You may edit the post and enclose the script in code quotes (highlight the text and press the Code button in the toolbar of the edit window).
I don't see any reason for the code to cause the servo to move as you describe.
However you would be better of sending hardware timed pulses to a servo, software timed pulses can introduce jitter. Have a look at (my) pigpio, or servoblaster, or RPIO.GPIO which can all generate hardware timed pulses.
I don't see any reason for the code to cause the servo to move as you describe.
However you would be better of sending hardware timed pulses to a servo, software timed pulses can introduce jitter. Have a look at (my) pigpio, or servoblaster, or RPIO.GPIO which can all generate hardware timed pulses.
Re: Rpi2 and 3 servo controi difference
I think that will just set the servo pin high, which will rather defeat the point of using PWM to pulse the pin.supra wrote:You're missing oneCode: Select all
GPIO.output(servoPin, True)